From f47729ed48512e2a4416daabe79502e49a22a383 Mon Sep 17 00:00:00 2001 From: Matt Thompson Date: Sat, 22 Feb 2025 16:39:17 -0800 Subject: [PATCH] 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 --- crates/bevy_winit/src/state.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/bevy_winit/src/state.rs b/crates/bevy_winit/src/state.rs index 0c1a02e0ce..dc27ee8dda 100644 --- a/crates/bevy_winit/src/state.rs +++ b/crates/bevy_winit/src/state.rs @@ -583,6 +583,15 @@ impl ApplicationHandler for WinitAppRunnerState { #[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::>() + { + if redraw_event_reader.read(app_redraw_events).last().is_some() { + self.redraw_requested = true; + } + } } else { self.redraw_requested = true; }