aboutsummaryrefslogtreecommitdiffstats
path: root/src/os/macos.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/macos.rs')
-rw-r--r--src/os/macos.rs48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/os/macos.rs b/src/os/macos.rs
index 16ffe33..06ea55c 100644
--- a/src/os/macos.rs
+++ b/src/os/macos.rs
@@ -1,7 +1,9 @@
#![cfg(target_os = "macos")]
+use std::convert::From;
use std::os::raw::c_void;
-use Window;
+use cocoa::appkit::NSApplicationActivationPolicy;
+use {Window, WindowBuilder};
/// Additional methods on `Window` that are specific to MacOS.
pub trait WindowExt {
@@ -17,3 +19,47 @@ impl WindowExt for Window {
self.window.platform_window() as *mut c_void
}
}
+
+/// Corresponds to `NSApplicationActivationPolicy`.
+#[derive(Debug, Clone, Copy, PartialEq)]
+pub enum ActivationPolicy {
+ /// Corresponds to `NSApplicationActivationPolicyRegular`.
+ Regular,
+ /// Corresponds to `NSApplicationActivationPolicyAccessory`.
+ Accessory,
+ /// Corresponds to `NSApplicationActivationPolicyProhibited`.
+ Prohibited,
+}
+
+impl Default for ActivationPolicy {
+ fn default() -> Self {
+ ActivationPolicy::Regular
+ }
+}
+
+impl From<ActivationPolicy> for NSApplicationActivationPolicy {
+ fn from(activation_policy: ActivationPolicy) -> Self {
+ match activation_policy {
+ ActivationPolicy::Regular =>
+ NSApplicationActivationPolicy::NSApplicationActivationPolicyRegular,
+ ActivationPolicy::Accessory =>
+ NSApplicationActivationPolicy::NSApplicationActivationPolicyAccessory,
+ ActivationPolicy::Prohibited =>
+ NSApplicationActivationPolicy::NSApplicationActivationPolicyProhibited,
+ }
+ }
+}
+
+/// Additional methods on `WindowBuilder` that are specific to MacOS.
+pub trait WindowBuilderExt<'a> {
+ fn with_activation_policy(mut self, activation_policy: ActivationPolicy) -> WindowBuilder<'a>;
+}
+
+impl<'a> WindowBuilderExt<'a> for WindowBuilder<'a> {
+ /// Sets the activation policy for the window being built
+ #[inline]
+ fn with_activation_policy(mut self, activation_policy: ActivationPolicy) -> WindowBuilder<'a> {
+ self.platform_specific.activation_policy = activation_policy;
+ self
+ }
+}