Skip to content

Fix fractions when promoting containers - #9249

Open
pablocpas wants to merge 1 commit into
swaywm:masterfrom
pablocpas:fix-directional-promotion-fractions
Open

Fix fractions when promoting containers#9249
pablocpas wants to merge 1 commit into
swaywm:masterfrom
pablocpas:fix-directional-promotion-fractions

Conversation

@pablocpas

@pablocpas pablocpas commented Aug 2, 2026

Copy link
Copy Markdown

Fixes #9248

Summary

When a directional move promotes a container out of its immediate parent, Sway currently preserves the moved container's fractions and invalidates the ancestor's fractions.

The moved container's fractions were calculated relative to its former parent, while the ancestor remains in the same parent. This differs from i3 and from Sway's other directional reparenting path.

Reset the moved container's geometry and fractions before inserting it, and preserve the ancestor's fractions. Resetting before workspace_insert_tiling() also ensures that a wrapper introduced by workspace_layout cannot inherit the stale fraction.

Test plan

Create this layout with equal fractions:

H[X Y H[A W]]

Focus W and run:

swaymsg move right

On master, moving through the outer workspace edge produces approximately:

 X = 3/14 ≈ 21.43%
 Y = 3/14 ≈ 21.43%
 A = 1/4  = 25%
 W = 9/28 ≈ 32.14%

With this patch, all four top-level entries receive:

1/4, 1/4, 1/4, 1/4

This matches i3 and the existing Sway behavior when W is moved toward the other top-level windows instead of through the outer edge.

Also verify:

  • horizontal and vertical promotion;
  • promotion through both workspace edges;
  • unequally resized top-level siblings retain their relative proportions;
  • moving into a neighboring container remains unchanged.

Tests

  • meson setup build --buildtype=debug -Dman-pages=disabled -Dswaybar=false -Dswaynag=false -Dtray=disabled -Dgdk-pixbuf=disabled
  • ninja -C build

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.
Copilot AI review requested due to automatic review settings August 2, 2026 14:30

This comment was marked as low quality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Directional promotion handles size fractions differently from i3

2 participants