Fix UpdateMode::Reactive behavior on Windows (#18493)

# Objective

The fix in #17488 forced Windows to always behave as if it were in
`UpdateMode::Continuous`.

CC https://github.com/bevyengine/bevy/pull/17991

## Solution

Removed the unconditional `redraw_requested = true` and added a check
for `Reactive` in `about_to_wait`.

## Testing

- Verified that the `low_power` example worked as expected with all
`UpdateMode` options.
- Verified that animation continued in both `eased_motion ` and
`low_power` examples when in `Continuous` update mode while:
  - Resizing the Window
  - Moving the window via clicking and dragging the title bar
- Verified that `window_settings` example still worked as expected.
- Verified that `monitor_info` example still worked as expected.
This commit is contained in:
aloucks 2025-03-25 16:29:50 -04:00 committed by François Mockers
parent b1c1aac1b3
commit 8dc1a7cd81

View File

@ -456,7 +456,6 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
// Have the startup behavior run in about_to_wait, which prevents issues with
// invisible window creation. https://github.com/bevyengine/bevy/issues/18027
if self.startup_forced_updates == 0 {
self.redraw_requested = true;
self.redraw_requested(_event_loop);
}
}
@ -510,11 +509,14 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
let winit_windows = self.world().non_send_resource::<WinitWindows>();
let headless = winit_windows.windows.is_empty();
let exiting = self.app_exit.is_some();
let reactive = matches!(self.update_mode, UpdateMode::Reactive { .. });
let all_invisible = winit_windows
.windows
.iter()
.all(|(_, w)| !w.is_visible().unwrap_or(false));
if !exiting && (self.startup_forced_updates > 0 || headless || all_invisible) {
if !exiting
&& (self.startup_forced_updates > 0 || headless || all_invisible || reactive)
{
self.redraw_requested(event_loop);
}
}