aboutsummaryrefslogtreecommitdiff
path: root/src/layout/mod.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-12-28 10:12:50 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-12-30 20:12:37 +0300
commit8b0cb0bb57112bd15bc7ac04e6952d857dadcbca (patch)
treec0a9cd138e768e7596d8cd324be65024fbb35756 /src/layout/mod.rs
parenta24a6e4e3c441389fd7731320f47e61e567e237f (diff)
downloadniri-8b0cb0bb57112bd15bc7ac04e6952d857dadcbca.tar.gz
niri-8b0cb0bb57112bd15bc7ac04e6952d857dadcbca.tar.bz2
niri-8b0cb0bb57112bd15bc7ac04e6952d857dadcbca.zip
Add set-window-width action
Diffstat (limited to 'src/layout/mod.rs')
-rw-r--r--src/layout/mod.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index 2b12c7bb..acdf1301 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -2592,6 +2592,29 @@ impl<W: LayoutElement> Layout<W> {
monitor.set_column_width(change);
}
+ pub fn set_window_width(&mut self, window: Option<&W::Id>, change: SizeChange) {
+ if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {
+ if window.is_none() || window == Some(move_.tile.window().id()) {
+ return;
+ }
+ }
+
+ let workspace = if let Some(window) = window {
+ Some(
+ self.workspaces_mut()
+ .find(|ws| ws.has_window(window))
+ .unwrap(),
+ )
+ } else {
+ self.active_workspace_mut()
+ };
+
+ let Some(workspace) = workspace else {
+ return;
+ };
+ workspace.set_window_width(window, change);
+ }
+
pub fn set_window_height(&mut self, window: Option<&W::Id>, change: SizeChange) {
if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {
if window.is_none() || window == Some(move_.tile.window().id()) {
@@ -4319,6 +4342,12 @@ mod tests {
},
MaximizeColumn,
SetColumnWidth(#[proptest(strategy = "arbitrary_size_change()")] SizeChange),
+ SetWindowWidth {
+ #[proptest(strategy = "proptest::option::of(1..=5usize)")]
+ id: Option<usize>,
+ #[proptest(strategy = "arbitrary_size_change()")]
+ change: SizeChange,
+ },
SetWindowHeight {
#[proptest(strategy = "proptest::option::of(1..=5usize)")]
id: Option<usize>,
@@ -4829,6 +4858,10 @@ mod tests {
}
Op::MaximizeColumn => layout.toggle_full_width(),
Op::SetColumnWidth(change) => layout.set_column_width(change),
+ Op::SetWindowWidth { id, change } => {
+ let id = id.filter(|id| layout.has_window(id));
+ layout.set_window_width(id.as_ref(), change);
+ }
Op::SetWindowHeight { id, change } => {
let id = id.filter(|id| layout.has_window(id));
layout.set_window_height(id.as_ref(), change);