Fix crash on windows when window is minimized
This commit is contained in:
+10
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user