aboutsummaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-03-05 13:32:30 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-03-05 13:32:52 +0400
commitae89b2e514fd4c22a38c2dce258707c369ca944a (patch)
tree743448567dbc92843b46fc677b39336df3406a58 /src/layout
parent732f7f6f33595924654d23a380cc2a48bf9f3257 (diff)
downloadniri-ae89b2e514fd4c22a38c2dce258707c369ca944a.tar.gz
niri-ae89b2e514fd4c22a38c2dce258707c369ca944a.tar.bz2
niri-ae89b2e514fd4c22a38c2dce258707c369ca944a.zip
Implement spring animations
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/monitor.rs4
-rw-r--r--src/layout/tile.rs1
-rw-r--r--src/layout/workspace.rs4
3 files changed, 9 insertions, 0 deletions
diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs
index ac9f3ff9..f2e4c30e 100644
--- a/src/layout/monitor.rs
+++ b/src/layout/monitor.rs
@@ -94,6 +94,7 @@ impl<W: LayoutElement> Monitor<W> {
return;
}
+ // FIXME: also compute and use current velocity.
let current_idx = self
.workspace_switch
.as_ref()
@@ -105,6 +106,7 @@ impl<W: LayoutElement> Monitor<W> {
self.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(
current_idx,
idx as f64,
+ 0.,
self.options.animations.workspace_switch,
niri_config::Animation::default_workspace_switch(),
)));
@@ -781,6 +783,7 @@ impl<W: LayoutElement> Monitor<W> {
return true;
}
+ let velocity = gesture.tracker.velocity() / WORKSPACE_GESTURE_MOVEMENT;
let pos = gesture.tracker.projected_end_pos() / WORKSPACE_GESTURE_MOVEMENT;
let min = gesture.center_idx.saturating_sub(1) as f64;
@@ -792,6 +795,7 @@ impl<W: LayoutElement> Monitor<W> {
self.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new(
gesture.current_idx,
new_idx as f64,
+ velocity,
self.options.animations.workspace_switch,
niri_config::Animation::default_workspace_switch(),
)));
diff --git a/src/layout/tile.rs b/src/layout/tile.rs
index 816c92e1..505a6ccd 100644
--- a/src/layout/tile.rs
+++ b/src/layout/tile.rs
@@ -111,6 +111,7 @@ impl<W: LayoutElement> Tile<W> {
self.open_animation = Some(Animation::new(
0.,
1.,
+ 0.,
self.options.animations.window_open,
niri_config::Animation::default_window_open(),
));
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index 5475862c..ac31cdfb 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -436,9 +436,11 @@ impl<W: LayoutElement> Workspace<W> {
return;
}
+ // FIXME: also compute and use current velocity.
self.view_offset_adj = Some(ViewOffsetAdjustment::Animation(Animation::new(
self.view_offset as f64,
new_view_offset as f64,
+ 0.,
self.options.animations.horizontal_view_movement,
niri_config::Animation::default_horizontal_view_movement(),
)));
@@ -1272,6 +1274,7 @@ impl<W: LayoutElement> Workspace<W> {
// effort and bug potential.
let norm_factor = self.working_area.size.w as f64 / VIEW_GESTURE_WORKING_AREA_MOVEMENT;
+ let velocity = gesture.tracker.velocity() * norm_factor;
let pos = gesture.tracker.pos() * norm_factor;
let current_view_offset = pos + gesture.delta_from_tracker;
@@ -1420,6 +1423,7 @@ impl<W: LayoutElement> Workspace<W> {
self.view_offset_adj = Some(ViewOffsetAdjustment::Animation(Animation::new(
current_view_offset + delta,
target_view_offset as f64,
+ velocity,
self.options.animations.horizontal_view_movement,
niri_config::Animation::default_horizontal_view_movement(),
)));