diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-12-28 18:53:08 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-12-28 18:53:08 +0400 |
| commit | 097c415036ed63c0736a6434ab9be25fbac042e1 (patch) | |
| tree | 57b4d3b6bdc7c70f82c77455e75480f0c810a6a7 /src/layout/tile.rs | |
| parent | 2d16c04869a545f3aa649947f151c158a13c3a3a (diff) | |
| download | niri-097c415036ed63c0736a6434ab9be25fbac042e1.tar.gz niri-097c415036ed63c0736a6434ab9be25fbac042e1.tar.bz2 niri-097c415036ed63c0736a6434ab9be25fbac042e1.zip | |
layout: Use saturating_add() in several places
Apparently VSCode sends i32::MAX worth of max_size?
Diffstat (limited to 'src/layout/tile.rs')
| -rw-r--r-- | src/layout/tile.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/layout/tile.rs b/src/layout/tile.rs index 3bc90687..bd684ea0 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -130,7 +130,8 @@ impl<W: LayoutElement> Tile<W> { } if let Some(width) = self.effective_border_width() { - size += (width * 2, width * 2).into(); + size.w = size.w.saturating_add(width * 2); + size.h = size.h.saturating_add(width * 2); } size @@ -172,7 +173,7 @@ impl<W: LayoutElement> Tile<W> { if self.border.is_off() { size } else { - size + self.border.width() * 2 + size.saturating_add(self.border.width() * 2) } } @@ -180,7 +181,7 @@ impl<W: LayoutElement> Tile<W> { if self.border.is_off() { size } else { - size + self.border.width() * 2 + size.saturating_add(self.border.width() * 2) } } @@ -204,7 +205,9 @@ impl<W: LayoutElement> Tile<W> { if let Some(width) = self.effective_border_width() { size.w = max(1, size.w); size.h = max(1, size.h); - size += (width * 2, width * 2).into(); + + size.w = size.w.saturating_add(width * 2); + size.h = size.h.saturating_add(width * 2); } size @@ -215,10 +218,10 @@ impl<W: LayoutElement> Tile<W> { if let Some(width) = self.effective_border_width() { if size.w > 0 { - size.w += width * 2; + size.w = size.w.saturating_add(width * 2); } if size.h > 0 { - size.h += width * 2; + size.h = size.h.saturating_add(width * 2); } } |
