example: Refactor event loop handling for continuous redraw (#542)
Switch to continuous redrawing using `Poll` and `MainEventsCleared`. Fixes hangs in case of non-Mailbox present modes.
This commit is contained in:
parent
8f05905ecb
commit
adf0338ed8
|
@ -184,9 +184,9 @@ impl ExampleBase {
|
|||
self.event_loop
|
||||
.borrow_mut()
|
||||
.run_return(|event, _, control_flow| {
|
||||
*control_flow = ControlFlow::Wait;
|
||||
f();
|
||||
if let Event::WindowEvent {
|
||||
*control_flow = ControlFlow::Poll;
|
||||
match event {
|
||||
Event::WindowEvent {
|
||||
event:
|
||||
WindowEvent::CloseRequested
|
||||
| WindowEvent::KeyboardInput {
|
||||
|
@ -199,9 +199,9 @@ impl ExampleBase {
|
|||
..
|
||||
},
|
||||
..
|
||||
} = event
|
||||
{
|
||||
*control_flow = ControlFlow::Exit
|
||||
} => *control_flow = ControlFlow::Exit,
|
||||
Event::MainEventsCleared => f(),
|
||||
_ => (),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue