diff --git a/examples/open_window.rs b/examples/open_window.rs index 861c95b..1371354 100644 --- a/examples/open_window.rs +++ b/examples/open_window.rs @@ -8,7 +8,7 @@ fn main() { parent: baseview::Parent::None, }; - Window::open::(window_open_options); + let _handle = Window::open::(window_open_options); } struct MyProgram {} diff --git a/src/macos/window.rs b/src/macos/window.rs index ee4c0d9..40c54b4 100644 --- a/src/macos/window.rs +++ b/src/macos/window.rs @@ -18,7 +18,7 @@ pub struct Window { } impl Window { - pub fn open(options: WindowOpenOptions) { + pub fn open(options: WindowOpenOptions) -> WindowHandle { unsafe { let _pool = NSAutoreleasePool::new(nil); @@ -52,6 +52,8 @@ impl Window { let current_app = NSRunningApplication::currentApplication(nil); current_app.activateWithOptions_(NSApplicationActivateIgnoringOtherApps); app.run(); + + WindowHandle } } } @@ -65,3 +67,5 @@ unsafe impl HasRawWindowHandle for Window { }) } } + +pub struct WindowHandle; diff --git a/src/win/window.rs b/src/win/window.rs index bcc53f9..e3b4cfa 100644 --- a/src/win/window.rs +++ b/src/win/window.rs @@ -136,7 +136,7 @@ pub struct Window { } impl Window { - pub fn open(options: WindowOpenOptions) { + pub fn open(options: WindowOpenOptions) -> WindowHandle { unsafe { let title = (options.title.to_owned() + "\0").as_ptr() as *const i8; @@ -213,6 +213,8 @@ impl Window { } } } + + WindowHandle } } @@ -224,3 +226,5 @@ unsafe impl HasRawWindowHandle for Window { }) } } + +pub struct WindowHandle; diff --git a/src/x11/window.rs b/src/x11/window.rs index c5c5a30..2974de6 100644 --- a/src/x11/window.rs +++ b/src/x11/window.rs @@ -13,7 +13,7 @@ pub struct Window { } impl Window { - pub fn open(options: WindowOpenOptions) { + pub fn open(options: WindowOpenOptions) -> WindowHandle { // Convert the parent to a X11 window ID if we're given one let parent = match options.parent { Parent::None => None, @@ -102,6 +102,8 @@ impl Window { let mut handler = H::build(&mut window); run_event_loop(&mut window, &mut handler); + + WindowHandle } } @@ -115,6 +117,8 @@ unsafe impl HasRawWindowHandle for Window { } } +pub struct WindowHandle; + // Event loop fn run_event_loop(window: &mut Window, handler: &mut H) { loop {