From 53dddf163de2b16d6140a47240e07925a529639d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 14 Sep 2020 08:35:44 -0400 Subject: [PATCH] gestures: Make claiming button release work When claiming a sequence in a gesture signal handler, the expected result is that GtkGesture::handle-event returns TRUE, causing the event to not be propagated further. This doesn't work for button release events, since gtk_gesture_handle_event does the following: add point emit ::update remove point check claimed status The ::update signal is where the application code claims the sequence. But removing the point purges the sequence from the gestures memory, so checking the claimed status returns FALSE. This patch fixes things to behave as expected, by checking the claimed status before removing the point. --- gtk/gtkgesture.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c index 1e425869b3..f0bb28421a 100644 --- a/gtk/gtkgesture.c +++ b/gtk/gtkgesture.c @@ -660,7 +660,7 @@ gtk_gesture_handle_event (GtkEventController *controller, (event_type == GDK_TOUCHPAD_SWIPE && phase == GDK_TOUCHPAD_GESTURE_PHASE_END) || (event_type == GDK_TOUCHPAD_PINCH && phase == GDK_TOUCHPAD_GESTURE_PHASE_END)) { - gboolean was_claimed; + gboolean was_claimed = FALSE; if (_gtk_gesture_update_point (gesture, event, target, x, y, FALSE)) { @@ -668,12 +668,12 @@ gtk_gesture_handle_event (GtkEventController *controller, _gtk_gesture_check_recognized (gesture, sequence)) g_signal_emit (gesture, signals[UPDATE], 0, sequence); + was_claimed = + gtk_gesture_get_sequence_state (gesture, sequence) == GTK_EVENT_SEQUENCE_CLAIMED; + _gtk_gesture_remove_point (gesture, event); } - was_claimed = - gtk_gesture_get_sequence_state (gesture, sequence) == GTK_EVENT_SEQUENCE_CLAIMED; - return was_claimed && was_recognized; } else if (event_type == GDK_MOTION_NOTIFY ||