From 47c4e38e50673cd6bda9b10ed8e35580f77588ab Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Wed, 24 Jul 2024 15:19:41 +0200 Subject: [PATCH] xwayland: Make sure output is suitable for fullscreen Since commit d370f1e58, Xwayland can optionally be started rootful and fullscreen. To do so, it will setup a viewport to scale the root window to match the size of the output. However, if the rootful Xwayland window receives an xdg-surface configure event before the output definition is complete, as with e.g. the labwc Wayland compositor, we might end up trying to setup a viewport with a destination size of 0x0 which is a protocol violation, and that kills Xwayland. To avoid that issue, only setup the viewport if the output size is meaningful. Also, please note that once the output definition is complete, i.e. when the "done" event is eventually received, we shall recompute the size for fullscreen again, hence achieving the desired fullscreen state. Fixes: d370f1e58 - xwayland: add fullscreen mode for rootful Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1717 Signed-off-by: Olivier Fourdan Part-of: (cherry picked from commit 66f5e7e96a00b1ed9d8c11b4661e8e8370b1adf0) --- hw/xwayland/xwayland-window.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index 1261ceaed..9474ee90a 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -494,6 +494,18 @@ window_get_client_toplevel(WindowPtr window) return window; } +static Bool +is_output_suitable_for_fullscreen(struct xwl_output *xwl_output) +{ + if (xwl_output == NULL) + return FALSE; + + if (xwl_output->width == 0 || xwl_output->height == 0) + return FALSE; + + return TRUE; +} + static struct xwl_output * xwl_window_get_output(struct xwl_window *xwl_window) { @@ -501,11 +513,11 @@ xwl_window_get_output(struct xwl_window *xwl_window) struct xwl_output *xwl_output; xwl_output = xwl_output_get_output_from_name(xwl_screen, xwl_screen->output_name); - if (xwl_output) + if (is_output_suitable_for_fullscreen(xwl_output)) return xwl_output; xwl_output = xwl_output_from_wl_output(xwl_screen, xwl_window->wl_output); - if (xwl_output) + if (is_output_suitable_for_fullscreen(xwl_output)) return xwl_output; return xwl_screen_get_first_output(xwl_screen);