diff options
-rw-r--r-- | src/events.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/events.rs b/src/events.rs index 78ef20a..733f1c5 100644 --- a/src/events.rs +++ b/src/events.rs @@ -4,6 +4,7 @@ use winit::dpi::PhysicalSize; use winit::event::ElementState; use winit::keyboard::KeyCode; +use std::cmp::max; use std::path::PathBuf; @@ -95,12 +96,12 @@ pub struct SizeBounds { impl SizeBounds { pub fn as_min_max_size(&self, scale: u32) -> (PhysicalSize<u32>, PhysicalSize<u32>) { let min_size = PhysicalSize { - width: std::cmp::max(1, self.min_width.unwrap_or(0)).saturating_mul(scale), - height: std::cmp::max(1, self.min_height.unwrap_or(0)).saturating_mul(scale), + width: max(8, self.min_width.unwrap_or(0)).saturating_mul(scale), + height: max(8, self.min_height.unwrap_or(0)).saturating_mul(scale), }; let max_size = PhysicalSize { - width: self.max_width.unwrap_or(u32::MAX).saturating_mul(scale), - height: self.max_height.unwrap_or(u32::MAX).saturating_mul(scale), + width: max(8, self.max_width.unwrap_or(u16::MAX as u32)).saturating_mul(scale), + height: max(8, self.max_height.unwrap_or(u16::MAX as u32)).saturating_mul(scale), }; return (min_size, max_size); } |