From 7a21c09c911a21a88470540dcd8dca04858b626d Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Tue, 19 Sep 2023 11:48:13 +0200 Subject: [PATCH] only change activation policy if it's not already set --- ...rg_cryptomator_macos_tray_ActivationPolicy_Native.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/native/org_cryptomator_macos_tray_ActivationPolicy_Native.m b/src/main/native/org_cryptomator_macos_tray_ActivationPolicy_Native.m index e4ae62a..88e661b 100644 --- a/src/main/native/org_cryptomator_macos_tray_ActivationPolicy_Native.m +++ b/src/main/native/org_cryptomator_macos_tray_ActivationPolicy_Native.m @@ -11,11 +11,15 @@ JNIEXPORT void JNICALL Java_org_cryptomator_macos_tray_ActivationPolicy_00024Native_transformToAccessory (JNIEnv *env, jobject thisObj) { - [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory]; + if (NSApp.activationPolicy != NSApplicationActivationPolicyAccessory) { + [NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory]; + } } JNIEXPORT void JNICALL Java_org_cryptomator_macos_tray_ActivationPolicy_00024Native_transformToRegular (JNIEnv *env, jobject thisObj) { - [NSApp activateIgnoringOtherApps:YES]; - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + if (NSApp.activationPolicy != NSApplicationActivationPolicyRegular) { + [NSApp activateIgnoringOtherApps:YES]; + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + } }