[gtk+/gestures: 131/173] widget: Change slightly the gesture cancellation policy in a same widget



commit e6b7b8d9c6e8ff2f57f21f14d6073ec03a55a99c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue May 6 14:12:13 2014 +0200

    widget: Change slightly the gesture cancellation policy in a same widget
    
    Within a widget, if a gesture accepts a sequence, it would previously
    cancel every other gesture that not in the same group. Change this to
    only cancelling gestures that previously claimed the gesture, and let
    gestures with state=NONE for that sequence remain like that.
    
    This enables late recognition of gestures, even on the presence of
    another gesture group that was more eager at claiming the gesture.
    
    One usecase is user-defined panning gestures on scrolledwindows,
    if ::capture-button-press is TRUE (eg. the default), the gesture is
    claimed early in order to consume the button press, but that would
    tipically make every other gesture group deny the sequence. With
    this change, the pan gesture can keep state=NONE, and later claim
    the sequence for itself if the panning gesture is recognized.
    
    Also, do not propagate state=DENIED to every gesture in the widget,
    that was unintended.

 gtk/gtkwidget.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 2d3407b..59aeebf 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -4216,18 +4216,23 @@ _gtk_widget_set_sequence_state_internal (GtkWidget             *widget,
           !gtk_gesture_handles_sequence (gesture, seq))
         seq = NULL;
 
-      /* If a group is provided, ensure only gestures pertaining to the group
-       * get a "claimed" state, all other gestures must deny the sequence.
-       */
-      if (group && gesture_state == GTK_EVENT_SEQUENCE_CLAIMED &&
-          !g_list_find (group, data->controller))
-        gesture_state = GTK_EVENT_SEQUENCE_DENIED;
+      if (group && !g_list_find (group, data->controller))
+        {
+          /* If a group is provided, ensure only gestures pertaining to the group
+           * get a "claimed" state, all other claiming gestures must deny the sequence.
+           */
+          if (gesture_state == GTK_EVENT_SEQUENCE_CLAIMED &&
+              gtk_gesture_get_sequence_state (gesture, sequence) == GTK_EVENT_SEQUENCE_CLAIMED)
+            gesture_state = GTK_EVENT_SEQUENCE_DENIED;
+          else
+            continue;
+        }
 
       g_signal_handler_block (data->controller, data->sequence_state_changed_id);
 
       sequence_handled =
         _gtk_gesture_handled_sequence_press (gesture, seq);
-      retval = gtk_gesture_set_sequence_state (gesture, seq, state);
+      retval = gtk_gesture_set_sequence_state (gesture, seq, gesture_state);
       handled |= retval;
 
       g_signal_handler_unblock (data->controller, data->sequence_state_changed_id);


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