Skip to content

Commit 777026f

Browse files
authored
Updating code to follow current coding style
1 parent 6a72520 commit 777026f

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

src/webui.c

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ typedef struct webui_event_inf_t {
276276
unsigned int y;
277277
bool stop;
278278
} _webui_wv_linux_t;
279+
280+
#define GTK_SET_SHOW (win, status) if (win->webView && win->has_all_events) win->webView->in_show = status;
281+
#define GTK_IS_SHOW (win) ((win->webView && win->has_all_events) ? win->webView->in_show : true)
282+
279283
#else
280284
extern bool _webui_macos_wv_new(int index, bool frameless, bool resizable);
281285
extern void _webui_macos_wv_new_thread_safe(int index, bool frameless, bool resizable);
@@ -8176,15 +8180,6 @@ static const char* _webui_get_local_ip(void) {
81768180
#endif
81778181
}
81788182

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-
81888183
static bool _webui_show_window(_webui_window_t* win, struct mg_connection* client, const char* content, int type, size_t browser) {
81898184

81908185
#ifdef WEBUI_LOG
@@ -8198,8 +8193,6 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
81988193
_webui_log_debug("[Core]\t\t_webui_show_window(FILE, [%zu])\n", browser);
81998194
#endif
82008195

8201-
CHECK_IN_SHOW(win, true)
8202-
82038196
#ifdef WEBUI_TLS
82048197
// TLS
82058198
if (_webui_is_empty(_webui.ssl_cert) || _webui_is_empty(_webui.ssl_key)) {
@@ -8230,7 +8223,6 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
82308223
_webui_free_mem((void*)ssl_cert);
82318224
_webui_free_mem((void*)ssl_key);
82328225
WEBUI_ASSERT("Generating self-signed TLS certificate failed");
8233-
CHECK_IN_SHOW(win, false)
82348226
return false;
82358227
}
82368228

@@ -8415,7 +8407,6 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
84158407
_webui_free_mem((void*)win->url);
84168408
_webui_free_port(win->server_port);
84178409
win->server_port = 0;
8418-
CHECK_IN_SHOW(win, false)
84198410
return false;
84208411
}
84218412
}
@@ -11863,6 +11854,15 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1186311854
#define GTK_RUNTIME_ARR { "libgtk-3.so.0" } // TODO: Add GTK v4 APIs "libgtk-4.so.1"
1186411855
#define WEBKIT_RUNTIME_ARR { "libwebkit2gtk-4.1.so.0", "libwebkit2gtk-4.0.so.37" }
1186511856

11857+
// Decision Event
11858+
#define WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION 0
11859+
#define WEBKIT_NAVIGATION_TYPE_LINK_CLICKED 0
11860+
#define WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED 1
11861+
#define WEBKIT_NAVIGATION_TYPE_BACK_FORWARD 2
11862+
#define WEBKIT_NAVIGATION_TYPE_RELOAD 3
11863+
#define WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED 4
11864+
#define WEBKIT_NAVIGATION_TYPE_OTHER 5
11865+
1186611866
// Title Event
1186711867
static void _webui_wv_event_title(void *web_view, void *pspec, void *arg) {
1186811868
#ifdef WEBUI_LOG
@@ -11879,15 +11879,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1187911879
}
1188011880
}
1188111881

11882-
// Decision Event
11883-
#define WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION 0
11884-
#define WEBKIT_NAVIGATION_TYPE_LINK_CLICKED 0
11885-
#define WEBKIT_NAVIGATION_TYPE_FORM_SUBMITTED 1
11886-
#define WEBKIT_NAVIGATION_TYPE_BACK_FORWARD 2
11887-
#define WEBKIT_NAVIGATION_TYPE_RELOAD 3
11888-
#define WEBKIT_NAVIGATION_TYPE_FORM_RESUBMITTED 4
11889-
#define WEBKIT_NAVIGATION_TYPE_OTHER 5
11890-
1189111882
static bool _webui_wv_event_decision(void *widget, void *decision, int decision_type, void *user_data) {
1189211883
switch(decision_type) {
1189311884
case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: {
@@ -11898,8 +11889,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1189811889
return false;
1189911890
}
1190011891

11901-
if (IS_IN_SHOW(win)) {
11902-
CHECK_IN_SHOW(win, false)
11892+
if (GTK_IS_SHOW(win)) {
11893+
GTK_SET_SHOW(win, false)
1190311894
return false;
1190411895
}
1190511896

@@ -12132,7 +12123,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1213212123
}
1213312124

1213412125
// Show
12135-
CHECK_IN_SHOW(win, true)
12126+
GTK_SET_SHOW(win, true) // TODO: Check if we need this here because we are about to load a URI
1213612127
webkit_web_view_load_uri(win->webView->gtk_wv, win->webView->url);
1213712128
gtk_widget_show_all(win->webView->gtk_win);
1213812129
win->webView->open = true;
@@ -12424,6 +12415,14 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1242412415
}
1242512416
}
1242612417

12418+
if (_webui.is_webview) {
12419+
// We have a Linux WebKitGTK WebView running
12420+
GTK_SET_SHOW(win, true)
12421+
} else {
12422+
// Failed to start the Linux WebKitGTK
12423+
GTK_SET_SHOW(win, false)
12424+
}
12425+
1242712426
#ifdef WEBUI_LOG
1242812427
_webui_log_debug("[Core]\t\t_webui_wv_show() -> Return [%d]\n", (_webui.is_webview == true));
1242912428
#endif

0 commit comments

Comments
 (0)