[gtk+/gestures: 50/140] scrolledwindow: Ensure the dragging sequence gets denied if more touches come in



commit dc03e13ef623e4d5e4de6b4909ce32a73a6554a8
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Mar 26 14:06:09 2014 +0100

    scrolledwindow: Ensure the dragging sequence gets denied if more touches come in
    
    This allows children to receive an emulated press, and handle it together with
    the new touch that made the scrolledwindow sequence denied.

 gtk/gtkscrolledwindow.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 875cc99..04bb0e5 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -656,15 +656,14 @@ scrolled_window_drag_end_cb (GtkScrolledWindow *scrolled_window,
                              GtkGesture        *gesture)
 {
   GtkScrolledWindowPrivate *priv = scrolled_window->priv;
+  GdkEventSequence *current, *last;
 
-  if (!priv->in_drag)
-    {
-      GdkEventSequence *sequence;
+  current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
+  last = gtk_gesture_get_last_updated_sequence (gesture);
 
-      sequence = gtk_gesture_get_last_updated_sequence (gesture);
-      gtk_widget_set_sequence_state (GTK_WIDGET (scrolled_window),
-                                     sequence, GTK_EVENT_SEQUENCE_DENIED);
-    }
+  if (!priv->in_drag || current != last)
+    gtk_widget_set_sequence_state (GTK_WIDGET (scrolled_window),
+                                   current, GTK_EVENT_SEQUENCE_DENIED);
 }
 
 static void
@@ -716,8 +715,11 @@ scrolled_window_long_press_cancelled_cb (GtkScrolledWindow *scrolled_window,
   sequence = gtk_gesture_get_last_updated_sequence (gesture);
   event = gtk_gesture_get_last_event (gesture, sequence);
 
-  if (event->type != GDK_TOUCH_END &&
-      event->type != GDK_BUTTON_RELEASE)
+  if (event->type == GDK_TOUCH_BEGIN)
+    gtk_widget_set_gesture_state (GTK_WIDGET (scrolled_window), gesture,
+                                  GTK_EVENT_SEQUENCE_DENIED);
+  else if (event->type != GDK_TOUCH_END &&
+           event->type != GDK_BUTTON_RELEASE)
     priv->in_drag = TRUE;
 }
 


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