Skip to content

Only open a URL on the initial button press - #1109

Open
Glen-Tigera wants to merge 1 commit into
gnome-terminator:masterfrom
Glen-Tigera:fix/url-opened-twice-on-double-click
Open

Only open a URL on the initial button press#1109
Glen-Tigera wants to merge 1 commit into
gnome-terminator:masterfrom
Glen-Tigera:fix/url-opened-twice-on-double-click

Conversation

@Glen-Tigera

Copy link
Copy Markdown

Problem

Ctrl+double-clicking a URL opens it twice — the browser gets two tabs for one gesture.

GDK delivers a double-click as BUTTON_PRESS, BUTTON_RELEASE, BUTTON_PRESS, _2BUTTON_PRESS. The URL branch of on_buttonpress tests only event.button and the Ctrl modifier:

if event.button == self.MOUSEBUTTON_LEFT:
    # Ctrl+leftclick on a URL should open it
    if self.config["link_single_click"] or event.get_state() & Gdk.ModifierType.CONTROL_MASK == Gdk.ModifierType.CONTROL_MASK:

so both the second BUTTON_PRESS and the _2BUTTON_PRESS reach open_url(). The _2BUTTON_PRESS guard near the top of the handler only covers Gtk.VScrollbar, not the terminal widget.

Same symptom in two other situations:

  • link_single_click enabled — an ordinary double-click on a URL opens two tabs
  • mouse switch bounce landing inside the double-click interval

Fix

Gate the URL branch on event.type == Gdk.EventType.BUTTON_PRESS.

Later event types fall through to the handler's closing return False, so VTE keeps handling double-click word selection and triple-click line selection exactly as before — only the duplicate open_url() calls go away.

Testing

Reproduced and verified on 2.1.3 (Ubuntu noble, GTK3, Wayland session, VTE 7600), with both link paths — OSC-8 hyperlinks via hyperlink_check_event and plain URLs via the regex match_check_event. Ctrl+double-click gave two browser tabs before the change and one after. Word and line selection unaffected.

🤖 Generated with Claude Code

Ctrl+double-clicking a URL opens it twice. GDK delivers a double-click as
BUTTON_PRESS, BUTTON_RELEASE, BUTTON_PRESS, _2BUTTON_PRESS; the URL branch
of on_buttonpress tests only event.button and the Ctrl modifier, so both the
second BUTTON_PRESS and the _2BUTTON_PRESS reach open_url and the browser
gets two tabs for one gesture. The same happens with a single click when
link_single_click is enabled, and with mouse switch bounce that lands inside
the double-click interval.

The existing _2BUTTON_PRESS guard near the top of the handler only covers
Gtk.VScrollbar, not the terminal widget.

Gate the URL branch on event.type == Gdk.EventType.BUTTON_PRESS. Later event
types fall through to the closing `return False`, so VTE still handles
double-click word selection and triple-click line selection as before.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant