From e3139d49ad62e07d0962fdae6d881b3914b17d30 Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 2 Aug 2026 15:16:25 +0200 Subject: [PATCH] Fix fractions when promoting containers Directional moves which promote a container currently retain the moved container's fraction from its former parent and invalidate the ancestor's fraction in the destination sibling list. This differs from i3 and from Sway's other reparenting paths. Reset the moved container's geometry and fractions before inserting it. Doing this before workspace_insert_tiling also ensures that a wrapper introduced by workspace_layout inherits an unknown fraction. Keep resetting the ancestor's cached geometry, but preserve its fractions because it remains in the same parent. --- sway/commands/move.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sway/commands/move.c b/sway/commands/move.c index 43fce0d6db..e26f7df4b4 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -394,6 +394,9 @@ static bool container_move_in_direction(struct sway_container *container, } else { // Container will be promoted struct sway_container *old_parent = container->pending.parent; + // The container's fractions were relative to its former parent. + container->pending.height = container->pending.width = 0; + container->height_fraction = container->width_fraction = 0; if (ancestor->pending.parent) { // Container will move in with its parent container_insert_child(ancestor->pending.parent, container, @@ -404,8 +407,8 @@ static bool container_move_in_direction(struct sway_container *container, workspace_insert_tiling(ancestor->pending.workspace, container, index + (offs < 0 ? 0 : 1)); } + // The ancestor remains in the same parent, so preserve its fractions. ancestor->pending.height = ancestor->pending.width = 0; - ancestor->height_fraction = ancestor->width_fraction = 0; if (old_parent) { container_reap_empty(old_parent); }