aboutsummaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-05-11 09:33:23 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-05-11 09:33:23 +0400
commit1c14a0a2a97867878c65ea33fa8b927618efb555 (patch)
tree16bb26bf1d8b83fca5d768bce7577443e26584e5 /src/layout
parent2fd9a03bd71b4709659cdd35192109b47c3b0e10 (diff)
downloadniri-1c14a0a2a97867878c65ea33fa8b927618efb555.tar.gz
niri-1c14a0a2a97867878c65ea33fa8b927618efb555.tar.bz2
niri-1c14a0a2a97867878c65ea33fa8b927618efb555.zip
Add a reset-window-height action
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/mod.rs9
-rw-r--r--src/layout/monitor.rs4
-rw-r--r--src/layout/workspace.rs17
3 files changed, 30 insertions, 0 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 22aaa7fa..75f6cd4c 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -1477,6 +1477,13 @@ impl<W: LayoutElement> Layout<W> {
monitor.set_window_height(change);
}
+ pub fn reset_window_height(&mut self) {
+ let Some(monitor) = self.active_monitor() else {
+ return;
+ };
+ monitor.reset_window_height();
+ }
+
pub fn focus_output(&mut self, output: &Output) {
if let MonitorSet::Normal {
monitors,
@@ -2335,6 +2342,7 @@ mod tests {
MaximizeColumn,
SetColumnWidth(#[proptest(strategy = "arbitrary_size_change()")] SizeChange),
SetWindowHeight(#[proptest(strategy = "arbitrary_size_change()")] SizeChange),
+ ResetWindowHeight,
Communicate(#[proptest(strategy = "1..=5usize")] usize),
MoveWorkspaceToOutput(#[proptest(strategy = "1..=5u8")] u8),
ViewOffsetGestureBegin {
@@ -2563,6 +2571,7 @@ mod tests {
Op::MaximizeColumn => layout.toggle_full_width(),
Op::SetColumnWidth(change) => layout.set_column_width(change),
Op::SetWindowHeight(change) => layout.set_window_height(change),
+ Op::ResetWindowHeight => layout.reset_window_height(),
Op::Communicate(id) => {
let mut update = false;
match &mut layout.monitor_set {
diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs
index 3833a61a..e12d544a 100644
--- a/src/layout/monitor.rs
+++ b/src/layout/monitor.rs
@@ -614,6 +614,10 @@ impl<W: LayoutElement> Monitor<W> {
self.active_workspace().set_window_height(change);
}
+ pub fn reset_window_height(&mut self) {
+ self.active_workspace().reset_window_height();
+ }
+
pub fn move_workspace_down(&mut self) {
let new_idx = min(self.active_workspace_idx + 1, self.workspaces.len() - 1);
if new_idx == self.active_workspace_idx {
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index 5deae266..3dbb473b 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -1988,6 +1988,17 @@ impl<W: LayoutElement> Workspace<W> {
cancel_resize_if_this_column(&mut self.interactive_resize, col);
}
+ pub fn reset_window_height(&mut self) {
+ if self.columns.is_empty() {
+ return;
+ }
+
+ let col = &mut self.columns[self.active_column_idx];
+ col.reset_window_height(None, true);
+
+ cancel_resize_if_this_column(&mut self.interactive_resize, col);
+ }
+
pub fn set_fullscreen(&mut self, window: &W::Id, is_fullscreen: bool) {
let (mut col_idx, tile_idx) = self
.columns
@@ -3091,6 +3102,12 @@ impl<W: LayoutElement> Column<W> {
self.update_tile_sizes(animate);
}
+ fn reset_window_height(&mut self, tile_idx: Option<usize>, animate: bool) {
+ let tile_idx = tile_idx.unwrap_or(self.active_tile_idx);
+ self.heights[tile_idx] = WindowHeight::Auto;
+ self.update_tile_sizes(animate);
+ }
+
fn set_fullscreen(&mut self, is_fullscreen: bool) {
assert_eq!(self.tiles.len(), 1);
self.is_fullscreen = is_fullscreen;