From dc49156fe6bd2d15c4bd5e5f9e1ff6f3ffe7d334 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Thu, 28 Apr 2016 19:30:44 -0400 Subject: Allow OSX WindowBuilder to specify 'activation behavior'. --- src/api/cocoa/mod.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/api') 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 { 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 { + fn create_app(activation_policy: ActivationPolicy) -> Option { unsafe { let app = NSApp(); if app == nil { None } else { - app.setActivationPolicy_(NSApplicationActivationPolicyRegular); + app.setActivationPolicy_(activation_policy.into()); app.finishLaunching(); Some(app) } -- cgit v1.2.3