1
0
Fork 0
forked from wry/wry

rect: safer construction

This commit is contained in:
Stipe Kotarac 2025-12-29 10:42:17 +01:00 committed by Julian Orth
parent 411af0ea18
commit a1dfc473a2
33 changed files with 245 additions and 159 deletions

View file

@ -47,7 +47,9 @@ impl WlRegionRequestHandler for WlRegion {
return Err(WlRegionError::NegativeExtents);
}
let mut region = self.region.borrow_mut();
region.add(Rect::new_sized(req.x, req.y, req.width, req.height).unwrap());
region.add(Rect::new_sized_saturating(
req.x, req.y, req.width, req.height,
));
Ok(())
}
@ -56,7 +58,9 @@ impl WlRegionRequestHandler for WlRegion {
return Err(WlRegionError::NegativeExtents);
}
let mut region = self.region.borrow_mut();
region.sub(Rect::new_sized(req.x, req.y, req.width, req.height).unwrap());
region.sub(Rect::new_sized_saturating(
req.x, req.y, req.width, req.height,
));
Ok(())
}
}