Skip to content

Commit 2f25574

Browse files
committed
With these changes, the navigation eventing works as one would expect it
to do. When one calls webui_show* manually all is loaded. Interaction from within the HTML by clicks, javascript, etc. is catched. Signed-off-by: Hans Dijkema <[email protected]>
1 parent 13a9d5a commit 2f25574

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/webui.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ typedef struct webui_event_inf_t {
264264
void* gtk_win;
265265
void* gtk_wv;
266266
bool open;
267+
bool in_show;
267268
// WebUI Window
268269
char* url;
269270
bool navigate;
@@ -8175,6 +8176,15 @@ static const char* _webui_get_local_ip(void) {
81758176
#endif
81768177
}
81778178

8179+
8180+
#if __linux__
8181+
#define CHECK_IN_SHOW(win, check) if (win->webView && win->has_all_events) win->webView->in_show = check;
8182+
#define IS_IN_SHOW(win) ((win->webView && win->has_all_events) ? win->webView->in_show : true)
8183+
#else
8184+
#define CHECK_IN_SHOW(win, check)
8185+
#define IS_IN_SHOW(win)
8186+
#endif
8187+
81788188
static bool _webui_show_window(_webui_window_t* win, struct mg_connection* client, const char* content, int type, size_t browser) {
81798189

81808190
#ifdef WEBUI_LOG
@@ -8188,6 +8198,8 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
81888198
_webui_log_debug("[Core]\t\t_webui_show_window(FILE, [%zu])\n", browser);
81898199
#endif
81908200

8201+
CHECK_IN_SHOW(win, true)
8202+
81918203
#ifdef WEBUI_TLS
81928204
// TLS
81938205
if (_webui_is_empty(_webui.ssl_cert) || _webui_is_empty(_webui.ssl_key)) {
@@ -8218,6 +8230,7 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
82188230
_webui_free_mem((void*)ssl_cert);
82198231
_webui_free_mem((void*)ssl_key);
82208232
WEBUI_ASSERT("Generating self-signed TLS certificate failed");
8233+
CHECK_IN_SHOW(win, false)
82218234
return false;
82228235
}
82238236

@@ -8402,6 +8415,7 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
84028415
_webui_free_mem((void*)win->url);
84038416
_webui_free_port(win->server_port);
84048417
win->server_port = 0;
8418+
CHECK_IN_SHOW(win, false)
84058419
return false;
84068420
}
84078421
}
@@ -11878,9 +11892,15 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1187811892
switch(decision_type) {
1187911893
case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: {
1188011894

11881-
webkit_policy_decision_ignore(decision);
11882-
1188311895
_webui_window_t* win = _webui_dereference_win_ptr(user_data);
11896+
11897+
if (IS_IN_SHOW(win)) {
11898+
CHECK_IN_SHOW(win, false)
11899+
return false;
11900+
}
11901+
11902+
webkit_policy_decision_ignore(decision);
11903+
1188411904
int navigation_type = webkit_navigation_policy_decision_get_navigation_type(decision);
1188511905
void *uri_request = webkit_navigation_policy_decision_get_request(decision);
1188611906
const char *webkit_uri = webkit_uri_request_get_uri(uri_request);
@@ -12108,6 +12128,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1210812128
}
1210912129

1211012130
// Show
12131+
CHECK_IN_SHOW(win, true)
1211112132
webkit_web_view_load_uri(win->webView->gtk_wv, win->webView->url);
1211212133
gtk_widget_show_all(win->webView->gtk_win);
1211312134
win->webView->open = true;

0 commit comments

Comments
 (0)