layout: Break out early on min size
Browse files at this commitf86a9bed1a821f8c818c9085f7fdd021020dfd56Parent: cfa87d51 changed file +15 -14
- src/layout/workspace.rs +15 -14
src/layout/workspace.rsmodified+15 -14
| @@ -3168,12 +3168,11 @@ impl<W: LayoutElement> Column<W> { | |||
| 3168 | // | 3168 | // |
| 3169 | // However, most max height uses are for fixed-size dialogs, where min height == max_height. | 3169 | // However, most max height uses are for fixed-size dialogs, where min height == max_height. |
| 3170 | // This case is separately handled above. | 3170 | // This case is separately handled above. |
| 3171 | - while auto_tiles_left > 0 { | 3171 | + 'outer: while auto_tiles_left > 0 { |
| 3172 | // Wayland requires us to round the requested size for a window to integer logical | 3172 | // Wayland requires us to round the requested size for a window to integer logical |
| 3173 | // pixels, therefore we compute the remaining auto height dynamically. | 3173 | // pixels, therefore we compute the remaining auto height dynamically. |
| 3174 | let mut height_left_2 = height_left; | 3174 | let mut height_left_2 = height_left; |
| 3175 | let mut total_weight_2 = total_weight; | 3175 | let mut total_weight_2 = total_weight; |
| 3176 | - let mut unsatisfied_min = false; | ||
| 3177 | for ((h, tile), min_size) in zip(zip(&mut heights, &self.tiles), &min_size) { | 3176 | for ((h, tile), min_size) in zip(zip(&mut heights, &self.tiles), &min_size) { |
| 3178 | let weight = match *h { | 3177 | let weight = match *h { |
| 3179 | WindowHeight::Auto { weight } => weight, | 3178 | WindowHeight::Auto { weight } => weight, |
| @@ -3191,24 +3190,26 @@ impl<W: LayoutElement> Column<W> { | |||
| 3191 | height_left -= auto; | 3190 | height_left -= auto; |
| 3192 | total_weight -= weight; | 3191 | total_weight -= weight; |
| 3193 | auto_tiles_left -= 1; | 3192 | auto_tiles_left -= 1; |
| 3194 | - unsatisfied_min = true; | 3193 | + |
| 3195 | - } else { | 3194 | + // If a min height was unsatisfied, then we allocate the tile more than the |
| 3196 | - auto = tile.tile_height_for_window_height( | 3195 | + // auto height, which means that the remaining auto tiles now have less height |
| 3197 | - tile.window_height_for_tile_height(auto).round().max(1.), | 3196 | + // to work with, and the loop must run again. |
| 3198 | - ); | 3197 | + // |
| 3198 | + // If we keep going in this loop and break out later, we may allocate less | ||
| 3199 | + // height to the subsequent tiles than would be available next iteration and | ||
| 3200 | + // potentially trip their min height check earlier than necessary, leading to | ||
| 3201 | + // visible snapping. | ||
| 3202 | + continue 'outer; | ||
| 3199 | } | 3203 | } |
| 3200 | 3204 | ||
| 3205 | + auto = tile.tile_height_for_window_height( | ||
| 3206 | + tile.window_height_for_tile_height(auto).round().max(1.), | ||
| 3207 | + ); | ||
| 3208 | + | ||
| 3201 | height_left_2 -= auto; | 3209 | height_left_2 -= auto; |
| 3202 | total_weight_2 -= weight; | 3210 | total_weight_2 -= weight; |
| 3203 | } | 3211 | } |
| 3204 | 3212 | ||
| 3205 | - // If some min height was unsatisfied, then we allocated the tile more than the auto | ||
| 3206 | - // height, which means that the remaining auto tiles now have less height to work | ||
| 3207 | - // with, and the loop must run again. | ||
| 3208 | - if unsatisfied_min { | ||
| 3209 | - continue; | ||
| 3210 | - } | ||
| 3211 | - | ||
| 3212 | // All min heights were satisfied, fill them in. | 3213 | // All min heights were satisfied, fill them in. |
| 3213 | for (h, tile) in zip(&mut heights, &self.tiles) { | 3214 | for (h, tile) in zip(&mut heights, &self.tiles) { |
| 3214 | let weight = match *h { | 3215 | let weight = match *h { |