mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
Winit update: fix suspend on Android (#11403)
# Objective - Android still plays audio when suspended ## Solution - When status is `WillSuspend`, trigger an update without requesting a redraw
This commit is contained in:
parent
a00c71ee5b
commit
f795656d65
1 changed files with 9 additions and 2 deletions
|
@ -407,11 +407,16 @@ pub fn winit_runner(mut app: App) {
|
||||||
should_update = true;
|
should_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Trigger one last update to enter suspended state
|
||||||
|
if runner_state.active == ActiveState::WillSuspend {
|
||||||
|
should_update = true;
|
||||||
|
}
|
||||||
|
|
||||||
if should_update {
|
if should_update {
|
||||||
let visible = windows.iter().any(|window| window.visible);
|
let visible = windows.iter().any(|window| window.visible);
|
||||||
let (_, winit_windows, _, _) =
|
let (_, winit_windows, _, _) =
|
||||||
event_writer_system_state.get_mut(&mut app.world);
|
event_writer_system_state.get_mut(&mut app.world);
|
||||||
if visible {
|
if visible && runner_state.active != ActiveState::WillSuspend {
|
||||||
for window in winit_windows.windows.values() {
|
for window in winit_windows.windows.values() {
|
||||||
window.request_redraw();
|
window.request_redraw();
|
||||||
}
|
}
|
||||||
|
@ -427,10 +432,12 @@ pub fn winit_runner(mut app: App) {
|
||||||
&mut app_exit_event_reader,
|
&mut app_exit_event_reader,
|
||||||
&mut redraw_event_reader,
|
&mut redraw_event_reader,
|
||||||
);
|
);
|
||||||
|
if runner_state.active != ActiveState::Suspended {
|
||||||
event_loop.set_control_flow(ControlFlow::Poll);
|
event_loop.set_control_flow(ControlFlow::Poll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Event::NewEvents(_) => {
|
Event::NewEvents(_) => {
|
||||||
if let Some(t) = runner_state.scheduled_update {
|
if let Some(t) = runner_state.scheduled_update {
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
|
|
Loading…
Reference in a new issue