summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2020-10-21 16:20:58 +0000
committerCarlos Garnacho <carlosg@gnome.org>2020-10-21 16:20:58 +0000
commit32b826e3123788f0d01c853902516717d9e9135f (patch)
treeb0bd33d1282590de5453cae6ff5d579633ab3792
parent8880e3bd2e060874aba303595303624116c883e0 (diff)
parent700ca3b946717ddc31ae5211251cfa4069d60ef0 (diff)
downloadgtk+-32b826e3123788f0d01c853902516717d9e9135f.tar.gz
Merge branch 'wip/exalm/swipe4' into 'master'
gestureswipe: Count last event when calculating velocity See merge request GNOME/gtk!2715
-rw-r--r--gtk/gtkgestureswipe.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/gtk/gtkgestureswipe.c b/gtk/gtkgestureswipe.c
index 59c7aba807..56de01c221 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;
@@ -150,6 +149,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,
double *velocity_x,
double *velocity_y)
@@ -202,6 +210,8 @@ gtk_gesture_swipe_end (GtkGesture *gesture,
if (gtk_gesture_is_active (gesture))
return;
+ gtk_gesture_swipe_append_event (swipe, sequence);
+
priv = gtk_gesture_swipe_get_instance_private (swipe);
_gtk_gesture_swipe_calculate_velocity (swipe, &velocity_x, &velocity_y);
g_signal_emit (gesture, signals[SWIPE], 0, velocity_x, velocity_y);