From: Carlos Garnacho Date: Tue, 15 Mar 2022 21:42:13 +0000 (+0100) Subject: gtkkineticscrolling: Do not take distance based shortcuts X-Git-Tag: archive/raspbian/4.8.3+ds-2+rpi1~3^2~20^2~4^2~296^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f7d9ede82dca41241902d86e5ee7d1997c02f4a2;p=gtk4.git gtkkineticscrolling: Do not take distance based shortcuts The pixel distance could be small enough between tick() calls that this kind of checks might potentially become a problem. Rely only on the calculated velocity to trigger the STOPPED phase, and use a lower threshold to avoid cutting the animation too early. Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/4725 --- diff --git a/gtk/gtkkineticscrolling.c b/gtk/gtkkineticscrolling.c index 8c697d54cd..1f02fe7993 100644 --- a/gtk/gtkkineticscrolling.c +++ b/gtk/gtkkineticscrolling.c @@ -181,8 +181,6 @@ gtk_kinetic_scrolling_tick (GtkKineticScrolling *data, { case GTK_KINETIC_SCROLLING_PHASE_DECELERATING: { - double last_position = data->position; - double last_time = data->t; double exp_part; data->t += time_delta; @@ -199,8 +197,7 @@ gtk_kinetic_scrolling_tick (GtkKineticScrolling *data, { gtk_kinetic_scrolling_init_overshoot(data, data->upper, data->position, data->velocity); } - else if (fabs(data->velocity) < 1 || - (last_time != 0.0 && fabs(data->position - last_position) < 1)) + else if (fabs(data->velocity) < 0.1) { gtk_kinetic_scrolling_stop (data); }