14 Commits

Author SHA1 Message Date
Mitchell Hashimoto
118b51157a macos: more robust surface focus state detection
Fixes #1500

This overhauls how we do focus management for surfaces to make it more
robust. This DID somehow all work before but was always brittle and was
a sketchy play with SwiftUI/AppKit behavior across macOS versions.

The new approach uses our window controller and terminal delegate
system to disseminate focus information whenever any surface changes
focus. This ensures that only ONE surface ever has focus in libghostty
because the controller ensures it is widely distributed.
2024-02-11 09:19:13 -08:00
Mitchell Hashimoto
cc01049d55 macos: select split above/below should go to correct split when nested
Fixes #1330

I admit this code is a mess to understand, so I'm not 100% certain this
fix is correct. It definitely fixes #1330 but I'm not sure if this
breaks other split scenarios.

I believe that our logic here was simply wrong, notice that left/right
had opposite logic and this brings it all into consistency.

Long term, we should redo all of our directional movement since we've
refactored how split state is stored now on the controller with parent
references.
2024-01-19 21:11:20 -08:00
Ryota
3500293bac Add firstOrLast search based on next and previous 2024-01-12 00:53:19 +00:00
Ryota
ab8dfab9de Add helper func for first and last leaf 2024-01-12 00:52:26 +00:00
Ryota
d9c4bd7e25 Add helper functions for finding root 2024-01-12 00:52:17 +00:00
Mitchell Hashimoto
98041940f0 macos: restore focused split on app restore 2023-12-26 14:45:27 -08:00
Mitchell Hashimoto
a321ef515d macos: assign unique UUID per surface, store in app state 2023-12-26 14:24:05 -08:00
Mitchell Hashimoto
a8568306c9 macos: store pwd with save/restore state 2023-12-23 17:06:34 -08:00
Mitchell Hashimoto
2390668834 macos: encode surface tree in state restore 2023-12-23 13:15:46 -08:00
Gregory Anders
cd01340cce macos: add key binding for equalizing split sizes 2023-11-07 16:23:28 -06:00
Gregory Anders
dc7c313166 macos: pass split as a binding to SplitView
Fixes: https://github.com/mitchellh/ghostty/issues/833
2023-11-07 11:55:29 -06:00
Gregory Anders
9b14398153 macos: support resizing splits 2023-11-05 20:42:59 -06:00
Gregory Anders
3b2799ce97 macos: refactor SplitNode
This commit does two things: adds a weak reference to the parent
container of each SplitNode.Container and SplitNode.Leaf and moves the
"direction" of a split out of the SplitNode enum and into the
SplitNode.Container struct as a field.

Both changes are required for supporting split resizing. A reference to
the parent in each leaf and split container is needed in order to
traverse upwards through the split tree. If the focused split is not
part of a container that is split along the direction that was requested
to be resized, then we instead try and resize the parent. If the parent
is split along the requested direction, then it is resized
appropriately; otherwise, repeat until the root of the tree is reached.

The direction is needed inside the SplitNode.Container object itself so
that the container knows whether or not it is able to resize itself in
the direction requested by the user. Once the split direction was moved
inside of SplitNode.Container, it became redundant to also have it as
part of the SplitNode enum, so this simplifies things.
2023-11-05 20:20:39 -06:00
Mitchell Hashimoto
f6d98ae40f macos: delete Ghostty.SplitView 2023-10-30 14:39:26 -07:00