]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0946: GTK2/3: mouse move starts Visual selection after a dialog v9.2.0946
authorHirohito Higashi <h.east.727@gmail.com>
Wed, 12 Aug 2026 18:53:42 +0000 (18:53 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 12 Aug 2026 19:01:20 +0000 (19:01 +0000)
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) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/gui_gtk_x11.c
src/version.c

index 2e60484ee000b73d8dcc699815805a9a894226f6..571f9381739594fd822e321ae6b18e9fbbcefd9b 100644 (file)
@@ -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);
 
index 7eb3acd6290682f9e904c5efc1df68adea96391f..7d7635c0454732d88bef459f76f3a7362e5eb815 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    946,
 /**/
     945,
 /**/