aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-10-04 09:00:23 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-10-15 09:04:16 +0300
commit536204fd82a37dfd2d7c0c7b5ce457197e7b4fec (patch)
treeaf4ab621d56160ad58e39b1c0401a5cfcadd7a45
parente1fad994da9565b43c7fb139cb2fb7bf404cc320 (diff)
downloadniri-536204fd82a37dfd2d7c0c7b5ce457197e7b4fec.tar.gz
niri-536204fd82a37dfd2d7c0c7b5ce457197e7b4fec.tar.bz2
niri-536204fd82a37dfd2d7c0c7b5ce457197e7b4fec.zip
layout: Make resizing actions unmaximize
I feel this is more intuitive compared to them doing nothing. True maximize is kinda similar to full-width in spirit, so make the actions behave the same.
-rw-r--r--src/layout/scrolling.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs
index fc163d72..f9e89ca7 100644
--- a/src/layout/scrolling.rs
+++ b/src/layout/scrolling.rs
@@ -4763,7 +4763,7 @@ impl<W: LayoutElement> Column<W> {
fn toggle_width(&mut self, tile_idx: Option<usize>, forwards: bool) {
let tile_idx = tile_idx.unwrap_or(self.active_tile_idx);
- let preset_idx = if self.is_full_width {
+ let preset_idx = if self.is_full_width || self.is_pending_maximized {
None
} else {
self.preset_width_idx
@@ -4812,12 +4812,19 @@ impl<W: LayoutElement> Column<W> {
}
fn toggle_full_width(&mut self) {
- self.is_full_width = !self.is_full_width;
+ if self.is_pending_maximized {
+ // Treat it as unmaximize.
+ self.is_pending_maximized = false;
+ self.is_full_width = false;
+ } else {
+ self.is_full_width = !self.is_full_width;
+ }
+
self.update_tile_sizes(true);
}
fn set_column_width(&mut self, change: SizeChange, tile_idx: Option<usize>, animate: bool) {
- let current = if self.is_full_width {
+ let current = if self.is_full_width || self.is_pending_maximized {
ColumnWidth::Proportion(1.)
} else {
self.width
@@ -4867,6 +4874,7 @@ impl<W: LayoutElement> Column<W> {
self.width = width;
self.preset_width_idx = None;
self.is_full_width = false;
+ self.is_pending_maximized = false;
self.update_tile_sizes(animate);
}
@@ -4945,6 +4953,7 @@ impl<W: LayoutElement> Column<W> {
}
self.data[tile_idx].height = WindowHeight::Fixed(window_height.clamp(1., MAX_PX));
+ self.is_pending_maximized = false;
self.update_tile_sizes(animate);
}
@@ -4977,7 +4986,9 @@ impl<W: LayoutElement> Column<W> {
let len = self.options.layout.preset_window_heights.len();
let preset_idx = match self.data[tile_idx].height {
- WindowHeight::Preset(idx) => (idx + if forwards { 1 } else { len - 1 }) % len,
+ WindowHeight::Preset(idx) if !self.is_pending_maximized => {
+ (idx + if forwards { 1 } else { len - 1 }) % len
+ }
_ => {
let current = self.data[tile_idx].size.h;
let tile = &self.tiles[tile_idx];
@@ -5012,6 +5023,7 @@ impl<W: LayoutElement> Column<W> {
}
};
self.data[tile_idx].height = WindowHeight::Preset(preset_idx);
+ self.is_pending_maximized = false;
self.update_tile_sizes(true);
}