From 999d17c49d6899dda8d8cdf74847e772c6abbb2e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 11 Sep 2023 15:44:28 -0700 Subject: [PATCH] macos: integrate needsConfirmQuit to quit if all windows are at prompt --- macos/Sources/AppDelegate.swift | 3 +++ macos/Sources/Ghostty/AppState.swift | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/macos/Sources/AppDelegate.swift b/macos/Sources/AppDelegate.swift index 6785c3a30..e412de441 100644 --- a/macos/Sources/AppDelegate.swift +++ b/macos/Sources/AppDelegate.swift @@ -102,6 +102,9 @@ class AppDelegate: NSObject, ObservableObject, NSApplicationDelegate, GhosttyApp } } + // If our app says we don't need to confirm, we can exit now. + if (!ghostty.needsConfirmQuit) { return .terminateNow } + // We have some visible window, and all our windows will watch the confirmQuit. confirmQuit = true return .terminateLater diff --git a/macos/Sources/Ghostty/AppState.swift b/macos/Sources/Ghostty/AppState.swift index c714a4f40..99ddf04ac 100644 --- a/macos/Sources/Ghostty/AppState.swift +++ b/macos/Sources/Ghostty/AppState.swift @@ -40,6 +40,12 @@ extension Ghostty { } } + /// True if we need to confirm before quitting. + var needsConfirmQuit: Bool { + guard let app = app else { return false } + return ghostty_app_needs_confirm_quit(app) + } + /// Cached clipboard string for `read_clipboard` callback. private var cached_clipboard_string: String? = nil