From d68f77738257f89f8a4819f61661481c9c4442a3 Mon Sep 17 00:00:00 2001
From: Daniel Carl <danielcarl@gmx.de>
Date: Sat, 4 Jan 2014 16:55:54 +0100
Subject: [PATCH] Allow to open links into new window by ctrl and left mouse.

---
 src/main.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/main.c b/src/main.c
index 09460dc..e2899e7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -800,15 +800,17 @@ static gboolean button_relase_cb(WebKitWebView *webview, GdkEventButton *event)
     WebKitHitTestResult *result = webkit_web_view_get_hit_test_result(webview, event);
 
     g_object_get(result, "context", &context, NULL);
-    if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE) {
+    if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) {
+        if (event->button == 2 || (event->button == 1 && event->state & GDK_CONTROL_MASK)) {
+            /* ctrl click or middle mouse click onto link */
+            Arg a = {VB_TARGET_NEW};
+            g_object_get(result, "link-uri", &a.s, NULL);
+            vb_load_uri(&a);
+
+            propagate = true;
+        }
+    } else if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE) {
         mode_enter('i');
-        propagate = true;
-    } else if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK && event->button == 2) {
-        /* middle mouse click onto link */
-        Arg a = {VB_TARGET_NEW};
-        g_object_get(result, "link-uri", &a.s, NULL);
-        vb_load_uri(&a);
-
         propagate = true;
     }
     g_object_unref(result);
-- 
2.20.1