From f2eba4cac7e293c60c6bd9021b1633d0ca1a09ee Mon Sep 17 00:00:00 2001 From: Ryan Hileman Date: Sun, 17 Nov 2024 15:43:34 -0800 Subject: [PATCH] macOS: don't implicitly activate background apps --- src/platform_impl/apple/appkit/app_state.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/platform_impl/apple/appkit/app_state.rs b/src/platform_impl/apple/appkit/app_state.rs index c2f107ee8c..722c44f065 100644 --- a/src/platform_impl/apple/appkit/app_state.rs +++ b/src/platform_impl/apple/appkit/app_state.rs @@ -115,12 +115,14 @@ impl AppState { // menu bar is initially unresponsive on macOS 10.15. // If no activation policy is explicitly provided, do not set it at all // to allow the package manifest to define behavior via LSUIElement. - if self.activation_policy.is_some() { - app.setActivationPolicy(self.activation_policy.unwrap()); + if let Some(activation_policy) = self.activation_policy { + app.setActivationPolicy(activation_policy); } - #[allow(deprecated)] - app.activateIgnoringOtherApps(self.activate_ignoring_other_apps); + if self.activate_ignoring_other_apps && self.activation_policy != Some(NSApplicationActivationPolicy::Prohibited) { + #[allow(deprecated)] + app.activateIgnoringOtherApps(true); + } if self.default_menu { // The menubar initialization should be before the `NewEvents` event, to allow