diff --git a/Cargo.toml b/Cargo.toml index 639e96c..9b0a819 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ libc = "0.2" os_info = "3.0.1" url = "2.1.1" uuid = { version = "1.1", features = ["v4"], optional = true } +bitflags = "2.6.0" [dev-dependencies] eval = "0.4" diff --git a/src/appkit/app/mod.rs b/src/appkit/app/mod.rs index 8b57f57..4ba533d 100644 --- a/src/appkit/app/mod.rs +++ b/src/appkit/app/mod.rs @@ -216,6 +216,15 @@ where } } +bitflags::bitflags! { + /// Flags for window activation + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] + pub struct ApplicationActivationOptions: u8 { + const ActivateAllWindows = 1 << 0; + const ActivateIgnoringOtherApps = 1 << 1; + } +} + impl App { /// Registers for remote notifications from APNS. pub fn register_for_remote_notifications() { @@ -294,13 +303,12 @@ impl App { /// For nib-less applications (which, if you're here, this is) need to call the activation /// routines after the NSMenu has been set, otherwise it won't be interact-able without /// switching away from the app and then coming back. - /// - /// @TODO: Accept an ActivationPolicy enum or something. - pub fn activate() { + pub fn activate(options: ApplicationActivationOptions) { + let options = options.bits(); shared_application(|app| unsafe { let _: () = msg_send![app, setActivationPolicy:0]; let current_app: id = msg_send![class!(NSRunningApplication), currentApplication]; - let _: () = msg_send![current_app, activateWithOptions:1<<1]; + let _: () = msg_send![current_app, activateWithOptions:options]; }); }