summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2019-03-24 00:53:47 +0100
committerDaniel Carl <danielcarl@gmx.de>2019-03-24 00:57:34 +0100
commit6ef95d13cf1f6313b67cf63acdb7fc07ac02cb2b (patch)
tree7dbfb6c23797497e645b11c82ed20215af930338 /src/main.c
parentbae3e38219d4ee82dc1b6209645cbc14256a9f32 (diff)
Prevent opening links into new window #544.
Added setting 'prevent-newwindow' to enforce opening links into same window even if they are crafted by `target="_blank"` or using `window.open()`. This option does not change the behaviour for links fired by hinting.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 87ba59e..8127235 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1214,6 +1214,14 @@ static void on_webview_close(WebKitWebView *webview, Client *c)
static WebKitWebView *on_webview_create(WebKitWebView *webview,
WebKitNavigationAction *navact, Client *c)
{
+ WebKitURIRequest *req;
+ if (c->config.prevent_newwindow) {
+ req = webkit_navigation_action_get_request(navact);
+ vb_load_uri(c, &(Arg){TARGET_CURRENT, (char*)webkit_uri_request_get_uri(req)});
+
+ return NULL;
+ }
+
Client *new = client_new(webview);
return new->webview;
@@ -1302,7 +1310,12 @@ static void decide_new_window_action(Client *c, WebKitPolicyDecision *dec)
* without user gesture. */
if (webkit_navigation_action_is_user_gesture(a)) {
req = webkit_navigation_action_get_request(a);
- spawn_new_instance(webkit_uri_request_get_uri(req));
+ if (c->config.prevent_newwindow) {
+ /* Load the uri into the browser instance. */
+ vb_load_uri(c, &(Arg){TARGET_CURRENT, (char*)webkit_uri_request_get_uri(req)});
+ } else {
+ spawn_new_instance(webkit_uri_request_get_uri(req));
+ }
}
break;