clutter/actor: Return the actor used when picking clock

The actor used might be relevant, so that e.g. if it moves or for some
other reason changes stage views, the user can listen for that.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1404
This commit is contained in:
Jonas Ådahl 2020-08-12 18:08:35 +02:00
parent 9bcb03ab48
commit 07e964e9fc
5 changed files with 21 additions and 10 deletions

View File

@ -16356,13 +16356,17 @@ clutter_actor_is_effectively_on_stage_view (ClutterActor *self,
/** /**
* clutter_actor_pick_frame_clock: (skip) * clutter_actor_pick_frame_clock: (skip)
* @self: a #ClutterActor * @self: a #ClutterActor
* @out_actor: (nullable): a pointer to an #ClutterActor
* *
* Pick the most suitable frame clock for driving animations for this actor. * Pick the most suitable frame clock for driving animations for this actor.
* *
* The #ClutterActor used for picking the frame clock is written @out_actor.
*
* Returns: (transfer none): a #ClutterFrameClock * Returns: (transfer none): a #ClutterFrameClock
*/ */
ClutterFrameClock * ClutterFrameClock *
clutter_actor_pick_frame_clock (ClutterActor *self) clutter_actor_pick_frame_clock (ClutterActor *self,
ClutterActor **out_actor)
{ {
ClutterActorPrivate *priv = self->priv; ClutterActorPrivate *priv = self->priv;
float max_refresh_rate = 0.0; float max_refresh_rate = 0.0;
@ -16372,7 +16376,7 @@ clutter_actor_pick_frame_clock (ClutterActor *self)
if (!priv->stage_views) if (!priv->stage_views)
{ {
if (priv->parent) if (priv->parent)
return clutter_actor_pick_frame_clock (priv->parent); return clutter_actor_pick_frame_clock (priv->parent, out_actor);
else else
return NULL; return NULL;
} }
@ -16391,9 +16395,15 @@ clutter_actor_pick_frame_clock (ClutterActor *self)
} }
if (best_view) if (best_view)
return clutter_stage_view_get_frame_clock (best_view); {
if (out_actor)
*out_actor = self;
return clutter_stage_view_get_frame_clock (best_view);
}
else else
return NULL; {
return NULL;
}
} }
/** /**

View File

@ -69,7 +69,8 @@ CLUTTER_EXPORT
gboolean clutter_actor_has_transitions (ClutterActor *actor); gboolean clutter_actor_has_transitions (ClutterActor *actor);
CLUTTER_EXPORT CLUTTER_EXPORT
ClutterFrameClock * clutter_actor_pick_frame_clock (ClutterActor *self); ClutterFrameClock * clutter_actor_pick_frame_clock (ClutterActor *self,
ClutterActor **out_actor);
#undef __CLUTTER_H_INSIDE__ #undef __CLUTTER_H_INSIDE__

View File

@ -393,7 +393,7 @@ update_frame_clock (ClutterTimeline *timeline)
if (!priv->actor) if (!priv->actor)
goto out; goto out;
frame_clock = clutter_actor_pick_frame_clock (priv->actor); frame_clock = clutter_actor_pick_frame_clock (priv->actor, NULL);
if (frame_clock) if (frame_clock)
{ {
g_clear_signal_handler (&priv->stage_stage_views_handler_id, priv->stage); g_clear_signal_handler (&priv->stage_stage_views_handler_id, priv->stage);

View File

@ -1237,7 +1237,7 @@ handle_stage_views_changed (MetaWindowActorX11 *actor_x11)
{ {
ClutterActor *actor = CLUTTER_ACTOR (actor_x11); ClutterActor *actor = CLUTTER_ACTOR (actor_x11);
actor_x11->frame_clock = clutter_actor_pick_frame_clock (actor); actor_x11->frame_clock = clutter_actor_pick_frame_clock (actor, NULL);
if (actor_x11->frame_clock && actor_x11->pending_schedule_update_now) if (actor_x11->frame_clock && actor_x11->pending_schedule_update_now)
{ {
clutter_frame_clock_schedule_update_now (actor_x11->frame_clock); clutter_frame_clock_schedule_update_now (actor_x11->frame_clock);

View File

@ -652,15 +652,15 @@ meta_test_actor_stage_views_frame_clock (void)
stage_views->data, stage_views->data,
stage_views->next->data); stage_views->next->data);
frame_clock = clutter_actor_pick_frame_clock (actor_1); frame_clock = clutter_actor_pick_frame_clock (actor_1, NULL);
g_assert_cmpfloat (clutter_frame_clock_get_refresh_rate (frame_clock), g_assert_cmpfloat (clutter_frame_clock_get_refresh_rate (frame_clock),
==, ==,
60.0); 60.0);
frame_clock = clutter_actor_pick_frame_clock (actor_2); frame_clock = clutter_actor_pick_frame_clock (actor_2, NULL);
g_assert_cmpfloat (clutter_frame_clock_get_refresh_rate (frame_clock), g_assert_cmpfloat (clutter_frame_clock_get_refresh_rate (frame_clock),
==, ==,
30.0); 30.0);
frame_clock = clutter_actor_pick_frame_clock (actor_3); frame_clock = clutter_actor_pick_frame_clock (actor_3, NULL);
g_assert_cmpfloat (clutter_frame_clock_get_refresh_rate (frame_clock), g_assert_cmpfloat (clutter_frame_clock_get_refresh_rate (frame_clock),
==, ==,
60.0); 60.0);