|
@@ -13,10 +13,14 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
private weak var launcherWindowReference: NSWindow?
|
|
private weak var launcherWindowReference: NSWindow?
|
|
|
|
|
|
|
|
private var launcherWindow: NSWindow? {
|
|
private var launcherWindow: NSWindow? {
|
|
|
- if let launcherWindowReference {
|
|
|
|
|
|
|
+ if let launcherWindowReference, launcherWindowReference.contentViewController is ViewController {
|
|
|
return launcherWindowReference
|
|
return launcherWindowReference
|
|
|
}
|
|
}
|
|
|
- let resolved = NSApp.windows.first
|
|
|
|
|
|
|
+ let resolved =
|
|
|
|
|
+ NSApp.windows.first(where: { $0.contentViewController is ViewController }) ??
|
|
|
|
|
+ NSApp.orderedWindows.first(where: { $0.contentViewController is ViewController }) ??
|
|
|
|
|
+ NSApp.windows.first ??
|
|
|
|
|
+ NSApp.orderedWindows.first
|
|
|
launcherWindowReference = resolved
|
|
launcherWindowReference = resolved
|
|
|
return resolved
|
|
return resolved
|
|
|
}
|
|
}
|
|
@@ -130,6 +134,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
private func showMainWindow() {
|
|
private func showMainWindow() {
|
|
|
configureMainWindowIfNeeded()
|
|
configureMainWindowIfNeeded()
|
|
|
NSApp.setActivationPolicy(.regular)
|
|
NSApp.setActivationPolicy(.regular)
|
|
|
|
|
+ NSRunningApplication.current.activate(options: [.activateAllWindows, .activateIgnoringOtherApps])
|
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
NSApp.activate(ignoringOtherApps: true)
|
|
|
guard let window = launcherWindow else { return }
|
|
guard let window = launcherWindow else { return }
|
|
|
if window.isMiniaturized {
|
|
if window.isMiniaturized {
|
|
@@ -137,6 +142,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
}
|
|
}
|
|
|
window.orderFrontRegardless()
|
|
window.orderFrontRegardless()
|
|
|
window.makeKeyAndOrderFront(nil)
|
|
window.makeKeyAndOrderFront(nil)
|
|
|
|
|
+ // Re-assert key/front on next runloop; status-bar activations can race app focus handoff.
|
|
|
|
|
+ DispatchQueue.main.async {
|
|
|
|
|
+ window.orderFrontRegardless()
|
|
|
|
|
+ window.makeKeyAndOrderFront(nil)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private func configureMainWindowIfNeeded() {
|
|
private func configureMainWindowIfNeeded() {
|