macos: only color the titlebar of surfaces that border the top

This commit is contained in:
Mitchell Hashimoto
2024-11-21 14:07:21 -08:00
parent 7fb86a3c9c
commit 36a57826a6
3 changed files with 53 additions and 8 deletions

View File

@@ -38,6 +38,16 @@ extension Ghostty {
}
}
func topLeft() -> SurfaceView {
switch (self) {
case .leaf(let leaf):
return leaf.surface
case .split(let container):
return container.topLeft.topLeft()
}
}
/// Returns the view that would prefer receiving focus in this tree. This is always the
/// top-left-most view. This is used when creating a split or closing a split to find the
/// next view to send focus to.
@@ -136,6 +146,24 @@ extension Ghostty {
}
}
/// Returns true if the surface borders the top. Assumes the view is in the tree.
func doesBorderTop(view: SurfaceView) -> Bool {
switch (self) {
case .leaf(let leaf):
return leaf.surface == view
case .split(let container):
switch (container.direction) {
case .vertical:
return container.topLeft.doesBorderTop(view: view)
case .horizontal:
return container.topLeft.doesBorderTop(view: view) ||
container.bottomRight.doesBorderTop(view: view)
}
}
}
// MARK: - Sequence
func makeIterator() -> IndexingIterator<[Leaf]> {