From aa1ec44e27e4ffc4ed11e750b674d13aaaf75bd6 Mon Sep 17 00:00:00 2001 From: Furkan Sahin Date: Wed, 15 Apr 2026 14:45:03 -0400 Subject: [PATCH] xdg_shell: don't overwrite for_window directive geometry When a floating container is resized (e.g., via for_window rules or internal transactions), a race condition occurs if the client commits a buffer with its old geometry before processing the new configure event. Sway currently accepts these stale dimensions and calls view_update_size, causing the container to snap back to the client's previous size and overwriting the compositor's intended geometry. This patch prevents the overwrite by checking two conditions: 1. !node.instruction: Ensures we aren't mid-transaction. 2. !pending_configures: Compares current.configure_serial against scheduled_serial to ensure the client has acknowledged the latest requested dimensions before we allow it to dictate a resize. --- sway/desktop/xdg_shell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 7217e1369..a0a05788b 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -321,7 +321,8 @@ static void handle_commit(struct wl_listener *listener, void *data) { // containers, we resize the container to match. For tiling containers, // we only recenter the surface. memcpy(&view->geometry, new_geo, sizeof(struct wlr_box)); - if (container_is_floating(view->container)) { + bool pending_configures = xdg_surface->current.configure_serial < xdg_surface->scheduled_serial; + if (container_is_floating(view->container) && !view->container->node.instruction && !pending_configures) { view_update_size(view); // Only set the toplevel size the current container actually has a size. if (view->container->current.width) {