clutter/stage: Make clutter_stage_schedule_update() always schedule

We could call clutter_stage_schedule_update() and it wouldn't actually
schedule anything, as the master frame clock only tries to reschedule if
1) there is an active timeline, 2) there are pending relayouts, 3) there
are pending redraws, or 4) there are pending events. Thus, a call to
clutter_stage_schedule_update() didn't have any effect if it was called
at the wrong time.

Fix this by adding a boolean state "needs_update" to the stage, set on
clutter_stage_schedule_update() and cleared on
_clutter_stage_do_update(), that will make the master clock reschedule
an update if it is TRUE.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
This commit is contained in:
Jonas Ådahl 2020-04-16 19:42:03 +02:00
parent 8e1bd64e05
commit b8003807b0

View File

@ -142,6 +142,8 @@ struct _ClutterStagePrivate
int update_freeze_count; int update_freeze_count;
gboolean needs_update;
guint redraw_pending : 1; guint redraw_pending : 1;
guint throttle_motion_events : 1; guint throttle_motion_events : 1;
guint min_size_changed : 1; guint min_size_changed : 1;
@ -1308,7 +1310,9 @@ _clutter_stage_needs_update (ClutterStage *stage)
priv = stage->priv; priv = stage->priv;
return priv->redraw_pending || g_hash_table_size (priv->pending_relayouts) > 0; return (priv->redraw_pending ||
priv->needs_update ||
g_hash_table_size (priv->pending_relayouts) > 0);
} }
void void
@ -1499,6 +1503,8 @@ _clutter_stage_do_update (ClutterStage *stage)
priv->stage_was_relayout = FALSE; priv->stage_was_relayout = FALSE;
priv->needs_update = FALSE;
/* if the stage is being destroyed, or if the destruction already /* if the stage is being destroyed, or if the destruction already
* happened and we don't have an StageWindow any more, then we * happened and we don't have an StageWindow any more, then we
* should bail out * should bail out
@ -3453,6 +3459,8 @@ _clutter_stage_schedule_update (ClutterStage *stage)
if (stage_window == NULL) if (stage_window == NULL)
return; return;
stage->priv->needs_update = TRUE;
return _clutter_stage_window_schedule_update (stage_window, return _clutter_stage_window_schedule_update (stage_window,
stage->priv->sync_delay); stage->priv->sync_delay);
} }