diff --git a/src/macos/window.rs b/src/macos/window.rs index 42429be..3add2ef 100644 --- a/src/macos/window.rs +++ b/src/macos/window.rs @@ -25,8 +25,8 @@ pub struct WindowHandle; impl WindowHandle { pub fn app_run_blocking(self) { unsafe { - let current_app = NSRunningApplication::currentApplication(nil); - current_app.activateWithOptions_(NSApplicationActivateIgnoringOtherApps); + let app = NSApp(); + app.setActivationPolicy_(NSApplicationActivationPolicyRegular); app.run(); } } @@ -37,9 +37,6 @@ impl Window { unsafe { let _pool = NSAutoreleasePool::new(nil); - let app = NSApp(); - app.setActivationPolicy_(NSApplicationActivationPolicyRegular); - let rect = NSRect::new( NSPoint::new(0.0, 0.0), NSSize::new(options.width as f64, options.height as f64), @@ -54,7 +51,7 @@ impl Window { ) .autorelease(); ns_window.center(); - ns_window.setTitle_(NSString::alloc(nil).init_str(options.title)); + ns_window.setTitle_(NSString::alloc(nil).init_str(&options.title)); ns_window.makeKeyAndOrderFront_(nil); let ns_view = NSView::alloc(nil).init(); @@ -64,6 +61,10 @@ impl Window { let handler = H::build(&mut window); + // FIXME: only do this in the unparented case + let current_app = NSRunningApplication::currentApplication(nil); + current_app.activateWithOptions_(NSApplicationActivateIgnoringOtherApps); + WindowHandle } }