macOS: Show app in dock when showing the manage tunnels window

This way, the app can participate in Cmd+Tab
This commit is contained in:
Roopesh Chander 2019-04-24 15:19:20 +05:30
parent 227ebef371
commit d3c3dcb924
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)