aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2014-11-06 17:04:45 +0100
committertomaka <pierre.krieger1708@gmail.com>2014-11-06 17:04:45 +0100
commitbb200a73f07eb5001ae60a04fd32528904d8e2f7 (patch)
treeb3fa28e6bada9d51f52dc50d7174fc2310731ec0
parent6208c59a48070aa3c58bb0372e95d1c946abe673 (diff)
parent2d76e0666fbb6dc3c8743d7365a234657e4b397a (diff)
downloadglutin-bb200a73f07eb5001ae60a04fd32528904d8e2f7.tar.gz
glutin-bb200a73f07eb5001ae60a04fd32528904d8e2f7.zip
Merge pull request #103 from DavidPartouche/cocoa_fullscreen
Added fullscreen support to osx
-rw-r--r--Cargo.toml10
-rw-r--r--src/osx/mod.rs31
2 files changed, 24 insertions, 17 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 6c76711..c126559 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,14 +24,8 @@ git = "https://github.com/DavidPartouche/rust-cocoa"
[target.x86_64-apple-darwin.dependencies.cocoa]
git = "https://github.com/DavidPartouche/rust-cocoa"
-[target.i686-apple-darwin.dependencies.core_foundation]
-git = "https://github.com/DavidPartouche/rust-core-foundation"
-
-[target.x86_64-apple-darwin.dependencies.core_foundation]
-git = "https://github.com/DavidPartouche/rust-core-foundation"
-
[target.i686-apple-darwin.dependencies.core_graphics]
-git = "https://github.com/DavidPartouche/rust-core-graphics"
+git = "https://github.com/servo/rust-core-graphics"
[target.x86_64-apple-darwin.dependencies.core_graphics]
-git = "https://github.com/DavidPartouche/rust-core-graphics"
+git = "https://github.com/servo/rust-core-graphics"
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)
}
}