From: Foxe Chen Date: Thu, 28 May 2026 20:20:31 +0000 (+0000) Subject: patch 9.2.0550: GTK4: 'mousehide' unhides cursor when switching tabs X-Git-Tag: v9.2.0550^0 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=880e06136b91fe4243757659368272dbd86021f2;p=thirdparty%2Fvim.git 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 Signed-off-by: Christian Brabandt --- diff --git a/src/gui_gtk4.c b/src/gui_gtk4.c index e87733728d..a4f5d1ee3d 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 575332e4e6..bf1c31fc28 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, /**/