From 5e5481b69b554003f2cc8575da3bb4f9739145a7 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Wed, 24 Apr 2019 15:19:20 +0530 Subject: [PATCH] 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 --- WireGuard/WireGuard/UI/macOS/AppDelegate.swift | 5 +++++ WireGuard/WireGuard/UI/macOS/StatusMenu.swift | 2 ++ 2 files changed, 7 insertions(+) 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)