diff options
author | Christian Hergert <chergert@redhat.com> | 2016-04-24 02:41:26 -0700 |
---|---|---|
committer | Christian Hergert <chergert@redhat.com> | 2016-04-24 03:49:20 -0700 |
commit | 4f63d839550f7a9038b391e7d3e1e6fc8bdfafa6 (patch) | |
tree | 7ce542fc88b6a602b6b22211481229d5a387deeb /gtk/gtkkineticscrolling.c | |
parent | aa99c64fdd1cd6caccd708ea258d50f1db97b544 (diff) | |
download | gtk+-4f63d839550f7a9038b391e7d3e1e6fc8bdfafa6.tar.gz |
kineticscrolling: avoid stutter at tail of kinetic deceleration
When decelerating the kinetic scroll, we can get into a position where it
looks like we are stuttering. This happens because the amount we move is
so little that it takes multiple frames to make forward progress by one
pixel.
This prevents that by detecting when we have reached the slow stutter of
the deceleration and simply stops the deceleration phase immediately.
https://bugzilla.gnome.org/show_bug.cgi?id=765493
Diffstat (limited to 'gtk/gtkkineticscrolling.c')
-rw-r--r-- | gtk/gtkkineticscrolling.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gtk/gtkkineticscrolling.c b/gtk/gtkkineticscrolling.c index c33faee9c3..29bf085674 100644 --- a/gtk/gtkkineticscrolling.c +++ b/gtk/gtkkineticscrolling.c @@ -152,6 +152,8 @@ gtk_kinetic_scrolling_tick (GtkKineticScrolling *data, { case GTK_KINETIC_SCROLLING_PHASE_DECELERATING: { + gdouble last_position = data->position; + gdouble last_time = data->t; gdouble exp_part; data->t += time_delta; @@ -168,7 +170,8 @@ gtk_kinetic_scrolling_tick (GtkKineticScrolling *data, { gtk_kinetic_scrolling_init_overshoot(data, data->upper, data->position, data->velocity); } - else if (fabs(data->velocity) < 1) + else if (fabs(data->velocity) < 1 || + (last_time != 0.0 && fabs(data->position - last_position) < 1)) { data->phase = GTK_KINETIC_SCROLLING_PHASE_FINISHED; data->position = round(data->position); |