From a9a601f884e46cca3969db11a2afdb41d103a1b0 Mon Sep 17 00:00:00 2001 From: Bryan Lee <38807139+liby@users.noreply.github.com> Date: Mon, 14 Apr 2025 00:55:10 +0800 Subject: [PATCH] Fix quick terminal fullscreen toggle in front of fullscreen window Implements custom fullscreen toggle for quick terminal to avoid presentation options conflicts when toggling fullscreen in front of an already fullscreen window. --- .../QuickTerminal/QuickTerminalController.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift b/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift index fac3a2fbb..690c7f132 100644 --- a/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift +++ b/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift @@ -33,6 +33,9 @@ class QuickTerminalController: BaseTerminalController { /// The configuration derived from the Ghostty config so we don't need to rely on references. private var derivedConfig: DerivedConfig + /// Storage for the window frame before entering fullscreen mode + private var savedWindowFrame: NSRect? = nil + init(_ ghostty: Ghostty.App, position: QuickTerminalPosition = .top, baseConfig base: Ghostty.SurfaceConfiguration? = nil, @@ -485,9 +488,16 @@ class QuickTerminalController: BaseTerminalController { @objc private func onToggleFullscreen(notification: SwiftUI.Notification) { guard let target = notification.object as? Ghostty.SurfaceView else { return } guard target == self.focusedSurface else { return } + guard let window = self.window else { return } + guard let screen = window.screen ?? NSScreen.main else { return } - // We ignore the requested mode and always use non-native for the quick terminal - toggleFullscreen(mode: .nonNative) + if let originalFrame = savedWindowFrame { + window.setFrame(originalFrame, display: true) + savedWindowFrame = nil + } else { + savedWindowFrame = window.frame + window.setFrame(screen.frame, display: true) + } } @objc private func ghosttyConfigDidChange(_ notification: Notification) {