aboutsummaryrefslogtreecommitdiff
path: root/src/layout/workspace.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-09-06 15:10:01 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-09-06 18:32:41 +0300
commitdcb29efce58ce0e122806b7f352a9f682e2fcbd8 (patch)
tree8b002d6e1ca6df7cd481ca4740829b33e9fd693d /src/layout/workspace.rs
parentcb5d97f600c7dc5bb31525c5cd664c1377145d87 (diff)
downloadniri-dcb29efce58ce0e122806b7f352a9f682e2fcbd8.tar.gz
niri-dcb29efce58ce0e122806b7f352a9f682e2fcbd8.tar.bz2
niri-dcb29efce58ce0e122806b7f352a9f682e2fcbd8.zip
Implement by-id window addressing in IPC and CLI, fix move-column-to-workspace
This is a JSON-breaking change for the IPC actions that changed from unit variants to struct variants. Unfortunately, I couldn't find a way with serde to both preserve a single variant, and make it serialize to the old value when the new field is None. I don't think anyone is using these actions from JSON at the moment, so this breaking change is fine.
Diffstat (limited to 'src/layout/workspace.rs')
-rw-r--r--src/layout/workspace.rs38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index b80cb95c..0064b8e3 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -2303,24 +2303,50 @@ impl<W: LayoutElement> Workspace<W> {
cancel_resize_for_column(&mut self.interactive_resize, col);
}
- pub fn set_window_height(&mut self, change: SizeChange) {
+ pub fn set_window_height(&mut self, window: Option<&W::Id>, change: SizeChange) {
if self.columns.is_empty() {
return;
}
- let col = &mut self.columns[self.active_column_idx];
- col.set_window_height(change, None, true);
+ let (col, tile_idx) = if let Some(window) = window {
+ self.columns
+ .iter_mut()
+ .find_map(|col| {
+ col.tiles
+ .iter()
+ .position(|tile| tile.window().id() == window)
+ .map(|tile_idx| (col, Some(tile_idx)))
+ })
+ .unwrap()
+ } else {
+ (&mut self.columns[self.active_column_idx], None)
+ };
+
+ col.set_window_height(change, tile_idx, true);
cancel_resize_for_column(&mut self.interactive_resize, col);
}
- pub fn reset_window_height(&mut self) {
+ pub fn reset_window_height(&mut self, window: Option<&W::Id>) {
if self.columns.is_empty() {
return;
}
- let col = &mut self.columns[self.active_column_idx];
- col.reset_window_height(None, true);
+ let (col, tile_idx) = if let Some(window) = window {
+ self.columns
+ .iter_mut()
+ .find_map(|col| {
+ col.tiles
+ .iter()
+ .position(|tile| tile.window().id() == window)
+ .map(|tile_idx| (col, Some(tile_idx)))
+ })
+ .unwrap()
+ } else {
+ (&mut self.columns[self.active_column_idx], None)
+ };
+
+ col.reset_window_height(tile_idx, true);
cancel_resize_for_column(&mut self.interactive_resize, col);
}