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

1 view
Skip to first unread message

Christian Brabandt

unread,
May 28, 2026, 4:30:13 PMMay 28
to vim...@googlegroups.com
patch 9.2.0550: GTK4: 'mousehide' unhides cursor when switching tabs

Commit: https://github.com/vim/vim/commit/880e06136b91fe4243757659368272dbd86021f2
Author: Foxe Chen <chen...@gmail.com>
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 <chen...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

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,
/**/
Reply all
Reply to author
Forward
0 new messages