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 <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2019-04-24 15:19:20 +05:30
parent 69b33c0fad
commit 5e5481b69b
2 changed files with 7 additions and 0 deletions

View File

@ -97,6 +97,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
return .terminateCancel
}
func applicationShouldTerminateAfterLastWindowClosed(_ application: NSApplication) -> Bool {
application.setActivationPolicy(.accessory)
return false
}
}
extension AppDelegate: StatusMenuWindowDelegate {

View File

@ -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)