summaryrefslogtreecommitdiff
path: root/src/window.rs
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2023-12-19 21:16:15 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2023-12-19 21:17:35 +1300
commit8ad5f17d122cdd9c7ba0bb23ae6035e73ecd01de (patch)
tree6d509ee7c0c186085b7859ba697ceaf05a5b091a /src/window.rs
parent11c29a04f33c5611de6ec79c2e8452bece1bb952 (diff)
downloadphosphor-8ad5f17d122cdd9c7ba0bb23ae6035e73ecd01de.zip
Prevent crash when window dimension resizes to zero
If an application attempted to change either of the window dimensions to zero, the surface would resize to the new dimensions and cause the window definition in the display server to enter an invalid state, causing the display server to crash the application. This change ensures that the window dimensions are always greater than zero.
Diffstat (limited to 'src/window.rs')
-rw-r--r--src/window.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/window.rs b/src/window.rs
index a7932de..c9bdbcf 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -202,7 +202,10 @@ impl Window {
}
fn dim_to_size(dimensions: Dimensions) -> Size {
- Size::Physical( PhysicalSize { width:dimensions.width, height:dimensions.height })
+ Size::Physical( PhysicalSize {
+ width: std::cmp::max(1, dimensions.width),
+ height: std::cmp::max(1, dimensions.height),
+ })
}
fn dim_to_nonzero_size(dimensions: Dimensions) -> Option<(NonZeroU32, NonZeroU32)> {