compositor-x11: Move synchronization to before-update

The synchronization must happen no matter the painting, as it in itself
might result in reported damage, making the stage actually painted. Thus
move it out of the "pre-paint" handler, to something explicitly not tied
to the painting itself - ClutterStage::before-update.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
This commit is contained in:
Jonas Ådahl 2020-05-29 23:47:29 +02:00
parent 110ed7ff8a
commit 551101c65c

View File

@ -39,6 +39,8 @@ struct _MetaCompositorX11
Window output;
gulong before_update_handler_id;
gboolean frame_has_updated_xsurfaces;
gboolean have_x11_sync_object;
@ -291,15 +293,10 @@ out:
}
static void
meta_compositor_x11_pre_paint (MetaCompositor *compositor)
on_before_update (ClutterStage *stage,
MetaCompositor *compositor)
{
MetaCompositorX11 *compositor_x11 = META_COMPOSITOR_X11 (compositor);
MetaCompositorClass *parent_class;
maybe_unredirect_top_window (compositor_x11);
parent_class = META_COMPOSITOR_CLASS (meta_compositor_x11_parent_class);
parent_class->pre_paint (compositor);
if (compositor_x11->frame_has_updated_xsurfaces)
{
@ -332,6 +329,18 @@ meta_compositor_x11_pre_paint (MetaCompositor *compositor)
}
}
static void
meta_compositor_x11_pre_paint (MetaCompositor *compositor)
{
MetaCompositorX11 *compositor_x11 = META_COMPOSITOR_X11 (compositor);
MetaCompositorClass *parent_class;
maybe_unredirect_top_window (compositor_x11);
parent_class = META_COMPOSITOR_CLASS (meta_compositor_x11_parent_class);
parent_class->pre_paint (compositor);
}
static void
meta_compositor_x11_post_paint (MetaCompositor *compositor)
{
@ -380,10 +389,26 @@ meta_compositor_x11_new (MetaDisplay *display,
NULL);
}
static void
meta_compositor_x11_constructed (GObject *object)
{
MetaCompositorX11 *compositor_x11 = META_COMPOSITOR_X11 (object);
MetaCompositor *compositor = META_COMPOSITOR (compositor_x11);
ClutterStage *stage = meta_compositor_get_stage (compositor);
compositor_x11->before_update_handler_id =
g_signal_connect (stage, "before-update",
G_CALLBACK (on_before_update), compositor);
G_OBJECT_CLASS (meta_compositor_x11_parent_class)->constructed (object);
}
static void
meta_compositor_x11_dispose (GObject *object)
{
MetaCompositorX11 *compositor_x11 = META_COMPOSITOR_X11 (object);
MetaCompositor *compositor = META_COMPOSITOR (compositor_x11);
ClutterStage *stage = meta_compositor_get_stage (compositor);
if (compositor_x11->have_x11_sync_object)
{
@ -391,6 +416,8 @@ meta_compositor_x11_dispose (GObject *object)
compositor_x11->have_x11_sync_object = FALSE;
}
g_clear_signal_handler (&compositor_x11->before_update_handler_id, stage);
G_OBJECT_CLASS (meta_compositor_x11_parent_class)->dispose (object);
}
@ -405,6 +432,7 @@ meta_compositor_x11_class_init (MetaCompositorX11Class *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
MetaCompositorClass *compositor_class = META_COMPOSITOR_CLASS (klass);
object_class->constructed = meta_compositor_x11_constructed;
object_class->dispose = meta_compositor_x11_dispose;
compositor_class->manage = meta_compositor_x11_manage;