patch 9.2.0550: GTK4: 'mousehide' unhides cursor when switching tabs

Commit: 
https://github.com/vim/vim/commit/880e06136b91fe4243757659368272dbd86021f2
Author: Foxe Chen <[email protected]>
Date:   Thu May 28 20:20:31 2026 +0000

    patch 9.2.0550: GTK4: 'mousehide' unhides cursor when switching tabs
    
    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/gui_gtk4.c b/src/gui_gtk4.c
index e87733728..a4f5d1ee3 100644
--- a/src/gui_gtk4.c
+++ b/src/gui_gtk4.c
@@ -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);
diff --git a/src/version.c b/src/version.c
index 575332e4e..bf1c31fc2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    550,
 /**/
     549,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1wShMj-00BSkf-E2%40256bit.org.

Raspunde prin e-mail lui