From 4681b95bb38a9107fb50a7c16eff7ebe9cc20042 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Mon, 9 Oct 2023 09:17:11 -0500 Subject: [PATCH] macos: force new window for "New Window" action There is a setting in the macOS System Preferences called "Prefer tabs when opening documents" (accessed through the userTabbingPreference field of NSWindow) which, when set to "Always", makes the "New Window" action open windows in tabs. Ideally, this setting would be controlled on a per-app basis in macOS, but unfortunately that is not the case. Because Ghostty explicitly offers both "New Tab" and "New Window" actions, this user setting should be ignored when creating new windows. --- .../Features/Primary Window/PrimaryWindowManager.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/macos/Sources/Features/Primary Window/PrimaryWindowManager.swift b/macos/Sources/Features/Primary Window/PrimaryWindowManager.swift index 994bf3bcf..1489b09dc 100644 --- a/macos/Sources/Features/Primary Window/PrimaryWindowManager.swift +++ b/macos/Sources/Features/Primary Window/PrimaryWindowManager.swift @@ -96,6 +96,14 @@ class PrimaryWindowManager { func addNewWindow(withBaseConfig config: Ghostty.SurfaceConfiguration? = nil) { guard let controller = createWindowController(withBaseConfig: config) else { return } + + // For new windows, explicitly disallow tabbing with other windows. + // This overrides the value of userTabbingPreference. Rationale: + // Ghostty explicitly provides both "New Tab" and "New Window" + // functionality, so there's no reason to make "New Window" open in a + // tab. + controller.window?.tabbingMode = .disallowed; + controller.showWindow(self) guard let newWindow = addManagedWindow(windowController: controller)?.window else { return } newWindow.makeKeyAndOrderFront(nil)