Fix crash on windows when window is minimized

This commit is contained in:
2024-11-10 15:03:07 -05:00
parent 5cb36d0bcc
commit 6dc3697baf
3 changed files with 30 additions and 6 deletions
+10 -3
View File
@@ -58,6 +58,7 @@ pub struct WindowState {
pub surface_desc: wgpu::SurfaceConfiguration,
pub surface: wgpu::Surface<'static>,
pub hidpi_factor: f64,
pub minimized: bool,
}
impl WindowState {
@@ -105,6 +106,7 @@ impl WindowState {
surface_desc,
surface,
hidpi_factor,
minimized: false,
}
}
@@ -114,9 +116,14 @@ impl WindowState {
}
pub fn handle_resize(&mut self, size: &PhysicalSize<u32>) {
self.surface_desc.width = size.width;
self.surface_desc.height = size.height;
self.surface.configure(&self.device, &self.surface_desc);
if size.width > 0 && size.height > 0 {
self.minimized = false;
self.surface_desc.width = size.width;
self.surface_desc.height = size.height;
self.surface.configure(&self.device, &self.surface_desc);
} else {
self.minimized = true;
}
}
}