From cd999f08c608458d6207110ed237c3a78441870b Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 25 Oct 2019 16:28:50 +0200 Subject: [PATCH] xwayland: Use multiple window buffers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Xwayland takes care of not attaching a new buffer if a frame callback is pending. Yet, the existing buffer (which was previously attached) may still be updated from the X11 side, causing unexpected visual glitches to the buffer. Add multiple buffering to the xwl_window and alternate between buffers, to leave the Wayland buffer untouched between frame callbacks and avoid stuttering or tearing issues. Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/835 Signed-off-by: Olivier Fourdan Reviewed-by: Michel Dänzer --- hw/xwayland/xwayland.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c index 3ec754047..fc7932f67 100644 --- a/hw/xwayland/xwayland.c +++ b/hw/xwayland/xwayland.c @@ -24,6 +24,7 @@ */ #include "xwayland.h" +#include "xwayland-window-buffers.h" #include @@ -902,6 +903,8 @@ ensure_surface_for_window(WindowPtr window) xorg_list_init(&xwl_window->link_damage); xorg_list_add(&xwl_window->link_window, &xwl_screen->window_list); + xwl_window_buffers_init(xwl_window); + xwl_window_init_allow_commits(xwl_window); return TRUE; @@ -1005,6 +1008,8 @@ xwl_unrealize_window(WindowPtr window) xorg_list_del(&xwl_window->link_window); unregister_damage(window); + xwl_window_buffers_dispose(xwl_window); + if (xwl_window->frame_callback) wl_callback_destroy(xwl_window->frame_callback); @@ -1053,6 +1058,7 @@ 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; @@ -1124,7 +1130,7 @@ xwl_window_post_damage(struct xwl_window *xwl_window) assert(!xwl_window->frame_callback); region = DamageRegion(window_get_damage(xwl_window->window)); - pixmap = (*xwl_screen->screen->GetWindowPixmap) (xwl_window->window); + pixmap = xwl_window_buffers_get_pixmap(xwl_window, region); #ifdef XWL_HAS_GLAMOR if (xwl_screen->glamor)