]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0550: GTK4: 'mousehide' unhides cursor when switching tabs v9.2.0550
authorFoxe Chen <chen.foxe@gmail.com>
Thu, 28 May 2026 20:20:31 +0000 (20:20 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 28 May 2026 20:20:31 +0000 (20:20 +0000)
Problem:  GTK4: 'mousehide' unhides cursor when switching tabs
Solution: Only unide if the mouse actually moved (Foxe Chen).

fixes:  #20346
closes: #20347

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/gui_gtk4.c
src/version.c

index e87733728d9c0a874155897fb57cda4dd8bb341a..a4f5d1ee3d0ceb8608d598d35c41549a4d51ae3a 100644 (file)
@@ -1774,6 +1774,9 @@ button_release_event(GtkGestureClick *gesture, int n_press UNUSED,
     gui_send_mouse_event(MOUSE_RELEASE, (int)x, (int)y, FALSE, vim_modifiers);
 }
 
+static double prev_mouse_x = -1.0;
+static double prev_mouse_y = -1.0;
+
     static void
 motion_notify_event(GtkEventControllerMotion *controller UNUSED,
        double x, double y, gpointer data UNUSED)
@@ -1793,8 +1796,14 @@ motion_notify_event(GtkEventControllerMotion *controller UNUSED,
        }
     }
 
-    if (p_mh)
+    // Only unhide if mouse actually moved. GTK seems to send a motion event
+    // when switching tabs, causing the cursor to unhide.
+    if (p_mh && fabs(prev_mouse_x - x) > 0.05
+           && fabs(prev_mouse_y - y) > 0.05)
        gui_mch_mousehide(FALSE);
+
+    prev_mouse_x = x;
+    prev_mouse_y = y;
 }
 
     static void
@@ -1804,6 +1813,9 @@ enter_notify_event(GtkEventControllerMotion *controller UNUSED,
     if (blink_state == BLINK_NONE)
        gui_mch_start_blink();
 
+    prev_mouse_x = x;
+    prev_mouse_y = y;
+
     // Make sure keyboard input goes to the drawing area.
     if (!gtk_widget_has_focus(gui.drawarea))
        gtk_widget_grab_focus(gui.drawarea);
index 575332e4e6ba501178dc1ad3c85847eac7cc0847..bf1c31fc28c7c7ced05940353e520fffdaf23375 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    550,
 /**/
     549,
 /**/