Skip to content

Commit

Permalink
macos: only set quick terminal level to popUpMenu during animation (#…
Browse files Browse the repository at this point in the history
…5000)

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.
  • Loading branch information
mitchellh authored Jan 12, 2025
2 parents caddf59 + ea07041 commit a244535
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
15 changes: 15 additions & 0 deletions macos/Sources/Features/QuickTerminal/QuickTerminalController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 0 additions & 18 deletions macos/Sources/Features/QuickTerminal/QuickTerminalWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
}

0 comments on commit a244535

Please sign in to comment.