mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-26 22:53:15 -04:00
34 lines
893 B
Rust
34 lines
893 B
Rust
extern crate winit;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
fn main() {
|
|
let mut events_loop = winit::EventLoop::new();
|
|
|
|
let mut windows = HashMap::new();
|
|
for _ in 0..3 {
|
|
let window = winit::Window::new(&events_loop).unwrap();
|
|
windows.insert(window.id(), window);
|
|
}
|
|
|
|
events_loop.run_forever(|event| {
|
|
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);
|
|
|
|
if windows.is_empty() {
|
|
return winit::ControlFlow::Break;
|
|
}
|
|
}
|
|
_ => (),
|
|
}
|
|
winit::ControlFlow::Continue
|
|
})
|
|
}
|