atagen

monolith

public
Star0
Watch0

Commit 91957f0ae29e

tarball

atagen <boss@atagen.co>2026-10-17 09:25 UTC

2 files changed+19-2
layout: let merge moves leave a stack at its edge

merge_window gave up when no lane lay in the direction, so a window at the top of a stack could only get out by inverting to swap mode. It now falls back to move_window's stepping out, so pressing the same direction keeps going.
Modified file: crates/layout/src/tests.rs+16 additions
@@ -261,3 +261,19 @@ fn moving_toward_a_hidden_lane_joins_it() {
261261 assert!(rect(d).x < rect(e).x);
262262 assert!(rect(a).y < rect(d).y);
263263 }
264+
265+#[test]
266+fn merging_past_the_last_lane_leaves_the_stack() {
267+ let (a, b, c) = (1, 2, 3);
268+ let mut t: Tree<u32> = Tree::default();
269+ t.insert_row(a);
270+ t.insert_after(b, a);
271+ t.insert_after(c, b);
272+ assert!(t.merge_window(b, Dir::Left, |_| true));
273+ assert!(t.merge_window(a, Dir::Up, |_| true));
274+ t.check();
275+ let all = t.arrange(AREA, 0.0, |_| true);
276+ let rect = |w| all.iter().find(|p| p.0 == w).unwrap().1;
277+ assert_eq!(rect(a).w, AREA.w);
278+ assert!(rect(a).bottom() <= rect(b).y && rect(b).y == rect(c).y);
279+}
Modified file: crates/layout/src/tree.rs+3 additions−2 deletions
@@ -200,7 +200,8 @@ impl<W: Copy + Eq + Hash> Tree<W> {
200200
201201 /// Moves a window to the end of the next visible lane in `dir`, stepping
202202 /// up a level when its container has none that way. A lone window there
203- /// becomes a stack with it.
203+ /// becomes a stack with it. With no lane anywhere that way, it leaves its
204+ /// stack as `move_window` would.
204205 pub fn merge_window(&mut self, w: W, dir: Dir, vis: impl Fn(W) -> bool) -> bool {
205206 let Some(&n) = self.leaves.get(&w) else {
206207 return false;
@@ -215,7 +216,7 @@ impl<W: Copy + Eq + Hash> Tree<W> {
215216 }
216217 cur = p;
217218 }
218- false
219+ self.move_node(n, dir, &vis, true)
219220 }
220221
221222 /// Whether every container above `w` is expanded towards it.