aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-05-22 19:38:15 +0530
committerRoopesh Chander <roop@roopc.net>2019-05-22 19:52:21 +0530
commit89264346829af90563d72c3c153e6e94f632b1c2 (patch)
tree55e9a69d2a18704b35cd491f87cab078b1273892 /WireGuard
parentmacOS: Ignore bogus reopen because of login item helper (diff)
downloadwireguard-apple-89264346829af90563d72c3c153e6e94f632b1c2.tar.xz
wireguard-apple-89264346829af90563d72c3c153e6e94f632b1c2.zip
macOS: Workaround for unresponsive main menu when launched from Xcode
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard')
-rw-r--r--WireGuard/WireGuard/UI/macOS/AppDelegate.swift14
1 files changed, 11 insertions, 3 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/AppDelegate.swift b/WireGuard/WireGuard/UI/macOS/AppDelegate.swift
index 453a152..d7a088b 100644
--- a/WireGuard/WireGuard/UI/macOS/AppDelegate.swift
+++ b/WireGuard/WireGuard/UI/macOS/AppDelegate.swift
@@ -15,6 +15,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
var manageTunnelsWindowObject: NSWindow?
var onAppDeactivation: (() -> Void)?
+ func applicationWillFinishLaunching(_ notification: Notification) {
+ // To workaround a possible AppKit bug that causes the main menu to become unresponsive sometimes
+ // (especially when launched through Xcode) if we call setActivationPolicy(.regular) in
+ // in applicationDidFinishLaunching, we set it to .prohibited here.
+ // Setting it to .regular would fix that problem too, but at this point, we don't know
+ // whether the app was launched at login or not, so we're not sure whether we should
+ // show the app icon in the dock or not.
+ NSApp.setActivationPolicy(.prohibited)
+ }
+
func applicationDidFinishLaunching(_ aNotification: Notification) {
Logger.configureGlobal(tagged: "APP", withFilePath: FileManager.logFileURL?.path)
registerLoginItem(shouldLaunchAtLogin: true)
@@ -24,10 +34,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
isLaunchedAtLogin = LaunchedAtLoginDetector.isLaunchedAtLogin(openAppleEvent: appleEvent)
}
- if !isLaunchedAtLogin {
- setDockIconAndMainMenuVisibility(isVisible: true)
- }
NSApp.mainMenu = MainMenu()
+ setDockIconAndMainMenuVisibility(isVisible: !isLaunchedAtLogin)
TunnelsManager.create { [weak self] result in
guard let self = self else { return }