]> git.armaanb.net Git - chorizo.git/commitdiff
Open new windows on middle click
authorPeter Hofmann <scm@uninformativ.de>
Sun, 15 Jun 2014 09:42:17 +0000 (11:42 +0200)
committerPeter Hofmann <scm@uninformativ.de>
Sun, 15 Jun 2014 09:55:52 +0000 (11:55 +0200)
browser.c

index 6a1d49e9501c734cdf73924f9bfc5c5aa2affa04..cd6044086a3f83f9f82c56cf62071260b2a46e11 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -467,6 +467,9 @@ gboolean
 key_web_view(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
        struct Client *c = (struct Client *)data;
+       WebKitHitTestResultContext ht_context;
+       WebKitHitTestResult *ht_result = NULL;
+       char *ht_uri =  NULL;
 
        (void)widget;
 
@@ -526,6 +529,20 @@ key_web_view(GtkWidget *widget, GdkEvent *event, gpointer data)
        {
                switch (((GdkEventButton *)event)->button)
                {
+                       case 2:
+                               ht_result = webkit_web_view_get_hit_test_result(
+                                                                  WEBKIT_WEB_VIEW(c->web_view),
+                                                                      (GdkEventButton *)event);
+                               g_object_get(ht_result, "context", &ht_context, NULL);
+                               if (ht_context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
+                               {
+                                       g_object_get(ht_result, "link-uri", &ht_uri, NULL);
+                                       client_new(ht_uri);
+                                       g_object_unref(ht_result);
+                                       return TRUE;
+                               }
+                               g_object_unref(ht_result);
+                               return FALSE;
                        case 8:
                                webkit_web_view_go_back(WEBKIT_WEB_VIEW(c->web_view));
                                return TRUE;