From 66f5e7e96a00b1ed9d8c11b4661e8e8370b1adf0 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: --- 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 6fe0db891..619050079 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -496,6 +496,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) { @@ -503,11 +515,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);