diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c index d9bb937876..924b9ced96 100644 --- a/gtk/gtkgesture.c +++ b/gtk/gtkgesture.c @@ -268,7 +268,9 @@ _gtk_gesture_check_recognized (GtkGesture *gesture, current_n_points = _gtk_gesture_effective_n_points (gesture); - if (priv->recognized && current_n_points != priv->n_points) + if (priv->recognized && + (current_n_points != priv->n_points || + g_hash_table_size (priv->points) != priv->n_points)) _gtk_gesture_set_recognized (gesture, FALSE, sequence); else if (!priv->recognized && current_n_points == priv->n_points && @@ -351,6 +353,7 @@ _gtk_gesture_update_point (GtkGesture *gesture, GdkWindow *widget_window; GtkGesturePrivate *priv; GdkDevice *device; + gboolean existed; PointData *data; gdouble x, y; @@ -384,9 +387,9 @@ _gtk_gesture_update_point (GtkGesture *gesture, return FALSE; sequence = gdk_event_get_event_sequence (event); - - if (!g_hash_table_lookup_extended (priv->points, sequence, - NULL, (gpointer *) &data)) + existed = g_hash_table_lookup_extended (priv->points, sequence, + NULL, (gpointer *) &data); + if (!existed) { if (!add) return FALSE; @@ -407,6 +410,14 @@ _gtk_gesture_update_point (GtkGesture *gesture, data->event = gdk_event_copy (event); _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 && g_hash_table_size (priv->points) > priv->n_points) + gtk_gesture_set_sequence_state (gesture, sequence, + GTK_EVENT_SEQUENCE_DENIED); + return TRUE; } diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index afab8127fa..01d5f52619 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -650,19 +650,13 @@ scrolled_window_drag_update_cb (GtkScrolledWindow *scrolled_window, static void scrolled_window_drag_end_cb (GtkScrolledWindow *scrolled_window, - gdouble offset_x, - gdouble offset_y, + GdkEventSequence *sequence, GtkGesture *gesture) { GtkScrolledWindowPrivate *priv = scrolled_window->priv; - GdkEventSequence *current, *last; - current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)); - last = gtk_gesture_get_last_updated_sequence (gesture); - - if (!priv->in_drag || current != last) - gtk_gesture_set_sequence_state (gesture, current, - GTK_EVENT_SEQUENCE_DENIED); + if (!priv->in_drag || !gtk_gesture_handles_sequence (gesture, sequence)) + gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_DENIED); } static void @@ -759,7 +753,7 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window) g_signal_connect_swapped (priv->drag_gesture, "drag-update", G_CALLBACK (scrolled_window_drag_update_cb), scrolled_window); - g_signal_connect_swapped (priv->drag_gesture, "drag-end", + g_signal_connect_swapped (priv->drag_gesture, "end", G_CALLBACK (scrolled_window_drag_end_cb), scrolled_window);