fix: exit non-native fullscreen on close (#7525)

Fixes https://github.com/ghostty-org/ghostty/discussions/7159.
pull/7527/head
Mitchell Hashimoto 2025-06-05 07:36:50 -07:00 committed by GitHub
commit 6db455eee5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 0 deletions

View File

@ -150,6 +150,26 @@ class NonNativeFullscreen: FullscreenBase, FullscreenStyle {
private var savedState: SavedState? private var savedState: SavedState?
required init?(_ window: NSWindow) {
super.init(window)
NotificationCenter.default.addObserver(
self,
selector: #selector(windowWillCloseNotification),
name: NSWindow.willCloseNotification,
object: window)
}
deinit {
NotificationCenter.default.removeObserver(self)
}
@objc private func windowWillCloseNotification(_ notification: Notification) {
// When the window closes we need to explicitly exit non-native fullscreen
// otherwise some state like the menu bar can remain hidden.
exit()
}
func enter() { func enter() {
// If we are in fullscreen we don't do it again. // If we are in fullscreen we don't do it again.
guard !isFullscreen else { return } guard !isFullscreen else { return }