macOS: Fix appearance of main menu when showing the manage window
This commit is contained in:
parent
b779114ccc
commit
4f79bf7b9b
|
@ -100,11 +100,27 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
}
|
||||
|
||||
func applicationShouldTerminateAfterLastWindowClosed(_ application: NSApplication) -> Bool {
|
||||
application.setActivationPolicy(.accessory)
|
||||
AppDelegate.setAppAppearsInDock(false)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
extension AppDelegate {
|
||||
static func setAppAppearsInDock(_ enabled: Bool) {
|
||||
if enabled {
|
||||
if NSApp.activationPolicy() != .regular {
|
||||
// It looks like we need to go from deactivated to activated with policy as .regular
|
||||
// for our app's main menu to show up.
|
||||
NSApp.deactivate()
|
||||
NSApp.setActivationPolicy(.regular)
|
||||
}
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
} else {
|
||||
NSApp.setActivationPolicy(.accessory)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension AppDelegate {
|
||||
@objc func aboutClicked() {
|
||||
var appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown"
|
||||
|
|
|
@ -151,15 +151,13 @@ class StatusMenu: NSMenu {
|
|||
}
|
||||
|
||||
@objc func manageTunnelsClicked() {
|
||||
NSApp.setActivationPolicy(.regular)
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
AppDelegate.setAppAppearsInDock(true)
|
||||
guard let manageTunnelsWindow = windowDelegate?.manageTunnelsWindow() else { return }
|
||||
manageTunnelsWindow.makeKeyAndOrderFront(self)
|
||||
}
|
||||
|
||||
@objc func importTunnelsClicked() {
|
||||
NSApp.setActivationPolicy(.regular)
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
AppDelegate.setAppAppearsInDock(true)
|
||||
guard let manageTunnelsWindow = windowDelegate?.manageTunnelsWindow() else { return }
|
||||
manageTunnelsWindow.makeKeyAndOrderFront(self)
|
||||
ImportPanelPresenter.presentImportPanel(tunnelsManager: tunnelsManager, sourceVC: manageTunnelsWindow.contentViewController)
|
||||
|
|
Loading…
Reference in New Issue