mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: quick terminal close focuses next window on same screen/space
Previously, we'd find the next Ghostty window anywhere. Now we find the one on the same screen/space to avoid moving the focus to a different screen.
This commit is contained in:
@ -177,13 +177,24 @@ class QuickTerminalController: BaseTerminalController {
|
||||
position.setInitial(in: window.animator(), on: screen)
|
||||
}, completionHandler: {
|
||||
guard wasKey else { return }
|
||||
self.focusNextWindow()
|
||||
self.focusNextWindow(on: screen)
|
||||
})
|
||||
}
|
||||
|
||||
private func focusNextWindow() {
|
||||
// We only want to consider windows that are visible
|
||||
let windows = NSApp.windows.filter { $0.isVisible }
|
||||
private func focusNextWindow(on screen: NSScreen) {
|
||||
let windows = NSApp.windows.filter {
|
||||
// Visible, otherwise we'll make an invisible window visible.
|
||||
guard $0.isVisible else { return false }
|
||||
|
||||
// Same screen, just a preference...
|
||||
guard $0.screen == screen else { return false }
|
||||
|
||||
// Same space (virtual screen). Otherwise we'll force an animation to
|
||||
// another space which is very jarring.
|
||||
guard $0.isOnActiveSpace else { return false }
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// If we have no windows there is nothing to focus.
|
||||
guard !windows.isEmpty else { return }
|
||||
|
Reference in New Issue
Block a user