From 45eecf801e5f51cc6d3756243026e7b8cd824845 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 16 Apr 2024 09:34:10 -0700 Subject: [PATCH] macos: show alert when creating new tab in non-native fs Fixes #1683 The root issue is #392 and we can likely find a way to fix it, but for now let's prevent the full program hang by showing an alert. --- .../Features/Terminal/TerminalController.swift | 2 +- .../Sources/Features/Terminal/TerminalManager.swift | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index ce22d3c3b..cea140995 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -34,7 +34,7 @@ class TerminalController: NSWindowController, NSWindowDelegate, } /// Fullscreen state management. - private let fullscreenHandler = FullScreenHandler() + let fullscreenHandler = FullScreenHandler() /// True when an alert is active so we don't overlap multiple. private var alert: NSAlert? = nil diff --git a/macos/Sources/Features/Terminal/TerminalManager.swift b/macos/Sources/Features/Terminal/TerminalManager.swift index a59741d3f..9ca44312f 100644 --- a/macos/Sources/Features/Terminal/TerminalManager.swift +++ b/macos/Sources/Features/Terminal/TerminalManager.swift @@ -105,6 +105,19 @@ class TerminalManager { } private func newTab(to parent: NSWindow, withBaseConfig base: Ghostty.SurfaceConfiguration?) { + // If our parent is in non-native fullscreen, then new tabs do not work. + // See: https://github.com/mitchellh/ghostty/issues/392 + if let controller = parent.windowController as? TerminalController, + controller.fullscreenHandler.isInNonNativeFullscreen { + let alert = NSAlert() + alert.messageText = "Cannot Create New Tab" + alert.informativeText = "New tabs are unsupported while in non-native fullscreen. Exit fullscreen and try again." + alert.addButton(withTitle: "OK") + alert.alertStyle = .warning + alert.beginSheetModal(for: parent) + return + } + // Create a new window and add it to the parent let controller = createWindow(withBaseConfig: base) let window = controller.window!