forge
Explore
Log in

Don't you dare go Hollow

Resolve animation defaults during parsing

Browse files at this commit

73e9ef5fe20825ed12f1bb05ba10e7eb69bc7662Ivan MolodetskikhParent: c40d4f3
niri-config/src/lib.rsmodified+214 -96
@@ -9,6 +9,7 @@ use std::time::Duration;
9 9
10 use bitflags::bitflags;10 use bitflags::bitflags;
11 use knuffel::errors::DecodeError;11 use knuffel::errors::DecodeError;
12+use knuffel::Decode as _;
12 use miette::{miette, Context, IntoDiagnostic, NarratableReportHandler};13 use miette::{miette, Context, IntoDiagnostic, NarratableReportHandler};
13 use niri_ipc::{LayoutSwitchTarget, SizeChange, Transform};14 use niri_ipc::{LayoutSwitchTarget, SizeChange, Transform};
14 use regex::Regex;15 use regex::Regex;
@@ -482,20 +483,20 @@ pub struct Animations {
482 pub off: bool,483 pub off: bool,
483 #[knuffel(child, unwrap(argument), default = 1.)]484 #[knuffel(child, unwrap(argument), default = 1.)]
484 pub slowdown: f64,485 pub slowdown: f64,
485- #[knuffel(child, default = Animation::default_workspace_switch())]486+ #[knuffel(child, default)]
486- pub workspace_switch: Animation,487+ pub workspace_switch: WorkspaceSwitchAnim,
487- #[knuffel(child, default = Animation::default_horizontal_view_movement())]488+ #[knuffel(child, default)]
488- pub horizontal_view_movement: Animation,489+ pub horizontal_view_movement: HorizontalViewMovementAnim,
489- #[knuffel(child, default = Animation::default_window_movement())]490+ #[knuffel(child, default)]
490- pub window_movement: Animation,491+ pub window_movement: WindowMovementAnim,
491- #[knuffel(child, default = Animation::default_window_open())]492+ #[knuffel(child, default)]
492- pub window_open: Animation,493+ pub window_open: WindowOpenAnim,
493- #[knuffel(child, default = Animation::default_window_close())]494+ #[knuffel(child, default)]
494- pub window_close: Animation,495+ pub window_close: WindowCloseAnim,
495- #[knuffel(child, default = Animation::default_window_resize())]496+ #[knuffel(child, default)]
496- pub window_resize: Animation,497+ pub window_resize: WindowResizeAnim,
497- #[knuffel(child, default = Animation::default_config_notification_open_close())]498+ #[knuffel(child, default)]
498- pub config_notification_open_close: Animation,499+ pub config_notification_open_close: ConfigNotificationOpenCloseAnim,
499 }500 }
500 501
501 impl Default for Animations {502 impl Default for Animations {
@@ -503,114 +504,133 @@ impl Default for Animations {
503 Self {504 Self {
504 off: false,505 off: false,
505 slowdown: 1.,506 slowdown: 1.,
506- workspace_switch: Animation::default_workspace_switch(),507+ workspace_switch: Default::default(),
507- horizontal_view_movement: Animation::default_horizontal_view_movement(),508+ horizontal_view_movement: Default::default(),
508- window_movement: Animation::default_window_movement(),509+ window_movement: Default::default(),
509- window_open: Animation::default_window_open(),510+ window_open: Default::default(),
510- window_close: Animation::default_window_close(),511+ window_close: Default::default(),
511- window_resize: Animation::default_window_resize(),512+ window_resize: Default::default(),
512- config_notification_open_close: Animation::default_config_notification_open_close(),513+ config_notification_open_close: Default::default(),
513 }514 }
514 }515 }
515 }516 }
516 517
517 #[derive(Debug, Clone, Copy, PartialEq)]518 #[derive(Debug, Clone, Copy, PartialEq)]
518-pub struct Animation {519+pub struct WorkspaceSwitchAnim(pub Animation);
519- pub off: bool,
520- pub kind: AnimationKind,
521-}
522 520
523-impl Animation {521+impl Default for WorkspaceSwitchAnim {
524- pub const fn unfilled() -> Self {522+ fn default() -> Self {
525- Self {523+ Self(Animation {
526- off: false,
527- kind: AnimationKind::Easing(EasingParams::unfilled()),
528- }
529- }
530-
531- pub const fn default() -> Self {
532- Self {
533- off: false,
534- kind: AnimationKind::Easing(EasingParams::default()),
535- }
536- }
537-
538- pub const fn default_workspace_switch() -> Self {
539- Self {
540 off: false,524 off: false,
541 kind: AnimationKind::Spring(SpringParams {525 kind: AnimationKind::Spring(SpringParams {
542 damping_ratio: 1.,526 damping_ratio: 1.,
543 stiffness: 1000,527 stiffness: 1000,
544 epsilon: 0.0001,528 epsilon: 0.0001,
545 }),529 }),
546- }530+ })
547 }531 }
532+}
548 533
549- pub const fn default_horizontal_view_movement() -> Self {534+#[derive(Debug, Clone, Copy, PartialEq)]
550- Self {535+pub struct HorizontalViewMovementAnim(pub Animation);
536+
537+impl Default for HorizontalViewMovementAnim {
538+ fn default() -> Self {
539+ Self(Animation {
551 off: false,540 off: false,
552 kind: AnimationKind::Spring(SpringParams {541 kind: AnimationKind::Spring(SpringParams {
553 damping_ratio: 1.,542 damping_ratio: 1.,
554 stiffness: 800,543 stiffness: 800,
555 epsilon: 0.0001,544 epsilon: 0.0001,
556 }),545 }),
557- }546+ })
558 }547 }
548+}
559 549
560- pub const fn default_window_movement() -> Self {550+#[derive(Debug, Clone, Copy, PartialEq)]
561- Self {551+pub struct WindowMovementAnim(pub Animation);
552+
553+impl Default for WindowMovementAnim {
554+ fn default() -> Self {
555+ Self(Animation {
562 off: false,556 off: false,
563 kind: AnimationKind::Spring(SpringParams {557 kind: AnimationKind::Spring(SpringParams {
564 damping_ratio: 1.,558 damping_ratio: 1.,
565 stiffness: 800,559 stiffness: 800,
566 epsilon: 0.0001,560 epsilon: 0.0001,
567 }),561 }),
568- }562+ })
569 }563 }
564+}
570 565
571- pub const fn default_config_notification_open_close() -> Self {566+#[derive(Debug, Clone, Copy, PartialEq)]
572- Self {567+pub struct ConfigNotificationOpenCloseAnim(pub Animation);
568+
569+impl Default for ConfigNotificationOpenCloseAnim {
570+ fn default() -> Self {
571+ Self(Animation {
573 off: false,572 off: false,
574 kind: AnimationKind::Spring(SpringParams {573 kind: AnimationKind::Spring(SpringParams {
575 damping_ratio: 0.6,574 damping_ratio: 0.6,
576 stiffness: 1000,575 stiffness: 1000,
577 epsilon: 0.001,576 epsilon: 0.001,
578 }),577 }),
579- }578+ })
580 }579 }
580+}
581 581
582- pub const fn default_window_open() -> Self {582+#[derive(Debug, Clone, Copy, PartialEq)]
583- Self {583+pub struct WindowOpenAnim(pub Animation);
584+
585+impl Default for WindowOpenAnim {
586+ fn default() -> Self {
587+ Self(Animation {
584 off: false,588 off: false,
585 kind: AnimationKind::Easing(EasingParams {589 kind: AnimationKind::Easing(EasingParams {
586- duration_ms: Some(150),590+ duration_ms: 150,
587- curve: Some(AnimationCurve::EaseOutExpo),591+ curve: AnimationCurve::EaseOutExpo,
588 }),592 }),
589- }593+ })
590 }594 }
595+}
591 596
592- pub const fn default_window_close() -> Self {597+#[derive(Debug, Clone, Copy, PartialEq)]
593- Self {598+pub struct WindowCloseAnim(pub Animation);
599+
600+impl Default for WindowCloseAnim {
601+ fn default() -> Self {
602+ Self(Animation {
594 off: false,603 off: false,
595 kind: AnimationKind::Easing(EasingParams {604 kind: AnimationKind::Easing(EasingParams {
596- duration_ms: Some(150),605+ duration_ms: 150,
597- curve: Some(AnimationCurve::EaseOutQuad),606+ curve: AnimationCurve::EaseOutQuad,
598 }),607 }),
599- }608+ })
600 }609 }
610+}
601 611
602- pub const fn default_window_resize() -> Self {612+#[derive(Debug, Clone, Copy, PartialEq)]
603- Self {613+pub struct WindowResizeAnim(pub Animation);
614+
615+impl Default for WindowResizeAnim {
616+ fn default() -> Self {
617+ Self(Animation {
604 off: false,618 off: false,
605 kind: AnimationKind::Spring(SpringParams {619 kind: AnimationKind::Spring(SpringParams {
606 damping_ratio: 1.,620 damping_ratio: 1.,
607 stiffness: 800,621 stiffness: 800,
608 epsilon: 0.0001,622 epsilon: 0.0001,
609 }),623 }),
610- }624+ })
611 }625 }
612 }626 }
613 627
628+#[derive(Debug, Clone, Copy, PartialEq)]
629+pub struct Animation {
630+ pub off: bool,
631+ pub kind: AnimationKind,
632+}
633+
614 #[derive(Debug, Clone, Copy, PartialEq)]634 #[derive(Debug, Clone, Copy, PartialEq)]
615 pub enum AnimationKind {635 pub enum AnimationKind {
616 Easing(EasingParams),636 Easing(EasingParams),
@@ -619,24 +639,8 @@ pub enum AnimationKind {
619 639
620 #[derive(Debug, Clone, Copy, PartialEq)]640 #[derive(Debug, Clone, Copy, PartialEq)]
621 pub struct EasingParams {641 pub struct EasingParams {
622- pub duration_ms: Option<u32>,642+ pub duration_ms: u32,
623- pub curve: Option<AnimationCurve>,643+ pub curve: AnimationCurve,
624-}
625-
626-impl EasingParams {
627- pub const fn unfilled() -> Self {
628- Self {
629- duration_ms: None,
630- curve: None,
631- }
632- }
633-
634- pub const fn default() -> Self {
635- Self {
636- duration_ms: Some(250),
637- curve: Some(AnimationCurve::EaseOutCubic),
638- }
639- }
640 }644 }
641 645
642 #[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq)]646 #[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq)]
@@ -1177,7 +1181,85 @@ fn parse_arg_node<S: knuffel::traits::ErrorSpan, T: knuffel::traits::DecodeScala
1177 Ok(value)1181 Ok(value)
1178 }1182 }
1179 1183
1180-impl<S> knuffel::Decode<S> for Animation1184+impl<S> knuffel::Decode<S> for WorkspaceSwitchAnim
1185+where
1186+ S: knuffel::traits::ErrorSpan,
1187+{
1188+ fn decode_node(
1189+ node: &knuffel::ast::SpannedNode<S>,
1190+ ctx: &mut knuffel::decode::Context<S>,
1191+ ) -> Result<Self, DecodeError<S>> {
1192+ let default = Self::default().0;
1193+ Ok(Self(Animation::decode_node(node, ctx, default)?))
1194+ }
1195+}
1196+
1197+impl<S> knuffel::Decode<S> for HorizontalViewMovementAnim
1198+where
1199+ S: knuffel::traits::ErrorSpan,
1200+{
1201+ fn decode_node(
1202+ node: &knuffel::ast::SpannedNode<S>,
1203+ ctx: &mut knuffel::decode::Context<S>,
1204+ ) -> Result<Self, DecodeError<S>> {
1205+ let default = Self::default().0;
1206+ Ok(Self(Animation::decode_node(node, ctx, default)?))
1207+ }
1208+}
1209+
1210+impl<S> knuffel::Decode<S> for WindowMovementAnim
1211+where
1212+ S: knuffel::traits::ErrorSpan,
1213+{
1214+ fn decode_node(
1215+ node: &knuffel::ast::SpannedNode<S>,
1216+ ctx: &mut knuffel::decode::Context<S>,
1217+ ) -> Result<Self, DecodeError<S>> {
1218+ let default = Self::default().0;
1219+ Ok(Self(Animation::decode_node(node, ctx, default)?))
1220+ }
1221+}
1222+
1223+impl<S> knuffel::Decode<S> for WindowOpenAnim
1224+where
1225+ S: knuffel::traits::ErrorSpan,
1226+{
1227+ fn decode_node(
1228+ node: &knuffel::ast::SpannedNode<S>,
1229+ ctx: &mut knuffel::decode::Context<S>,
1230+ ) -> Result<Self, DecodeError<S>> {
1231+ let default = Self::default().0;
1232+ Ok(Self(Animation::decode_node(node, ctx, default)?))
1233+ }
1234+}
1235+
1236+impl<S> knuffel::Decode<S> for WindowCloseAnim
1237+where
1238+ S: knuffel::traits::ErrorSpan,
1239+{
1240+ fn decode_node(
1241+ node: &knuffel::ast::SpannedNode<S>,
1242+ ctx: &mut knuffel::decode::Context<S>,
1243+ ) -> Result<Self, DecodeError<S>> {
1244+ let default = Self::default().0;
1245+ Ok(Self(Animation::decode_node(node, ctx, default)?))
1246+ }
1247+}
1248+
1249+impl<S> knuffel::Decode<S> for WindowResizeAnim
1250+where
1251+ S: knuffel::traits::ErrorSpan,
1252+{
1253+ fn decode_node(
1254+ node: &knuffel::ast::SpannedNode<S>,
1255+ ctx: &mut knuffel::decode::Context<S>,
1256+ ) -> Result<Self, DecodeError<S>> {
1257+ let default = Self::default().0;
1258+ Ok(Self(Animation::decode_node(node, ctx, default)?))
1259+ }
1260+}
1261+
1262+impl<S> knuffel::Decode<S> for ConfigNotificationOpenCloseAnim
1181 where1263 where
1182 S: knuffel::traits::ErrorSpan,1264 S: knuffel::traits::ErrorSpan,
1183 {1265 {
@@ -1185,10 +1267,27 @@ where
1185 node: &knuffel::ast::SpannedNode<S>,1267 node: &knuffel::ast::SpannedNode<S>,
1186 ctx: &mut knuffel::decode::Context<S>,1268 ctx: &mut knuffel::decode::Context<S>,
1187 ) -> Result<Self, DecodeError<S>> {1269 ) -> Result<Self, DecodeError<S>> {
1270+ let default = Self::default().0;
1271+ Ok(Self(Animation::decode_node(node, ctx, default)?))
1272+ }
1273+}
1274+
1275+impl Animation {
1276+ fn decode_node<S: knuffel::traits::ErrorSpan>(
1277+ node: &knuffel::ast::SpannedNode<S>,
1278+ ctx: &mut knuffel::decode::Context<S>,
1279+ default: Self,
1280+ ) -> Result<Self, DecodeError<S>> {
1281+ #[derive(Default, PartialEq)]
1282+ struct OptionalEasingParams {
1283+ duration_ms: Option<u32>,
1284+ curve: Option<AnimationCurve>,
1285+ }
1286+
1188 expect_only_children(node, ctx);1287 expect_only_children(node, ctx);
1189 1288
1190 let mut off = false;1289 let mut off = false;
1191- let mut easing_params = EasingParams::unfilled();1290+ let mut easing_params = OptionalEasingParams::default();
1192 let mut spring_params = None;1291 let mut spring_params = None;
1193 1292
1194 for child in node.children() {1293 for child in node.children() {
@@ -1206,7 +1305,7 @@ where
1206 }1305 }
1207 }1306 }
1208 "spring" => {1307 "spring" => {
1209- if easing_params != EasingParams::unfilled() {1308+ if easing_params != OptionalEasingParams::default() {
1210 ctx.emit_error(DecodeError::unexpected(1309 ctx.emit_error(DecodeError::unexpected(
1211 child,1310 child,
1212 "node",1311 "node",
@@ -1270,9 +1369,28 @@ where
1270 }1369 }
1271 1370
1272 let kind = if let Some(spring_params) = spring_params {1371 let kind = if let Some(spring_params) = spring_params {
1372+ // Configured spring.
1273 AnimationKind::Spring(spring_params)1373 AnimationKind::Spring(spring_params)
1374+ } else if easing_params == OptionalEasingParams::default() {
1375+ // Did not configure anything.
1376+ default.kind
1274 } else {1377 } else {
1275- AnimationKind::Easing(easing_params)1378+ // Configured easing.
1379+ let default = if let AnimationKind::Easing(easing) = default.kind {
1380+ easing
1381+ } else {
1382+ // Generic fallback values for when the default animation is spring, but the user
1383+ // configured an easing animation.
1384+ EasingParams {
1385+ duration_ms: 250,
1386+ curve: AnimationCurve::EaseOutCubic,
1387+ }
1388+ };
1389+
1390+ AnimationKind::Easing(EasingParams {
1391+ duration_ms: easing_params.duration_ms.unwrap_or(default.duration_ms),
1392+ curve: easing_params.curve.unwrap_or(default.curve),
1393+ })
1276 };1394 };
1277 1395
1278 Ok(Self { off, kind })1396 Ok(Self { off, kind })
@@ -1948,25 +2066,25 @@ mod tests {
1948 },2066 },
1949 animations: Animations {2067 animations: Animations {
1950 slowdown: 2.,2068 slowdown: 2.,
1951- workspace_switch: Animation {2069+ workspace_switch: WorkspaceSwitchAnim(Animation {
1952 off: false,2070 off: false,
1953 kind: AnimationKind::Spring(SpringParams {2071 kind: AnimationKind::Spring(SpringParams {
1954 damping_ratio: 1.,2072 damping_ratio: 1.,
1955 stiffness: 1000,2073 stiffness: 1000,
1956 epsilon: 0.0001,2074 epsilon: 0.0001,
1957 }),2075 }),
1958- },2076+ }),
1959- horizontal_view_movement: Animation {2077+ horizontal_view_movement: HorizontalViewMovementAnim(Animation {
1960 off: false,2078 off: false,
1961 kind: AnimationKind::Easing(EasingParams {2079 kind: AnimationKind::Easing(EasingParams {
1962- duration_ms: Some(100),2080+ duration_ms: 100,
1963- curve: Some(AnimationCurve::EaseOutExpo),2081+ curve: AnimationCurve::EaseOutExpo,
1964 }),2082 }),
1965- },2083+ }),
1966- window_open: Animation {2084+ window_open: WindowOpenAnim(Animation {
1967 off: true,2085 off: true,
1968- ..Animation::unfilled()2086+ ..WindowOpenAnim::default().0
1969- },2087+ }),
1970 ..Default::default()2088 ..Default::default()
1971 },2089 },
1972 environment: Environment(vec![2090 environment: Environment(vec![
src/animation/mod.rsmodified+12 -40
@@ -46,52 +46,27 @@ pub enum Curve {
46 }46 }
47 47
48 impl Animation {48 impl Animation {
49- pub fn new(49+ pub fn new(from: f64, to: f64, initial_velocity: f64, config: niri_config::Animation) -> Self {
50- from: f64,
51- to: f64,
52- initial_velocity: f64,
53- config: niri_config::Animation,
54- default: niri_config::Animation,
55- ) -> Self {
56 let mut rv = Self::ease(from, to, initial_velocity, 0, Curve::EaseOutCubic);50 let mut rv = Self::ease(from, to, initial_velocity, 0, Curve::EaseOutCubic);
57 if config.off {51 if config.off {
58 return rv;52 return rv;
59 }53 }
60 54
61- rv.replace_config(config, default);55+ rv.replace_config(config);
62 rv56 rv
63 }57 }
64 58
65- pub fn replace_config(59+ pub fn replace_config(&mut self, config: niri_config::Animation) {
66- &mut self,60+ if config.off {
67- config: niri_config::Animation,61+ self.duration = Duration::ZERO;
68- default: niri_config::Animation,62+ self.clamped_duration = Duration::ZERO;
69- ) {63+ return;
64+ }
65+
70 let start_time = self.start_time;66 let start_time = self.start_time;
71 let current_time = self.current_time;67 let current_time = self.current_time;
72 68
73- // Resolve defaults.69+ match config.kind {
74- let (kind, easing_defaults) = match (config.kind, default.kind) {
75- // Configured spring.
76- (configured @ niri_config::AnimationKind::Spring(_), _) => (configured, None),
77- // Configured nothing, defaults spring.
78- (
79- niri_config::AnimationKind::Easing(easing),
80- defaults @ niri_config::AnimationKind::Spring(_),
81- ) if easing == niri_config::EasingParams::unfilled() => (defaults, None),
82- // Configured easing or nothing, defaults easing.
83- (
84- configured @ niri_config::AnimationKind::Easing(_),
85- niri_config::AnimationKind::Easing(defaults),
86- ) => (configured, Some(defaults)),
87- // Configured easing, defaults spring.
88- (
89- configured @ niri_config::AnimationKind::Easing(_),
90- niri_config::AnimationKind::Spring(_),
91- ) => (configured, None),
92- };
93-
94- match kind {
95 niri_config::AnimationKind::Spring(p) => {70 niri_config::AnimationKind::Spring(p) => {
96 let params = SpringParams::new(p.damping_ratio, f64::from(p.stiffness), p.epsilon);71 let params = SpringParams::new(p.damping_ratio, f64::from(p.stiffness), p.epsilon);
97 72
@@ -104,15 +79,12 @@ impl Animation {
104 *self = Self::spring(spring);79 *self = Self::spring(spring);
105 }80 }
106 niri_config::AnimationKind::Easing(p) => {81 niri_config::AnimationKind::Easing(p) => {
107- let defaults = easing_defaults.unwrap_or(niri_config::EasingParams::default());
108- let duration_ms = p.duration_ms.or(defaults.duration_ms).unwrap();
109- let curve = Curve::from(p.curve.or(defaults.curve).unwrap());
110 *self = Self::ease(82 *self = Self::ease(
111 self.from,83 self.from,
112 self.to,84 self.to,
113 self.initial_velocity,85 self.initial_velocity,
114- u64::from(duration_ms),86+ u64::from(p.duration_ms),
115- curve,87+ Curve::from(p.curve),
116 );88 );
117 }89 }
118 }90 }
src/layout/monitor.rsmodified+2 -4
@@ -127,8 +127,7 @@ impl<W: LayoutElement> Monitor<W> {
127 current_idx,127 current_idx,
128 idx as f64,128 idx as f64,
129 0.,129 0.,
130- self.options.animations.workspace_switch,130+ self.options.animations.workspace_switch.0,
131- niri_config::Animation::default_workspace_switch(),
132 )));131 )));
133 }132 }
134 133
@@ -882,8 +881,7 @@ impl<W: LayoutElement> Monitor<W> {
882 gesture.current_idx,881 gesture.current_idx,
883 new_idx as f64,882 new_idx as f64,
884 velocity,883 velocity,
885- self.options.animations.workspace_switch,884+ self.options.animations.workspace_switch.0,
886- niri_config::Animation::default_workspace_switch(),
887 )));885 )));
888 886
889 true887 true
src/layout/tile.rsmodified+4 -16
@@ -150,13 +150,7 @@ impl<W: LayoutElement> Tile<W> {
150 let change = self.window.size().to_point() - size_from.to_point();150 let change = self.window.size().to_point() - size_from.to_point();
151 let change = max(change.x.abs(), change.y.abs());151 let change = max(change.x.abs(), change.y.abs());
152 if change > RESIZE_ANIMATION_THRESHOLD {152 if change > RESIZE_ANIMATION_THRESHOLD {
153- let anim = Animation::new(153+ let anim = Animation::new(0., 1., 0., self.options.animations.window_resize.0);
154- 0.,
155- 1.,
156- 0.,
157- self.options.animations.window_resize,
158- niri_config::Animation::default_window_resize(),
159- );
160 self.resize_animation = Some(ResizeAnimation {154 self.resize_animation = Some(ResizeAnimation {
161 anim,155 anim,
162 size_from,156 size_from,
@@ -230,8 +224,7 @@ impl<W: LayoutElement> Tile<W> {
230 0.,224 0.,
231 1.,225 1.,
232 0.,226 0.,
233- self.options.animations.window_open,227+ self.options.animations.window_open.0,
234- niri_config::Animation::default_window_open(),
235 ));228 ));
236 }229 }
237 230
@@ -244,23 +237,18 @@ impl<W: LayoutElement> Tile<W> {
244 }237 }
245 238
246 pub fn animate_move_from(&mut self, from: Point<i32, Logical>) {239 pub fn animate_move_from(&mut self, from: Point<i32, Logical>) {
247- self.animate_move_from_with_config(240+ self.animate_move_from_with_config(from, self.options.animations.window_movement.0);
248- from,
249- self.options.animations.window_movement,
250- niri_config::Animation::default_window_movement(),
251- );
252 }241 }
253 242
254 pub fn animate_move_from_with_config(243 pub fn animate_move_from_with_config(
255 &mut self,244 &mut self,
256 from: Point<i32, Logical>,245 from: Point<i32, Logical>,
257 config: niri_config::Animation,246 config: niri_config::Animation,
258- default: niri_config::Animation,
259 ) {247 ) {
260 let current_offset = self.render_offset();248 let current_offset = self.render_offset();
261 249
262 self.move_animation = Some(MoveAnimation {250 self.move_animation = Some(MoveAnimation {
263- anim: Animation::new(1., 0., 0., config, default),251+ anim: Animation::new(1., 0., 0., config),
264 from: from + current_offset,252 from: from + current_offset,
265 });253 });
266 }254 }
src/layout/workspace.rsmodified+9 -27
@@ -525,8 +525,7 @@ impl<W: LayoutElement> Workspace<W> {
525 self.view_offset as f64,525 self.view_offset as f64,
526 new_view_offset as f64,526 new_view_offset as f64,
527 0.,527 0.,
528- self.options.animations.horizontal_view_movement,528+ self.options.animations.horizontal_view_movement.0,
529- niri_config::Animation::default_horizontal_view_movement(),
530 )));529 )));
531 }530 }
532 531
@@ -857,8 +856,7 @@ impl<W: LayoutElement> Workspace<W> {
857 for tile in &mut column.tiles[window_idx + 1..] {856 for tile in &mut column.tiles[window_idx + 1..] {
858 tile.animate_move_from_with_config(857 tile.animate_move_from_with_config(
859 Point::from((0, offset_y)),858 Point::from((0, offset_y)),
860- self.options.animations.window_resize,859+ self.options.animations.window_resize.0,
861- niri_config::Animation::default_window_resize(),
862 );860 );
863 }861 }
864 862
@@ -1034,16 +1032,14 @@ impl<W: LayoutElement> Workspace<W> {
1034 for col in &mut self.columns[col_idx + 1..] {1032 for col in &mut self.columns[col_idx + 1..] {
1035 col.animate_move_from_with_config(1033 col.animate_move_from_with_config(
1036 offset,1034 offset,
1037- self.options.animations.window_resize,1035+ self.options.animations.window_resize.0,
1038- niri_config::Animation::default_window_resize(),
1039 );1036 );
1040 }1037 }
1041 } else {1038 } else {
1042 for col in &mut self.columns[..=col_idx] {1039 for col in &mut self.columns[..=col_idx] {
1043 col.animate_move_from_with_config(1040 col.animate_move_from_with_config(
1044 -offset,1041 -offset,
1045- self.options.animations.window_resize,1042+ self.options.animations.window_resize.0,
1046- niri_config::Animation::default_window_resize(),
1047 );1043 );
1048 }1044 }
1049 }1045 }
@@ -1074,10 +1070,7 @@ impl<W: LayoutElement> Workspace<W> {
1074 // offset animation if the target was the same; maybe we shouldn't replace in this1070 // offset animation if the target was the same; maybe we shouldn't replace in this
1075 // case?1071 // case?
1076 if started_animation {1072 if started_animation {
1077- anim.replace_config(1073+ anim.replace_config(self.options.animations.window_resize.0);
1078- self.options.animations.window_resize,
1079- niri_config::Animation::default_window_resize(),
1080- );
1081 }1074 }
1082 }1075 }
1083 }1076 }
@@ -1149,13 +1142,7 @@ impl<W: LayoutElement> Workspace<W> {
1149 (1., 1.)1142 (1., 1.)
1150 };1143 };
1151 1144
1152- let anim = Animation::new(1145+ let anim = Animation::new(1., 0., 0., self.options.animations.window_close.0);
1153- 1.,
1154- 0.,
1155- 0.,
1156- self.options.animations.window_close,
1157- niri_config::Animation::default_window_close(),
1158- );
1159 1146
1160 let res = ClosingWindow::new(1147 let res = ClosingWindow::new(
1161 renderer,1148 renderer,
@@ -2021,8 +2008,7 @@ impl<W: LayoutElement> Workspace<W> {
2021 current_view_offset + delta,2008 current_view_offset + delta,
2022 target_view_offset as f64,2009 target_view_offset as f64,
2023 velocity,2010 velocity,
2024- self.options.animations.horizontal_view_movement,2011+ self.options.animations.horizontal_view_movement.0,
2025- niri_config::Animation::default_horizontal_view_movement(),
2026 )));2012 )));
2027 2013
2028 // HACK: deal with things like snapping to the right edge of a larger-than-view window.2014 // 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> {
2188 pub fn animate_move_from(&mut self, from_x_offset: i32) {2174 pub fn animate_move_from(&mut self, from_x_offset: i32) {
2189 self.animate_move_from_with_config(2175 self.animate_move_from_with_config(
2190 from_x_offset,2176 from_x_offset,
2191- self.options.animations.window_movement,2177+ self.options.animations.window_movement.0,
2192- niri_config::Animation::default_window_movement(),
2193 );2178 );
2194 }2179 }
2195 2180
@@ -2197,7 +2182,6 @@ impl<W: LayoutElement> Column<W> {
2197 &mut self,2182 &mut self,
2198 from_x_offset: i32,2183 from_x_offset: i32,
2199 config: niri_config::Animation,2184 config: niri_config::Animation,
2200- default: niri_config::Animation,
2201 ) {2185 ) {
2202 let current_offset = self.move_animation.as_ref().map_or(0., Animation::value);2186 let current_offset = self.move_animation.as_ref().map_or(0., Animation::value);
2203 2187
@@ -2206,7 +2190,6 @@ impl<W: LayoutElement> Column<W> {
2206 0.,2190 0.,
2207 0.,2191 0.,
2208 config,2192 config,
2209- default,
2210 ));2193 ));
2211 }2194 }
2212 2195
@@ -2257,8 +2240,7 @@ impl<W: LayoutElement> Column<W> {
2257 for tile in &mut self.tiles[tile_idx + 1..] {2240 for tile in &mut self.tiles[tile_idx + 1..] {
2258 tile.animate_move_from_with_config(2241 tile.animate_move_from_with_config(
2259 Point::from((0, offset)),2242 Point::from((0, offset)),
2260- self.options.animations.window_resize,2243+ self.options.animations.window_resize.0,
2261- niri_config::Animation::default_window_resize(),
2262 );2244 );
2263 }2245 }
2264 }2246 }
src/ui/config_error_notification.rsmodified+1 -7
@@ -59,13 +59,7 @@ impl ConfigErrorNotification {
59 59
60 fn animation(&self, from: f64, to: f64) -> Animation {60 fn animation(&self, from: f64, to: f64) -> Animation {
61 let c = self.config.borrow();61 let c = self.config.borrow();
62- Animation::new(62+ Animation::new(from, to, 0., c.animations.config_notification_open_close.0)
63- from,
64- to,
65- 0.,
66- c.animations.config_notification_open_close,
67- niri_config::Animation::default_config_notification_open_close(),
68- )
69 }63 }
70 64
71 pub fn show_created(&mut self, created_path: Option<PathBuf>) {65 pub fn show_created(&mut self, created_path: Option<PathBuf>) {