focus last active tiling

This commit is contained in:
2026-06-01 17:27:08 +02:00
parent 556ec9787b
commit 64d86fe487

View File

@@ -27,6 +27,8 @@ final class Tab implements AutoCloseable {
// The floating pane to re-focus when the group is shown again, and to prefer when promoting // The floating pane to re-focus when the group is shown again, and to prefer when promoting
// after the last tiled pane closes. // after the last tiled pane closes.
private TerminalPane lastFocusedFloating; private TerminalPane lastFocusedFloating;
// The tiled pane to re-focus when the floating group is hidden.
private TerminalPane lastFocusedTiled;
// Last laid-out size, so a newly opened pane can be created at roughly its eventual rect // Last laid-out size, so a newly opened pane can be created at roughly its eventual rect
// (and thus grid). Seeded from the configured window size for the first pane, which is // (and thus grid). Seeded from the configured window size for the first pane, which is
// opened before any layout pass runs. // opened before any layout pass runs.
@@ -193,7 +195,7 @@ final class Tab implements AutoCloseable {
if (floatingVisible) { if (floatingVisible) {
floatingVisible = false; floatingVisible = false;
if (floating.contains(active)) { if (floating.contains(active)) {
setActive(tiled.get(0)); setActive(tiled.contains(lastFocusedTiled) ? lastFocusedTiled : tiled.get(0));
} }
} else { } else {
floatingVisible = true; floatingVisible = true;
@@ -273,13 +275,17 @@ final class Tab implements AutoCloseable {
floatingVisible = false; floatingVisible = false;
} }
setActive(wasFloating && floatingVisible ? floating.get(floating.size() - 1) : tiled.get(0)); setActive(wasFloating && floatingVisible
? floating.get(floating.size() - 1)
: tiled.contains(lastFocusedTiled) ? lastFocusedTiled : tiled.get(0));
} }
private void setActive(TerminalPane pane) { private void setActive(TerminalPane pane) {
active = pane; active = pane;
if (floating.contains(pane)) { if (floating.contains(pane)) {
lastFocusedFloating = pane; lastFocusedFloating = pane;
} else if (tiled.contains(pane)) {
lastFocusedTiled = pane;
} }
} }