layout: Find preset width for new columns

Fixes first Mod+R doing nothing on windows like non-tiled foot.
This commit is contained in:
Ivan Molodetskikh
2025-10-31 08:34:24 +03:00
parent 94eeecac8c
commit e257687921
+17 -1
View File
@@ -3934,12 +3934,28 @@ impl<W: LayoutElement> Column<W> {
.default_column_display
.unwrap_or(options.layout.default_column_display);
// Try to match width to a preset width. Consider the following case: a terminal (foot)
// sizes itself to the terminal grid. We open it with default-column-width 0.5. It shrinks
// by a few pixels to evenly match the terminal grid. Then we press
// switch-preset-column-width intending to go to proportion 0.667, but the preset width
// matching code picks the proportion 0.5 preset because it's the next smallest width after
// the current foot's window width. Effectively, this makes the first
// switch-preset-column-width press ignored.
//
// However, here, we do know that width = proportion 0.5 (regardless of what the window
// opened with), and we can match it to a preset right away, if one exists.
let preset_width_idx = options
.layout
.preset_column_widths
.iter()
.position(|preset| width == ColumnWidth::from(*preset));
let mut rv = Self {
tiles: vec![],
data: vec![],
active_tile_idx: 0,
width,
preset_width_idx: None,
preset_width_idx,
is_full_width,
is_pending_maximized: false,
is_pending_fullscreen: false,