From 50a7852cb857cd110077ffce492bafe9ebe8786c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Dec 2023 08:56:57 +0100 Subject: Stop polling in event loop on `RedrawRequest::NextFrame` --- winit/src/application.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index 75be08f1..5ff76060 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -314,7 +314,6 @@ async fn run_instance( match event { event::Event::NewEvents( event::StartCause::Init - | event::StartCause::Poll | event::StartCause::ResumeTimeReached { .. }, ) if !redraw_pending => { window.request_redraw(); @@ -387,7 +386,11 @@ async fn run_instance( user_interface::State::Updated { redraw_request: Some(redraw_request), } => match redraw_request { - window::RedrawRequest::NextFrame => ControlFlow::Poll, + window::RedrawRequest::NextFrame => { + window.request_redraw(); + + ControlFlow::Wait + } window::RedrawRequest::At(at) => { ControlFlow::WaitUntil(at) } @@ -469,7 +472,7 @@ async fn run_instance( _ => {} } - if !redraw_pending && events.is_empty() && messages.is_empty() { + if events.is_empty() && messages.is_empty() { continue; } -- cgit