[gtk/wip/carlosg/sequence-accepted-in-group-3-24] gtkgesture: Apply gesture group state after setting up sequence




commit 944a75659c199083180ae8141aac361aaa561e61
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon May 17 23:34:44 2021 +0200

    gtkgesture: Apply gesture group state after setting up sequence
    
    When a new sequence is added to a GtkGesture, its state is looked
    in other gestures in the same group, and made to match in this
    gesture. This however happened a bit too early, before the
    gesture touchpoint was fully set up. As this may result in signal
    emission and whatnot, it's a good idea to make it happen with a
    fully set up touchpoint.
    
    Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3946
    
    (Cherry-picked from commit 53df32e6cf1e2a7cbec8dd8d3b3acd4ddae2b9bf)

 gtk/gtkgesture.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c
index 98e07c7b6e..a867a5fd1d 100644
--- a/gtk/gtkgesture.c
+++ b/gtk/gtkgesture.c
@@ -585,8 +585,6 @@ _gtk_gesture_update_point (GtkGesture     *gesture,
                                           NULL, (gpointer *) &data);
   if (!existed)
     {
-      GtkEventSequenceState group_state;
-
       if (!add)
         return FALSE;
 
@@ -599,9 +597,6 @@ _gtk_gesture_update_point (GtkGesture     *gesture,
 
       data = g_new0 (PointData, 1);
       g_hash_table_insert (priv->points, sequence, data);
-
-      group_state = gtk_gesture_get_group_state (gesture, sequence);
-      gtk_gesture_set_sequence_state (gesture, sequence, group_state);
     }
 
   if (data->event)
@@ -611,13 +606,24 @@ _gtk_gesture_update_point (GtkGesture     *gesture,
   _update_touchpad_deltas (data);
   _update_widget_coordinates (gesture, data);
 
-  /* Deny the sequence right away if the expected
-   * number of points is exceeded, so this sequence
-   * can be tracked with gtk_gesture_handles_sequence().
-   */
-  if (!existed && _gtk_gesture_get_n_physical_points (gesture, FALSE) > priv->n_points)
-    gtk_gesture_set_sequence_state (gesture, sequence,
-                                    GTK_EVENT_SEQUENCE_DENIED);
+  if (!existed)
+    {
+      GtkEventSequenceState state;
+
+      /* Deny the sequence right away if the expected
+       * number of points is exceeded, so this sequence
+       * can be tracked with gtk_gesture_handles_sequence().
+       *
+       * Otherwise, make the sequence inherit the same state
+       * from other gestures in the same group.
+       */
+      if (_gtk_gesture_get_n_physical_points (gesture, FALSE) > priv->n_points)
+        state = GTK_EVENT_SEQUENCE_DENIED;
+      else
+        state = gtk_gesture_get_group_state (gesture, sequence);
+
+      gtk_gesture_set_sequence_state (gesture, sequence, state);
+    }
 
   return TRUE;
 }


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