Add animation-slowdown debug setting

This commit is contained in:
Ivan Molodetskikh
2023-09-06 15:49:46 +04:00
parent c7a7b2daf2
commit 7460737481
5 changed files with 37 additions and 1 deletions
Generated
+7
View File
@@ -1376,6 +1376,7 @@ dependencies = [
"knuffel", "knuffel",
"logind-zbus", "logind-zbus",
"miette", "miette",
"portable-atomic",
"profiling", "profiling",
"sd-notify", "sd-notify",
"serde", "serde",
@@ -1666,6 +1667,12 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "portable-atomic"
version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b"
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.17" version = "0.2.17"
+1
View File
@@ -16,6 +16,7 @@ keyframe = { version = "1.1.1", default-features = false }
knuffel = "3.2.0" knuffel = "3.2.0"
logind-zbus = "3.1.2" logind-zbus = "3.1.2"
miette = { version = "5.10.0", features = ["fancy"] } miette = { version = "5.10.0", features = ["fancy"] }
portable-atomic = { version = "1.4.3", default-features = false, features = ["float"] }
profiling = "1.0.9" profiling = "1.0.9"
sd-notify = "0.4.1" sd-notify = "0.4.1"
serde = { version = "1.0.188", features = ["derive"] } serde = { version = "1.0.188", features = ["derive"] }
+4 -1
View File
@@ -2,9 +2,12 @@ use std::time::Duration;
use keyframe::functions::EaseOutCubic; use keyframe::functions::EaseOutCubic;
use keyframe::EasingFunction; use keyframe::EasingFunction;
use portable_atomic::{AtomicF64, Ordering};
use crate::utils::get_monotonic_time; use crate::utils::get_monotonic_time;
pub static ANIMATION_SLOWDOWN: AtomicF64 = AtomicF64::new(1.);
#[derive(Debug)] #[derive(Debug)]
pub struct Animation { pub struct Animation {
from: f64, from: f64,
@@ -23,7 +26,7 @@ impl Animation {
Self { Self {
from, from,
to, to,
duration: over, duration: over.mul_f64(ANIMATION_SLOWDOWN.load(Ordering::Relaxed)),
start_time: now, start_time: now,
current_time: now, current_time: now,
} }
+23
View File
@@ -13,6 +13,8 @@ pub struct Config {
pub input: Input, pub input: Input,
#[knuffel(child, default)] #[knuffel(child, default)]
pub binds: Binds, pub binds: Binds,
#[knuffel(child, default)]
pub debug: DebugConfig,
} }
// FIXME: Add other devices. // FIXME: Add other devices.
@@ -122,6 +124,20 @@ pub enum Action {
MaximizeColumn, MaximizeColumn,
} }
#[derive(knuffel::Decode, Debug, PartialEq)]
pub struct DebugConfig {
#[knuffel(child, unwrap(argument), default = 1.)]
pub animation_slowdown: f64,
}
impl Default for DebugConfig {
fn default() -> Self {
Self {
animation_slowdown: 1.,
}
}
}
impl Config { impl Config {
pub fn load(path: Option<PathBuf>) -> miette::Result<Self> { pub fn load(path: Option<PathBuf>) -> miette::Result<Self> {
let path = if let Some(path) = path { let path = if let Some(path) = path {
@@ -233,6 +249,10 @@ mod tests {
Mod+Ctrl+Shift+L { move-window-to-monitor-right; } Mod+Ctrl+Shift+L { move-window-to-monitor-right; }
Mod+Comma { consume-window-into-column; } Mod+Comma { consume-window-into-column; }
} }
debug {
animation-slowdown 2.0
}
"#, "#,
Config { Config {
input: Input { input: Input {
@@ -286,6 +306,9 @@ mod tests {
actions: vec![Action::ConsumeWindowIntoColumn], actions: vec![Action::ConsumeWindowIntoColumn],
}, },
]), ]),
debug: DebugConfig {
animation_slowdown: 2.,
},
}, },
); );
} }
+2
View File
@@ -20,6 +20,7 @@ use clap::Parser;
use config::Config; use config::Config;
use miette::Context; use miette::Context;
use niri::{Niri, State}; use niri::{Niri, State};
use portable_atomic::Ordering;
use smithay::reexports::calloop::EventLoop; use smithay::reexports::calloop::EventLoop;
use smithay::reexports::wayland_server::Display; use smithay::reexports::wayland_server::Display;
use tracing_subscriber::EnvFilter; use tracing_subscriber::EnvFilter;
@@ -61,6 +62,7 @@ fn main() {
Config::default() Config::default()
} }
}; };
animation::ANIMATION_SLOWDOWN.store(config.debug.animation_slowdown, Ordering::Relaxed);
let mut event_loop = EventLoop::try_new().unwrap(); let mut event_loop = EventLoop::try_new().unwrap();
let mut display = Display::new().unwrap(); let mut display = Display::new().unwrap();