mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-05-16 21:28:38 +03:00
set the title of the window
This commit is contained in:
@ -16,12 +16,13 @@ struct PrimaryView: View {
|
||||
@State private var window: NSWindow?
|
||||
|
||||
// This handles non-native fullscreen
|
||||
@State private var fsHandler = FullScreenHandler()
|
||||
@State private var fullScreen = FullScreenHandler()
|
||||
|
||||
// This seems like a crutch after switchign from SwiftUI to AppKit lifecycle.
|
||||
@FocusState private var focused: Bool
|
||||
|
||||
@FocusedValue(\.ghosttySurfaceView) private var focusedSurface
|
||||
@FocusedValue(\.ghosttySurfaceTitle) private var surfaceTitle
|
||||
|
||||
var body: some View {
|
||||
switch ghostty.readiness {
|
||||
@ -58,6 +59,13 @@ struct PrimaryView: View {
|
||||
.onChange(of: focusedSurface) { newValue in
|
||||
self.focusedSurfaceWrapper.surface = newValue?.surface
|
||||
}
|
||||
.onChange(of: surfaceTitle) { 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
|
||||
}
|
||||
.confirmationDialog(
|
||||
"Quit Ghostty?",
|
||||
isPresented: confirmQuitting) {
|
||||
@ -115,7 +123,7 @@ struct PrimaryView: View {
|
||||
guard let useNonNativeFullscreenAny = notification.userInfo?[Ghostty.Notification.NonNativeFullscreenKey] else { return }
|
||||
guard let useNonNativeFullscreen = useNonNativeFullscreenAny as? Bool else { return }
|
||||
|
||||
self.fsHandler.toggleFullscreen(window: window, nonNativeFullscreen: useNonNativeFullscreen)
|
||||
self.fullScreen.toggleFullscreen(window: window, nonNativeFullscreen: useNonNativeFullscreen)
|
||||
// After toggling fullscreen we need to focus the terminal again.
|
||||
self.focused = true
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ class PrimaryWindow: NSWindow {
|
||||
appDelegate: appDelegate,
|
||||
focusedSurfaceWrapper: window.focusedSurfaceWrapper))
|
||||
window.windowController?.shouldCascadeWindows = true
|
||||
window.title = "Ghostty 👻"
|
||||
return window
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user