rust_macios/appkit/
ns_running_application.rs1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4 object,
5 objective_c_runtime::traits::{FromId, PNSObject},
6};
7
8use super::{interface_impl, NSApplicationActivationOptions};
9
10object! {
11 unsafe pub struct NSRunningApplication;
13}
14
15#[interface_impl(NSObject)]
16impl NSRunningApplication {
17 #[property]
19 pub fn current_application() -> Self
20 where
21 Self: Sized + FromId,
22 {
23 unsafe { Self::from_id(msg_send![Self::m_class(), currentApplication]) }
24 }
25
26 #[property]
28 pub fn is_active(&self) -> bool {
29 unsafe { msg_send![self.m_self(), isActive] }
30 }
31
32 #[method]
34 pub fn activate_with_options(&mut self, options: NSApplicationActivationOptions) {
35 unsafe { msg_send![self.m_self(), activateWithOptions: options] }
36 }
37}