Add linear tiled window animations
This commit is contained in:
parent
a29937ebe8
commit
3540cdc4be
17 changed files with 913 additions and 64 deletions
|
|
@ -266,6 +266,13 @@ pub struct UiDrag {
|
|||
pub threshold: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Animations {
|
||||
pub enabled: Option<bool>,
|
||||
pub duration_ms: Option<u32>,
|
||||
pub curve: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum OutputMatch {
|
||||
Any(Vec<OutputMatch>),
|
||||
|
|
@ -567,6 +574,7 @@ pub struct Config {
|
|||
pub tearing: Option<Tearing>,
|
||||
pub libei: Libei,
|
||||
pub ui_drag: UiDrag,
|
||||
pub animations: Animations,
|
||||
pub xwayland: Option<Xwayland>,
|
||||
pub color_management: Option<ColorManagement>,
|
||||
pub float: Option<Float>,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use {
|
|||
|
||||
pub mod action;
|
||||
mod actions;
|
||||
mod animations;
|
||||
mod capabilities;
|
||||
mod clean_logs_older_than;
|
||||
mod client_match;
|
||||
|
|
|
|||
50
toml-config/src/config/parsers/animations.rs
Normal file
50
toml-config/src/config/parsers/animations.rs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
use {
|
||||
crate::{
|
||||
config::{
|
||||
Animations,
|
||||
context::Context,
|
||||
extractor::{Extractor, ExtractorError, bol, n32, opt, recover, str},
|
||||
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||
},
|
||||
toml::{
|
||||
toml_span::{DespanExt, Span, Spanned},
|
||||
toml_value::Value,
|
||||
},
|
||||
},
|
||||
indexmap::IndexMap,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AnimationsParserError {
|
||||
#[error(transparent)]
|
||||
Expected(#[from] UnexpectedDataType),
|
||||
#[error(transparent)]
|
||||
Extract(#[from] ExtractorError),
|
||||
}
|
||||
|
||||
pub struct AnimationsParser<'a>(pub &'a Context<'a>);
|
||||
|
||||
impl Parser for AnimationsParser<'_> {
|
||||
type Value = Animations;
|
||||
type Error = AnimationsParserError;
|
||||
const EXPECTED: &'static [DataType] = &[DataType::Table];
|
||||
|
||||
fn parse_table(
|
||||
&mut self,
|
||||
span: Span,
|
||||
table: &IndexMap<Spanned<String>, Spanned<Value>>,
|
||||
) -> ParseResult<Self> {
|
||||
let mut ext = Extractor::new(self.0, span, table);
|
||||
let (enabled, duration_ms, curve) = ext.extract((
|
||||
recover(opt(bol("enabled"))),
|
||||
recover(opt(n32("duration-ms"))),
|
||||
recover(opt(str("curve"))),
|
||||
))?;
|
||||
Ok(Animations {
|
||||
enabled: enabled.despan(),
|
||||
duration_ms: duration_ms.despan(),
|
||||
curve: curve.despan().map(|s| s.to_string()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
use {
|
||||
crate::{
|
||||
config::{
|
||||
Action, Config, Libei, Theme, UiDrag,
|
||||
Action, Animations, Config, Libei, Theme, UiDrag,
|
||||
context::Context,
|
||||
extractor::{Extractor, ExtractorError, arr, bol, int, opt, recover, str, val},
|
||||
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||
parsers::{
|
||||
action::ActionParser,
|
||||
actions::ActionsParser,
|
||||
animations::AnimationsParser,
|
||||
clean_logs_older_than::CleanLogsOlderThanParser,
|
||||
client_rule::ClientRulesParser,
|
||||
color_management::ColorManagementParser,
|
||||
|
|
@ -153,6 +154,7 @@ impl Parser for ConfigParser<'_> {
|
|||
fallback_output_mode_val,
|
||||
clean_logs_older_than_val,
|
||||
mouse_follows_focus,
|
||||
animations_val,
|
||||
),
|
||||
) = ext.extract((
|
||||
(
|
||||
|
|
@ -213,6 +215,7 @@ impl Parser for ConfigParser<'_> {
|
|||
opt(val("fallback-output-mode")),
|
||||
opt(val("clean-logs-older-than")),
|
||||
recover(opt(bol("unstable-mouse-follows-focus"))),
|
||||
opt(val("animations")),
|
||||
),
|
||||
))?;
|
||||
let mut keymap = None;
|
||||
|
|
@ -429,6 +432,15 @@ impl Parser for ConfigParser<'_> {
|
|||
}
|
||||
}
|
||||
}
|
||||
let mut animations = Animations::default();
|
||||
if let Some(value) = animations_val {
|
||||
match value.parse(&mut AnimationsParser(self.0)) {
|
||||
Ok(v) => animations = v,
|
||||
Err(e) => {
|
||||
log::warn!("Could not parse animations setting: {}", self.0.error(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut xwayland = None;
|
||||
if let Some(value) = xwayland_val {
|
||||
match value.parse(&mut XwaylandParser(self.0)) {
|
||||
|
|
@ -587,6 +599,7 @@ impl Parser for ConfigParser<'_> {
|
|||
tearing,
|
||||
libei,
|
||||
ui_drag,
|
||||
animations,
|
||||
xwayland,
|
||||
color_management,
|
||||
float,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use {
|
|||
ahash::{AHashMap, AHashSet},
|
||||
error_reporter::Report,
|
||||
jay_config::{
|
||||
Axis,
|
||||
AnimationCurve, Axis,
|
||||
client::Client,
|
||||
config, config_dir,
|
||||
exec::{Command, set_env, unset_env},
|
||||
|
|
@ -37,7 +37,8 @@ use {
|
|||
is_reload,
|
||||
keyboard::Keymap,
|
||||
logging::{clean_logs_older_than, set_log_level},
|
||||
on_devices_enumerated, on_idle, on_unload, quit, reload, set_autotile,
|
||||
on_devices_enumerated, on_idle, on_unload, quit, reload, set_animation_curve,
|
||||
set_animation_duration_ms, set_animations_enabled, set_autotile,
|
||||
set_color_management_enabled, set_corner_radius, set_default_workspace_capture,
|
||||
set_explicit_sync_enabled, set_float_above_fullscreen, set_floating_titles, set_idle,
|
||||
set_idle_grace_period, set_middle_click_paste_enabled, set_show_bar,
|
||||
|
|
@ -1649,6 +1650,23 @@ fn load_config(initial_load: bool, auto_reload: bool, persistent: &Rc<Persistent
|
|||
if let Some(threshold) = config.ui_drag.threshold {
|
||||
set_ui_drag_threshold(threshold);
|
||||
}
|
||||
set_animations_enabled(config.animations.enabled.unwrap_or(false));
|
||||
set_animation_duration_ms(config.animations.duration_ms.unwrap_or(160));
|
||||
let curve_name = config.animations.curve.as_deref().unwrap_or("ease-out");
|
||||
let curve = match curve_name {
|
||||
"linear" => Some(AnimationCurve::LINEAR),
|
||||
"ease" => Some(AnimationCurve::EASE),
|
||||
"ease-in" => Some(AnimationCurve::EASE_IN),
|
||||
"ease-out" => Some(AnimationCurve::EASE_OUT),
|
||||
"ease-in-out" => Some(AnimationCurve::EASE_IN_OUT),
|
||||
_ => {
|
||||
log::warn!("Unknown animation curve: {curve_name}");
|
||||
None
|
||||
}
|
||||
};
|
||||
if let Some(curve) = curve {
|
||||
set_animation_curve(curve);
|
||||
}
|
||||
if let Some(xwayland) = config.xwayland {
|
||||
if let Some(enabled) = xwayland.enabled {
|
||||
set_x_wayland_enabled(enabled);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue