Module: wine Branch: master Commit: 35193586f78863810f6bb886abca2bc940890acd URL: https://gitlab.winehq.org/wine/wine/-/commit/35193586f78863810f6bb886abca2bc...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Wed Jul 19 17:25:46 2023 +0800
winex11.drv: Move the dummy parent window to (0, 0).
Move the dummy parent window from (-1, -1) to (0, 0) so that the window is considered visible by Wayland. The X11 window region is set to an empty rectangle so that the window is still in fact invisible. If Xshape support is not compiled in, then fall back to using (-1, -1).
This fixes poor performance when running Office 2016 on Xwayland. It's caused by glXWaitForSbcOML() in glxdrv_wglSwapBuffers() taking 1 second every time it gets called. The timeout is from TIMER_LEN_FLIP (1000ms) in xwl_present_reset_timer() in the xserver source code hw/xwayland/xwayland-present.c. Xwayland doesn't actually know when a frame is visible on screen[1][2]. It relies on a timer to simulate the process and when the window is invisible it uses a timer with a 1000ms timeout. This patch makes the dummy parent window visible so that Xwayland will use the timer with a 17ms timeout(~60fps), which also means that there will still be a 60fps limit for some windows when running on Xwayland.
[1]: https://gitlab.freedesktop.org/xorg/xserver/-/issues/971 [2]: https://gitlab.freedesktop.org/xorg/xserver/-/issues/973
---
dlls/winex11.drv/window.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 14490ecd028..9ada6a63d59 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1512,9 +1512,22 @@ Window get_dummy_parent(void) attrib.override_redirect = True; attrib.border_pixel = 0; attrib.colormap = default_colormap; + +#ifdef HAVE_LIBXSHAPE + { + static XRectangle empty_rect; + dummy_parent = XCreateWindow( gdi_display, root_window, 0, 0, 1, 1, 0, + default_visual.depth, InputOutput, default_visual.visual, + CWColormap | CWBorderPixel | CWOverrideRedirect, &attrib ); + XShapeCombineRectangles( gdi_display, dummy_parent, ShapeBounding, 0, 0, &empty_rect, 1, + ShapeSet, YXBanded ); + } +#else dummy_parent = XCreateWindow( gdi_display, root_window, -1, -1, 1, 1, 0, default_visual.depth, InputOutput, default_visual.visual, CWColormap | CWBorderPixel | CWOverrideRedirect, &attrib ); + WARN("Xshape support is not compiled in. Applications under XWayland may have poor performance."); +#endif XMapWindow( gdi_display, dummy_parent ); } return dummy_parent;