aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-10-17 08:21:37 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-10-17 08:59:06 +0300
commit4b837f429c525d37785b17a29fec7d137cd7a1fe (patch)
tree2957afae3561dd60b841814b78ec0dd73c7fa60e /src
parenta480087618ea8835663ae0eb7da3bd066c1941d0 (diff)
downloadniri-4b837f429c525d37785b17a29fec7d137cd7a1fe.tar.gz
niri-4b837f429c525d37785b17a29fec7d137cd7a1fe.tar.bz2
niri-4b837f429c525d37785b17a29fec7d137cd7a1fe.zip
layout: Accept anim_config in remove_column_by_idx
Diffstat (limited to 'src')
-rw-r--r--src/layout/mod.rs2
-rw-r--r--src/layout/monitor.rs6
-rw-r--r--src/layout/workspace.rs34
3 files changed, 31 insertions, 11 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index e88182c0..e72da2d0 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -2176,7 +2176,7 @@ impl<W: LayoutElement> Layout<W> {
if !ws.has_windows() {
return;
}
- let column = ws.remove_column_by_idx(ws.active_column_idx);
+ let column = ws.remove_column_by_idx(ws.active_column_idx, None);
let workspace_idx = monitors[new_idx].active_workspace_idx;
self.add_column_by_idx(new_idx, workspace_idx, column, true);
diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs
index f43c91b3..78216dc5 100644
--- a/src/layout/monitor.rs
+++ b/src/layout/monitor.rs
@@ -570,7 +570,7 @@ impl<W: LayoutElement> Monitor<W> {
return;
}
- let column = workspace.remove_column_by_idx(workspace.active_column_idx);
+ let column = workspace.remove_column_by_idx(workspace.active_column_idx, None);
self.add_column(new_idx, column, true);
}
@@ -587,7 +587,7 @@ impl<W: LayoutElement> Monitor<W> {
return;
}
- let column = workspace.remove_column_by_idx(workspace.active_column_idx);
+ let column = workspace.remove_column_by_idx(workspace.active_column_idx, None);
self.add_column(new_idx, column, true);
}
@@ -604,7 +604,7 @@ impl<W: LayoutElement> Monitor<W> {
return;
}
- let column = workspace.remove_column_by_idx(workspace.active_column_idx);
+ let column = workspace.remove_column_by_idx(workspace.active_column_idx, None);
self.add_column(new_idx, column, true);
}
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index b1afa24d..9cd2b0d3 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -1254,16 +1254,21 @@ impl<W: LayoutElement> Workspace<W> {
tile
}
- pub fn remove_column_by_idx(&mut self, column_idx: usize) -> Column<W> {
+ pub fn remove_column_by_idx(
+ &mut self,
+ column_idx: usize,
+ anim_config: Option<niri_config::Animation>,
+ ) -> Column<W> {
// Animate movement of the other columns.
+ let movement_config = anim_config.unwrap_or(self.options.animations.window_movement.0);
let offset = self.column_x(column_idx + 1) - self.column_x(column_idx);
if self.active_column_idx <= column_idx {
for col in &mut self.columns[column_idx + 1..] {
- col.animate_move_from(offset);
+ col.animate_move_from_with_config(offset, movement_config);
}
} else {
for col in &mut self.columns[..column_idx] {
- col.animate_move_from(-offset);
+ col.animate_move_from_with_config(-offset, movement_config);
}
}
@@ -1301,6 +1306,8 @@ impl<W: LayoutElement> Workspace<W> {
return column;
}
+ let view_config = anim_config.unwrap_or(self.options.animations.horizontal_view_movement.0);
+
if column_idx < self.active_column_idx {
// A column to the left was removed; preserve the current position.
// FIXME: preserve activate_prev_column_on_removal.
@@ -1313,16 +1320,29 @@ impl<W: LayoutElement> Workspace<W> {
if 0 < column_idx {
let prev_offset = self.activate_prev_column_on_removal.unwrap();
- self.activate_column(self.active_column_idx - 1);
+ self.activate_column_with_anim_config(self.active_column_idx - 1, view_config);
// Restore the view offset but make sure to scroll the view in case the
// previous window had resized.
let current_x = self.view_pos();
- self.animate_view_offset(current_x, self.active_column_idx, prev_offset);
- self.animate_view_offset_to_column(current_x, self.active_column_idx, None);
+ self.animate_view_offset_with_config(
+ current_x,
+ self.active_column_idx,
+ prev_offset,
+ view_config,
+ );
+ self.animate_view_offset_to_column_with_config(
+ current_x,
+ self.active_column_idx,
+ None,
+ view_config,
+ );
}
} else {
- self.activate_column(min(self.active_column_idx, self.columns.len() - 1));
+ self.activate_column_with_anim_config(
+ min(self.active_column_idx, self.columns.len() - 1),
+ view_config,
+ );
}
column