macOS: fix quit alert missing when hidden

This commit is contained in:
Lukas
2026-08-07 20:11:16 +02:00
parent 34282fc7b3
commit e83cf0b06f
3 changed files with 11 additions and 12 deletions

View File

@@ -380,17 +380,6 @@ class AppDelegate: NSObject,
return .terminateNow
}
// This probably isn't fully safe. The isEmpty check above is aspirational, it doesn't
// quite work with SwiftUI because windows are retained on close. So instead we check
// if there are any that are visible. I'm guessing this breaks under certain scenarios.
//
// NOTE(mitchellh): I don't think we need this check at all anymore. I'm keeping it
// here because I don't want to remove it in a patch release cycle but we should
// target removing it soon.
if (windows.allSatisfy { !$0.isVisible }) {
return .terminateNow
}
// If the user is shutting down, restarting, or logging out, we don't confirm quit.
why: if let event = NSAppleEventManager.shared().currentAppleEvent {
// If all Ghostty windows are in the background (i.e. you Cmd-Q from the Cmd-Tab

View File

@@ -639,6 +639,16 @@ class QuickTerminalController: BaseTerminalController {
terminalViewContainer?.ghosttyConfigDidChange(ghostty.config, preferredBackgroundColor: nil)
}
override func confirmCloseAsync(messageText: String, informativeText: String, confirmButtonTitle: String = "Close") async -> NSApplication.ModalResponse? {
let waitTime = visible ? 0 : 0.25
animateIn()
try? await Task.sleep(for: .seconds(waitTime))
return await super.confirmCloseAsync(messageText: messageText, informativeText: informativeText, confirmButtonTitle: confirmButtonTitle)
}
private func showNoNewTabAlert() {
guard let window else { return }
let alert = NSAlert()

View File

@@ -1254,7 +1254,7 @@ class BaseTerminalController: NSWindowController,
/// Check whether window should be closed without showing an alert
func windowCanBeClosedWithoutConfirmation() -> Bool {
// We must have a window. Is it even possible not to?
guard let window = self.window else { return true }
guard window != nil else { return true }
// If we have no surfaces, close.
if surfaceTree.isEmpty { return true }