From bc79e423142e18614cc69c8229bc1cf2be78f0f1 Mon Sep 17 00:00:00 2001 From: William Light Date: Fri, 11 Sep 2020 18:33:06 +0200 Subject: [PATCH] macOS: WindowHandle.app_run_blocking() --- src/macos/window.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/macos/window.rs b/src/macos/window.rs index 6ae0ae6..42429be 100644 --- a/src/macos/window.rs +++ b/src/macos/window.rs @@ -20,6 +20,18 @@ pub struct Window { ns_view: id, } +pub struct WindowHandle; + +impl WindowHandle { + pub fn app_run_blocking(self) { + unsafe { + let current_app = NSRunningApplication::currentApplication(nil); + current_app.activateWithOptions_(NSApplicationActivateIgnoringOtherApps); + app.run(); + } + } +} + impl Window { pub fn open(options: WindowOpenOptions) -> WindowHandle { unsafe { @@ -52,10 +64,6 @@ impl Window { let handler = H::build(&mut window); - let current_app = NSRunningApplication::currentApplication(nil); - current_app.activateWithOptions_(NSApplicationActivateIgnoringOtherApps); - app.run(); - WindowHandle } } @@ -70,5 +78,3 @@ unsafe impl HasRawWindowHandle for Window { }) } } - -pub struct WindowHandle;