Skip to content

Commit

Permalink
gtkscrolledwindow: Refactor kinetic scroll animation
Browse files Browse the repository at this point in the history
Do not depend on the kinetic scroll helpers existing or not before
exiting the animation, as we may want to keep those a little bit
longer after stopped.
  • Loading branch information
garnacho committed Mar 19, 2022
1 parent 274e2b2 commit 129bc27
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions gtk/gtkscrolledwindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -3268,6 +3268,7 @@ scrolled_window_deceleration_cb (GtkWidget *widget,
GtkAdjustment *hadjustment, *vadjustment;
gint64 current_time;
double position, elapsed;
gboolean retval = G_SOURCE_REMOVE;

current_time = gdk_frame_clock_get_frame_time (frame_clock);
elapsed = (current_time - priv->last_deceleration_time) / (double)G_TIME_SPAN_SECOND;
Expand All @@ -3283,6 +3284,7 @@ scrolled_window_deceleration_cb (GtkWidget *widget,
{
priv->unclamped_hadj_value = position;
gtk_adjustment_set_value (hadjustment, position);
retval = G_SOURCE_CONTINUE;
}
else if (priv->hscrolling)
g_clear_pointer (&priv->hscrolling, gtk_kinetic_scrolling_free);
Expand All @@ -3292,19 +3294,17 @@ scrolled_window_deceleration_cb (GtkWidget *widget,
{
priv->unclamped_vadj_value = position;
gtk_adjustment_set_value (vadjustment, position);
retval = G_SOURCE_CONTINUE;
}
else if (priv->vscrolling)
g_clear_pointer (&priv->vscrolling, gtk_kinetic_scrolling_free);

if (!priv->hscrolling && !priv->vscrolling)
{
gtk_scrolled_window_cancel_deceleration (scrolled_window);
return G_SOURCE_REMOVE;
}

gtk_scrolled_window_invalidate_overshoot (scrolled_window);
if (retval == G_SOURCE_REMOVE)
gtk_scrolled_window_cancel_deceleration (scrolled_window);
else
gtk_scrolled_window_invalidate_overshoot (scrolled_window);

return G_SOURCE_CONTINUE;
return retval;
}

static void
Expand Down

0 comments on commit 129bc27

Please sign in to comment.