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