diff options
Diffstat (limited to 'WireGuard/WireGuard/UI/macOS/AppDelegate.swift')
-rw-r--r-- | WireGuard/WireGuard/UI/macOS/AppDelegate.swift | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/AppDelegate.swift b/WireGuard/WireGuard/UI/macOS/AppDelegate.swift index 8dc5825..d3e2c0a 100644 --- a/WireGuard/WireGuard/UI/macOS/AppDelegate.swift +++ b/WireGuard/WireGuard/UI/macOS/AppDelegate.swift @@ -124,9 +124,13 @@ extension AppDelegate { } extension AppDelegate: StatusMenuWindowDelegate { - func manageTunnelsWindow() -> NSWindow { + func showManageTunnelsWindow(completion: ((NSWindow?) -> Void)?) { + guard let tunnelsManager = tunnelsManager else { + completion?(nil) + return + } if manageTunnelsWindowObject == nil { - manageTunnelsRootVC = ManageTunnelsRootViewController(tunnelsManager: tunnelsManager!) + manageTunnelsRootVC = ManageTunnelsRootViewController(tunnelsManager: tunnelsManager) let window = NSWindow(contentViewController: manageTunnelsRootVC!) window.title = tr("macWindowTitleManageTunnels") window.setContentSize(NSSize(width: 800, height: 480)) @@ -134,7 +138,10 @@ extension AppDelegate: StatusMenuWindowDelegate { manageTunnelsWindowObject = window tunnelsTracker?.manageTunnelsRootVC = manageTunnelsRootVC } - return manageTunnelsWindowObject! + NSApp.setActivationPolicy(.regular) + NSApp.activate(ignoringOtherApps: true) + manageTunnelsWindowObject!.makeKeyAndOrderFront(self) + completion?(manageTunnelsWindowObject) } } |