Fancy: fix left-click on links not opening in browser.
authorColin Leroy <colin@colino.net>
Mon, 15 Oct 2018 08:39:21 +0000 (10:39 +0200)
committerColin Leroy <colin@colino.net>
Mon, 15 Oct 2018 08:39:21 +0000 (10:39 +0200)
src/plugins/fancy/fancy_viewer.c

index a10f6bca1e601c37a0a6fcf9a664c71266c42fa0..3792e846bbc767a298e03fc1e5c27cf9095a5c3d 100644 (file)
@@ -902,17 +902,30 @@ static gboolean press_button_cb (WebKitWebView *view, GdkEvent *ev,
                FancyViewer *viewer)
 {
        gint type = 0;
+       gchar *link = NULL;
+
        WebKitHitTestResult *result =
                webkit_web_view_get_hit_test_result(view, (GdkEventButton *)ev);
 
        g_object_get(G_OBJECT(result),
                        "context", &type,
-                       "x", &viewer->click_x, "y", &viewer->click_y,
+                       "x", &viewer->click_x,
+                       "y", &viewer->click_y,
+                       "link-uri", &link,
                        NULL);
 
        if (type & WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION)
                return FALSE;
 
+       if (viewer->cur_link) {
+               g_free(viewer->cur_link);
+               viewer->cur_link = NULL;
+       }
+       if (link != NULL) {
+               debug_print("press on %s\n", link);
+               viewer->cur_link = link; /* g_context returned a newly-allocated string */
+       }
+
        viewer->doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(viewer->view));
        viewer->window = webkit_dom_document_get_default_view (viewer->doc);
        viewer->selection = webkit_dom_dom_window_get_selection (viewer->window);