From c3d3edebf416716881bd54b5cdf6e7f3436887da 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 | 12 ++++++++---- 1 file changed, 8 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..253632c647 100644 --- a/src/platform_impl/apple/appkit/app_state.rs +++ b/src/platform_impl/apple/appkit/app_state.rs @@ -115,12 +115,16 @@ 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