[gtk/wip/carlosg/tablet-fixes: 3/3] gesturestylus: Use GtkEventControllerEvent events to track changes




commit ba5cfdc2004a77f9ee3bebc01157454f06cceb76
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Dec 2 17:00:10 2021 +0100

    gesturestylus: Use GtkEventControllerEvent events to track changes
    
    We use gtk_gesture_get_last_event() underneath at places that need to
    work during ::proximity emission. Since GtkGesture only tracks events
    while there are button/touch presses involved, this is not going to
    bring the right result there.
    
    Use gtk_event_controller_get_current_event() consistently inside,
    which always pokes at the event being handled (which is the correct
    intent here).

 gtk/gtkgesturestylus.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkgesturestylus.c b/gtk/gtkgesturestylus.c
index 3422a037f5..eba6848759 100644
--- a/gtk/gtkgesturestylus.c
+++ b/gtk/gtkgesturestylus.c
@@ -194,16 +194,6 @@ gtk_gesture_stylus_new (void)
                        NULL);
 }
 
-static GdkEvent *
-gesture_get_current_event (GtkGestureStylus *gesture)
-{
-  GdkEventSequence *sequence;
-
-  sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
-
-  return gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
-}
-
 /**
  * gtk_gesture_stylus_get_axis:
  * @gesture: a `GtkGestureStylus`
@@ -230,7 +220,7 @@ gtk_gesture_stylus_get_axis (GtkGestureStylus *gesture,
   g_return_val_if_fail (axis < GDK_AXIS_LAST, FALSE);
   g_return_val_if_fail (value != NULL, FALSE);
 
-  event = gesture_get_current_event (gesture);
+  event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
   if (!event)
     return FALSE;
 
@@ -264,7 +254,7 @@ gtk_gesture_stylus_get_axes (GtkGestureStylus  *gesture,
   g_return_val_if_fail (GTK_IS_GESTURE_STYLUS (gesture), FALSE);
   g_return_val_if_fail (values != NULL, FALSE);
 
-  event = gesture_get_current_event (gesture);
+  event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
   if (!event)
     return FALSE;
 
@@ -331,7 +321,7 @@ gtk_gesture_stylus_get_backlog (GtkGestureStylus  *gesture,
   g_return_val_if_fail (GTK_IS_GESTURE_STYLUS (gesture), FALSE);
   g_return_val_if_fail (backlog != NULL && n_elems != NULL, FALSE);
 
-  event = gesture_get_current_event (gesture);
+  event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
 
   if (event && GDK_IS_EVENT_TYPE (event, GDK_MOTION_NOTIFY))
     history = gdk_event_get_history (event, &n_coords);
@@ -391,7 +381,7 @@ gtk_gesture_stylus_get_device_tool (GtkGestureStylus *gesture)
 
   g_return_val_if_fail (GTK_IS_GESTURE_STYLUS (gesture), FALSE);
 
-  event = gesture_get_current_event (gesture);
+  event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
   if (!event)
     return NULL;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]