aboutsummaryrefslogtreecommitdiffstats
path: root/src/os/macos.rs
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2016-04-29 20:39:59 +0200
committertomaka <pierre.krieger1708@gmail.com>2016-04-29 20:39:59 +0200
commit2e2febaa42f8f308760e0a33003d46841d892f43 (patch)
tree11e04bd8607b2443b05e0781fa63c58dfff1f19d /src/os/macos.rs
parente46781979499e47e04697fe96994dfe96b7f1e59 (diff)
parentdc49156fe6bd2d15c4bd5e5f9e1ff6f3ffe7d334 (diff)
downloadglutin-2e2febaa42f8f308760e0a33003d46841d892f43.tar.gz
glutin-2e2febaa42f8f308760e0a33003d46841d892f43.zip
Merge pull request #769 from frewsxcv/activation-policy
Allow OSX WindowBuilder to specify 'activation behavior'.
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
+ }
+}