diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-08-15 11:46:13 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-08-15 11:46:13 +0300 |
| commit | dfc2d452c55d59d6d9014c98a9da3a082c4f7379 (patch) | |
| tree | 7b1d28ec421668c0d19e470ecc49957c47dc3f1f /src | |
| parent | 66f23c39809eef827ef7f47fab7bdbf68dd69a26 (diff) | |
| download | niri-dfc2d452c55d59d6d9014c98a9da3a082c4f7379.tar.gz niri-dfc2d452c55d59d6d9014c98a9da3a082c4f7379.tar.bz2 niri-dfc2d452c55d59d6d9014c98a9da3a082c4f7379.zip | |
layout: Do not recompute total_weight every iteration
Diffstat (limited to 'src')
| -rw-r--r-- | src/layout/workspace.rs | 23 |
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; } |
