Accept FloatOrInt for input accel_speed, animation slowdown

Technically cfg-breaking due to introducing min/max limits at parse time, but
values outside these limits were invalid anyway, so maybe it's fine?
This commit is contained in:
Ivan Molodetskikh
2025-06-09 14:02:17 +03:00
parent 3edb8fd906
commit 6bab912383
3 changed files with 13 additions and 13 deletions
+7 -7
View File
@@ -206,7 +206,7 @@ pub struct Touchpad {
#[knuffel(child, unwrap(argument, str))]
pub click_method: Option<ClickMethod>,
#[knuffel(child, unwrap(argument), default)]
pub accel_speed: f64,
pub accel_speed: FloatOrInt<-1, 1>,
#[knuffel(child, unwrap(argument, str))]
pub accel_profile: Option<AccelProfile>,
#[knuffel(child, unwrap(argument, str))]
@@ -232,7 +232,7 @@ pub struct Mouse {
#[knuffel(child)]
pub natural_scroll: bool,
#[knuffel(child, unwrap(argument), default)]
pub accel_speed: f64,
pub accel_speed: FloatOrInt<-1, 1>,
#[knuffel(child, unwrap(argument, str))]
pub accel_profile: Option<AccelProfile>,
#[knuffel(child, unwrap(argument, str))]
@@ -254,7 +254,7 @@ pub struct Trackpoint {
#[knuffel(child)]
pub natural_scroll: bool,
#[knuffel(child, unwrap(argument), default)]
pub accel_speed: f64,
pub accel_speed: FloatOrInt<-1, 1>,
#[knuffel(child, unwrap(argument, str))]
pub accel_profile: Option<AccelProfile>,
#[knuffel(child, unwrap(argument, str))]
@@ -274,7 +274,7 @@ pub struct Trackball {
#[knuffel(child)]
pub natural_scroll: bool,
#[knuffel(child, unwrap(argument), default)]
pub accel_speed: f64,
pub accel_speed: FloatOrInt<-1, 1>,
#[knuffel(child, unwrap(argument, str))]
pub accel_profile: Option<AccelProfile>,
#[knuffel(child, unwrap(argument, str))]
@@ -1047,8 +1047,8 @@ pub struct Clipboard {
pub struct Animations {
#[knuffel(child)]
pub off: bool,
#[knuffel(child, unwrap(argument), default = 1.)]
pub slowdown: f64,
#[knuffel(child, unwrap(argument), default = FloatOrInt(1.))]
pub slowdown: FloatOrInt<0, { i32::MAX }>,
#[knuffel(child, default)]
pub workspace_switch: WorkspaceSwitchAnim,
#[knuffel(child, default)]
@@ -1073,7 +1073,7 @@ impl Default for Animations {
fn default() -> Self {
Self {
off: false,
slowdown: 1.,
slowdown: FloatOrInt(1.),
workspace_switch: Default::default(),
horizontal_view_movement: Default::default(),
window_movement: Default::default(),
+4 -4
View File
@@ -4162,7 +4162,7 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
let _ = device.config_dwtp_set_enabled(c.dwtp);
let _ = device.config_tap_set_drag_lock_enabled(c.drag_lock);
let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll);
let _ = device.config_accel_set_speed(c.accel_speed);
let _ = device.config_accel_set_speed(c.accel_speed.0);
let _ = device.config_left_handed_set(c.left_handed);
let _ = device.config_middle_emulation_set_enabled(c.middle_emulation);
@@ -4237,7 +4237,7 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
input::SendEventsMode::ENABLED
});
let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll);
let _ = device.config_accel_set_speed(c.accel_speed);
let _ = device.config_accel_set_speed(c.accel_speed.0);
let _ = device.config_left_handed_set(c.left_handed);
let _ = device.config_middle_emulation_set_enabled(c.middle_emulation);
@@ -4274,7 +4274,7 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
input::SendEventsMode::ENABLED
});
let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll);
let _ = device.config_accel_set_speed(c.accel_speed);
let _ = device.config_accel_set_speed(c.accel_speed.0);
let _ = device.config_middle_emulation_set_enabled(c.middle_emulation);
let _ = device.config_left_handed_set(c.left_handed);
@@ -4311,7 +4311,7 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
input::SendEventsMode::ENABLED
});
let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll);
let _ = device.config_accel_set_speed(c.accel_speed);
let _ = device.config_accel_set_speed(c.accel_speed.0);
let _ = device.config_left_handed_set(c.left_handed);
let _ = device.config_middle_emulation_set_enabled(c.middle_emulation);
+2 -2
View File
@@ -1319,7 +1319,7 @@ impl State {
self.niri.layout.ensure_named_workspace(ws_config);
}
let rate = 1.0 / config.animations.slowdown.max(0.001);
let rate = 1.0 / config.animations.slowdown.0.max(0.001);
self.niri.clock.set_rate(rate);
self.niri
.clock
@@ -2227,7 +2227,7 @@ impl Niri {
let mut animation_clock = Clock::default();
let rate = 1.0 / config_.animations.slowdown.max(0.001);
let rate = 1.0 / config_.animations.slowdown.0.max(0.001);
animation_clock.set_rate(rate);
animation_clock.set_complete_instantly(config_.animations.off);