From 9b08329319db71bc8a46294caa91d37497cd3ba8 Mon Sep 17 00:00:00 2001 From: msiglreith Date: Mon, 3 Jan 2022 14:58:04 +0100 Subject: [PATCH 1/2] example: only redraw when requested by the event loop. Fixes hangs in case of non-Mailbox present modes. --- examples/src/lib.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/src/lib.rs b/examples/src/lib.rs index ab087e949..5222f8603 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -185,23 +185,23 @@ impl ExampleBase { .borrow_mut() .run_return(|event, _, control_flow| { *control_flow = ControlFlow::Wait; - f(); - if let Event::WindowEvent { - event: - WindowEvent::CloseRequested - | WindowEvent::KeyboardInput { - input: - KeyboardInput { - state: ElementState::Pressed, - virtual_keycode: Some(VirtualKeyCode::Escape), - .. - }, - .. - }, - .. - } = event - { - *control_flow = ControlFlow::Exit + match event { + Event::WindowEvent { + event: + WindowEvent::CloseRequested + | WindowEvent::KeyboardInput { + input: + KeyboardInput { + state: ElementState::Pressed, + virtual_keycode: Some(VirtualKeyCode::Escape), + .. + }, + .. + }, + .. + } => *control_flow = ControlFlow::Exit, + Event::RedrawRequested(_) => f(), + _ => (), } }); } From 70b15478bd07885868645e566674f05dbdc28a33 Mon Sep 17 00:00:00 2001 From: msiglreith Date: Mon, 3 Jan 2022 22:30:04 +0100 Subject: [PATCH 2/2] example: switch to continuous redrawing using Poll and MainEventsCleared --- examples/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 5222f8603..e88da2b3c 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -184,7 +184,7 @@ impl ExampleBase { self.event_loop .borrow_mut() .run_return(|event, _, control_flow| { - *control_flow = ControlFlow::Wait; + *control_flow = ControlFlow::Poll; match event { Event::WindowEvent { event: @@ -200,7 +200,7 @@ impl ExampleBase { }, .. } => *control_flow = ControlFlow::Exit, - Event::RedrawRequested(_) => f(), + Event::MainEventsCleared => f(), _ => (), } });