mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
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.
This commit is contained in:
+16
-4
@@ -4763,7 +4763,7 @@ impl<W: LayoutElement> Column<W> {
|
|||||||
fn toggle_width(&mut self, tile_idx: Option<usize>, forwards: bool) {
|
fn toggle_width(&mut self, tile_idx: Option<usize>, forwards: bool) {
|
||||||
let tile_idx = tile_idx.unwrap_or(self.active_tile_idx);
|
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
|
None
|
||||||
} else {
|
} else {
|
||||||
self.preset_width_idx
|
self.preset_width_idx
|
||||||
@@ -4812,12 +4812,19 @@ impl<W: LayoutElement> Column<W> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_full_width(&mut self) {
|
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);
|
self.update_tile_sizes(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_column_width(&mut self, change: SizeChange, tile_idx: Option<usize>, animate: bool) {
|
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.)
|
ColumnWidth::Proportion(1.)
|
||||||
} else {
|
} else {
|
||||||
self.width
|
self.width
|
||||||
@@ -4867,6 +4874,7 @@ impl<W: LayoutElement> Column<W> {
|
|||||||
self.width = width;
|
self.width = width;
|
||||||
self.preset_width_idx = None;
|
self.preset_width_idx = None;
|
||||||
self.is_full_width = false;
|
self.is_full_width = false;
|
||||||
|
self.is_pending_maximized = false;
|
||||||
self.update_tile_sizes(animate);
|
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.data[tile_idx].height = WindowHeight::Fixed(window_height.clamp(1., MAX_PX));
|
||||||
|
self.is_pending_maximized = false;
|
||||||
self.update_tile_sizes(animate);
|
self.update_tile_sizes(animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4977,7 +4986,9 @@ impl<W: LayoutElement> Column<W> {
|
|||||||
|
|
||||||
let len = self.options.layout.preset_window_heights.len();
|
let len = self.options.layout.preset_window_heights.len();
|
||||||
let preset_idx = match self.data[tile_idx].height {
|
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 current = self.data[tile_idx].size.h;
|
||||||
let tile = &self.tiles[tile_idx];
|
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.data[tile_idx].height = WindowHeight::Preset(preset_idx);
|
||||||
|
self.is_pending_maximized = false;
|
||||||
self.update_tile_sizes(true);
|
self.update_tile_sizes(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user