From 09cf223aa2ec4b629826646cb26b34183f8749ad Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Mon, 21 Jun 2021 15:48:24 +1000 Subject: [PATCH] [windows] Workaround webview2 bug being blank. Reduced flashing at start. --- v2/internal/ffenestri/ffenestri_windows.cpp | 31 ++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/v2/internal/ffenestri/ffenestri_windows.cpp b/v2/internal/ffenestri/ffenestri_windows.cpp index 77d9da0f8..f1243722f 100644 --- a/v2/internal/ffenestri/ffenestri_windows.cpp +++ b/v2/internal/ffenestri/ffenestri_windows.cpp @@ -263,11 +263,26 @@ void completed(struct Application* app) { delete[] app->initialCode; app->initialCode = nullptr; + // Process whether window should show by default + int startVisibility = SW_SHOWNORMAL; + if ( app->startHidden == 1 ) { + startVisibility = SW_HIDE; + } + // Fix for webview2 bug: https://github.com/MicrosoftEdge/WebView2Feedback/issues/1077 // Will be fixed in next stable release app->webviewController->put_IsVisible(false); app->webviewController->put_IsVisible(true); + // Private setTitle as we're on the main thread + if( app->frame == 1) { + setTitle(app, app->title); + } + + ShowWindow(app->window, startVisibility); + UpdateWindow(app->window); + SetFocus(app->window); + if( app->startupURL == nullptr ) { messageFromWindowCallback("SS"); return; @@ -461,28 +476,12 @@ void Run(struct Application* app, int argc, char **argv) { SetLayeredWindowAttributes(app->window,RGB(255,255,255),0,LWA_COLORKEY); } - - // Private setTitle as we're on the main thread - if( app->frame == 1) { - setTitle(app, app->title); - } - // Store application pointer in window handle SetWindowLongPtr(app->window, GWLP_USERDATA, (LONG_PTR)app); - // Process whether window should show by default - int startVisibility = SW_SHOWNORMAL; - if ( app->startHidden == 1 ) { - startVisibility = SW_HIDE; - } - // private center() as we are on main thread center(app); - ShowWindow(app->window, startVisibility); - UpdateWindow(app->window); - SetFocus(app->window); - // Add webview2 initWebView2(app, debug, initialCallback);