aboutsummaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-04-15 21:19:09 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-04-15 21:19:09 +0400
commit69f723d68aa28698488618e00688ef3a84e40819 (patch)
tree3f7983e9257c87297dd699c84ac2077fefff386f /src/layout
parent568fbe26fe58be7de34e46ddb980a26d12e85ac6 (diff)
downloadniri-69f723d68aa28698488618e00688ef3a84e40819.tar.gz
niri-69f723d68aa28698488618e00688ef3a84e40819.tar.bz2
niri-69f723d68aa28698488618e00688ef3a84e40819.zip
Implement vertical window move animations
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/tile.rs8
-rw-r--r--src/layout/workspace.rs28
2 files changed, 34 insertions, 2 deletions
diff --git a/src/layout/tile.rs b/src/layout/tile.rs
index e1f9297f..b578b0c0 100644
--- a/src/layout/tile.rs
+++ b/src/layout/tile.rs
@@ -243,6 +243,14 @@ impl<W: LayoutElement> Tile<W> {
self.resize_animation.as_ref().map(|resize| &resize.anim)
}
+ pub fn animate_move_from(&mut self, from: Point<i32, Logical>) {
+ self.animate_move_from_with_config(
+ from,
+ self.options.animations.window_movement,
+ niri_config::Animation::default_window_movement(),
+ );
+ }
+
pub fn animate_move_from_with_config(
&mut self,
from: Point<i32, Logical>,
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index 39e377b5..186b3d22 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -2250,9 +2250,19 @@ impl<W: LayoutElement> Column<W> {
return;
}
+ let mut ys = self.tile_ys().skip(self.active_tile_idx);
+ let active_y = ys.next().unwrap();
+ let next_y = ys.next().unwrap();
+ drop(ys);
+
self.tiles.swap(self.active_tile_idx, new_idx);
self.heights.swap(self.active_tile_idx, new_idx);
self.active_tile_idx = new_idx;
+
+ // Animate the movement.
+ let new_active_y = self.tile_y(new_idx);
+ self.tiles[new_idx].animate_move_from(Point::from((0, active_y - new_active_y)));
+ self.tiles[new_idx + 1].animate_move_from(Point::from((0, active_y - next_y)));
}
fn move_down(&mut self) {
@@ -2261,9 +2271,19 @@ impl<W: LayoutElement> Column<W> {
return;
}
+ let mut ys = self.tile_ys().skip(self.active_tile_idx);
+ let active_y = ys.next().unwrap();
+ let next_y = ys.next().unwrap();
+ drop(ys);
+
self.tiles.swap(self.active_tile_idx, new_idx);
self.heights.swap(self.active_tile_idx, new_idx);
self.active_tile_idx = new_idx;
+
+ // Animate the movement.
+ let new_active_y = self.tile_y(new_idx);
+ self.tiles[new_idx].animate_move_from(Point::from((0, active_y - new_active_y)));
+ self.tiles[new_idx - 1].animate_move_from(Point::from((0, next_y - active_y)));
}
#[cfg(test)]
@@ -2431,9 +2451,13 @@ impl<W: LayoutElement> Column<W> {
y = self.working_area.loc.y + self.options.gaps;
}
- self.tiles.iter().map(move |tile| {
+ let heights = self.tiles.iter().map(|tile| tile.tile_size().h);
+
+ // Chain an arbitrary height to be able to get the Y that the next tile past the end would
+ // have.
+ heights.chain(iter::once(0)).map(move |h| {
let pos = y;
- y += tile.tile_size().h + self.options.gaps;
+ y += h + self.options.gaps;
pos
})
}