mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 22:31:30 +11:00
0c151f9fb3
* Implement changes to `RedrawRequested` event Implements the changes described in #1041 for the X11 platform and for platform-independent public-facing code. * Fix `request_redraw` example * Fix examples in lib docs * Only issue `RedrawRequested` on final `Expose` event
33 lines
838 B
Rust
33 lines
838 B
Rust
use instant::Instant;
|
|
use std::time::Duration;
|
|
|
|
use winit::{
|
|
event::{Event, WindowEvent},
|
|
event_loop::{ControlFlow, EventLoop},
|
|
window::WindowBuilder,
|
|
};
|
|
|
|
fn main() {
|
|
let event_loop = EventLoop::new();
|
|
|
|
let window = WindowBuilder::new()
|
|
.with_title("A fantastic window!")
|
|
.build(&event_loop)
|
|
.unwrap();
|
|
|
|
event_loop.run(move |event, _, control_flow| match event {
|
|
Event::WindowEvent {
|
|
event: WindowEvent::CloseRequested,
|
|
..
|
|
} => *control_flow = ControlFlow::Exit,
|
|
Event::MainEventsCleared => {
|
|
window.request_redraw();
|
|
*control_flow = ControlFlow::WaitUntil(Instant::now() + Duration::new(1, 0))
|
|
}
|
|
Event::RedrawRequested(_) => {
|
|
println!("{:?}", event);
|
|
}
|
|
_ => (),
|
|
});
|
|
}
|