aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-09-06 15:49:46 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-09-06 15:49:46 +0400
commit74607374819e000fb4d43a923176be17b838ff29 (patch)
treec3800ba27f7d75aef5f174fe7a7cc8f54a9027ed
parentc7a7b2daf29565a736f7e895230daeb9f18b7610 (diff)
downloadniri-74607374819e000fb4d43a923176be17b838ff29.tar.gz
niri-74607374819e000fb4d43a923176be17b838ff29.tar.bz2
niri-74607374819e000fb4d43a923176be17b838ff29.zip
Add animation-slowdown debug setting
-rw-r--r--Cargo.lock7
-rw-r--r--Cargo.toml1
-rw-r--r--src/animation.rs5
-rw-r--r--src/config.rs23
-rw-r--r--src/main.rs2
5 files changed, 37 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index d35694a3..b8403ed6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1376,6 +1376,7 @@ dependencies = [
"knuffel",
"logind-zbus",
"miette",
+ "portable-atomic",
"profiling",
"sd-notify",
"serde",
@@ -1667,6 +1668,12 @@ dependencies = [
]
[[package]]
+name = "portable-atomic"
+version = "1.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b"
+
+[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 165dfde7..5b3c42ac 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,6 +16,7 @@ keyframe = { version = "1.1.1", default-features = false }
knuffel = "3.2.0"
logind-zbus = "3.1.2"
miette = { version = "5.10.0", features = ["fancy"] }
+portable-atomic = { version = "1.4.3", default-features = false, features = ["float"] }
profiling = "1.0.9"
sd-notify = "0.4.1"
serde = { version = "1.0.188", features = ["derive"] }
diff --git a/src/animation.rs b/src/animation.rs
index 27449243..430e3516 100644
--- a/src/animation.rs
+++ b/src/animation.rs
@@ -2,9 +2,12 @@ use std::time::Duration;
use keyframe::functions::EaseOutCubic;
use keyframe::EasingFunction;
+use portable_atomic::{AtomicF64, Ordering};
use crate::utils::get_monotonic_time;
+pub static ANIMATION_SLOWDOWN: AtomicF64 = AtomicF64::new(1.);
+
#[derive(Debug)]
pub struct Animation {
from: f64,
@@ -23,7 +26,7 @@ impl Animation {
Self {
from,
to,
- duration: over,
+ duration: over.mul_f64(ANIMATION_SLOWDOWN.load(Ordering::Relaxed)),
start_time: now,
current_time: now,
}
diff --git a/src/config.rs b/src/config.rs
index a7d6fd7d..9d03275e 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -13,6 +13,8 @@ pub struct Config {
pub input: Input,
#[knuffel(child, default)]
pub binds: Binds,
+ #[knuffel(child, default)]
+ pub debug: DebugConfig,
}
// FIXME: Add other devices.
@@ -122,6 +124,20 @@ pub enum Action {
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 {
pub fn load(path: Option<PathBuf>) -> miette::Result<Self> {
let path = if let Some(path) = path {
@@ -233,6 +249,10 @@ mod tests {
Mod+Ctrl+Shift+L { move-window-to-monitor-right; }
Mod+Comma { consume-window-into-column; }
}
+
+ debug {
+ animation-slowdown 2.0
+ }
"#,
Config {
input: Input {
@@ -286,6 +306,9 @@ mod tests {
actions: vec![Action::ConsumeWindowIntoColumn],
},
]),
+ debug: DebugConfig {
+ animation_slowdown: 2.,
+ },
},
);
}
diff --git a/src/main.rs b/src/main.rs
index f71a959a..81422065 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -20,6 +20,7 @@ use clap::Parser;
use config::Config;
use miette::Context;
use niri::{Niri, State};
+use portable_atomic::Ordering;
use smithay::reexports::calloop::EventLoop;
use smithay::reexports::wayland_server::Display;
use tracing_subscriber::EnvFilter;
@@ -61,6 +62,7 @@ fn main() {
Config::default()
}
};
+ animation::ANIMATION_SLOWDOWN.store(config.debug.animation_slowdown, Ordering::Relaxed);
let mut event_loop = EventLoop::try_new().unwrap();
let mut display = Display::new().unwrap();