From f5fb030c3625a16fcc02cf01bdc0e383fdcfe6a0 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Sun, 18 Jan 2015 19:51:23 +1100 Subject: Squash some warnings --- examples/multiwindow.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/multiwindow.rs b/examples/multiwindow.rs index 96b5842..cd57d2e 100644 --- a/examples/multiwindow.rs +++ b/examples/multiwindow.rs @@ -32,9 +32,9 @@ fn main() { run(window3, (1.0, 0.0, 0.0, 1.0)); }); - t1.join(); - t2.join(); - t3.join(); + let _ = t1.join(); + let _ = t2.join(); + let _ = t3.join(); } #[cfg(feature = "window")] -- cgit v1.2.3 From f8f2950afd44747dfcde057134f72a15db0c5bd3 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Sun, 18 Jan 2015 20:11:23 +1100 Subject: Remove unnecessary inner method --- src/osx/mod.rs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/osx/mod.rs b/src/osx/mod.rs index 86a891c..5ef1c65 100644 --- a/src/osx/mod.rs +++ b/src/osx/mod.rs @@ -64,17 +64,6 @@ pub struct Window { is_closed: Cell, } -#[cfg(feature = "window")] -impl Window { - pub fn new(builder: BuilderAttribs) -> Result { - 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")] @@ -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, - vsync: bool, visible: bool, gl_version: Option<(u32, u32)>) -> Result { + #[cfg(feature = "window")] + pub fn new(builder: BuilderAttribs) -> Result { + 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(); -- cgit v1.2.3 From 1891764afd315db61aa1c34b127e862cb1f5aed7 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Sun, 18 Jan 2015 20:22:33 +1100 Subject: Clean up pattern matches --- src/osx/mod.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/osx/mod.rs b/src/osx/mod.rs index 5ef1c65..58b6176 100644 --- a/src/osx/mod.rs +++ b/src/osx/mod.rs @@ -208,27 +208,25 @@ impl Window { fn create_window(dimensions: (u32, u32), title: &str, monitor: Option) -> Option { 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, -- cgit v1.2.3