diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-03-25 22:40:30 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-03-26 10:30:33 -0400 |
commit | cdfdf031b5c9e677976488a12206562a0788fffd (patch) | |
tree | de23ff4ae58007caf7f3aa84961f2df2ca9e66d3 | |
parent | f131d68fef9ba92aad1eb3d838a4b930d8f1f2bf (diff) | |
download | gtk+-cdfdf031b5c9e677976488a12206562a0788fffd.tar.gz |
text: Use device timestamps for obscured cursors
Stash away the device timestamp when obscuring
the pointer, and compare it when we decice whether
to unobscure it. This fixes a problem where synthetic
motion events would make the cursor reappear
prematurely.
-rw-r--r-- | gtk/gtktext.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gtk/gtktext.c b/gtk/gtktext.c index d0711ed3f8..183bb3a269 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -205,6 +205,7 @@ struct _GtkTextPrivate int scroll_offset; int width_chars; int max_width_chars; + guint32 obscured_cursor_timestamp; gunichar invisible_char; @@ -2940,8 +2941,12 @@ gtk_text_motion_controller_motion (GtkEventControllerMotion *controller, GtkText *self) { GtkTextPrivate *priv = gtk_text_get_instance_private (self); + GdkDevice *device; - if (priv->mouse_cursor_obscured) + device = gtk_event_controller_get_current_event_device (GTK_EVENT_CONTROLLER (controller)); + + if (priv->mouse_cursor_obscured && + gdk_device_get_timestamp (device) != priv->obscured_cursor_timestamp) { set_text_cursor (GTK_WIDGET (self)); priv->mouse_cursor_obscured = FALSE; @@ -3162,12 +3167,20 @@ static void gtk_text_obscure_mouse_cursor (GtkText *self) { GtkTextPrivate *priv = gtk_text_get_instance_private (self); + GdkDisplay *display; + GdkSeat *seat; + GdkDevice *device; if (priv->mouse_cursor_obscured) return; gtk_widget_set_cursor_from_name (GTK_WIDGET (self), "none"); + display = gtk_widget_get_display (GTK_WIDGET (self)); + seat = gdk_display_get_default_seat (display); + device = gdk_seat_get_pointer (seat); + + priv->obscured_cursor_timestamp = gdk_device_get_timestamp (device); priv->mouse_cursor_obscured = TRUE; } |