Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added window activation flags #128

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 12 additions & 4 deletions src/appkit/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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];
});
}

Expand Down
Loading