macOS: restore visiblity state when hiding quick terminal
parent
0f64b9a8e8
commit
bcb5112b24
|
|
@ -110,7 +110,7 @@ class AppDelegate: NSObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tracks the windows that we hid for toggleVisibility.
|
/// Tracks the windows that we hid for toggleVisibility.
|
||||||
private var hiddenState: ToggleVisibilityState? = nil
|
private(set) var hiddenState: ToggleVisibilityState? = nil
|
||||||
|
|
||||||
/// The observer for the app appearance.
|
/// The observer for the app appearance.
|
||||||
private var appearanceObserver: NSKeyValueObservation? = nil
|
private var appearanceObserver: NSKeyValueObservation? = nil
|
||||||
|
|
@ -280,6 +280,11 @@ class AppDelegate: NSObject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func applicationDidHide(_ notification: Notification) {
|
||||||
|
// Keep track of our hidden state to restore properly
|
||||||
|
self.hiddenState = .init()
|
||||||
|
}
|
||||||
|
|
||||||
func applicationDidBecomeActive(_ notification: Notification) {
|
func applicationDidBecomeActive(_ notification: Notification) {
|
||||||
// If we're back manually then clear the hidden state because macOS handles it.
|
// If we're back manually then clear the hidden state because macOS handles it.
|
||||||
self.hiddenState = nil
|
self.hiddenState = nil
|
||||||
|
|
@ -1084,8 +1089,6 @@ class AppDelegate: NSObject,
|
||||||
guard let keyWindow = NSApp.keyWindow,
|
guard let keyWindow = NSApp.keyWindow,
|
||||||
!keyWindow.styleMask.contains(.fullScreen) else { return }
|
!keyWindow.styleMask.contains(.fullScreen) else { return }
|
||||||
|
|
||||||
// Keep track of our hidden state to restore properly
|
|
||||||
self.hiddenState = .init()
|
|
||||||
NSApp.hide(nil)
|
NSApp.hide(nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -1134,11 +1137,11 @@ class AppDelegate: NSObject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct ToggleVisibilityState {
|
struct ToggleVisibilityState {
|
||||||
let hiddenWindows: [Weak<NSWindow>]
|
let hiddenWindows: [Weak<NSWindow>]
|
||||||
let keyWindow: Weak<NSWindow>?
|
let keyWindow: Weak<NSWindow>?
|
||||||
|
|
||||||
init() {
|
fileprivate init() {
|
||||||
// We need to know the key window so that we can bring focus back to the
|
// We need to know the key window so that we can bring focus back to the
|
||||||
// right window if it was hidden.
|
// right window if it was hidden.
|
||||||
self.keyWindow = if let keyWindow = NSApp.keyWindow {
|
self.keyWindow = if let keyWindow = NSApp.keyWindow {
|
||||||
|
|
|
||||||
|
|
@ -513,6 +513,10 @@ class QuickTerminalController: BaseTerminalController {
|
||||||
if !window.isOnActiveSpace {
|
if !window.isOnActiveSpace {
|
||||||
self.previousApp = nil
|
self.previousApp = nil
|
||||||
window.orderOut(self)
|
window.orderOut(self)
|
||||||
|
// If our application is hidden previously, we hide it again
|
||||||
|
if (NSApp.delegate as? AppDelegate)?.hiddenState != nil {
|
||||||
|
NSApp.hide(nil)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -549,6 +553,10 @@ class QuickTerminalController: BaseTerminalController {
|
||||||
// This causes the window to be removed from the screen list and macOS
|
// This causes the window to be removed from the screen list and macOS
|
||||||
// handles what should be focused next.
|
// handles what should be focused next.
|
||||||
window.orderOut(self)
|
window.orderOut(self)
|
||||||
|
// If our application is hidden previously, we hide it again
|
||||||
|
if (NSApp.delegate as? AppDelegate)?.hiddenState != nil {
|
||||||
|
NSApp.hide(nil)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue