From 1cb886bc2a3e556b15779300350ec8867b4f907e Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 13 Dec 2019 11:10:03 +0100 Subject: [PATCH] xwayland: Recycle window buffers when setting pixmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Right now, we would recycle the window buffers whenever the window the window is resized. This, however, is not sufficient to guarantee that the buffers are up to date, since changing the window border width for example would not trigger a `WindowResize` (the border being outside the window). Make sure we recycle the buffers on `SetWindowPixmap` to ensure that the buffers will be recycled whenever the pixmap size is changed. Related: https://gitlab.freedesktop.org/xorg/xserver/issues/951 Suggested-by: Michel Dänzer Signed-off-by: Olivier Fourdan Reviewed-by: Michel Dänzer --- hw/xwayland/xwayland.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c index fc7932f67..54a1fdac0 100644 --- a/hw/xwayland/xwayland.c +++ b/hw/xwayland/xwayland.c @@ -1025,7 +1025,10 @@ xwl_set_window_pixmap(WindowPtr window, { ScreenPtr screen = window->drawable.pScreen; struct xwl_screen *xwl_screen; + struct xwl_window *xwl_window; + PixmapPtr old_pixmap; + old_pixmap = (*screen->GetWindowPixmap) (window); xwl_screen = xwl_screen_get(screen); screen->SetWindowPixmap = xwl_screen->SetWindowPixmap; @@ -1037,6 +1040,14 @@ xwl_set_window_pixmap(WindowPtr window, return; ensure_surface_for_window(window); + + if (old_pixmap->drawable.width == pixmap->drawable.width && + old_pixmap->drawable.height == pixmap->drawable.height) + return; + + xwl_window = xwl_window_get(window); + if (xwl_window) + xwl_window_buffers_recycle(xwl_window); } static void @@ -1058,7 +1069,6 @@ xwl_resize_window(WindowPtr window, screen->ResizeWindow = xwl_resize_window; if (xwl_window) { - xwl_window_buffers_recycle(xwl_window); xwl_window->x = x; xwl_window->y = y; xwl_window->width = width;