Skip to content

Commit 88978ed

Browse files
committed
Now WebUI always prioritizes Browser over WebView
1 parent 170ba91 commit 88978ed

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

src/webui.c

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8971,62 +8971,62 @@ static bool _webui_show_window(_webui_window_t* win, struct mg_connection* clien
89718971
#endif
89728972
}
89738973

8974-
// New WebView
8975-
bool runWebView = false;
8976-
if (win->allow_webview) {
8977-
// Trying to use WebView
8978-
if (_webui_wv_show(win, window_url)) {
8979-
#ifdef WEBUI_LOG
8980-
_webui_log_debug("[Core]\t\t_webui_show_window() -> WebView Found\n");
8981-
#endif
8982-
win->current_browser = Webview;
8983-
_webui.current_browser = Webview;
8984-
runWebView = true;
8985-
}
8986-
else {
8987-
#ifdef WEBUI_LOG
8988-
_webui_log_debug("[Core]\t\t_webui_show_window() -> WebView Not Found\n");
8989-
#endif
8990-
}
8991-
}
8992-
8993-
// Run browser
8974+
// Try first to open the UI in a browser if allowed.
89948975
bool runBrowser = false;
8995-
if (!runWebView) {
8996-
if (win->allow_browser) {
8997-
if (browser != NoBrowser) {
8998-
if (!_webui_browser_start(win, window_url, browser)) {
8976+
if (win->allow_browser) {
8977+
if (browser != NoBrowser) {
8978+
if (!_webui_browser_start(win, window_url, browser)) {
8979+
#ifdef WEBUI_LOG
8980+
_webui_log_debug("[Core]\t\t_webui_show_window() -> App-mode browser failed\n");
8981+
#endif
8982+
// Opening App-mode browser failed
8983+
// let's try opening UI in native default browser
8984+
if (browser == AnyBrowser && _webui_open_url_native(window_url)) {
89998985
#ifdef WEBUI_LOG
9000-
_webui_log_debug("[Core]\t\t_webui_show_window() -> App-mode browser failed\n");
8986+
_webui_log_debug("[Core]\t\t_webui_show_window() -> Native browser succeeded\n");
90018987
#endif
9002-
// Opening App-mode browser failed
9003-
// let's try opening UI in native default browser
9004-
if (browser == AnyBrowser && _webui_open_url_native(window_url)) {
9005-
#ifdef WEBUI_LOG
9006-
_webui_log_debug("[Core]\t\t_webui_show_window() -> Native browser succeeded\n");
9007-
#endif
9008-
runBrowser = true;
9009-
// To avoid terminating the user's native browser on exit
9010-
_webui.current_browser = WEBUI_NATIVE_BROWSER;
9011-
}
9012-
else {
9013-
#ifdef WEBUI_LOG
9014-
_webui_log_debug("[Core]\t\t_webui_show_window() -> Native browser failed\n");
9015-
#endif
9016-
}
8988+
runBrowser = true;
8989+
// To avoid terminating the user's native browser on exit
8990+
_webui.current_browser = WEBUI_NATIVE_BROWSER;
90178991
}
90188992
else {
90198993
#ifdef WEBUI_LOG
9020-
_webui_log_debug("[Core]\t\t_webui_show_window() -> App-mode browser succeeded\n");
8994+
_webui_log_debug("[Core]\t\t_webui_show_window() -> Native browser failed\n");
90218995
#endif
9022-
runBrowser = true;
90238996
}
9024-
} else {
8997+
}
8998+
else {
90258999
#ifdef WEBUI_LOG
9026-
_webui_log_debug("[Core]\t\t_webui_show_window() -> Starting server only mode (NoBrowser)\n");
9000+
_webui_log_debug("[Core]\t\t_webui_show_window() -> App-mode browser succeeded\n");
90279001
#endif
90289002
runBrowser = true;
90299003
}
9004+
} else {
9005+
#ifdef WEBUI_LOG
9006+
_webui_log_debug("[Core]\t\t_webui_show_window() -> Starting server only mode (NoBrowser)\n");
9007+
#endif
9008+
runBrowser = true;
9009+
}
9010+
}
9011+
9012+
// Try to open the UI in WebView if allowed and browser is failed.
9013+
bool runWebView = false;
9014+
if (!runBrowser) {
9015+
if (win->allow_webview) {
9016+
// Trying to use WebView
9017+
if (_webui_wv_show(win, window_url)) {
9018+
#ifdef WEBUI_LOG
9019+
_webui_log_debug("[Core]\t\t_webui_show_window() -> WebView Found\n");
9020+
#endif
9021+
win->current_browser = Webview;
9022+
_webui.current_browser = Webview;
9023+
runWebView = true;
9024+
}
9025+
else {
9026+
#ifdef WEBUI_LOG
9027+
_webui_log_debug("[Core]\t\t_webui_show_window() -> WebView Not Found\n");
9028+
#endif
9029+
}
90309030
}
90319031
}
90329032

0 commit comments

Comments
 (0)