From 8904c55a862e1dc823a290bf897eec0552568c12 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Fri, 16 Mar 2018 17:04:09 -0400 Subject: [PATCH] compositor: get rid of initial black rectangle on xwayland clients At the moment when a legacy X11 application client is first mapped it gets briefly shown as a black rectangle before redrawing. That behavior is because the initial Configure operation on the window leads to the surface immediately getting full window damage posted by Xwayland before the client has a chance to draw. This commit changes mutter to send a sync request right away, when a window first shows up, then waits until the reply from the application before showing the window. It leverages the same code paths already used to prevent flicker from subsequent (non-initial) resizes on the window. --- src/compositor/meta-window-actor.c | 16 ++++++++++++++++ src/x11/window-x11.c | 5 +++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index efb939a20..6d384587c 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -53,6 +53,8 @@ struct _MetaWindowActorPrivate MetaWindow *window; MetaCompositor *compositor; + MetaCompEffect pending_effect; + MetaSurfaceActor *surface; /* MetaShadowFactory only caches shadows that are actually in use; @@ -117,6 +119,7 @@ struct _MetaWindowActorPrivate guint updates_frozen : 1; guint first_frame_state : 2; /* FirstFrameState */ + guint has_pending_effect : 1; }; typedef struct _FrameData FrameData; @@ -363,6 +366,12 @@ meta_window_actor_sync_thawed_state (MetaWindowActor *self) if (priv->first_frame_state == INITIALLY_FROZEN) priv->first_frame_state = DRAWING_FIRST_FRAME; + if (priv->has_pending_effect) + { + meta_window_actor_show (self, priv->pending_effect); + priv->has_pending_effect = FALSE; + } + if (priv->surface) meta_surface_actor_set_frozen (priv->surface, FALSE); @@ -1321,6 +1330,13 @@ meta_window_actor_show (MetaWindowActor *self, g_return_if_fail (!priv->visible); + if (is_frozen (self)) + { + priv->pending_effect = effect; + priv->has_pending_effect = TRUE; + return; + } + self->priv->visible = TRUE; switch (effect) diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 94f62718b..c14f90070 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -1244,8 +1244,9 @@ meta_window_x11_move_resize_internal (MetaWindow *window, { meta_error_trap_push (window->display); - if (window == window->display->grab_window && - meta_grab_op_is_resizing (window->display->grab_op) && + if ((window->constructing || + (window == window->display->grab_window && + meta_grab_op_is_resizing (window->display->grab_op))) && !window->disable_sync && window->sync_request_counter != None && window->sync_request_alarm != None &&