From 9a55c402aa803fb10e39ab4fd18a709d0cd06fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 31 Mar 2023 16:01:20 +0200 Subject: [PATCH] xwayland/window: Queue damage after commits are allowed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compositors may use XWAYLAND_ALLOW_COMMITS to communicate when Xwayland may or may not commit new buffers to a wl_surface. If commits are denied, then later allowed, we'll only get a buffer attached if there is actual damage posted, which might be long after. This fixes an issue where the window manager would reparent a window while denying commits, then after reparenting, allow commits. The window in question belonged to a game and took several seconds produce the next frame, resulting in an empty window appearing as if it had just disappeared. Signed-off-by: Jonas Ã…dahl --- hw/xwayland/xwayland-window.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index b7574eeb5..67485d1d3 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -106,9 +106,21 @@ static void xwl_window_set_allow_commits(struct xwl_window *xwl_window, Bool allow, const char *debug_msg) { + struct xwl_screen *xwl_screen = xwl_window->xwl_screen; + DamagePtr damage; + xwl_window->allow_commits = allow; DebugF("XWAYLAND: win %d allow_commits = %d (%s)\n", xwl_window->window->drawable.id, allow, debug_msg); + + damage = window_get_damage(xwl_window->window); + if (allow && + xorg_list_is_empty(&xwl_window->link_damage) && + damage && + RegionNotEmpty(DamageRegion(damage))) { + xorg_list_add(&xwl_window->link_damage, + &xwl_screen->damage_window_list); + } } static void