[gtk/device-timestamp: 7/8] text: Use device timestamps for obscured cursors
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/device-timestamp: 7/8] text: Use device timestamps for obscured cursors
- Date: Fri, 26 Mar 2021 14:31:11 +0000 (UTC)
commit cdfdf031b5c9e677976488a12206562a0788fffd
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Mar 25 22:40:30 2021 -0400
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.
gtk/gtktext.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
---
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]