]> git.armaanb.net Git - chorizo.git/commitdiff
Fix opening links in new tabs (partially)
authorPeter Hofmann <scm@uninformativ.de>
Sun, 16 Aug 2020 05:53:37 +0000 (07:53 +0200)
committerPeter Hofmann <scm@uninformativ.de>
Sun, 16 Aug 2020 06:00:46 +0000 (08:00 +0200)
Also, no NULL guard needed for g_free().

BUGS [new file with mode: 0644]
CHANGES
browser.c

diff --git a/BUGS b/BUGS
new file mode 100644 (file)
index 0000000..2be5ead
--- /dev/null
+++ b/BUGS
@@ -0,0 +1,15 @@
+Links sometimes do not open in a new tab
+========================================
+
+We select for "mouse-target-changed" events: When the pointer is being
+moved, WebKit tells us if it's now being positioned over a link or not.
+
+However, when a new link pops into existence right below the mouse
+pointer (without the pointer being moved), we don't get this event. When
+the user now issues a middle-click, we open the link in the same tab.
+This is wrong.
+
+Ideally, we could access a hit test result while processing the click
+event, but that doesn't appear to be possible?
+
+This bug is also present in suckless surf and GNOME Epiphany.
diff --git a/CHANGES b/CHANGES
index 42bb1c5bf36d7a29e5409fefed2733efc3e803ca..538ad112c1a8c664e66845362d100b263792262c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,11 @@
 Release history for lariza
 
+next
+  [Fixed]
+  - Middle-click to open in a new tab has been improved. In certain
+    conditions, the user's intention to open a new tab has been ignored
+    and URLs haven been opened in the current tab.
+
 v20.07  2020-07-19
   [Fixed]
   - Build no longer depends on GNU sed.
index 8df0e330777700e743a953d9cd7123db95e30109..3e0a4a7df8e40858942fb3b38dd27848b67b0578 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -767,28 +767,23 @@ hover_web_view(WebKitWebView *web_view, WebKitHitTestResult *ht, guint modifiers
                gpointer data)
 {
     struct Client *c = (struct Client *)data;
+    const char *to_show;
 
-    if (!gtk_widget_is_focus(c->location))
-    {
-        if (webkit_hit_test_result_context_is_link(ht))
-        {
-            gtk_entry_set_text(GTK_ENTRY(c->location),
-                               webkit_hit_test_result_get_link_uri(ht));
-
-            if (c->hover_uri != NULL)
-                g_free(c->hover_uri);
-            c->hover_uri = g_strdup(webkit_hit_test_result_get_link_uri(ht));
-        }
-        else
-        {
-            gtk_entry_set_text(GTK_ENTRY(c->location),
-                               webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view)));
+    g_free(c->hover_uri);
 
-            if (c->hover_uri != NULL)
-                g_free(c->hover_uri);
-            c->hover_uri = NULL;
-        }
+    if (webkit_hit_test_result_context_is_link(ht))
+    {
+        to_show = webkit_hit_test_result_get_link_uri(ht);
+        c->hover_uri = g_strdup(to_show);
     }
+    else
+    {
+        to_show = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(c->web_view));
+        c->hover_uri = NULL;
+    }
+
+    if (!gtk_widget_is_focus(c->location))
+        gtk_entry_set_text(GTK_ENTRY(c->location), to_show);
 }
 
 void