Skip to content

Commit 4f19374

Browse files
committed
Reorder request_redraw checks so that the update_mode logic is localized
1 parent e16dada commit 4f19374

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

crates/bevy_winit/src/state.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,12 @@ impl<T: Event> WinitAppRunnerState<T> {
650650
self.redraw_requested = true;
651651
}
652652

653-
// Running the app may have changed the WinitSettings resource, so we have to re-extract it.
654-
let (config, windows) = focused_windows_state.get(self.world());
655-
let focused = windows.iter().any(|(_, window)| window.focused);
656-
update_mode = config.update_mode(focused);
653+
// Read RequestRedraw events that may have been sent during the update
654+
if let Some(app_redraw_events) = self.world().get_resource::<Events<RequestRedraw>>() {
655+
if redraw_event_reader.read(app_redraw_events).last().is_some() {
656+
self.redraw_requested = true;
657+
}
658+
}
657659

658660
// Running the app may have produced WindowCloseRequested events that should be processed
659661
if let Some(close_request_events) =
@@ -668,12 +670,10 @@ impl<T: Event> WinitAppRunnerState<T> {
668670
}
669671
}
670672

671-
// Read RequestRedraw events that may have been sent during the update
672-
if let Some(app_redraw_events) = self.world().get_resource::<Events<RequestRedraw>>() {
673-
if redraw_event_reader.read(app_redraw_events).last().is_some() {
674-
self.redraw_requested = true;
675-
}
676-
}
673+
// Running the app may have changed the WinitSettings resource, so we have to re-extract it.
674+
let (config, windows) = focused_windows_state.get(self.world());
675+
let focused = windows.iter().any(|(_, window)| window.focused);
676+
update_mode = config.update_mode(focused);
677677
}
678678

679679
// The update mode could have been changed, so we need to redraw and force an update

0 commit comments

Comments
 (0)