From fe1112f48033ed672cf4060e9d86b2fa7b840b94 Mon Sep 17 00:00:00 2001 From: Laan Tungir Date: Sat, 18 Jul 2026 20:28:51 -0400 Subject: [PATCH] v0.0.46 - Release: target=_blank links open in new tab instead of new window --- VERSION | 2 +- src/tab_manager.c | 39 +++++++++++++++++++++------------------ src/version.h | 4 ++-- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/VERSION b/VERSION index 31c01c9..1df5b7e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.45 +0.0.46 diff --git a/src/tab_manager.c b/src/tab_manager.c index 70db4fb..feb9fb7 100644 --- a/src/tab_manager.c +++ b/src/tab_manager.c @@ -1082,8 +1082,15 @@ static gboolean on_decide_policy(WebKitWebView *webview, /* ── New webview creation (target="_blank") ────────────────────────── * * When a page requests a new window (target="_blank", window.open()), - * WebKit fires the "create" signal on the webview. We create a new tab - * with the requested URI and return its webview. + * WebKit fires the "create" signal on the webview. We open the requested + * URI in a new tab in the current window (matching the behavior of other + * tabbed browsers like Brave/Firefox) and return the new tab's webview. + * + * The new webview is created with webkit_web_view_new_with_related_view() + * (via the g_target_related_view mechanism in tab_create) so it shares the + * parent's WebProcess and window features — this avoids the + * std::optional assertion crash that occurs with + * webkit_web_view_new_with_context() for target="_blank" requests. */ static GtkWidget *on_create_webview(WebKitWebView *webview, @@ -1094,24 +1101,20 @@ static GtkWidget *on_create_webview(WebKitWebView *webview, WebKitURIRequest *request = webkit_navigation_action_get_request(action); const char *uri = webkit_uri_request_get_uri(request); - /* When a page requests a new window (target="_blank", window.open()), - * WebKit fires the "create" signal. We create a real GtkWindow with - * its own webview (created with webkit_web_view_new_with_related_view - * so it shares the parent's WebProcess) and return that webview. - * - * Using webkit_web_view_new_with_related_view() shares the WebProcess - * and the related view's window features, which avoids the previous - * std::optional assertion crash that occurred when - * returning a webview created with webkit_web_view_new_with_context(). - * - * If new window creation fails, fall back to opening a tab. */ if (uri && uri[0]) { - GtkWidget *new_wv = tab_manager_new_window(uri, webview); - if (new_wv != NULL) { - return new_wv; + /* Set the related view so tab_create() uses + * webkit_web_view_new_with_related_view() — shares the parent's + * WebProcess and avoids the WindowFeatures assertion crash. */ + g_target_related_view = webview; + int idx = tab_manager_new_tab(uri); + g_target_related_view = NULL; + + if (idx >= 0) { + tab_info_t *tab = tab_manager_get(idx); + if (tab && tab->webview) { + return GTK_WIDGET(tab->webview); + } } - /* Fallback: open in a new tab in the main window. */ - tab_manager_new_tab(uri); } return NULL; diff --git a/src/version.h b/src/version.h index d79fbb3..3c07207 100644 --- a/src/version.h +++ b/src/version.h @@ -11,9 +11,9 @@ #ifndef SOVEREIGN_BROWSER_VERSION_H #define SOVEREIGN_BROWSER_VERSION_H -#define SB_VERSION "v0.0.45" +#define SB_VERSION "v0.0.46" #define SB_VERSION_MAJOR 0 #define SB_VERSION_MINOR 0 -#define SB_VERSION_PATCH 45 +#define SB_VERSION_PATCH 46 #endif /* SOVEREIGN_BROWSER_VERSION_H */