Fixes missed RequestRedraw events in about_to_wait()

This fixes RequestRedraw events that can be missed in `about_to_wait()` which was reading from the cursor before `run_app_update()` is called.

This adds a subsequent read to update the redraw_requested flag if any `RequestRedraw` were sent.

Was reported in #16817
This commit is contained in:
Matt Thompson 2025-02-22 16:39:17 -08:00
parent ad3817cc1b
commit f47729ed48

View File

@ -583,6 +583,15 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
#[cfg(not(feature = "custom_cursor"))]
self.update_cursors();
self.ran_update_since_last_redraw = true;
// Read RequestRedraw events that may have been sent during the update
if let Some(app_redraw_events) =
self.world().get_resource::<Events<RequestRedraw>>()
{
if redraw_event_reader.read(app_redraw_events).last().is_some() {
self.redraw_requested = true;
}
}
} else {
self.redraw_requested = true;
}