aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-10-31 08:34:24 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-10-31 08:35:58 +0300
commite2576879216a39e5c45b9d2906531bc2065e724c (patch)
treeaed987e420883d19a00ed0e377a3926b79cac3c0 /src
parent94eeecac8c67b2b3f03536bbe4f74b4030afcea8 (diff)
downloadniri-e2576879216a39e5c45b9d2906531bc2065e724c.tar.gz
niri-e2576879216a39e5c45b9d2906531bc2065e724c.tar.bz2
niri-e2576879216a39e5c45b9d2906531bc2065e724c.zip
layout: Find preset width for new columns
Fixes first Mod+R doing nothing on windows like non-tiled foot.
Diffstat (limited to 'src')
-rw-r--r--src/layout/scrolling.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs
index f9e89ca7..6e819ea4 100644
--- a/src/layout/scrolling.rs
+++ b/src/layout/scrolling.rs
@@ -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,