From ea0704148d8fc205de16fc2ef1da88b162c0c739 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 12 Jan 2025 12:48:53 -0800 Subject: [PATCH] macos: only set quick terminal level to popUpMenu during animation Fixes #4999 We need to set the level to popUpMenu so that we can move the window offscreen and animate it over the main menu, but we must reset it back to floating after the animation is complete so that other higher-level windows can be shown on top of it such as IME windows. --- .../QuickTerminalController.swift | 15 +++++++++++++++ .../QuickTerminal/QuickTerminalWindow.swift | 18 ------------------ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift b/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift index fee6f0735..c23aad755 100644 --- a/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift +++ b/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift @@ -230,6 +230,11 @@ class QuickTerminalController: BaseTerminalController { // Move our window off screen to the top position.setInitial(in: window, on: screen) + // We need to set our window level to a high value. In testing, only + // popUpMenu and above do what we want. This gets it above the menu bar + // and lets us render off screen. + window.level = .popUpMenu + // Move it to the visible position since animation requires this DispatchQueue.main.async { window.makeKeyAndOrderFront(nil) @@ -248,6 +253,11 @@ class QuickTerminalController: BaseTerminalController { // If we canceled our animation in we do nothing guard self.visible else { return } + // After animating in, we reset the window level to a value that + // is above other windows but not as high as popUpMenu. This allows + // things like IME dropdowns to appear properly. + window.level = .floating + // Now that the window is visible, sync our appearance. This function // requires the window is visible. self.syncAppearance() @@ -339,6 +349,11 @@ class QuickTerminalController: BaseTerminalController { } } + // We need to set our window level to a high value. In testing, only + // popUpMenu and above do what we want. This gets it above the menu bar + // and lets us render off screen. + window.level = .popUpMenu + NSAnimationContext.runAnimationGroup({ context in context.duration = derivedConfig.quickTerminalAnimationDuration context.timingFunction = .init(name: .easeIn) diff --git a/macos/Sources/Features/QuickTerminal/QuickTerminalWindow.swift b/macos/Sources/Features/QuickTerminal/QuickTerminalWindow.swift index 552b87e25..005808a23 100644 --- a/macos/Sources/Features/QuickTerminal/QuickTerminalWindow.swift +++ b/macos/Sources/Features/QuickTerminal/QuickTerminalWindow.swift @@ -28,23 +28,5 @@ class QuickTerminalWindow: NSPanel { // We don't want to activate the owning app when quick terminal is triggered. self.styleMask.insert(.nonactivatingPanel) - - // We need to set our window level to a high value. In testing, only - // popUpMenu and above do what we want. This gets it above the menu bar - // and lets us render off screen. - self.level = .popUpMenu - - // This plus the level above was what was needed for the animation to work, - // because it gets the window off screen properly. Plus we add some fields - // we just want the behavior of. - self.collectionBehavior = [ - // We want this to be part of every space because it is a singleton. - .canJoinAllSpaces, - - // We don't want to be part of command-tilde - .ignoresCycle, - - // We want to show the window on another space if it is visible - .fullScreenAuxiliary] } }