Fix invisible window creation on Windows (#18105)
# Objective Fixes #18027 ## Solution Run `redraw_requested` logic in `about_to_wait` on Windows during initial application startup and when in headless mode ## Testing - Ran `cargo run --example window_settings` to demonstrate invisible window creation worked again and fixes #18027 - Ran `cargo run --example eased_motion` to demonstrate no regression with the fix for #17488 Ran all additional `window` examples. Notes: - The `transparent_window` was not transparent but this appears to have been broken prior to #18004. See: #7544
This commit is contained in:
parent
57143a8298
commit
ef9b898c2d
@ -435,8 +435,12 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
|
||||
// https://github.com/bevyengine/bevy/issues/17488
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
self.redraw_requested = true;
|
||||
self.redraw_requested(_event_loop);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
@ -480,6 +484,21 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
|
||||
// The monitor sync logic likely belongs in monitor event handlers and not here.
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
self.redraw_requested(event_loop);
|
||||
|
||||
// Have the startup behavior run in about_to_wait, which prevents issues with
|
||||
// invisible window creation. https://github.com/bevyengine/bevy/issues/18027
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
let winit_windows = self.world().non_send_resource::<WinitWindows>();
|
||||
let headless = winit_windows.windows.is_empty();
|
||||
let all_invisible = winit_windows
|
||||
.windows
|
||||
.iter()
|
||||
.all(|(_, w)| !w.is_visible().unwrap_or(false));
|
||||
if self.startup_forced_updates > 0 || headless || all_invisible {
|
||||
self.redraw_requested(event_loop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn suspended(&mut self, _event_loop: &ActiveEventLoop) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user