winit-sonoma-fix/examples/multiwindow.rs
Victor Berger 61d25be3e0
wayland: upgrade wayland-window (#339)
* wayland: upgrade wayland-window

This new version of wayland window considerably simplifies the
window handling for winit, meaning much of the previous juggling
is no longer needed, and the windows will appear even if nothing is
drawn.

* wayland: cleanup unused stuff
2017-11-03 17:35:29 +01:00

35 lines
1.1 KiB
Rust

extern crate winit;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let window1 = winit::Window::new(&events_loop).unwrap();
let window2 = winit::Window::new(&events_loop).unwrap();
let window3 = winit::Window::new(&events_loop).unwrap();
let mut num_windows = 3;
events_loop.run_forever(|event| {
match event {
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, window_id } => {
if window_id == window1.id() {
println!("Window 1 has been closed")
} else if window_id == window2.id() {
println!("Window 2 has been closed")
} else if window_id == window3.id() {
println!("Window 3 has been closed");
} else {
unreachable!()
}
num_windows -= 1;
if num_windows == 0 {
return winit::ControlFlow::Break;
}
},
_ => (),
}
winit::ControlFlow::Continue
})
}