winit-sonoma-fix/examples/multiwindow.rs

34 lines
894 B
Rust
Raw Normal View History

2016-03-26 18:07:52 +01:00
extern crate winit;
use std::collections::HashMap;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let mut windows = HashMap::new();
for _ in 0..3 {
let window = winit::Window::new(&events_loop).unwrap();
windows.insert(window.id(), window);
}
2014-12-23 17:12:29 +01:00
2017-01-28 15:45:01 +01:00
events_loop.run_forever(|event| {
2015-06-16 13:48:08 +02:00
match event {
winit::Event::WindowEvent {
event: winit::WindowEvent::CloseRequested,
window_id,
} => {
println!("Window {:?} has received the signal to close", window_id);
// This drops the window, causing it to close.
windows.remove(&window_id);
2017-01-28 15:45:01 +01:00
if windows.is_empty() {
return winit::ControlFlow::Break;
2017-01-28 15:45:01 +01:00
}
}
2017-01-28 15:45:01 +01:00
_ => (),
2015-06-16 13:48:08 +02:00
}
winit::ControlFlow::Continue
2017-01-28 15:45:01 +01:00
})
}