laters: Use clutter_stage_schedule_update() instead of timeline

The MetaLater functionality needs to make sure an update is scheduled so
that it can run its callbacks etc. This used a ClutterTimeline (which is
an object more or less meant to drive animations markers, frames etc)
just to keep the master frame clock running. We're moving away from a
single master clock, so just schedule updates directly instead, with the
newly exposed API.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
This commit is contained in:
Jonas Ådahl 2020-04-16 19:16:26 +02:00
parent 1e284c601c
commit fc0b8f9d9c

View File

@ -50,7 +50,6 @@ struct _MetaLaters
GSList *laters[META_LATER_N_TYPES]; GSList *laters[META_LATER_N_TYPES];
ClutterTimeline *timeline;
gulong pre_paint_handler_id; gulong pre_paint_handler_id;
}; };
@ -171,7 +170,7 @@ on_pre_paint (MetaCompositor *compositor,
{ {
unsigned int i; unsigned int i;
GSList *l; GSList *l;
gboolean keep_timeline_running = FALSE; gboolean needs_schedule_update = FALSE;
for (i = 0; i < G_N_ELEMENTS (laters->laters); i++) for (i = 0; i < G_N_ELEMENTS (laters->laters); i++)
run_repaint_laters (&laters->laters[i]); run_repaint_laters (&laters->laters[i]);
@ -183,18 +182,16 @@ on_pre_paint (MetaCompositor *compositor,
MetaLater *later = l->data; MetaLater *later = l->data;
if (!later->source_id) if (!later->source_id)
keep_timeline_running = TRUE; needs_schedule_update = TRUE;
} }
} }
if (!keep_timeline_running) if (needs_schedule_update)
clutter_timeline_stop (laters->timeline); {
} ClutterStage *stage = meta_compositor_get_stage (compositor);
static void clutter_stage_schedule_update (stage);
ensure_timeline_running (MetaLaters *laters) }
{
clutter_timeline_start (laters->timeline);
} }
static gboolean static gboolean
@ -221,6 +218,7 @@ meta_laters_add (MetaLaters *laters,
gpointer user_data, gpointer user_data,
GDestroyNotify notify) GDestroyNotify notify)
{ {
ClutterStage *stage = meta_compositor_get_stage (laters->compositor);
MetaLater *later = g_slice_new0 (MetaLater); MetaLater *later = g_slice_new0 (MetaLater);
later->id = ++laters->last_later_id; later->id = ++laters->last_later_id;
@ -239,13 +237,13 @@ meta_laters_add (MetaLaters *laters,
invoke_later_idle, invoke_later_idle,
later, NULL); later, NULL);
g_source_set_name_by_id (later->source_id, "[mutter] invoke_later_idle"); g_source_set_name_by_id (later->source_id, "[mutter] invoke_later_idle");
ensure_timeline_running (laters); clutter_stage_schedule_update (stage);
break; break;
case META_LATER_CALC_SHOWING: case META_LATER_CALC_SHOWING:
case META_LATER_CHECK_FULLSCREEN: case META_LATER_CHECK_FULLSCREEN:
case META_LATER_SYNC_STACK: case META_LATER_SYNC_STACK:
case META_LATER_BEFORE_REDRAW: case META_LATER_BEFORE_REDRAW:
ensure_timeline_running (laters); clutter_stage_schedule_update (stage);
break; break;
case META_LATER_IDLE: case META_LATER_IDLE:
later->source_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, later->source_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
@ -326,7 +324,6 @@ meta_laters_new (MetaCompositor *compositor)
laters = g_new0 (MetaLaters, 1); laters = g_new0 (MetaLaters, 1);
laters->compositor = compositor; laters->compositor = compositor;
laters->timeline = clutter_timeline_new (G_MAXUINT);
laters->pre_paint_handler_id = g_signal_connect (compositor, "pre-paint", laters->pre_paint_handler_id = g_signal_connect (compositor, "pre-paint",
G_CALLBACK (on_pre_paint), G_CALLBACK (on_pre_paint),
@ -343,7 +340,6 @@ meta_laters_free (MetaLaters *laters)
for (i = 0; i < G_N_ELEMENTS (laters->laters); i++) for (i = 0; i < G_N_ELEMENTS (laters->laters); i++)
g_slist_free_full (laters->laters[i], (GDestroyNotify) meta_later_unref); g_slist_free_full (laters->laters[i], (GDestroyNotify) meta_later_unref);
g_clear_object (&laters->timeline);
g_clear_signal_handler (&laters->pre_paint_handler_id, laters->compositor); g_clear_signal_handler (&laters->pre_paint_handler_id, laters->compositor);
g_free (laters); g_free (laters);
} }