Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions crates/bevy_winit/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,13 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
}
WindowEvent::RedrawRequested => {
self.ran_update_since_last_redraw = false;

// https://github.com/bevyengine/bevy/issues/17488
#[cfg(target_os = "windows")]
{
self.redraw_requested = true;
self.redraw_requested(_event_loop);
}
}
_ => {}
}
Expand Down Expand Up @@ -468,6 +475,27 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
create_windows(event_loop, create_window.get_mut(self.world_mut()));
create_window.apply(self.world_mut());

// TODO: This is a workaround for https://github.com/bevyengine/bevy/issues/17488
// while preserving the iOS fix in https://github.com/bevyengine/bevy/pull/11245
// The monitor sync logic likely belongs in monitor event handlers and not here.
#[cfg(not(target_os = "windows"))]
self.redraw_requested(event_loop);
}

fn suspended(&mut self, _event_loop: &ActiveEventLoop) {
// Mark the state as `WillSuspend`. This will let the schedule run one last time
// before actually suspending to let the application react
self.lifecycle = AppLifecycle::WillSuspend;
}

fn exiting(&mut self, _event_loop: &ActiveEventLoop) {
let world = self.world_mut();
world.clear_all();
}
}

impl<T: Event> WinitAppRunnerState<T> {
fn redraw_requested(&mut self, event_loop: &ActiveEventLoop) {
let mut redraw_event_reader = EventCursor::<RequestRedraw>::default();

let mut focused_windows_state: SystemState<(Res<WinitSettings>, Query<(Entity, &Window)>)> =
Expand Down Expand Up @@ -662,19 +690,6 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
}
}

fn suspended(&mut self, _event_loop: &ActiveEventLoop) {
// Mark the state as `WillSuspend`. This will let the schedule run one last time
// before actually suspending to let the application react
self.lifecycle = AppLifecycle::WillSuspend;
}

fn exiting(&mut self, _event_loop: &ActiveEventLoop) {
let world = self.world_mut();
world.clear_all();
}
}

impl<T: Event> WinitAppRunnerState<T> {
fn should_update(&self, update_mode: UpdateMode) -> bool {
let handle_event = match update_mode {
UpdateMode::Continuous => {
Expand Down