patch 9.2.0946: GTK2/3: mouse move starts Visual selection after a dialog
Commit:
https://github.com/vim/vim/commit/2efa9e317955057433b8aada30f3e91f9bdaffd0
Author: Hirohito Higashi <
h.eas...@gmail.com>
Date: Wed Aug 12 18:53:42 2026 +0000
patch 9.2.0946: GTK2/3: mouse move starts Visual selection after a dialog
Problem: In GTK2/GTK3, 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 another widget
shadows the text area with a grab, since the button release
event goes to that widget (Hirohito Higashi).
fixes: #20907
closes: #21014
Co-Authored-By: Claude Opus 5 (1M context) <
nor...@anthropic.com>
Signed-off-by: Hirohito Higashi <
h.eas...@gmail.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 2e60484ee..571f93817 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -2222,6 +2222,20 @@ button_release_event(GtkWidget *widget UNUSED,
return TRUE;
}
+/*
+ * Another widget, e.g. a modal dialog, was shadowing us with a GTK grab. The
+ * button release went to that widget, thus forget about the pressed button to
+ * avoid that the next mouse move is taken for a drag.
+ */
+ static void
+grab_notify_event(GtkWidget *widget UNUSED,
+ gboolean was_grabbed,
+ gpointer data UNUSED)
+{
+ if (!was_grabbed)
+ dragging_button_state = 0;
+}
+
#ifdef FEAT_DND
/////////////////////////////////////////////////////////////////////////////
@@ -4228,6 +4242,8 @@ gui_mch_init(void)
G_CALLBACK(button_press_event), NULL);
g_signal_connect(G_OBJECT(gui.drawarea), "button-release-event",
G_CALLBACK(button_release_event), NULL);
+ g_signal_connect(G_OBJECT(gui.drawarea), "grab-notify",
+ G_CALLBACK(grab_notify_event), NULL);
g_signal_connect(G_OBJECT(gui.drawarea), "scroll-event",
G_CALLBACK(scroll_event), NULL);
diff --git a/src/version.c b/src/version.c
index 7eb3acd62..7d7635c04 100644
--- a/src/version.c
+++ b/src/version.c
@@ -763,6 +763,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 946,
/**/
945,
/**/