diff options
author | David Partouche <david@manateedev.com> | 2014-11-06 16:40:30 +0100 |
---|---|---|
committer | David Partouche <david@manateedev.com> | 2014-11-06 16:40:30 +0100 |
commit | 2d76e0666fbb6dc3c8743d7365a234657e4b397a (patch) | |
tree | b3fa28e6bada9d51f52dc50d7174fc2310731ec0 /src | |
parent | 6208c59a48070aa3c58bb0372e95d1c946abe673 (diff) | |
download | glutin-2d76e0666fbb6dc3c8743d7365a234657e4b397a.tar.gz glutin-2d76e0666fbb6dc3c8743d7365a234657e4b397a.zip |
Added fullscreen support to osx
Diffstat (limited to 'src')
-rw-r--r-- | src/osx/mod.rs | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/osx/mod.rs b/src/osx/mod.rs index 3d1df8b..de7e902 100644 --- a/src/osx/mod.rs +++ b/src/osx/mod.rs @@ -49,25 +49,25 @@ impl Deref<Window> for HeadlessContext { #[cfg(feature = "window")] impl Window { pub fn new(builder: WindowBuilder) -> Result<Window, CreationError> { - Window::new_impl(builder.dimensions, builder.title.as_slice(), true) + Window::new_impl(builder.dimensions, builder.title.as_slice(), builder.monitor, true) } } #[cfg(feature = "headless")] impl HeadlessContext { pub fn new(builder: HeadlessRendererBuilder) -> Result<HeadlessContext, CreationError> { - Window::new_impl(Some(builder.dimensions), "", false) + Window::new_impl(Some(builder.dimensions), "", None, false) .map(|w| HeadlessContext(w)) } } impl Window { - fn new_impl(dimensions: Option<(uint, uint)>, title: &str, visible: bool) -> Result<Window, CreationError> { + fn new_impl(dimensions: Option<(uint, uint)>, title: &str, monitor: Option<MonitorID>, visible: bool) -> Result<Window, CreationError> { let app = match Window::create_app() { Some(app) => app, None => { return Err(OsError(format!("Couldn't create NSApplication"))); }, }; - let window = match Window::create_window(dimensions.unwrap_or((800, 600)), title) { + let window = match Window::create_window(dimensions.unwrap_or((800, 600)), title, monitor) { Some(window) => window, None => { return Err(OsError(format!("Couldn't create NSWindow"))); }, }; @@ -108,16 +108,26 @@ impl Window { } } - fn create_window(dimensions: (uint, uint), title: &str) -> Option<id> { + fn create_window(dimensions: (uint, uint), title: &str, monitor: Option<MonitorID>) -> Option<id> { unsafe { - let (width, height) = dimensions; - let scr_frame = NSRect::new(NSPoint::new(0., 0.), NSSize::new(width as f64, height as f64)); + let scr_frame = match monitor { + Some(_) => NSScreen::mainScreen(nil).frame(), + None => { + let (width, height) = dimensions; + NSRect::new(NSPoint::new(0., 0.), NSSize::new(width as f64, height as f64)) + } + }; + + let masks = match monitor { + Some(_) => NSBorderlessWindowMask as NSUInteger, + None => NSTitledWindowMask as NSUInteger | NSClosableWindowMask as NSUInteger | NSMiniaturizableWindowMask as NSUInteger, + }; let window = NSWindow::alloc(nil).initWithContentRect_styleMask_backing_defer_( scr_frame, - NSTitledWindowMask as NSUInteger | NSClosableWindowMask as NSUInteger | NSMiniaturizableWindowMask as NSUInteger, + masks, NSBackingStoreBuffered, - false + false, ); if window == nil { @@ -127,6 +137,9 @@ impl Window { window.setTitle_(title); window.center(); window.setAcceptsMouseMovedEvents_(true); + if monitor.is_some() { + window.setLevel_(NSMainMenuWindowLevel as i64 + 1); + } Some(window) } } |