From 626c3745e2678eaa825b188bfe1f88404534b455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 14 Nov 2018 13:22:05 +0100 Subject: [PATCH] clutter/master-clock: Destroy source when paused Pausing the master clock didn't actually pause it if there was already a scheduled frame in progress. This is problematic if one actually expects to see no new frame scheduling to happen after pausing, for example it caused actor 'pre-paint' to be signalled on actors, but nothing was ever painted. Avoid this by destroying the master clock source when pausing, and then recreating it when resuming. https://gitlab.gnome.org/GNOME/mutter/merge_requests/309 --- clutter/clutter/clutter-master-clock-default.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/clutter/clutter/clutter-master-clock-default.c b/clutter/clutter/clutter-master-clock-default.c index 440382e76..d28dd474f 100644 --- a/clutter/clutter/clutter-master-clock-default.c +++ b/clutter/clutter/clutter-master-clock-default.c @@ -470,6 +470,8 @@ clutter_clock_source_new (ClutterMasterClockDefault *master_clock) ClutterClockSource *clock_source = (ClutterClockSource *) source; g_source_set_name (source, "Clutter master clock"); + g_source_set_priority (source, CLUTTER_PRIORITY_REDRAW); + g_source_set_can_recurse (source, FALSE); clock_source->master_clock = master_clock; return source; @@ -615,8 +617,6 @@ clutter_master_clock_default_init (ClutterMasterClockDefault *self) self->frame_budget = G_USEC_PER_SEC / 60; #endif - g_source_set_priority (source, CLUTTER_PRIORITY_REDRAW); - g_source_set_can_recurse (source, FALSE); g_source_attach (source, NULL); } @@ -675,6 +675,16 @@ clutter_master_clock_default_set_paused (ClutterMasterClock *clock, { ClutterMasterClockDefault *master_clock = (ClutterMasterClockDefault *) clock; + if (paused && !master_clock->paused) + { + g_clear_pointer (&master_clock->source, g_source_destroy); + } + else if (!paused && master_clock->paused) + { + master_clock->source = clutter_clock_source_new (master_clock); + g_source_attach (master_clock->source, NULL); + } + master_clock->paused = !!paused; }