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)