[gtk/wip/exalm/swipe4] gestureswipe: Count last event when calculating velocity
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/exalm/swipe4] gestureswipe: Count last event when calculating velocity
- Date: Mon, 19 Oct 2020 12:01:23 +0000 (UTC)
commit 38901f58f358e32dc6e5018363c68bc8967a3083
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Oct 19 14:13:56 2020 +0500
gestureswipe: Count last event when calculating velocity
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 5dc6194b98792d937c648835cfadbe64977db443 for a similar fix in
GtkEventControllerScroll.
gtk/gtkgestureswipe.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkgestureswipe.c b/gtk/gtkgestureswipe.c
index 59c7aba807..8381f4810c 100644
--- a/gtk/gtkgestureswipe.c
+++ b/gtk/gtkgestureswipe.c
@@ -130,17 +130,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;
double 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.x = x;
new.y = y;
@@ -149,6 +148,15 @@ gtk_gesture_swipe_update (GtkGesture *gesture,
g_array_append_val (priv->events, new);
}
+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,
double *velocity_x,
@@ -194,6 +202,8 @@ gtk_gesture_swipe_end (GtkGesture *gesture,
double 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]