From 73b9ff53c39a56c8d84a20214e9f8da162d56059 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 10 Nov 2023 09:08:57 +0100 Subject: [PATCH] xwayland: Add a helper function to update fullscreen Whenever the output configuration changes, if Xwayland is running fullscreen, we may need to update the viewport in use or even update the output on which Xwayland is currently running fullscreen. Add a new helper function xwl_window_rootful_update_fullscreen() that will recompute the fullscreen state and the viewport setup so that the fullscreen Xwayland rootful window matches the new setup. Signed-off-by: Olivier Fourdan Reviewed-by: Kenny Levinsen --- hw/xwayland/xwayland-window.c | 23 +++++++++++++++++++++++ hw/xwayland/xwayland-window.h | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index a4f02a058..92ec4995c 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -569,6 +569,29 @@ xwl_window_set_fullscreen(struct xwl_window *xwl_window) return TRUE; } +void +xwl_window_rootful_update_fullscreen(struct xwl_window *xwl_window, + struct xwl_output *xwl_output) +{ + struct xwl_screen *xwl_screen = xwl_window->xwl_screen; + + if (!xwl_screen->fullscreen) + return; + + if (xwl_window->window != xwl_screen->screen->root) + return; + + if (xwl_window->wl_output_fullscreen != xwl_output->output) + return; + + /* The size and position of the output may have changed, clear our + * output to make sure the next call to xwl_window_set_fullscreen() + * recomputes the size and updates the viewport as needed. + */ + xwl_window->wl_output_fullscreen = NULL; + xwl_window_set_fullscreen(xwl_window); +} + void xwl_window_rootful_update_title(struct xwl_window *xwl_window) { diff --git a/hw/xwayland/xwayland-window.h b/hw/xwayland/xwayland-window.h index 45ae16da0..7fbb2a623 100644 --- a/hw/xwayland/xwayland-window.h +++ b/hw/xwayland/xwayland-window.h @@ -135,7 +135,8 @@ Bool xwl_window_has_viewport_enabled(struct xwl_window *xwl_window); Bool xwl_window_is_toplevel(WindowPtr window); void xwl_window_check_resolution_change_emulation(struct xwl_window *xwl_window); void xwl_window_rootful_update_title(struct xwl_window *xwl_window); - +void xwl_window_rootful_update_fullscreen(struct xwl_window *xwl_window, + struct xwl_output *xwl_output); void xwl_window_set_window_pixmap(WindowPtr window, PixmapPtr pixmap); Bool xwl_realize_window(WindowPtr window);