@@ -26,9 +26,7 @@ use tauri_runtime::{
2626} ;
2727
2828#[ cfg( target_os = "macos" ) ]
29- use tao:: platform:: macos:: EventLoopWindowTargetExtMacOS ;
30- #[ cfg( target_os = "macos" ) ]
31- use tao:: platform:: macos:: WindowBuilderExtMacOS ;
29+ use tao:: platform:: macos:: { EventLoopWindowTargetExtMacOS , WindowBuilderExtMacOS } ;
3230#[ cfg( target_os = "linux" ) ]
3331use tao:: platform:: unix:: { WindowBuilderExtUnix , WindowExtUnix } ;
3432#[ cfg( windows) ]
@@ -431,6 +429,16 @@ pub fn map_theme(theme: &TaoTheme) -> Theme {
431429 }
432430}
433431
432+ #[ cfg( target_os = "macos" ) ]
433+ fn tao_activation_policy ( activation_policy : ActivationPolicy ) -> TaoActivationPolicy {
434+ match activation_policy {
435+ ActivationPolicy :: Regular => TaoActivationPolicy :: Regular ,
436+ ActivationPolicy :: Accessory => TaoActivationPolicy :: Accessory ,
437+ ActivationPolicy :: Prohibited => TaoActivationPolicy :: Prohibited ,
438+ _ => unimplemented ! ( ) ,
439+ }
440+ }
441+
434442impl < ' a > From < & TaoWindowEvent < ' a > > for WindowEventWrapper {
435443 fn from ( event : & TaoWindowEvent < ' a > ) -> Self {
436444 let event = match event {
@@ -1201,6 +1209,8 @@ pub type CreateWebviewClosure = Box<dyn FnOnce(&Window) -> Result<WebviewWrapper
12011209
12021210pub enum Message < T : ' static > {
12031211 Task ( Box < dyn FnOnce ( ) + Send > ) ,
1212+ #[ cfg( target_os = "macos" ) ]
1213+ SetActivationPolicy ( ActivationPolicy ) ,
12041214 RequestExit ( i32 ) ,
12051215 #[ cfg( target_os = "macos" ) ]
12061216 Application ( ApplicationMessage ) ,
@@ -1995,6 +2005,14 @@ impl<T: UserEvent> RuntimeHandle<T> for WryHandle<T> {
19952005 EventProxy ( self . context . proxy . clone ( ) )
19962006 }
19972007
2008+ #[ cfg( target_os = "macos" ) ]
2009+ fn set_activation_policy ( & self , activation_policy : ActivationPolicy ) -> Result < ( ) > {
2010+ send_user_message (
2011+ & self . context ,
2012+ Message :: SetActivationPolicy ( activation_policy) ,
2013+ )
2014+ }
2015+
19982016 fn request_exit ( & self , code : i32 ) -> Result < ( ) > {
19992017 // NOTE: request_exit cannot use the `send_user_message` function because it accesses the event loop callback
20002018 self
@@ -2296,12 +2314,7 @@ impl<T: UserEvent> Runtime<T> for Wry<T> {
22962314 fn set_activation_policy ( & mut self , activation_policy : ActivationPolicy ) {
22972315 self
22982316 . event_loop
2299- . set_activation_policy ( match activation_policy {
2300- ActivationPolicy :: Regular => TaoActivationPolicy :: Regular ,
2301- ActivationPolicy :: Accessory => TaoActivationPolicy :: Accessory ,
2302- ActivationPolicy :: Prohibited => TaoActivationPolicy :: Prohibited ,
2303- _ => unimplemented ! ( ) ,
2304- } ) ;
2317+ . set_activation_policy ( tao_activation_policy ( activation_policy) ) ;
23052318 }
23062319
23072320 #[ cfg( target_os = "macos" ) ]
@@ -2446,6 +2459,10 @@ fn handle_user_message<T: UserEvent>(
24462459 } = context;
24472460 match message {
24482461 Message :: Task ( task) => task ( ) ,
2462+ #[ cfg( target_os = "macos" ) ]
2463+ Message :: SetActivationPolicy ( activation_policy) => {
2464+ event_loop. set_activation_policy_at_runtime ( tao_activation_policy ( activation_policy) )
2465+ }
24492466 Message :: RequestExit ( _code) => panic ! ( "cannot handle RequestExit on the main thread" ) ,
24502467 #[ cfg( target_os = "macos" ) ]
24512468 Message :: Application ( application_message) => match application_message {
0 commit comments