macOS: move window title handling fully to AppKit

Fixes #7236
Supersedes #7249

This removes all of our `focusedValue`-based tracking of the surface
title and moves it completely to the window controller. The window
controller now sets up event listeners (via Combine) when the focused
surface changes and updates the window title accordingly.

There is some complicated logic here to handle when we lose focus to
something other than a surface. In this case, we want our title to be
the last focused surface so long as it exists.
This commit is contained in:
Mitchell Hashimoto
2025-05-06 14:54:59 -07:00
parent 27cdd6d79c
commit 2caa8a3fe1
5 changed files with 23 additions and 31 deletions

View File

@@ -45,8 +45,6 @@ extension Ghostty {
/// this one.
@Binding var zoomedSurface: SurfaceView?
@FocusedValue(\.ghosttySurfaceTitle) private var surfaceTitle: String?
var body: some View {
let center = NotificationCenter.default
let pubZoom = center.publisher(for: Notification.didToggleSplitZoom)
@@ -77,7 +75,6 @@ extension Ghostty {
.onReceive(pubZoom) { onZoom(notification: $0) }
}
}
.navigationTitle(surfaceTitle ?? "Ghostty")
.id(node) // Needed for change detection on node
} else {
// On these events we want to reset the split state and call it.