mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-26 07:11:31 +11:00
7b23d190b1
* Fix old `use` declarations * Fix hidden lifetime parameter * Fix missing methods in `web::Monitor`. Originally fixed by @ryanisaacg in 94387c4bf5bca35f4e24562ce89a4f4badd53aa8. * Disable some tests and examples on `wasm32`
44 lines
1.1 KiB
Rust
44 lines
1.1 KiB
Rust
#[cfg(not(target_arch = "wasm32"))]
|
|
fn main() {
|
|
use winit::{
|
|
event::{Event, WindowEvent},
|
|
event_loop::{ControlFlow, EventLoop},
|
|
window::WindowBuilder,
|
|
};
|
|
|
|
let event_loop: EventLoop<i32> = EventLoop::new_user_event();
|
|
|
|
let _window = WindowBuilder::new()
|
|
.with_title("A fantastic window!")
|
|
.build(&event_loop)
|
|
.unwrap();
|
|
|
|
let proxy = event_loop.create_proxy();
|
|
|
|
std::thread::spawn(move || {
|
|
let mut counter = 0;
|
|
// Wake up the `event_loop` once every second.
|
|
loop {
|
|
std::thread::sleep(std::time::Duration::from_secs(1));
|
|
proxy.send_event(counter).unwrap();
|
|
counter += 1;
|
|
}
|
|
});
|
|
|
|
event_loop.run(move |event, _, control_flow| {
|
|
println!("{:?}", event);
|
|
match event {
|
|
Event::WindowEvent {
|
|
event: WindowEvent::CloseRequested,
|
|
..
|
|
} => *control_flow = ControlFlow::Exit,
|
|
_ => *control_flow = ControlFlow::Wait,
|
|
}
|
|
});
|
|
}
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
fn main() {
|
|
panic!("Example not supported on Wasm");
|
|
}
|