diff options
| author | user <user@clank> | 2026-08-22 18:59:41 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-22 18:59:41 +0200 |
| commit | 4d2cd060089a4c48c24b93253f49bfd5bf22d53b (patch) | |
| tree | c1efaecb6259e32ecab70dd5457d5581a0194592 | |
| parent | DEMO-VIDEO.md: a scene list for the social cut (diff) | |
| download | slosh-4d2cd060089a4c48c24b93253f49bfd5bf22d53b.tar.gz slosh-4d2cd060089a4c48c24b93253f49bfd5bf22d53b.tar.xz slosh-4d2cd060089a4c48c24b93253f49bfd5bf22d53b.zip | |
slosh: a pane arriving in a zoomed tab ends the zoom
A split, the config editor or a new float while zoomed used to land the
new pane behind the pane filling the tab -- which looks exactly like the
verb having failed. Whoever asked for a new pane asked to see it, so the
zoom yields, in place_beside where every such arrival funnels through;
the move-pane unzoom was this rule as a special case and folds in.
Minimising the zoomed pane ends the zoom too, or the layout would solo a
pane the strip now holds.
Diffstat (limited to '')
| -rw-r--r-- | src/app_layout.c | 12 | ||||
| -rw-r--r-- | tests/test_zoom.py | 74 |
2 files changed, 83 insertions, 3 deletions
diff --git a/src/app_layout.c b/src/app_layout.c index b7587fc..6618a2a 100644 --- a/src/app_layout.c +++ b/src/app_layout.c @@ -536,6 +536,12 @@ void split_node(app_t *a, node_t *leaf, split_dir_t dir, bool before) { * splitting the pane you were looking at. */ static void place_beside(app_t *a, tab_t *t, node_t *leaf, node_t *node, split_dir_t dir, bool before) { + /* A zoomed tab shows one pane and nothing else, so a pane arriving in it + * would be hidden behind the pane filling it — which looks exactly like the + * split, the move or the editor having failed. Whoever asked for a new pane + * asked to see it, so the zoom yields. Here rather than in each caller, + * because every way a pane lands beside another funnels through this. */ + t->zoom = 0; /* Growing an existing split in the same direction keeps the tree flat, so * three vertical splits are three equal columns rather than 1/2 + 1/4 + 1/4. */ if (leaf->parent && leaf->parent->dir == dir) { @@ -1001,6 +1007,9 @@ bool app_minimize(app_t *a, uint32_t id) { n->minimized = true; a->cur = ti; + /* A zoom naming this pane must end with it: left standing, the layout would + * solo a pane the strip now holds — filling the tab and put away at once. */ + if (a->tabs[ti].zoom == n->id) a->tabs[ti].zoom = 0; /* Focus has to leave, or the rule that a focused pane is never minimised * would undo this on the next frame. */ if (a->tabs[ti].focus == n) a->tabs[ti].focus = next; @@ -1362,9 +1371,6 @@ bool app_move_pane_to_tab(app_t *a, uint32_t pane_id, uint32_t tab_id, node_t *beside = dest->focus ? dest->focus : first_leaf(dest->root); place_beside(a, dest, beside, leaf, rows ? SPLIT_ROWS : SPLIT_COLS, false); dest->focus = leaf; - /* A zoomed destination would hide the arrival behind the pane filling it, which - * looks exactly like the move having failed. */ - dest->zoom = 0; /* Stay where we were looking, unless that tab is the one that just went. */ for (size_t i = 0; i < a->ntabs; i++) diff --git a/tests/test_zoom.py b/tests/test_zoom.py index 43cc545..821987f 100644 --- a/tests/test_zoom.py +++ b/tests/test_zoom.py @@ -225,6 +225,77 @@ def test_the_buttons_can_be_turned_off(): os.unlink(conf) +def test_a_new_pane_unzooms(): + """A pane arriving in a zoomed tab would land behind the pane filling it, + which looks exactly like the split having failed — so asking for a new + pane implicitly asks for the layout back.""" + with Session(SH, cols=90, rows=24) as s: + s.settle(20) + s.api("split", dir="cols") + s.settle(20) + s.send(r"\x01z") + s.settle(20) + check("zoomed: one pane on screen", len(visible(s)) == 1, str(visible(s))) + s.send(r"\x01-") + s.settle(30) + vis = visible(s) + check("a split unzooms", len(vis) == 3, str(vis)) + check( + "and the status stops saying so", + "zoomed" not in s.snapshot().text[-2], + repr(s.snapshot().text[-2]), + ) + check( + "the new pane holds focus", + [p for p in vis if p["focused"]] != [], + str(vis), + ) + + +def test_a_new_float_unzooms(): + """Floats are hidden while a tab is zoomed, so a new float opened over a + zoomed tab would be invisible on arrival. Same rule, same fix.""" + with Session(SH, cols=90, rows=24) as s: + s.settle(20) + s.api("split", dir="cols") + s.settle(20) + s.send(r"\x01z") + s.settle(20) + r = s.api("new-float") + s.settle(30) + check("the float opened", r.get("ok") and r.get("id"), str(r)) + fl = [p for p in visible(s) if p["floating"] and p["w"] > 1] + check("and is on screen, not behind a zoom", len(fl) == 1, str(visible(s))) + check( + "the zoom is gone", + "zoomed" not in s.snapshot().text[-2], + repr(s.snapshot().text[-2]), + ) + + +def test_minimising_the_zoomed_pane_unzooms(): + """A zoom naming a minimised pane would solo a pane the strip holds — + filling the tab and put away at once. Minimising it ends the zoom.""" + with Session(SH, cols=90, rows=24) as s: + s.settle(20) + s.api("split", dir="cols") + s.settle(20) + s.api("split", dir="cols") + s.settle(20) + s.send(r"\x01z") + s.settle(20) + check("zoomed over three panes", len(visible(s)) == 1, str(visible(s))) + s.send(r"\x01m") + s.settle(30) + vis = [p for p in visible(s) if p["w"] > 1] + check("the two others lay out again", len(vis) == 2, str(visible(s))) + check( + "and the status stops saying zoomed", + "zoomed" not in s.snapshot().text[-2], + repr(s.snapshot().text[-2]), + ) + + if __name__ == "__main__": test_zoom_fills_the_tab_and_puts_it_back() test_the_button_toggles_and_says_which_way() @@ -233,4 +304,7 @@ if __name__ == "__main__": test_zoom_is_per_tab() test_the_status_line_says_zoomed() test_the_buttons_can_be_turned_off() + test_a_new_pane_unzooms() + test_a_new_float_unzooms() + test_minimising_the_zoomed_pane_unzooms() sys.exit(report()) |
