Merge branch 'wip/exalm/swipe' into 'gtk-3-24'

gestureswipe: Count last event when calculating velocity

See merge request GNOME/gtk!2714
This commit is contained in:
Carlos Garnacho 2020-10-21 16:58:27 +00:00
commit f4c366044b

View File

@ -126,17 +126,16 @@ _gtk_gesture_swipe_clear_backlog (GtkGestureSwipe *gesture,
}
static void
gtk_gesture_swipe_update (GtkGesture *gesture,
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;
@ -145,6 +144,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,
gdouble *velocity_x,
@ -198,6 +206,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);