From: Roopesh Chander Date: Wed, 24 Apr 2019 09:49:20 +0000 (+0530) Subject: macOS: Show app in dock when showing the manage tunnels window X-Git-Tag: 0.0.20190531-9~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e5481b69b554003f2cc8575da3bb4f9739145a7;p=thirdparty%2Fwireguard-apple.git macOS: Show app in dock when showing the manage tunnels window This way, the app can participate in Cmd+Tab Signed-off-by: Roopesh Chander --- diff --git a/WireGuard/WireGuard/UI/macOS/AppDelegate.swift b/WireGuard/WireGuard/UI/macOS/AppDelegate.swift index a5f8c34..3f69ea3 100644 --- a/WireGuard/WireGuard/UI/macOS/AppDelegate.swift +++ b/WireGuard/WireGuard/UI/macOS/AppDelegate.swift @@ -97,6 +97,11 @@ class AppDelegate: NSObject, NSApplicationDelegate { } return .terminateCancel } + + func applicationShouldTerminateAfterLastWindowClosed(_ application: NSApplication) -> Bool { + application.setActivationPolicy(.accessory) + return false + } } extension AppDelegate: StatusMenuWindowDelegate { diff --git a/WireGuard/WireGuard/UI/macOS/StatusMenu.swift b/WireGuard/WireGuard/UI/macOS/StatusMenu.swift index 5cf04d3..150c55e 100644 --- a/WireGuard/WireGuard/UI/macOS/StatusMenu.swift +++ b/WireGuard/WireGuard/UI/macOS/StatusMenu.swift @@ -151,12 +151,14 @@ class StatusMenu: NSMenu { } @objc func manageTunnelsClicked() { + NSApp.setActivationPolicy(.regular) NSApp.activate(ignoringOtherApps: true) guard let manageTunnelsWindow = windowDelegate?.manageTunnelsWindow() else { return } manageTunnelsWindow.makeKeyAndOrderFront(self) } @objc func importTunnelsClicked() { + NSApp.setActivationPolicy(.regular) NSApp.activate(ignoringOtherApps: true) guard let manageTunnelsWindow = windowDelegate?.manageTunnelsWindow() else { return } manageTunnelsWindow.makeKeyAndOrderFront(self)