mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 09:16:11 +03:00
macos: zoomed splits put an emoji in the title bar
This commit is contained in:
@ -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?",
|
||||
|
@ -33,6 +33,7 @@ extension Ghostty {
|
||||
SurfaceWrapper(surfaceView: surfaceView)
|
||||
}
|
||||
}
|
||||
.focusedValue(\.ghosttySurfaceZoomed, zoomedSurface != nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user