aboutsummaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-04-17 14:06:32 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-04-17 14:06:32 +0400
commit73e9ef5fe20825ed12f1bb05ba10e7eb69bc7662 (patch)
treecdb4d408a50494fd86695ce0807602869c047f93 /src/layout
parentc40d4f3268318ac295f21bfce38b9809c5e48f0d (diff)
downloadniri-73e9ef5fe20825ed12f1bb05ba10e7eb69bc7662.tar.gz
niri-73e9ef5fe20825ed12f1bb05ba10e7eb69bc7662.tar.bz2
niri-73e9ef5fe20825ed12f1bb05ba10e7eb69bc7662.zip
Resolve animation defaults during parsing
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/monitor.rs6
-rw-r--r--src/layout/tile.rs20
-rw-r--r--src/layout/workspace.rs36
3 files changed, 15 insertions, 47 deletions
diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs
index 7a19673e..604dcab3 100644
--- a/src/layout/monitor.rs
+++ b/src/layout/monitor.rs
@@ -127,8 +127,7 @@ impl<W: LayoutElement> Monitor<W> {
current_idx,
idx as f64,
0.,
- self.options.animations.workspace_switch,
- niri_config::Animation::default_workspace_switch(),
+ self.options.animations.workspace_switch.0,
)));
}
@@ -882,8 +881,7 @@ impl<W: LayoutElement> Monitor<W> {
gesture.current_idx,
new_idx as f64,
velocity,
- self.options.animations.workspace_switch,
- niri_config::Animation::default_workspace_switch(),
+ self.options.animations.workspace_switch.0,
)));
true
diff --git a/src/layout/tile.rs b/src/layout/tile.rs
index 87c168b0..16779c10 100644
--- a/src/layout/tile.rs
+++ b/src/layout/tile.rs
@@ -150,13 +150,7 @@ impl<W: LayoutElement> Tile<W> {
let change = self.window.size().to_point() - size_from.to_point();
let change = max(change.x.abs(), change.y.abs());
if change > RESIZE_ANIMATION_THRESHOLD {
- let anim = Animation::new(
- 0.,
- 1.,
- 0.,
- self.options.animations.window_resize,
- niri_config::Animation::default_window_resize(),
- );
+ let anim = Animation::new(0., 1., 0., self.options.animations.window_resize.0);
self.resize_animation = Some(ResizeAnimation {
anim,
size_from,
@@ -230,8 +224,7 @@ impl<W: LayoutElement> Tile<W> {
0.,
1.,
0.,
- self.options.animations.window_open,
- niri_config::Animation::default_window_open(),
+ self.options.animations.window_open.0,
));
}
@@ -244,23 +237,18 @@ impl<W: LayoutElement> Tile<W> {
}
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(),
- );
+ self.animate_move_from_with_config(from, self.options.animations.window_movement.0);
}
pub fn animate_move_from_with_config(
&mut self,
from: Point<i32, Logical>,
config: niri_config::Animation,
- default: niri_config::Animation,
) {
let current_offset = self.render_offset();
self.move_animation = Some(MoveAnimation {
- anim: Animation::new(1., 0., 0., config, default),
+ anim: Animation::new(1., 0., 0., config),
from: from + current_offset,
});
}
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index 271f6639..7474d650 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -525,8 +525,7 @@ impl<W: LayoutElement> Workspace<W> {
self.view_offset as f64,
new_view_offset as f64,
0.,
- self.options.animations.horizontal_view_movement,
- niri_config::Animation::default_horizontal_view_movement(),
+ self.options.animations.horizontal_view_movement.0,
)));
}
@@ -857,8 +856,7 @@ impl<W: LayoutElement> Workspace<W> {
for tile in &mut column.tiles[window_idx + 1..] {
tile.animate_move_from_with_config(
Point::from((0, offset_y)),
- self.options.animations.window_resize,
- niri_config::Animation::default_window_resize(),
+ self.options.animations.window_resize.0,
);
}
@@ -1034,16 +1032,14 @@ impl<W: LayoutElement> Workspace<W> {
for col in &mut self.columns[col_idx + 1..] {
col.animate_move_from_with_config(
offset,
- self.options.animations.window_resize,
- niri_config::Animation::default_window_resize(),
+ self.options.animations.window_resize.0,
);
}
} else {
for col in &mut self.columns[..=col_idx] {
col.animate_move_from_with_config(
-offset,
- self.options.animations.window_resize,
- niri_config::Animation::default_window_resize(),
+ self.options.animations.window_resize.0,
);
}
}
@@ -1074,10 +1070,7 @@ impl<W: LayoutElement> Workspace<W> {
// offset animation if the target was the same; maybe we shouldn't replace in this
// case?
if started_animation {
- anim.replace_config(
- self.options.animations.window_resize,
- niri_config::Animation::default_window_resize(),
- );
+ anim.replace_config(self.options.animations.window_resize.0);
}
}
}
@@ -1149,13 +1142,7 @@ impl<W: LayoutElement> Workspace<W> {
(1., 1.)
};
- let anim = Animation::new(
- 1.,
- 0.,
- 0.,
- self.options.animations.window_close,
- niri_config::Animation::default_window_close(),
- );
+ let anim = Animation::new(1., 0., 0., self.options.animations.window_close.0);
let res = ClosingWindow::new(
renderer,
@@ -2021,8 +2008,7 @@ impl<W: LayoutElement> Workspace<W> {
current_view_offset + delta,
target_view_offset as f64,
velocity,
- self.options.animations.horizontal_view_movement,
- niri_config::Animation::default_horizontal_view_movement(),
+ self.options.animations.horizontal_view_movement.0,
)));
// HACK: deal with things like snapping to the right edge of a larger-than-view window.
@@ -2188,8 +2174,7 @@ impl<W: LayoutElement> Column<W> {
pub fn animate_move_from(&mut self, from_x_offset: i32) {
self.animate_move_from_with_config(
from_x_offset,
- self.options.animations.window_movement,
- niri_config::Animation::default_window_movement(),
+ self.options.animations.window_movement.0,
);
}
@@ -2197,7 +2182,6 @@ impl<W: LayoutElement> Column<W> {
&mut self,
from_x_offset: i32,
config: niri_config::Animation,
- default: niri_config::Animation,
) {
let current_offset = self.move_animation.as_ref().map_or(0., Animation::value);
@@ -2206,7 +2190,6 @@ impl<W: LayoutElement> Column<W> {
0.,
0.,
config,
- default,
));
}
@@ -2257,8 +2240,7 @@ impl<W: LayoutElement> Column<W> {
for tile in &mut self.tiles[tile_idx + 1..] {
tile.animate_move_from_with_config(
Point::from((0, offset)),
- self.options.animations.window_resize,
- niri_config::Animation::default_window_resize(),
+ self.options.animations.window_resize.0,
);
}
}