Skip to content

Commit

Permalink
kinetic-scroll-view: Handle ClutterTimeline:stopped not :completed
Browse files Browse the repository at this point in the history
The former is always emitted when the timeline stops (either due to
reaching its duration, or due to clutter_timeline_stop() being called);
the latter is only emitted in the first case.

Changing signals means we can eliminate manual cleanup code after calls
to clutter_timeline_stop().

clutter-project#98
  • Loading branch information
Philip Withnall committed Sep 21, 2015
1 parent 63da1f2 commit 07d5575
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions mx/mx-kinetic-scroll-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,17 +1087,17 @@ clamp_adjustments (MxKineticScrollView *scroll,
}

static void
deceleration_completed_cb (ClutterTimeline *timeline,
MxKineticScrollView *scroll)
deceleration_stopped_cb (ClutterTimeline *timeline,
gboolean is_finished,
MxKineticScrollView *scroll)
{
MxKineticScrollViewPrivate *priv = scroll->priv;
guint duration;

duration = (priv->overshoot > 0.0) ? priv->clamp_duration : 10;
clamp_adjustments (scroll, duration, priv->hmoving, priv->vmoving);

g_object_unref (timeline);
priv->deceleration_timeline = NULL;
g_clear_object (&priv->deceleration_timeline);
}

static void
Expand Down Expand Up @@ -1201,7 +1201,6 @@ deceleration_new_frame_cb (ClutterTimeline *timeline,
if (stop)
{
clutter_timeline_stop (timeline);
deceleration_completed_cb (timeline, scroll);
}
}
}
Expand Down Expand Up @@ -1464,8 +1463,8 @@ release_event (MxKineticScrollView *scroll,

g_signal_connect (priv->deceleration_timeline, "new_frame",
G_CALLBACK (deceleration_new_frame_cb), scroll);
g_signal_connect (priv->deceleration_timeline, "completed",
G_CALLBACK (deceleration_completed_cb), scroll);
g_signal_connect (priv->deceleration_timeline, "stopped",
G_CALLBACK (deceleration_stopped_cb), scroll);
priv->accumulated_delta = 0;
priv->hmoving = priv->vmoving = TRUE;
clutter_timeline_start (priv->deceleration_timeline);
Expand Down Expand Up @@ -1530,9 +1529,6 @@ press_event (MxKineticScrollView *scroll,
clutter_timeline_stop (priv->deceleration_timeline);
g_object_unref (priv->deceleration_timeline);
priv->deceleration_timeline = NULL;

clamp_adjustments (scroll, priv->clamp_duration, priv->hmoving,
priv->vmoving);
}

if (priv->use_captured)
Expand Down

0 comments on commit 07d5575

Please sign in to comment.