Make all animations configurable
Browse files at this commit6424a2738db6349de62dab150d5d6f1d431ca6c4Parent: 753a90410 changed files +231 -48
- niri-config/src/lib.rs +110 -19
- resources/default-config.kdl +46 -3
- src/animation.rs +25 -8
- src/config_error_notification.rs +19 -10
- src/layout/mod.rs +5 -1
- src/layout/monitor.rs +2 -1
- src/layout/tile.rs +7 -2
- src/layout/workspace.rs +2 -1
- src/main.rs +7 -1
- src/niri.rs +8 -2
niri-config/src/lib.rsmodified+110 -19
| @@ -36,6 +36,8 @@ pub struct Config { | |||
| 36 | #[knuffel(child, default)] | 36 | #[knuffel(child, default)] |
| 37 | pub hotkey_overlay: HotkeyOverlay, | 37 | pub hotkey_overlay: HotkeyOverlay, |
| 38 | #[knuffel(child, default)] | 38 | #[knuffel(child, default)] |
| 39 | + pub animations: Animations, | ||
| 40 | + #[knuffel(child, default)] | ||
| 39 | pub binds: Binds, | 41 | pub binds: Binds, |
| 40 | #[knuffel(child, default)] | 42 | #[knuffel(child, default)] |
| 41 | pub debug: DebugConfig, | 43 | pub debug: DebugConfig, |
| @@ -399,6 +401,89 @@ pub struct HotkeyOverlay { | |||
| 399 | pub skip_at_startup: bool, | 401 | pub skip_at_startup: bool, |
| 400 | } | 402 | } |
| 401 | 403 | ||
| 404 | +#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] | ||
| 405 | +pub struct Animations { | ||
| 406 | + #[knuffel(child)] | ||
| 407 | + pub off: bool, | ||
| 408 | + #[knuffel(child, unwrap(argument), default = 1.)] | ||
| 409 | + pub slowdown: f64, | ||
| 410 | + #[knuffel(child, default = Animation::default_workspace_switch())] | ||
| 411 | + pub workspace_switch: Animation, | ||
| 412 | + #[knuffel(child, default = Animation::default_horizontal_view_movement())] | ||
| 413 | + pub horizontal_view_movement: Animation, | ||
| 414 | + #[knuffel(child, default = Animation::default_window_open())] | ||
| 415 | + pub window_open: Animation, | ||
| 416 | + #[knuffel(child, default = Animation::default_config_notification_open_close())] | ||
| 417 | + pub config_notification_open_close: Animation, | ||
| 418 | +} | ||
| 419 | + | ||
| 420 | +impl Default for Animations { | ||
| 421 | + fn default() -> Self { | ||
| 422 | + Self { | ||
| 423 | + off: false, | ||
| 424 | + slowdown: 1., | ||
| 425 | + workspace_switch: Animation::default_workspace_switch(), | ||
| 426 | + horizontal_view_movement: Animation::default_horizontal_view_movement(), | ||
| 427 | + window_open: Animation::default_window_open(), | ||
| 428 | + config_notification_open_close: Animation::default_config_notification_open_close(), | ||
| 429 | + } | ||
| 430 | + } | ||
| 431 | +} | ||
| 432 | + | ||
| 433 | +#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] | ||
| 434 | +pub struct Animation { | ||
| 435 | + #[knuffel(child)] | ||
| 436 | + pub off: bool, | ||
| 437 | + #[knuffel(child, unwrap(argument))] | ||
| 438 | + pub duration_ms: Option<u32>, | ||
| 439 | + #[knuffel(child, unwrap(argument))] | ||
| 440 | + pub curve: Option<AnimationCurve>, | ||
| 441 | +} | ||
| 442 | + | ||
| 443 | +impl Animation { | ||
| 444 | + pub const fn unfilled() -> Self { | ||
| 445 | + Self { | ||
| 446 | + off: false, | ||
| 447 | + duration_ms: None, | ||
| 448 | + curve: None, | ||
| 449 | + } | ||
| 450 | + } | ||
| 451 | + | ||
| 452 | + pub const fn default() -> Self { | ||
| 453 | + Self { | ||
| 454 | + off: false, | ||
| 455 | + duration_ms: Some(250), | ||
| 456 | + curve: Some(AnimationCurve::EaseOutCubic), | ||
| 457 | + } | ||
| 458 | + } | ||
| 459 | + | ||
| 460 | + pub const fn default_workspace_switch() -> Self { | ||
| 461 | + Self::default() | ||
| 462 | + } | ||
| 463 | + | ||
| 464 | + pub const fn default_horizontal_view_movement() -> Self { | ||
| 465 | + Self::default() | ||
| 466 | + } | ||
| 467 | + | ||
| 468 | + pub const fn default_config_notification_open_close() -> Self { | ||
| 469 | + Self::default() | ||
| 470 | + } | ||
| 471 | + | ||
| 472 | + pub const fn default_window_open() -> Self { | ||
| 473 | + Self { | ||
| 474 | + duration_ms: Some(150), | ||
| 475 | + curve: Some(AnimationCurve::EaseOutExpo), | ||
| 476 | + ..Self::default() | ||
| 477 | + } | ||
| 478 | + } | ||
| 479 | +} | ||
| 480 | + | ||
| 481 | +#[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq)] | ||
| 482 | +pub enum AnimationCurve { | ||
| 483 | + EaseOutCubic, | ||
| 484 | + EaseOutExpo, | ||
| 485 | +} | ||
| 486 | + | ||
| 402 | #[derive(knuffel::Decode, Debug, Default, PartialEq)] | 487 | #[derive(knuffel::Decode, Debug, Default, PartialEq)] |
| 403 | pub struct Binds(#[knuffel(children)] pub Vec<Bind>); | 488 | pub struct Binds(#[knuffel(children)] pub Vec<Bind>); |
| 404 | 489 | ||
| @@ -515,10 +600,8 @@ pub enum LayoutAction { | |||
| 515 | Prev, | 600 | Prev, |
| 516 | } | 601 | } |
| 517 | 602 | ||
| 518 | -#[derive(knuffel::Decode, Debug, PartialEq)] | 603 | +#[derive(knuffel::Decode, Debug, Default, PartialEq)] |
| 519 | pub struct DebugConfig { | 604 | pub struct DebugConfig { |
| 520 | - #[knuffel(child, unwrap(argument), default = 1.)] | ||
| 521 | - pub animation_slowdown: f64, | ||
| 522 | #[knuffel(child)] | 605 | #[knuffel(child)] |
| 523 | pub dbus_interfaces_in_non_session_instances: bool, | 606 | pub dbus_interfaces_in_non_session_instances: bool, |
| 524 | #[knuffel(child)] | 607 | #[knuffel(child)] |
| @@ -533,20 +616,6 @@ pub struct DebugConfig { | |||
| 533 | pub render_drm_device: Option<PathBuf>, | 616 | pub render_drm_device: Option<PathBuf>, |
| 534 | } | 617 | } |
| 535 | 618 | ||
| 536 | -impl Default for DebugConfig { | ||
| 537 | - fn default() -> Self { | ||
| 538 | - Self { | ||
| 539 | - animation_slowdown: 1., | ||
| 540 | - dbus_interfaces_in_non_session_instances: false, | ||
| 541 | - wait_for_frame_completion_before_queueing: false, | ||
| 542 | - enable_color_transformations_capability: false, | ||
| 543 | - enable_overlay_planes: false, | ||
| 544 | - disable_cursor_plane: false, | ||
| 545 | - render_drm_device: None, | ||
| 546 | - } | ||
| 547 | - } | ||
| 548 | -} | ||
| 549 | - | ||
| 550 | impl Config { | 619 | impl Config { |
| 551 | pub fn load(path: &Path) -> miette::Result<Self> { | 620 | pub fn load(path: &Path) -> miette::Result<Self> { |
| 552 | let _span = tracy_client::span!("Config::load"); | 621 | let _span = tracy_client::span!("Config::load"); |
| @@ -841,6 +910,17 @@ mod tests { | |||
| 841 | skip-at-startup | 910 | skip-at-startup |
| 842 | } | 911 | } |
| 843 | 912 | ||
| 913 | + animations { | ||
| 914 | + slowdown 2.0 | ||
| 915 | + | ||
| 916 | + workspace-switch { off; } | ||
| 917 | + | ||
| 918 | + horizontal-view-movement { | ||
| 919 | + duration-ms 100 | ||
| 920 | + curve "ease-out-expo" | ||
| 921 | + } | ||
| 922 | + } | ||
| 923 | + | ||
| 844 | binds { | 924 | binds { |
| 845 | Mod+T { spawn "alacritty"; } | 925 | Mod+T { spawn "alacritty"; } |
| 846 | Mod+Q { close-window; } | 926 | Mod+Q { close-window; } |
| @@ -851,7 +931,6 @@ mod tests { | |||
| 851 | } | 931 | } |
| 852 | 932 | ||
| 853 | debug { | 933 | debug { |
| 854 | - animation-slowdown 2.0 | ||
| 855 | render-drm-device "/dev/dri/renderD129" | 934 | render-drm-device "/dev/dri/renderD129" |
| 856 | } | 935 | } |
| 857 | "#, | 936 | "#, |
| @@ -961,6 +1040,19 @@ mod tests { | |||
| 961 | hotkey_overlay: HotkeyOverlay { | 1040 | hotkey_overlay: HotkeyOverlay { |
| 962 | skip_at_startup: true, | 1041 | skip_at_startup: true, |
| 963 | }, | 1042 | }, |
| 1043 | + animations: Animations { | ||
| 1044 | + slowdown: 2., | ||
| 1045 | + workspace_switch: Animation { | ||
| 1046 | + off: true, | ||
| 1047 | + ..Animation::unfilled() | ||
| 1048 | + }, | ||
| 1049 | + horizontal_view_movement: Animation { | ||
| 1050 | + duration_ms: Some(100), | ||
| 1051 | + curve: Some(AnimationCurve::EaseOutExpo), | ||
| 1052 | + ..Animation::unfilled() | ||
| 1053 | + }, | ||
| 1054 | + ..Default::default() | ||
| 1055 | + }, | ||
| 964 | binds: Binds(vec![ | 1056 | binds: Binds(vec![ |
| 965 | Bind { | 1057 | Bind { |
| 966 | key: Key { | 1058 | key: Key { |
| @@ -1006,7 +1098,6 @@ mod tests { | |||
| 1006 | }, | 1098 | }, |
| 1007 | ]), | 1099 | ]), |
| 1008 | debug: DebugConfig { | 1100 | debug: DebugConfig { |
| 1009 | - animation_slowdown: 2., | ||
| 1010 | render_drm_device: Some(PathBuf::from("/dev/dri/renderD129")), | 1101 | render_drm_device: Some(PathBuf::from("/dev/dri/renderD129")), |
| 1011 | ..Default::default() | 1102 | ..Default::default() |
| 1012 | }, | 1103 | }, |
resources/default-config.kdlmodified+46 -3
| @@ -198,6 +198,52 @@ hotkey-overlay { | |||
| 198 | // skip-at-startup | 198 | // skip-at-startup |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | +// Animation settings. | ||
| 202 | +animations { | ||
| 203 | + // Uncomment to turn off all animations. | ||
| 204 | + // off | ||
| 205 | + | ||
| 206 | + // Slow down all animations by this factor. Values below 1 speed them up instead. | ||
| 207 | + // slowdown 3.0 | ||
| 208 | + | ||
| 209 | + // You can configure all individual animations. | ||
| 210 | + // Available settings are the same for all of them. | ||
| 211 | + | ||
| 212 | + // Animation when switching workspaces up and down, | ||
| 213 | + // including after the touchpad gesture. | ||
| 214 | + workspace-switch { | ||
| 215 | + // off | ||
| 216 | + // duration-ms 250 | ||
| 217 | + // curve "ease-out-cubic" | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + // All horizontal camera view movement: | ||
| 221 | + // - When a window off-screen is focused and the camera scrolls to it. | ||
| 222 | + // - When a new window appears off-screen and the camera scrolls to it. | ||
| 223 | + // - When a window resizes bigger and the camera scrolls to show it in full. | ||
| 224 | + // - And so on. | ||
| 225 | + horizontal-view-movement { | ||
| 226 | + // off | ||
| 227 | + // duration-ms 250 | ||
| 228 | + // curve "ease-out-cubic" | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + // Window opening animation. Note that this one has different defaults. | ||
| 232 | + window-open { | ||
| 233 | + // off | ||
| 234 | + // duration-ms 150 | ||
| 235 | + // curve "ease-out-expo" | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + // Config parse error and new default config creation notification | ||
| 239 | + // open/close animation. | ||
| 240 | + config-notification-open-close { | ||
| 241 | + // off | ||
| 242 | + // duration-ms 250 | ||
| 243 | + // curve "ease-out-cubic" | ||
| 244 | + } | ||
| 245 | +} | ||
| 246 | + | ||
| 201 | binds { | 247 | binds { |
| 202 | // Keys consist of modifiers separated by + signs, followed by an XKB key name | 248 | // Keys consist of modifiers separated by + signs, followed by an XKB key name |
| 203 | // in the end. To find an XKB name for a particular key, you may use a program | 249 | // in the end. To find an XKB name for a particular key, you may use a program |
| @@ -385,9 +431,6 @@ debug { | |||
| 385 | // The cursor will be rendered together with the rest of the frame. | 431 | // The cursor will be rendered together with the rest of the frame. |
| 386 | // disable-cursor-plane | 432 | // disable-cursor-plane |
| 387 | 433 | ||
| 388 | - // Slow down animations by this factor. | ||
| 389 | - // animation-slowdown 3.0 | ||
| 390 | - | ||
| 391 | // Override the DRM device that niri will use for all rendering. | 434 | // Override the DRM device that niri will use for all rendering. |
| 392 | // render-drm-device "/dev/dri/renderD129" | 435 | // render-drm-device "/dev/dri/renderD129" |
| 393 | } | 436 | } |
src/animation.rsmodified+25 -8
| @@ -25,28 +25,36 @@ pub enum Curve { | |||
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | impl Animation { | 27 | impl Animation { |
| 28 | - pub fn new(from: f64, to: f64, over_ms: u32) -> Self { | 28 | + pub fn new( |
| 29 | + from: f64, | ||
| 30 | + to: f64, | ||
| 31 | + config: niri_config::Animation, | ||
| 32 | + default: niri_config::Animation, | ||
| 33 | + ) -> Self { | ||
| 29 | // FIXME: ideally we shouldn't use current time here because animations started within the | 34 | // FIXME: ideally we shouldn't use current time here because animations started within the |
| 30 | // same frame cycle should have the same start time to be synchronized. | 35 | // same frame cycle should have the same start time to be synchronized. |
| 31 | let now = get_monotonic_time(); | 36 | let now = get_monotonic_time(); |
| 32 | 37 | ||
| 33 | - let duration = Duration::from_millis(u64::from(over_ms)) | 38 | + let duration_ms = if config.off { |
| 39 | + 0 | ||
| 40 | + } else { | ||
| 41 | + config.duration_ms.unwrap_or(default.duration_ms.unwrap()) | ||
| 42 | + }; | ||
| 43 | + let duration = Duration::from_millis(u64::from(duration_ms)) | ||
| 34 | .mul_f64(ANIMATION_SLOWDOWN.load(Ordering::Relaxed)); | 44 | .mul_f64(ANIMATION_SLOWDOWN.load(Ordering::Relaxed)); |
| 45 | + | ||
| 46 | + let curve = Curve::from(config.curve.unwrap_or(default.curve.unwrap())); | ||
| 47 | + | ||
| 35 | Self { | 48 | Self { |
| 36 | from, | 49 | from, |
| 37 | to, | 50 | to, |
| 38 | duration, | 51 | duration, |
| 39 | start_time: now, | 52 | start_time: now, |
| 40 | current_time: now, | 53 | current_time: now, |
| 41 | - curve: Curve::EaseOutCubic, | 54 | + curve, |
| 42 | } | 55 | } |
| 43 | } | 56 | } |
| 44 | 57 | ||
| 45 | - pub fn with_curve(mut self, curve: Curve) -> Self { | ||
| 46 | - self.curve = curve; | ||
| 47 | - self | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | pub fn set_current_time(&mut self, time: Duration) { | 58 | pub fn set_current_time(&mut self, time: Duration) { |
| 51 | self.current_time = time; | 59 | self.current_time = time; |
| 52 | } | 60 | } |
| @@ -80,3 +88,12 @@ impl Curve { | |||
| 80 | } | 88 | } |
| 81 | } | 89 | } |
| 82 | } | 90 | } |
| 91 | + | ||
| 92 | +impl From<niri_config::AnimationCurve> for Curve { | ||
| 93 | + fn from(value: niri_config::AnimationCurve) -> Self { | ||
| 94 | + match value { | ||
| 95 | + niri_config::AnimationCurve::EaseOutCubic => Curve::EaseOutCubic, | ||
| 96 | + niri_config::AnimationCurve::EaseOutExpo => Curve::EaseOutExpo, | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | +} | ||
src/config_error_notification.rsmodified+19 -10
| @@ -1,8 +1,10 @@ | |||
| 1 | use std::cell::RefCell; | 1 | use std::cell::RefCell; |
| 2 | use std::collections::HashMap; | 2 | use std::collections::HashMap; |
| 3 | use std::path::{Path, PathBuf}; | 3 | use std::path::{Path, PathBuf}; |
| 4 | +use std::rc::Rc; | ||
| 4 | use std::time::Duration; | 5 | use std::time::Duration; |
| 5 | 6 | ||
| 7 | +use niri_config::Config; | ||
| 6 | use pangocairo::cairo::{self, ImageSurface}; | 8 | use pangocairo::cairo::{self, ImageSurface}; |
| 7 | use pangocairo::pango::FontDescription; | 9 | use pangocairo::pango::FontDescription; |
| 8 | use smithay::backend::renderer::element::memory::{ | 10 | use smithay::backend::renderer::element::memory::{ |
| @@ -31,6 +33,8 @@ pub struct ConfigErrorNotification { | |||
| 31 | // If set, this is a "Created config at {path}" notification. If unset, this is a config error | 33 | // If set, this is a "Created config at {path}" notification. If unset, this is a config error |
| 32 | // notification. | 34 | // notification. |
| 33 | created_path: Option<PathBuf>, | 35 | created_path: Option<PathBuf>, |
| 36 | + | ||
| 37 | + config: Rc<RefCell<Config>>, | ||
| 34 | } | 38 | } |
| 35 | 39 | ||
| 36 | enum State { | 40 | enum State { |
| @@ -44,21 +48,32 @@ pub type ConfigErrorNotificationRenderElement<R> = | |||
| 44 | RelocateRenderElement<MemoryRenderBufferRenderElement<R>>; | 48 | RelocateRenderElement<MemoryRenderBufferRenderElement<R>>; |
| 45 | 49 | ||
| 46 | impl ConfigErrorNotification { | 50 | impl ConfigErrorNotification { |
| 47 | - pub fn new() -> Self { | 51 | + pub fn new(config: Rc<RefCell<Config>>) -> Self { |
| 48 | Self { | 52 | Self { |
| 49 | state: State::Hidden, | 53 | state: State::Hidden, |
| 50 | buffers: RefCell::new(HashMap::new()), | 54 | buffers: RefCell::new(HashMap::new()), |
| 51 | created_path: None, | 55 | created_path: None, |
| 56 | + config, | ||
| 52 | } | 57 | } |
| 53 | } | 58 | } |
| 54 | 59 | ||
| 60 | + fn animation(&self, from: f64, to: f64) -> Animation { | ||
| 61 | + let c = self.config.borrow(); | ||
| 62 | + Animation::new( | ||
| 63 | + from, | ||
| 64 | + to, | ||
| 65 | + c.animations.config_notification_open_close, | ||
| 66 | + niri_config::Animation::default_config_notification_open_close(), | ||
| 67 | + ) | ||
| 68 | + } | ||
| 69 | + | ||
| 55 | pub fn show_created(&mut self, created_path: Option<PathBuf>) { | 70 | pub fn show_created(&mut self, created_path: Option<PathBuf>) { |
| 56 | if self.created_path != created_path { | 71 | if self.created_path != created_path { |
| 57 | self.created_path = created_path; | 72 | self.created_path = created_path; |
| 58 | self.buffers.borrow_mut().clear(); | 73 | self.buffers.borrow_mut().clear(); |
| 59 | } | 74 | } |
| 60 | 75 | ||
| 61 | - self.state = State::Showing(Animation::new(0., 1., 250)); | 76 | + self.state = State::Showing(self.animation(0., 1.)); |
| 62 | } | 77 | } |
| 63 | 78 | ||
| 64 | pub fn show(&mut self) { | 79 | pub fn show(&mut self) { |
| @@ -68,7 +83,7 @@ impl ConfigErrorNotification { | |||
| 68 | } | 83 | } |
| 69 | 84 | ||
| 70 | // Show from scratch even if already showing to bring attention. | 85 | // Show from scratch even if already showing to bring attention. |
| 71 | - self.state = State::Showing(Animation::new(0., 1., 250)); | 86 | + self.state = State::Showing(self.animation(0., 1.)); |
| 72 | } | 87 | } |
| 73 | 88 | ||
| 74 | pub fn hide(&mut self) { | 89 | pub fn hide(&mut self) { |
| @@ -76,7 +91,7 @@ impl ConfigErrorNotification { | |||
| 76 | return; | 91 | return; |
| 77 | } | 92 | } |
| 78 | 93 | ||
| 79 | - self.state = State::Hiding(Animation::new(1., 0., 250)); | 94 | + self.state = State::Hiding(self.animation(1., 0.)); |
| 80 | } | 95 | } |
| 81 | 96 | ||
| 82 | pub fn advance_animations(&mut self, target_presentation_time: Duration) { | 97 | pub fn advance_animations(&mut self, target_presentation_time: Duration) { |
| @@ -167,12 +182,6 @@ impl ConfigErrorNotification { | |||
| 167 | } | 182 | } |
| 168 | } | 183 | } |
| 169 | 184 | ||
| 170 | -impl Default for ConfigErrorNotification { | ||
| 171 | - fn default() -> Self { | ||
| 172 | - Self::new() | ||
| 173 | - } | ||
| 174 | -} | ||
| 175 | - | ||
| 176 | fn render(scale: i32, created_path: Option<&Path>) -> anyhow::Result<MemoryRenderBuffer> { | 185 | fn render(scale: i32, created_path: Option<&Path>) -> anyhow::Result<MemoryRenderBuffer> { |
| 177 | let _span = tracy_client::span!("config_error_notification::render"); | 186 | let _span = tracy_client::span!("config_error_notification::render"); |
| 178 | 187 | ||
src/layout/mod.rsmodified+5 -1
| @@ -158,6 +158,7 @@ pub struct Options { | |||
| 158 | pub preset_widths: Vec<ColumnWidth>, | 158 | pub preset_widths: Vec<ColumnWidth>, |
| 159 | /// Initial width for new columns. | 159 | /// Initial width for new columns. |
| 160 | pub default_width: Option<ColumnWidth>, | 160 | pub default_width: Option<ColumnWidth>, |
| 161 | + pub animations: niri_config::Animations, | ||
| 161 | } | 162 | } |
| 162 | 163 | ||
| 163 | impl Default for Options { | 164 | impl Default for Options { |
| @@ -174,6 +175,7 @@ impl Default for Options { | |||
| 174 | ColumnWidth::Proportion(2. / 3.), | 175 | ColumnWidth::Proportion(2. / 3.), |
| 175 | ], | 176 | ], |
| 176 | default_width: None, | 177 | default_width: None, |
| 178 | + animations: Default::default(), | ||
| 177 | } | 179 | } |
| 178 | } | 180 | } |
| 179 | } | 181 | } |
| @@ -209,6 +211,7 @@ impl Options { | |||
| 209 | center_focused_column: layout.center_focused_column, | 211 | center_focused_column: layout.center_focused_column, |
| 210 | preset_widths, | 212 | preset_widths, |
| 211 | default_width, | 213 | default_width, |
| 214 | + animations: config.animations, | ||
| 212 | } | 215 | } |
| 213 | } | 216 | } |
| 214 | } | 217 | } |
| @@ -1577,7 +1580,8 @@ impl<W: LayoutElement> Layout<W> { | |||
| 1577 | monitor.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new( | 1580 | monitor.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new( |
| 1578 | current_idx, | 1581 | current_idx, |
| 1579 | idx as f64, | 1582 | idx as f64, |
| 1580 | - 250, | 1583 | + self.options.animations.workspace_switch, |
| 1584 | + niri_config::Animation::default_workspace_switch(), | ||
| 1581 | ))); | 1585 | ))); |
| 1582 | 1586 | ||
| 1583 | return Some(monitor.output.clone()); | 1587 | return Some(monitor.output.clone()); |
src/layout/monitor.rsmodified+2 -1
| @@ -96,7 +96,8 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 96 | self.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new( | 96 | self.workspace_switch = Some(WorkspaceSwitch::Animation(Animation::new( |
| 97 | current_idx, | 97 | current_idx, |
| 98 | idx as f64, | 98 | idx as f64, |
| 99 | - 250, | 99 | + self.options.animations.workspace_switch, |
| 100 | + niri_config::Animation::default_workspace_switch(), | ||
| 100 | ))); | 101 | ))); |
| 101 | } | 102 | } |
| 102 | 103 | ||
src/layout/tile.rsmodified+7 -2
| @@ -11,7 +11,7 @@ use smithay::utils::{Logical, Point, Rectangle, Scale, Size}; | |||
| 11 | 11 | ||
| 12 | use super::focus_ring::FocusRing; | 12 | use super::focus_ring::FocusRing; |
| 13 | use super::{LayoutElement, LayoutElementRenderElement, Options}; | 13 | use super::{LayoutElement, LayoutElementRenderElement, Options}; |
| 14 | -use crate::animation::{Animation, Curve}; | 14 | +use crate::animation::Animation; |
| 15 | use crate::niri_render_elements; | 15 | use crate::niri_render_elements; |
| 16 | use crate::render_helpers::offscreen::OffscreenRenderElement; | 16 | use crate::render_helpers::offscreen::OffscreenRenderElement; |
| 17 | use crate::render_helpers::renderer::NiriRenderer; | 17 | use crate::render_helpers::renderer::NiriRenderer; |
| @@ -114,7 +114,12 @@ impl<W: LayoutElement> Tile<W> { | |||
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | pub fn start_open_animation(&mut self) { | 116 | pub fn start_open_animation(&mut self) { |
| 117 | - self.open_animation = Some(Animation::new(0., 1., 150).with_curve(Curve::EaseOutExpo)); | 117 | + self.open_animation = Some(Animation::new( |
| 118 | + 0., | ||
| 119 | + 1., | ||
| 120 | + self.options.animations.window_open, | ||
| 121 | + niri_config::Animation::default_window_open(), | ||
| 122 | + )); | ||
| 118 | } | 123 | } |
| 119 | 124 | ||
| 120 | pub fn window(&self) -> &W { | 125 | pub fn window(&self) -> &W { |
src/layout/workspace.rsmodified+2 -1
| @@ -401,7 +401,8 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 401 | self.view_offset_anim = Some(Animation::new( | 401 | self.view_offset_anim = Some(Animation::new( |
| 402 | self.view_offset as f64, | 402 | self.view_offset as f64, |
| 403 | new_view_offset as f64, | 403 | new_view_offset as f64, |
| 404 | - 250, | 404 | + self.options.animations.horizontal_view_movement, |
| 405 | + niri_config::Animation::default_horizontal_view_movement(), | ||
| 405 | )); | 406 | )); |
| 406 | } | 407 | } |
| 407 | 408 | ||
src/main.rsmodified+7 -1
| @@ -177,7 +177,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | |||
| 177 | }) | 177 | }) |
| 178 | .unwrap_or_default(); | 178 | .unwrap_or_default(); |
| 179 | 179 | ||
| 180 | - animation::ANIMATION_SLOWDOWN.store(config.debug.animation_slowdown, Ordering::Relaxed); | 180 | + let slowdown = if config.animations.off { |
| 181 | + 0. | ||
| 182 | + } else { | ||
| 183 | + config.animations.slowdown | ||
| 184 | + }; | ||
| 185 | + animation::ANIMATION_SLOWDOWN.store(slowdown, Ordering::Relaxed); | ||
| 186 | + | ||
| 181 | let spawn_at_startup = mem::take(&mut config.spawn_at_startup); | 187 | let spawn_at_startup = mem::take(&mut config.spawn_at_startup); |
| 182 | 188 | ||
| 183 | // Create the compositor. | 189 | // Create the compositor. |
src/niri.rsmodified+8 -2
| @@ -581,7 +581,13 @@ impl State { | |||
| 581 | self.niri.config_error_notification.hide(); | 581 | self.niri.config_error_notification.hide(); |
| 582 | 582 | ||
| 583 | self.niri.layout.update_config(&config); | 583 | self.niri.layout.update_config(&config); |
| 584 | - animation::ANIMATION_SLOWDOWN.store(config.debug.animation_slowdown, Ordering::Relaxed); | 584 | + |
| 585 | + let slowdown = if config.animations.off { | ||
| 586 | + 0. | ||
| 587 | + } else { | ||
| 588 | + config.animations.slowdown | ||
| 589 | + }; | ||
| 590 | + animation::ANIMATION_SLOWDOWN.store(slowdown, Ordering::Relaxed); | ||
| 585 | 591 | ||
| 586 | let mut reload_xkb = None; | 592 | let mut reload_xkb = None; |
| 587 | let mut libinput_config_changed = false; | 593 | let mut libinput_config_changed = false; |
| @@ -902,7 +908,7 @@ impl Niri { | |||
| 902 | }); | 908 | }); |
| 903 | 909 | ||
| 904 | let screenshot_ui = ScreenshotUi::new(); | 910 | let screenshot_ui = ScreenshotUi::new(); |
| 905 | - let config_error_notification = ConfigErrorNotification::new(); | 911 | + let config_error_notification = ConfigErrorNotification::new(config.clone()); |
| 906 | 912 | ||
| 907 | let mut hotkey_overlay = HotkeyOverlay::new(config.clone(), backend.mod_key()); | 913 | let mut hotkey_overlay = HotkeyOverlay::new(config.clone(), backend.mod_key()); |
| 908 | if !config_.hotkey_overlay.skip_at_startup { | 914 | if !config_.hotkey_overlay.skip_at_startup { |