From 5f83b27d62d7d0bbfd29a803104e7a3b499413ee Mon Sep 17 00:00:00 2001 From: nodscher Date: Sun, 28 Jun 2026 18:20:38 +0200 Subject: [PATCH] xdg_shell: fix windows requesting fullscreen on startup --- xdg_shell.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/xdg_shell.c b/xdg_shell.c index 4da19a0..c7d94f8 100644 --- a/xdg_shell.c +++ b/xdg_shell.c @@ -192,15 +192,8 @@ close(struct cg_view *view) } static void -handle_xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *data) +set_fullscreen(struct cg_xdg_shell_view *xdg_shell_view, bool fullscreen) { - struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, request_fullscreen); - bool fullscreen = xdg_shell_view->xdg_toplevel->requested.fullscreen; - - if (!xdg_shell_view->xdg_toplevel->base->surface->mapped) { - return; - } - /** * Certain clients do not like figuring out their own window geometry if they * display in fullscreen mode, so we set it here. @@ -209,7 +202,19 @@ handle_xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *data) wlr_output_layout_get_box(xdg_shell_view->view.server->output_layout, NULL, &layout_box); wlr_xdg_toplevel_set_size(xdg_shell_view->xdg_toplevel, layout_box.width, layout_box.height); wlr_xdg_toplevel_set_fullscreen(xdg_shell_view->xdg_toplevel, fullscreen); - wlr_foreign_toplevel_handle_v1_set_fullscreen(xdg_shell_view->view.foreign_toplevel_handle, fullscreen); +} + +static void +handle_xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *data) +{ + struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, request_fullscreen); + bool fullscreen = xdg_shell_view->xdg_toplevel->requested.fullscreen; + + if (!xdg_shell_view->xdg_toplevel->base->initialized) { + return; + } + + set_fullscreen(xdg_shell_view, fullscreen); } static void @@ -243,15 +248,24 @@ handle_xdg_toplevel_commit(struct wl_listener *listener, void *data) { struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, commit); + if (xdg_shell_view->xdg_toplevel->base->surface->mapped) { + wlr_foreign_toplevel_handle_v1_set_fullscreen(xdg_shell_view->view.foreign_toplevel_handle, + xdg_shell_view->xdg_toplevel->current.fullscreen); + } + if (!xdg_shell_view->xdg_toplevel->base->initial_commit) { return; } wlr_xdg_toplevel_set_wm_capabilities(xdg_shell_view->xdg_toplevel, XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN); - /* When an xdg_surface performs an initial commit, the compositor must - * reply with a configure so the client can map the surface. */ - view_position(&xdg_shell_view->view); + if (xdg_shell_view->xdg_toplevel->requested.fullscreen) { + set_fullscreen(xdg_shell_view, true); + } else { + /* When an xdg_surface performs an initial commit, the compositor must + * reply with a configure so the client can map the surface. */ + view_position(&xdg_shell_view->view); + } } static void