Skip to content

Commit

Permalink
fix: Ignore window resized to (0, 0) events when minimizing window …
Browse files Browse the repository at this point in the history
…on Windows OS
  • Loading branch information
ShoyuVanilla committed Oct 4, 2024
1 parent e72b962 commit 8c50e16
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions crates/bevy_winit/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,25 @@ impl<T: Event> ApplicationHandler<T> for WinitAppRunnerState<T> {
return;
};

// winit sends `WindowEvent::Resized(0)` when minimizing the window on Windows OS,
// but not on the other OSs (See https://github.com/rust-windowing/winit/issues/2015)
// So, ignore those events on Windows to avoid screen aspects calculations panicking
#[cfg(target_os = "windows")]
if matches!(
event,
WindowEvent::Resized(PhysicalSize {
width: 0,
height: 0
})
) {
if let Some(winit_window) = winit_windows.get_window(window) {
if winit_window.is_minimized().unwrap_or(false) {
self.window_event_received = false;
return;
}
}
}

// Allow AccessKit to respond to `WindowEvent`s before they reach
// the engine.
if let Some(adapter) = access_kit_adapters.get_mut(&window) {
Expand Down

0 comments on commit 8c50e16

Please sign in to comment.