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.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Foxe Chen
2026-05-28 20:20:31 +00:00
committed by Christian Brabandt
parent 179f9efc7e
commit 880e06136b
2 changed files with 15 additions and 1 deletions
+13 -1
View 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);
+2
View File
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
550,
/**/
549,
/**/