Skip to content

GTK4: mouse move starts Visual selection after a dialog - #21022

Open
h-east wants to merge 1 commit into
vim:masterfrom
h-east:gtk4-forget-mouse-button-on-move
Open

GTK4: mouse move starts Visual selection after a dialog#21022
h-east wants to merge 1 commit into
vim:masterfrom
h-east:gtk4-forget-mouse-button-on-move

Conversation

@h-east

@h-east h-east commented Aug 12, 2026

Copy link
Copy Markdown
Member
Problem:  In GTK4, when a dialog pops up while a mouse button is pressed,
          moving the mouse afterwards starts a Visual selection without
          any button being held down.
Solution: Forget about the pressed mouse button when a mouse move reports
          that no button is down, since the button release event may have
          gone to another widget.

related: #20907


The GTK4 half of #21014, which fixes the same bug for GTK2/GTK3.

mouse_pressed_button is only cleared in button_release_event(). When a modal
dialog takes the release, the latch stays set and every later pointer motion is
reported as MOUSE_DRAG, which Vim turns into K_LEFTDRAG.

The fix differs from #21014 on purpose. GTK3 has gtk_grab_add() and
GtkWidget::grab-notify, so there the latch is cleared when another widget
shadows the text area with a grab. GTK4 has neither, and it is not clear that
GtkGestureClick gets a ::cancel when a modal toplevel appears. Here the latch
is dropped when a motion event reports that no button is down, which does not
depend on why the release was lost.

The comment claiming that the modifier state may not carry button masks on
Wayland is removed with it: dragging to extend a Visual selection was checked on
a Wayland session and works.

Problem:  In GTK4, when a dialog pops up while a mouse button is pressed,
          moving the mouse afterwards starts a Visual selection without
          any button being held down.
Solution: Forget about the pressed mouse button when a mouse move reports
          that no button is down, since the button release event may have
          gone to another widget.

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