aboutsummaryrefslogtreecommitdiffstats
path: root/src/os
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-04-28 19:30:44 -0400
committerCorey Farwell <coreyf@rwell.org>2016-04-29 10:43:30 -0400
commitdc49156fe6bd2d15c4bd5e5f9e1ff6f3ffe7d334 (patch)
tree11e04bd8607b2443b05e0781fa63c58dfff1f19d /src/os
parente46781979499e47e04697fe96994dfe96b7f1e59 (diff)
downloadglutin-dc49156fe6bd2d15c4bd5e5f9e1ff6f3ffe7d334.tar.gz
glutin-dc49156fe6bd2d15c4bd5e5f9e1ff6f3ffe7d334.zip
Allow OSX WindowBuilder to specify 'activation behavior'.
Diffstat (limited to 'src/os')
-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
+ }
+}