Merge pull request #2376 from lucymhdavies/macos-initial-window-false

Implements initial-window=false for macOS
This commit is contained in:
Mitchell Hashimoto
2024-10-04 08:47:49 -07:00
committed by GitHub
3 changed files with 11 additions and 3 deletions

View File

@ -173,7 +173,7 @@ class AppDelegate: NSObject,
// is possible to have other windows in a few scenarios:
// - if we're opening a URL since `application(_:openFile:)` is called before this.
// - if we're restoring from persisted state
if terminalManager.windows.count == 0 {
if terminalManager.windows.count == 0 && ghostty.config.initialWindow {
terminalManager.newWindow()
}
}
@ -587,7 +587,7 @@ class AppDelegate: NSObject,
if !isVisible {
NSApp.activate(ignoringOtherApps: true)
}
isVisible.toggle()
}
}

View File

@ -151,6 +151,14 @@ extension Ghostty {
/// details on what each means. We only add documentation if there is a strange conversion
/// due to the embedded library and Swift.
var initialWindow: Bool {
guard let config = self.config else { return true }
var v = true;
let key = "initial-window"
_ = ghostty_config_get(config, &v, key, UInt(key.count))
return v
}
var shouldQuitAfterLastWindowClosed: Bool {
guard let config = self.config else { return true }
var v = false;

View File

@ -1229,7 +1229,7 @@ keybind: Keybinds = .{},
/// is run. Note that if `quit-after-last-window-closed` is `true` and
/// `quit-after-last-window-closed-delay` is set, setting `initial-window` to
/// `false` will mean that Ghostty will quit after the configured delay if no
/// window is ever created. Only implemented on Linux.
/// window is ever created. Only implemented on Linux and macOS.
@"initial-window": bool = true,
/// The position of the "quick" terminal window. To learn more about the