diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 15 | ||||
-rw-r--r-- | src/main.h | 1 | ||||
-rw-r--r-- | src/setting.c | 1 |
3 files changed, 16 insertions, 1 deletions
@@ -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; @@ -235,6 +235,7 @@ struct Client { guint scrollstep; gboolean input_autohide; gboolean incsearch; + gboolean prevent_newwindow; guint default_zoom; /* default zoom level in percent */ Shortcut *shortcuts; } config; diff --git a/src/setting.c b/src/setting.c index ea58fc2..51883ee 100644 --- a/src/setting.c +++ b/src/setting.c @@ -114,6 +114,7 @@ void setting_init(Client *c) setting_add(c, "monospace-font-size", TYPE_INTEGER, &i, webkit, 0, "default-monospace-font-size"); setting_add(c, "offline-cache", TYPE_BOOLEAN, &on, webkit, 0, "enable-offline-web-application-cache"); setting_add(c, "plugins", TYPE_BOOLEAN, &on, webkit, 0, "enable-plugins"); + setting_add(c, "prevent-newwindow", TYPE_BOOLEAN, &off, internal, 0, &c->config.prevent_newwindow); setting_add(c, "print-backgrounds", TYPE_BOOLEAN, &on, webkit, 0, "print-backgrounds"); setting_add(c, "private-browsing", TYPE_BOOLEAN, &off, webkit, 0, "enable-private-browsing"); setting_add(c, "sans-serif-font", TYPE_CHAR, &"sans-serif", webkit, 0, "sans-serif-font-family"); |