summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Mikhaylenko <alexm@gnome.org>2020-10-19 14:13:56 +0500
committerAlexander Mikhaylenko <alexm@gnome.org>2020-10-19 17:00:25 +0500
commit888e3f45ab5bec71ad7a3453983ebbf8ccbf7436 (patch)
treeb6aa7ac251fcf7be89f9e353bb76449aaa2ddf4b
parentddb7cab4acfe86ecdfa88eb0fc1c16dfb1efeeac (diff)
downloadgtk+-wip/exalm/swipe.tar.gz
gestureswipe: Count last event when calculating velocitywip/exalm/swipe
The last event, matching lifting the finger/releasing the mouse button, is important when there's a large delay between it and the previous events, as in when performing a movement, stopping, then releasing fingers as opposed to doing a swipe. If this event is skipped, doing this will result in kinetic deceleration matching the previous finger movement, while the expected behavior would be no deceleration. See also 97f540622abca60b54d5a8141d6f05bf791ffdb8 for a similar fix in GtkEventControllerScroll.
-rw-r--r--gtk/gtkgestureswipe.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/gtk/gtkgestureswipe.c b/gtk/gtkgestureswipe.c
index bf84eb5a3e..92efd25141 100644
--- a/gtk/gtkgestureswipe.c
+++ b/gtk/gtkgestureswipe.c
@@ -126,17 +126,16 @@ _gtk_gesture_swipe_clear_backlog (GtkGestureSwipe *gesture,
}
static void
-gtk_gesture_swipe_update (GtkGesture *gesture,
- GdkEventSequence *sequence)
+gtk_gesture_swipe_append_event (GtkGestureSwipe *swipe,
+ GdkEventSequence *sequence)
{
- GtkGestureSwipe *swipe = GTK_GESTURE_SWIPE (gesture);
GtkGestureSwipePrivate *priv;
EventData new;
gdouble x, y;
priv = gtk_gesture_swipe_get_instance_private (swipe);
- _gtk_gesture_get_last_update_time (gesture, sequence, &new.evtime);
- gtk_gesture_get_point (gesture, sequence, &x, &y);
+ _gtk_gesture_get_last_update_time (GTK_GESTURE (swipe), sequence, &new.evtime);
+ gtk_gesture_get_point (GTK_GESTURE (swipe), sequence, &x, &y);
new.point.x = x;
new.point.y = y;
@@ -146,6 +145,15 @@ gtk_gesture_swipe_update (GtkGesture *gesture,
}
static void
+gtk_gesture_swipe_update (GtkGesture *gesture,
+ GdkEventSequence *sequence)
+{
+ GtkGestureSwipe *swipe = GTK_GESTURE_SWIPE (gesture);
+
+ gtk_gesture_swipe_append_event (swipe, sequence);
+}
+
+static void
_gtk_gesture_swipe_calculate_velocity (GtkGestureSwipe *gesture,
gdouble *velocity_x,
gdouble *velocity_y)
@@ -190,6 +198,8 @@ gtk_gesture_swipe_end (GtkGesture *gesture,
gdouble velocity_x, velocity_y;
GdkEventSequence *seq;
+ gtk_gesture_swipe_append_event (swipe, sequence);
+
seq = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
if (gtk_gesture_get_sequence_state (gesture, seq) == GTK_EVENT_SEQUENCE_DENIED)