diff options
Diffstat (limited to 'niri-config/src')
| -rw-r--r-- | niri-config/src/lib.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index 6d104827..cad39c66 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -142,6 +142,8 @@ pub struct Touchpad { pub dwtp: bool, #[knuffel(child)] pub natural_scroll: bool, + #[knuffel(child, unwrap(argument, str))] + pub click_method: Option<ClickMethod>, #[knuffel(child, unwrap(argument), default)] pub accel_speed: f64, #[knuffel(child, unwrap(argument, str))] @@ -171,6 +173,21 @@ pub struct Trackpoint { } #[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ClickMethod { + Clickfinger, + ButtonAreas, +} + +impl From<ClickMethod> for input::ClickMethod { + fn from(value: ClickMethod) -> Self { + match value { + ClickMethod::Clickfinger => Self::Clickfinger, + ClickMethod::ButtonAreas => Self::ButtonAreas, + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum AccelProfile { Adaptive, Flat, @@ -1469,6 +1486,20 @@ impl FromStr for Key { } } +impl FromStr for ClickMethod { + type Err = miette::Error; + + fn from_str(s: &str) -> Result<Self, Self::Err> { + match s { + "clickfinger" => Ok(Self::Clickfinger), + "button-areas" => Ok(Self::ButtonAreas), + _ => Err(miette!( + r#"invalid click method, can be "button-areas" or "clickfinger""# + )), + } + } +} + impl FromStr for AccelProfile { type Err = miette::Error; @@ -1534,6 +1565,7 @@ mod tests { tap dwt dwtp + click-method "clickfinger" accel-speed 0.2 accel-profile "flat" tap-button-map "left-middle-right" @@ -1676,6 +1708,7 @@ mod tests { tap: true, dwt: true, dwtp: true, + click_method: Some(ClickMethod::Clickfinger), natural_scroll: false, accel_speed: 0.2, accel_profile: Some(AccelProfile::Flat), |
