diff options
author | Corey Farwell <coreyf@rwell.org> | 2016-04-28 19:30:44 -0400 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2016-04-29 10:43:30 -0400 |
commit | dc49156fe6bd2d15c4bd5e5f9e1ff6f3ffe7d334 (patch) | |
tree | 11e04bd8607b2443b05e0781fa63c58dfff1f19d /src/api | |
parent | e46781979499e47e04697fe96994dfe96b7f1e59 (diff) | |
download | glutin-dc49156fe6bd2d15c4bd5e5f9e1ff6f3ffe7d334.tar.gz glutin-dc49156fe6bd2d15c4bd5e5f9e1ff6f3ffe7d334.zip |
Allow OSX WindowBuilder to specify 'activation behavior'.
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/cocoa/mod.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs index da7c1ec..3c4d802 100644 --- a/src/api/cocoa/mod.rs +++ b/src/api/cocoa/mod.rs @@ -15,6 +15,7 @@ use ReleaseBehavior; use Robustness; use WindowAttributes; use native_monitor::NativeMonitorId; +use os::macos::ActivationPolicy; use objc::runtime::{Class, Object, Sel, BOOL, YES, NO}; use objc::declare::ClassDecl; @@ -181,7 +182,9 @@ impl Drop for WindowDelegate { } #[derive(Default)] -pub struct PlatformSpecificWindowBuilderAttributes; +pub struct PlatformSpecificWindowBuilderAttributes { + pub activation_policy: ActivationPolicy, +} pub struct Window { view: IdRef, @@ -276,7 +279,8 @@ impl<'a> Iterator for WaitEventsIterator<'a> { impl Window { pub fn new(win_attribs: &WindowAttributes, pf_reqs: &PixelFormatRequirements, - opengl: &GlAttributes<&Window>, _: &PlatformSpecificWindowBuilderAttributes) + opengl: &GlAttributes<&Window>, + pl_attribs: &PlatformSpecificWindowBuilderAttributes) -> Result<Window, CreationError> { if opengl.sharing.is_some() { @@ -294,7 +298,7 @@ impl Window { _ => () } - let app = match Window::create_app() { + let app = match Window::create_app(pl_attribs.activation_policy) { Some(app) => app, None => { return Err(OsError(format!("Couldn't create NSApplication"))); }, }; @@ -359,13 +363,13 @@ impl Window { Ok(window) } - fn create_app() -> Option<id> { + fn create_app(activation_policy: ActivationPolicy) -> Option<id> { unsafe { let app = NSApp(); if app == nil { None } else { - app.setActivationPolicy_(NSApplicationActivationPolicyRegular); + app.setActivationPolicy_(activation_policy.into()); app.finishLaunching(); Some(app) } |