aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-08-15 11:46:13 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-08-15 11:46:13 +0300
commitdfc2d452c55d59d6d9014c98a9da3a082c4f7379 (patch)
tree7b1d28ec421668c0d19e470ecc49957c47dc3f1f
parent66f23c39809eef827ef7f47fab7bdbf68dd69a26 (diff)
downloadniri-dfc2d452c55d59d6d9014c98a9da3a082c4f7379.tar.gz
niri-dfc2d452c55d59d6d9014c98a9da3a082c4f7379.tar.bz2
niri-dfc2d452c55d59d6d9014c98a9da3a082c4f7379.zip
layout: Do not recompute total_weight every iteration
-rw-r--r--src/layout/workspace.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index f4f3917a..85ba7b46 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -3074,6 +3074,17 @@ impl<W: LayoutElement> Column<W> {
}
}
+ let mut total_weight: f64 = heights
+ .iter()
+ .filter_map(|h| {
+ if let WindowHeight::Auto { weight } = *h {
+ Some(weight)
+ } else {
+ None
+ }
+ })
+ .sum();
+
// Iteratively try to distribute the remaining height, checking against tile min heights.
// Pick an auto height according to the current sizes, then check if it satisfies all
// remaining min heights. If not, allocate fixed height to those tiles and repeat the
@@ -3086,17 +3097,6 @@ impl<W: LayoutElement> Column<W> {
// However, most max height uses are for fixed-size dialogs, where min height == max_height.
// This case is separately handled above.
while auto_tiles_left > 0 {
- let mut total_weight: f64 = heights
- .iter()
- .filter_map(|h| {
- if let WindowHeight::Auto { weight } = *h {
- Some(weight)
- } else {
- None
- }
- })
- .sum();
-
// Wayland requires us to round the requested size for a window to integer logical
// pixels, therefore we compute the remaining auto height dynamically.
let mut height_left_2 = height_left;
@@ -3120,6 +3120,7 @@ impl<W: LayoutElement> Column<W> {
auto = min_size.h;
*h = WindowHeight::Fixed(auto);
height_left -= auto;
+ total_weight -= weight;
auto_tiles_left -= 1;
unsatisfied_min = true;
}