diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-03-25 22:42:10 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-03-25 22:42:10 -0400 |
commit | ba0722719ddc486c75578cdcdbbd8b18e97b8988 (patch) | |
tree | 6c9d9f4259efcadfddbcb60578c00a4cb8a22c72 | |
parent | 33ba1c77ae691d176d2fb5bc6010ee043ce69c4e (diff) | |
download | gtk+-device-timestamp.tar.gz |
textview: Use device timestamps for obscured cursorsdevice-timestamp
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.
Fixes: #3792
-rw-r--r-- | gtk/gtktextview.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 13b0e67752..33c40d3555 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -259,8 +259,12 @@ struct _GtkTextViewPrivate int bottom_padding; int indent; + + guint32 obscured_cursor_timestamp; + gint64 handle_place_time; PangoTabArray *tabs; + guint editable : 1; guint overwrite_mode : 1; @@ -5048,18 +5052,36 @@ gtk_text_view_state_flags_changed (GtkWidget *widget, static void gtk_text_view_obscure_mouse_cursor (GtkTextView *text_view) { + GdkDisplay *display; + GdkSeat *seat; + GdkDevice *device; + if (text_view->priv->mouse_cursor_obscured) return; gtk_widget_set_cursor_from_name (GTK_WIDGET (text_view), "none"); + display = gtk_widget_get_display (GTK_WIDGET (text_view)); + seat = gdk_display_get_default_seat (display); + device = gdk_seat_get_pointer (seat); + + text_view->priv->obscured_cursor_timestamp = gdk_device_get_timestamp (device); text_view->priv->mouse_cursor_obscured = TRUE; } static void gtk_text_view_unobscure_mouse_cursor (GtkTextView *text_view) { - if (text_view->priv->mouse_cursor_obscured) + GdkDisplay *display; + GdkSeat *seat; + GdkDevice *device; + + display = gtk_widget_get_display (GTK_WIDGET (text_view)); + seat = gdk_display_get_default_seat (display); + device = gdk_seat_get_pointer (seat); + + if (text_view->priv->mouse_cursor_obscured && + gdk_device_get_timestamp (device) != text_view->priv->obscured_cursor_timestamp) { gtk_widget_set_cursor_from_name (GTK_WIDGET (text_view), "text"); text_view->priv->mouse_cursor_obscured = FALSE; |