aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-01-18 10:38:59 +0100
committertomaka <pierre.krieger1708@gmail.com>2015-01-18 10:38:59 +0100
commit0d114c72b3362fb6e5094bf225e323941135b81a (patch)
treef08052eb65f35006a6368e377fa31986037088cb /src
parent00460364cabc33435a9fd46af74739edbee6f482 (diff)
parent1891764afd315db61aa1c34b127e862cb1f5aed7 (diff)
downloadglutin-0d114c72b3362fb6e5094bf225e323941135b81a.tar.gz
glutin-0d114c72b3362fb6e5094bf225e323941135b81a.zip
Merge pull request #209 from bjz/osx-window
Remove unnecessary inner method in OSX window constructor
Diffstat (limited to 'src')
-rw-r--r--src/osx/mod.rs58
1 files changed, 26 insertions, 32 deletions
diff --git a/src/osx/mod.rs b/src/osx/mod.rs
index 86a891c..58b6176 100644
--- a/src/osx/mod.rs
+++ b/src/osx/mod.rs
@@ -65,17 +65,6 @@ pub struct Window {
}
#[cfg(feature = "window")]
-impl Window {
- pub fn new(builder: BuilderAttribs) -> Result<Window, CreationError> {
- if builder.sharing.is_some() {
- unimplemented!()
- }
-
- Window::new_impl(builder.dimensions, builder.title.as_slice(), builder.monitor, builder.vsync, builder.visible, builder.gl_version)
- }
-}
-
-#[cfg(feature = "window")]
unsafe impl Send for Window {}
#[cfg(feature = "window")]
unsafe impl Sync for Window {}
@@ -137,13 +126,20 @@ extern fn window_did_resize(this: id, _: id) -> id {
}
impl Window {
- fn new_impl(dimensions: Option<(u32, u32)>, title: &str, monitor: Option<MonitorID>,
- vsync: bool, visible: bool, gl_version: Option<(u32, u32)>) -> Result<Window, CreationError> {
+ #[cfg(feature = "window")]
+ pub fn new(builder: BuilderAttribs) -> Result<Window, CreationError> {
+ if builder.sharing.is_some() {
+ unimplemented!()
+ }
+
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, monitor) {
+ let window = match Window::create_window(builder.dimensions.unwrap_or((800, 600)),
+ &*builder.title,
+ builder.monitor)
+ {
Some(window) => window,
None => { return Err(OsError(format!("Couldn't create NSWindow"))); },
};
@@ -152,14 +148,14 @@ impl Window {
None => { return Err(OsError(format!("Couldn't create NSView"))); },
};
- let context = match Window::create_context(view, vsync, gl_version) {
+ let context = match Window::create_context(view, builder.vsync, builder.gl_version) {
Some(context) => context,
None => { return Err(OsError(format!("Couldn't create OpenGL context"))); },
};
unsafe {
app.activateIgnoringOtherApps_(true);
- if visible {
+ if builder.visible {
window.makeKeyAndOrderFront_(nil);
} else {
window.makeKeyWindow();
@@ -212,27 +208,25 @@ impl Window {
fn create_window(dimensions: (u32, u32), title: &str, monitor: Option<MonitorID>) -> Option<id> {
unsafe {
- let scr_frame = match monitor {
- Some(_) => {
- let screen = NSScreen::mainScreen(nil);
- NSScreen::frame(screen)
- }
- None => {
- let (width, height) = dimensions;
- NSRect::new(NSPoint::new(0., 0.), NSSize::new(width as f64, height as f64))
- }
+ let frame = if monitor.is_some() {
+ let screen = NSScreen::mainScreen(nil);
+ NSScreen::frame(screen)
+ } else {
+ 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 |
- NSResizableWindowMask as NSUInteger,
+ let masks = if monitor.is_some() {
+ NSBorderlessWindowMask as NSUInteger
+ } else {
+ NSTitledWindowMask as NSUInteger |
+ NSClosableWindowMask as NSUInteger |
+ NSMiniaturizableWindowMask as NSUInteger |
+ NSResizableWindowMask as NSUInteger
};
let window = NSWindow::alloc(nil).initWithContentRect_styleMask_backing_defer_(
- scr_frame,
+ frame,
masks,
NSBackingStoreBuffered,
false,