aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolay Yakimov <root@livid.pp.ru>2025-06-19 02:22:01 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-06-19 05:05:47 -0700
commite0b0b04b445f7044f383e50104f861e632e1c905 (patch)
tree39e25b9ae148688e6cf1fb868a94817d20153001
parented14e8da8476d5fde27b14d1dde03256a2f6e11b (diff)
downloadniri-e0b0b04b445f7044f383e50104f861e632e1c905.tar.gz
niri-e0b0b04b445f7044f383e50104f861e632e1c905.tar.bz2
niri-e0b0b04b445f7044f383e50104f861e632e1c905.zip
Expose libinput Button Scrolling Button Lock Enabled property
-rw-r--r--niri-config/src/lib.rs14
-rw-r--r--resources/default-config.kdl5
-rw-r--r--src/input/mod.rs40
-rw-r--r--wiki/Configuration:-Input.md5
4 files changed, 62 insertions, 2 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index 2d42e9f2..7c67f2dc 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -213,6 +213,8 @@ pub struct Touchpad {
pub scroll_method: Option<ScrollMethod>,
#[knuffel(child, unwrap(argument))]
pub scroll_button: Option<u32>,
+ #[knuffel(child)]
+ pub scroll_button_lock: bool,
#[knuffel(child, unwrap(argument, str))]
pub tap_button_map: Option<TapButtonMap>,
#[knuffel(child)]
@@ -240,6 +242,8 @@ pub struct Mouse {
#[knuffel(child, unwrap(argument))]
pub scroll_button: Option<u32>,
#[knuffel(child)]
+ pub scroll_button_lock: bool,
+ #[knuffel(child)]
pub left_handed: bool,
#[knuffel(child)]
pub middle_emulation: bool,
@@ -262,6 +266,8 @@ pub struct Trackpoint {
#[knuffel(child, unwrap(argument))]
pub scroll_button: Option<u32>,
#[knuffel(child)]
+ pub scroll_button_lock: bool,
+ #[knuffel(child)]
pub left_handed: bool,
#[knuffel(child)]
pub middle_emulation: bool,
@@ -282,6 +288,8 @@ pub struct Trackball {
#[knuffel(child, unwrap(argument))]
pub scroll_button: Option<u32>,
#[knuffel(child)]
+ pub scroll_button_lock: bool,
+ #[knuffel(child)]
pub left_handed: bool,
#[knuffel(child)]
pub middle_emulation: bool,
@@ -3954,6 +3962,7 @@ mod tests {
accel-profile "flat"
scroll-method "two-finger"
scroll-button 272
+ scroll-button-lock
tap-button-map "left-middle-right"
disabled-on-external-mouse
scroll-factor 0.9
@@ -3985,6 +3994,7 @@ mod tests {
accel-profile "flat"
scroll-method "edge"
scroll-button 275
+ scroll-button-lock
left-handed
middle-emulation
}
@@ -4235,6 +4245,7 @@ mod tests {
scroll_button: Some(
272,
),
+ scroll_button_lock: true,
tap_button_map: Some(
LeftMiddleRight,
),
@@ -4262,6 +4273,7 @@ mod tests {
scroll_button: Some(
273,
),
+ scroll_button_lock: false,
left_handed: false,
middle_emulation: true,
scroll_factor: Some(
@@ -4285,6 +4297,7 @@ mod tests {
scroll_button: Some(
274,
),
+ scroll_button_lock: false,
left_handed: false,
middle_emulation: false,
},
@@ -4303,6 +4316,7 @@ mod tests {
scroll_button: Some(
275,
),
+ scroll_button_lock: true,
left_handed: true,
middle_emulation: true,
},
diff --git a/resources/default-config.kdl b/resources/default-config.kdl
index ae78be13..81ac8976 100644
--- a/resources/default-config.kdl
+++ b/resources/default-config.kdl
@@ -53,6 +53,7 @@ input {
// accel-profile "flat"
// scroll-method "on-button-down"
// scroll-button 273
+ // scroll-button-lock
// middle-emulation
}
@@ -219,13 +220,13 @@ layout {
// radius. It has to assume that windows have square corners, leading to
// shadow artifacts inside the CSD rounded corners. This setting fixes
// those artifacts.
- //
+ //
// However, instead you may want to set prefer-no-csd and/or
// geometry-corner-radius. Then, niri will know the corner radius and
// draw the shadow correctly, without having to draw it behind the
// window. These will also remove client-side shadows if the window
// draws any.
- //
+ //
// draw-behind-window true
// You can change how shadows look. The values below are in logical
diff --git a/src/input/mod.rs b/src/input/mod.rs
index fec6c2d5..76f575b9 100644
--- a/src/input/mod.rs
+++ b/src/input/mod.rs
@@ -4290,6 +4290,11 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
+ let _ = device.config_scroll_set_button_lock(if c.scroll_button_lock {
+ input::ScrollButtonLockState::Enabled
+ } else {
+ input::ScrollButtonLockState::Disabled
+ });
}
} else if let Some(default) = device.config_scroll_default_method() {
let _ = device.config_scroll_set_method(default);
@@ -4298,6 +4303,11 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
+ let _ = device.config_scroll_set_button_lock(if c.scroll_button_lock {
+ input::ScrollButtonLockState::Enabled
+ } else {
+ input::ScrollButtonLockState::Disabled
+ });
}
}
@@ -4358,6 +4368,11 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
+ let _ = device.config_scroll_set_button_lock(if c.scroll_button_lock {
+ input::ScrollButtonLockState::Enabled
+ } else {
+ input::ScrollButtonLockState::Disabled
+ });
}
} else if let Some(default) = device.config_scroll_default_method() {
let _ = device.config_scroll_set_method(default);
@@ -4366,6 +4381,11 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
+ let _ = device.config_scroll_set_button_lock(if c.scroll_button_lock {
+ input::ScrollButtonLockState::Enabled
+ } else {
+ input::ScrollButtonLockState::Disabled
+ });
}
}
}
@@ -4395,6 +4415,11 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
+ let _ = device.config_scroll_set_button_lock(if c.scroll_button_lock {
+ input::ScrollButtonLockState::Enabled
+ } else {
+ input::ScrollButtonLockState::Disabled
+ });
}
} else if let Some(default) = device.config_scroll_default_method() {
let _ = device.config_scroll_set_method(default);
@@ -4403,6 +4428,11 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
+ let _ = device.config_scroll_set_button_lock(if c.scroll_button_lock {
+ input::ScrollButtonLockState::Enabled
+ } else {
+ input::ScrollButtonLockState::Disabled
+ });
}
}
}
@@ -4432,6 +4462,11 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
+ let _ = device.config_scroll_set_button_lock(if c.scroll_button_lock {
+ input::ScrollButtonLockState::Enabled
+ } else {
+ input::ScrollButtonLockState::Disabled
+ });
}
} else if let Some(default) = device.config_scroll_default_method() {
let _ = device.config_scroll_set_method(default);
@@ -4440,6 +4475,11 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
if let Some(button) = c.scroll_button {
let _ = device.config_scroll_set_button(button);
}
+ let _ = device.config_scroll_set_button_lock(if c.scroll_button_lock {
+ input::ScrollButtonLockState::Enabled
+ } else {
+ input::ScrollButtonLockState::Disabled
+ });
}
}
}
diff --git a/wiki/Configuration:-Input.md b/wiki/Configuration:-Input.md
index 5cba545c..b1e3a279 100644
--- a/wiki/Configuration:-Input.md
+++ b/wiki/Configuration:-Input.md
@@ -39,6 +39,7 @@ input {
// scroll-factor 1.0
// scroll-method "two-finger"
// scroll-button 273
+ // scroll-button-lock
// tap-button-map "left-middle-right"
// click-method "clickfinger"
// left-handed
@@ -54,6 +55,7 @@ input {
// scroll-factor 1.0
// scroll-method "no-scroll"
// scroll-button 273
+ // scroll-button-lock
// left-handed
// middle-emulation
}
@@ -65,6 +67,7 @@ input {
// accel-profile "flat"
// scroll-method "on-button-down"
// scroll-button 273
+ // scroll-button-lock
// left-handed
// middle-emulation
}
@@ -76,6 +79,7 @@ input {
// accel-profile "flat"
// scroll-method "on-button-down"
// scroll-button 273
+ // scroll-button-lock
// left-handed
// middle-emulation
}
@@ -201,6 +205,7 @@ A few settings are common between `touchpad`, `mouse`, `trackpoint`, and `trackb
- `scroll-method`: when to generate scroll events instead of pointer motion events, can be `no-scroll`, `two-finger`, `edge`, or `on-button-down`.
The default and supported methods vary depending on the device type.
- `scroll-button`: <sup>Since: 0.1.10</sup> the button code used for the `on-button-down` scroll method. You can find it in `libinput debug-events`.
+- `scroll-button-lock`: <sup>Since: next release</sup> when enabled, the button does not need to be held down. Pressing once engages scrolling, pressing a second time disengages it, and double click acts as single click of the the underlying button.
- `left-handed`: if set, changes the device to left-handed mode.
- `middle-emulation`: emulate a middle mouse click by pressing left and right mouse buttons at once.