@@ -58,6 +58,8 @@ struct WinitAppRunnerState<T: Event> {
5858 user_event_received : bool ,
5959 /// Is `true` if the app has requested a redraw since the last update.
6060 redraw_requested : bool ,
61+ /// Is `true` if the app has already updated since the last redraw.
62+ ran_update_since_last_redraw : bool ,
6163 /// Is `true` if enough time has elapsed since `last_update` to run another update.
6264 wait_elapsed : bool ,
6365 /// Number of "forced" updates to trigger on application start
@@ -104,6 +106,7 @@ impl<T: Event> WinitAppRunnerState<T> {
104106 device_event_received : false ,
105107 user_event_received : false ,
106108 redraw_requested : false ,
109+ ran_update_since_last_redraw : false ,
107110 wait_elapsed : false ,
108111 // 3 seems to be enough, 5 is a safe margin
109112 startup_forced_updates : 5 ,
@@ -369,6 +372,9 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
369372 WindowEvent :: Destroyed => {
370373 self . winit_events . send ( WindowDestroyed { window } ) ;
371374 }
375+ WindowEvent :: RedrawRequested => {
376+ self . ran_update_since_last_redraw = false ;
377+ }
372378 _ => { }
373379 }
374380
@@ -499,7 +505,12 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
499505
500506 if should_update {
501507 // Not redrawing, but the timeout elapsed.
502- self . run_app_update ( ) ;
508+ if !self . ran_update_since_last_redraw {
509+ self . run_app_update ( ) ;
510+ self . ran_update_since_last_redraw = true ;
511+ } else {
512+ self . redraw_requested = true ;
513+ }
503514
504515 // Running the app may have changed the WinitSettings resource, so we have to re-extract it.
505516 let ( config, windows) = focused_windows_state. get ( self . world ( ) ) ;
0 commit comments