laters: Use 'before-update' signal from stage

Instead of the 'pre-paint' signal on MetaCompositor, rely directly on
the 'before-update' signal on the stage. A reason for this is that the
callback should not only invoked in connection to painting, but updating
in general. Currently the 'pre-paint' signal is emitted no matter
whether there were any painting or not, but that's both misleading and
will go away.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
This commit is contained in:
Jonas Ådahl 2020-05-29 23:33:46 +02:00
parent 2afe3e9223
commit 110ed7ff8a
2 changed files with 22 additions and 14 deletions

View File

@ -1246,10 +1246,16 @@ meta_compositor_get_property (GObject *object,
static void
meta_compositor_init (MetaCompositor *compositor)
{
}
static void
meta_compositor_constructed (GObject *object)
{
MetaCompositor *compositor = META_COMPOSITOR (object);
MetaCompositorPrivate *priv =
meta_compositor_get_instance_private (compositor);
MetaBackend *backend = meta_get_backend ();
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
ClutterBackend *clutter_backend =
meta_backend_get_clutter_backend (priv->backend);
priv->context = clutter_backend->cogl_context;
@ -1265,6 +1271,8 @@ meta_compositor_init (MetaCompositor *compositor)
NULL);
priv->laters = meta_laters_new (compositor);
G_OBJECT_CLASS (meta_compositor_parent_class)->constructed (object);
}
static void
@ -1303,6 +1311,7 @@ meta_compositor_class_init (MetaCompositorClass *klass)
object_class->set_property = meta_compositor_set_property;
object_class->get_property = meta_compositor_get_property;
object_class->constructed = meta_compositor_constructed;
object_class->dispose = meta_compositor_dispose;
klass->remove_window = meta_compositor_real_remove_window;

View File

@ -50,7 +50,7 @@ struct _MetaLaters
GSList *laters[META_LATER_N_TYPES];
gulong pre_paint_handler_id;
gulong before_update_handler_id;
};
static MetaLater *
@ -165,7 +165,7 @@ run_repaint_laters (GSList **laters_list)
}
static void
on_pre_paint (MetaCompositor *compositor,
on_before_update (ClutterStage *stage,
MetaLaters *laters)
{
unsigned int i;
@ -187,12 +187,8 @@ on_pre_paint (MetaCompositor *compositor,
}
if (needs_schedule_update)
{
ClutterStage *stage = meta_compositor_get_stage (compositor);
clutter_stage_schedule_update (stage);
}
}
static gboolean
invoke_later_idle (gpointer data)
@ -320,13 +316,15 @@ meta_later_remove (unsigned int later_id)
MetaLaters *
meta_laters_new (MetaCompositor *compositor)
{
ClutterStage *stage = meta_compositor_get_stage (compositor);
MetaLaters *laters;
laters = g_new0 (MetaLaters, 1);
laters->compositor = compositor;
laters->pre_paint_handler_id = g_signal_connect (compositor, "pre-paint",
G_CALLBACK (on_pre_paint),
laters->before_update_handler_id =
g_signal_connect (stage, "before-update",
G_CALLBACK (on_before_update),
laters);
return laters;
@ -335,11 +333,12 @@ meta_laters_new (MetaCompositor *compositor)
void
meta_laters_free (MetaLaters *laters)
{
ClutterStage *stage = meta_compositor_get_stage (laters->compositor);
unsigned int i;
for (i = 0; i < G_N_ELEMENTS (laters->laters); i++)
g_slist_free_full (laters->laters[i], (GDestroyNotify) meta_later_unref);
g_clear_signal_handler (&laters->pre_paint_handler_id, laters->compositor);
g_clear_signal_handler (&laters->before_update_handler_id, stage);
g_free (laters);
}