Window::open() returns WindowHandle struct
This commit is contained in:
parent
601a5d62a4
commit
5ecce5d28d
|
@ -8,7 +8,7 @@ fn main() {
|
|||
parent: baseview::Parent::None,
|
||||
};
|
||||
|
||||
Window::open::<MyProgram>(window_open_options);
|
||||
let _handle = Window::open::<MyProgram>(window_open_options);
|
||||
}
|
||||
|
||||
struct MyProgram {}
|
||||
|
|
|
@ -18,7 +18,7 @@ pub struct Window {
|
|||
}
|
||||
|
||||
impl Window {
|
||||
pub fn open<H: WindowHandler>(options: WindowOpenOptions) {
|
||||
pub fn open<H: WindowHandler>(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;
|
||||
|
|
|
@ -136,7 +136,7 @@ pub struct Window {
|
|||
}
|
||||
|
||||
impl Window {
|
||||
pub fn open<H: WindowHandler>(options: WindowOpenOptions) {
|
||||
pub fn open<H: WindowHandler>(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;
|
||||
|
|
|
@ -13,7 +13,7 @@ pub struct Window {
|
|||
}
|
||||
|
||||
impl Window {
|
||||
pub fn open<H: WindowHandler>(options: WindowOpenOptions) {
|
||||
pub fn open<H: WindowHandler>(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<H: WindowHandler>(window: &mut Window, handler: &mut H) {
|
||||
loop {
|
||||
|
|
Loading…
Reference in a new issue