x11: WindowHandle.app_run_blocking()
This commit is contained in:
parent
5207d961d9
commit
196883b390
|
@ -1,16 +1,5 @@
|
|||
use baseview::{Event, Window, WindowHandler};
|
||||
|
||||
fn main() {
|
||||
let window_open_options = baseview::WindowOpenOptions {
|
||||
title: "baseview".into(),
|
||||
width: 512,
|
||||
height: 512,
|
||||
parent: baseview::Parent::None,
|
||||
};
|
||||
|
||||
let _handle = Window::open::<MyProgram>(window_open_options);
|
||||
}
|
||||
|
||||
struct MyProgram {}
|
||||
|
||||
impl WindowHandler for MyProgram {
|
||||
|
@ -33,3 +22,15 @@ impl WindowHandler for MyProgram {
|
|||
|
||||
fn on_message(&mut self, _window: &mut Window, _message: Self::Message) {}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let window_open_options = baseview::WindowOpenOptions {
|
||||
title: "baseview".into(),
|
||||
width: 512,
|
||||
height: 512,
|
||||
parent: baseview::Parent::None,
|
||||
};
|
||||
|
||||
let handle = Window::open::<MyProgram>(window_open_options);
|
||||
handle.app_run_blocking();
|
||||
}
|
||||
|
|
|
@ -21,18 +21,24 @@ pub struct Window {
|
|||
}
|
||||
|
||||
// FIXME: move to outer crate context
|
||||
pub struct WindowHandle;
|
||||
pub struct WindowHandle {
|
||||
thread: std::thread::JoinHandle<()>
|
||||
}
|
||||
|
||||
impl WindowHandle {
|
||||
pub fn app_run_blocking(self) {
|
||||
let _ = self.thread.join();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Window {
|
||||
pub fn open<H: WindowHandler>(options: WindowOpenOptions) -> WindowHandle {
|
||||
let runner = thread::spawn(move || {
|
||||
Self::window_thread::<H>(options);
|
||||
});
|
||||
|
||||
let _ = runner.join();
|
||||
|
||||
WindowHandle
|
||||
WindowHandle {
|
||||
thread: thread::spawn(move || {
|
||||
Self::window_thread::<H>(options);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn window_thread<H: WindowHandler>(options: WindowOpenOptions) {
|
||||
|
|
Loading…
Reference in a new issue