@@ -264,7 +264,6 @@ typedef struct webui_event_inf_t {
264264 void * gtk_win ;
265265 void * gtk_wv ;
266266 bool open ;
267- bool in_show ;
268267 // WebUI Window
269268 char * url ;
270269 bool navigate ;
@@ -277,6 +276,8 @@ typedef struct webui_event_inf_t {
277276 bool stop ;
278277 } _webui_wv_linux_t ;
279278
279+ #define GTK_WEBVIEW_SET_IN_SHOW (win , status ) if (win && win->has_all_events) { win->in_show = status; }
280+
280281#else
281282 extern bool _webui_macos_wv_new (int index , bool frameless , bool resizable );
282283 extern void _webui_macos_wv_new_thread_safe (int index , bool frameless , bool resizable );
@@ -387,6 +388,7 @@ typedef struct _webui_window_t {
387388 #ifdef _WIN32
388389 _webui_wv_win32_t * webView ;
389390 #elif __linux__
391+ bool in_show ;
390392 _webui_wv_linux_t * webView ;
391393 #else
392394 _webui_wv_macos_t * webView ;
@@ -8190,6 +8192,10 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
81908192 _webui_log_debug ("[Core]\t\t_webui_show_window(FILE, [%zu])\n" , browser );
81918193 #endif
81928194
8195+ #if __linux__
8196+ GTK_WEBVIEW_SET_IN_SHOW (win , true)
8197+ #endif
8198+
81938199 #ifdef WEBUI_TLS
81948200 // TLS
81958201 if (_webui_is_empty (_webui .ssl_cert ) || _webui_is_empty (_webui .ssl_key )) {
@@ -11876,35 +11882,19 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1187611882 }
1187711883 }
1187811884
11879- static inline void _webui_wv_gtk_set_show (_webui_window_t * win , bool status ) {
11880- if (win ) {
11881- if (win -> webView && win -> has_all_events ) {
11882- win -> webView -> in_show = status ;
11883- }
11884- }
11885- }
11886-
11887- static inline bool _webui_wv_gtk_is_show (_webui_window_t * win ) {
11888- if (win ) {
11889- if (win -> webView && win -> has_all_events ) {
11890- return win -> webView -> in_show ;
11891- }
11892- }
11893- return true;
11894- }
11895-
1189611885 static bool _webui_wv_event_decision (void * widget , void * decision , int decision_type , void * user_data ) {
1189711886 switch (decision_type ) {
1189811887 case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION : {
1189911888
1190011889 _webui_window_t * win = _webui_dereference_win_ptr (user_data );
1190111890
11902- if (!win -> has_all_events ) {
11903- return false;
11904- }
11905-
11906- if (_webui_wv_gtk_is_show (win )) {
11907- _webui_wv_gtk_set_show (win , false);
11891+ // If all events are handled, check in_show
11892+ if (win -> has_all_events ) {
11893+ if (win -> in_show ) { // Don't catch navigation event
11894+ GTK_WEBVIEW_SET_IN_SHOW (win , false)
11895+ return false;
11896+ }
11897+ } else { // Don't catch navigation event
1190811898 return false;
1190911899 }
1191011900
@@ -12137,7 +12127,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1213712127 }
1213812128
1213912129 // Show
12140- _webui_wv_gtk_set_show ( win , true); // TODO: Check if we need this here because we are about to load a URI
12130+
1214112131 webkit_web_view_load_uri (win -> webView -> gtk_wv , win -> webView -> url );
1214212132 gtk_widget_show_all (win -> webView -> gtk_win );
1214312133 win -> webView -> open = true;
@@ -12348,6 +12338,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1234812338
1234912339 // Linux GTK WebView
1235012340
12341+ GTK_WEBVIEW_SET_IN_SHOW (win , true)
12342+
1235112343 #ifdef WEBUI_DYNAMIC
1235212344 #ifdef WEBUI_LOG
1235312345 _webui_log_debug ("[Core]\t\t_webui_wv_show() -> WebUI dynamic version does not support Linux WebView\n" );
@@ -12429,14 +12421,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1242912421 }
1243012422 }
1243112423
12432- if (_webui .is_webview ) {
12433- // We have a Linux WebKitGTK WebView running
12434- _webui_wv_gtk_set_show (win , true);
12435- } else {
12436- // Failed to start the Linux WebKitGTK
12437- _webui_wv_gtk_set_show (win , false);
12438- }
12439-
1244012424 #ifdef WEBUI_LOG
1244112425 _webui_log_debug ("[Core]\t\t_webui_wv_show() -> Return [%d]\n" , (_webui .is_webview == true));
1244212426 #endif
0 commit comments