diff --git a/macos/Sources/Features/Primary Window/PrimaryView.swift b/macos/Sources/Features/Primary Window/PrimaryView.swift index 1aefbdd0e..f52aef9a4 100644 --- a/macos/Sources/Features/Primary Window/PrimaryView.swift +++ b/macos/Sources/Features/Primary Window/PrimaryView.swift @@ -26,6 +26,7 @@ struct PrimaryView: View { @FocusedValue(\.ghosttySurfaceView) private var focusedSurface @FocusedValue(\.ghosttySurfaceTitle) private var surfaceTitle + @FocusedValue(\.ghosttySurfaceZoomed) private var zoomedSplit // This is true if this view should be the one to show the quit confirmation. var ownsQuitConfirmation: Bool { @@ -49,6 +50,25 @@ struct PrimaryView: View { return window == firstWindow } + // The title for our window + private var title: String { + var title = "👻" + + if let surfaceTitle = surfaceTitle { + if (surfaceTitle.count > 0) { + title = surfaceTitle + } + } + + if let zoomedSplit = zoomedSplit { + if zoomedSplit { + title = "🔍 " + title + } + } + + return title + } + var body: some View { switch ghostty.readiness { case .loading: @@ -84,12 +104,11 @@ struct PrimaryView: View { .onChange(of: focusedSurface) { newValue in self.focusedSurfaceWrapper.surface = newValue?.surface } - .onChange(of: surfaceTitle) { newValue in + .onChange(of: title) { newValue in // We need to handle this manually because we are using AppKit lifecycle // so navigationTitle no longer works. guard let window = self.window else { return } - guard let title = newValue else { return } - window.title = title + window.title = newValue } .confirmationDialog( "Quit Ghostty?", diff --git a/macos/Sources/Ghostty/Ghostty.SplitView.swift b/macos/Sources/Ghostty/Ghostty.SplitView.swift index 4dc9c24df..924b24603 100644 --- a/macos/Sources/Ghostty/Ghostty.SplitView.swift +++ b/macos/Sources/Ghostty/Ghostty.SplitView.swift @@ -33,6 +33,7 @@ extension Ghostty { SurfaceWrapper(surfaceView: surfaceView) } } + .focusedValue(\.ghosttySurfaceZoomed, zoomedSurface != nil) } } } diff --git a/macos/Sources/Ghostty/SurfaceView.swift b/macos/Sources/Ghostty/SurfaceView.swift index 37812893a..118213608 100644 --- a/macos/Sources/Ghostty/SurfaceView.swift +++ b/macos/Sources/Ghostty/SurfaceView.swift @@ -710,3 +710,13 @@ extension FocusedValues { } } +extension FocusedValues { + var ghosttySurfaceZoomed: Bool? { + get { self[FocusedGhosttySurfaceZoomed.self] } + set { self[FocusedGhosttySurfaceZoomed.self] = newValue } + } + + struct FocusedGhosttySurfaceZoomed: FocusedValueKey { + typealias Value = Bool + } +}