Add onbutton scrollMethod, scrollButton

This commit is contained in:
diniamo 2026-04-25 20:44:02 +02:00 committed by Johan Malm
parent 7d264c907f
commit 5c7bfe3c67
6 changed files with 33 additions and 4 deletions

View file

@ -1140,6 +1140,7 @@ Note: To rotate touch events with output rotation, use the libinput
<disableWhileTyping></disableWhileTyping> <disableWhileTyping></disableWhileTyping>
<clickMethod></clickMethod> <clickMethod></clickMethod>
<scrollMethod></scrollMethod> <scrollMethod></scrollMethod>
<scrollButton></scrollButton>
<sendEventsMode></sendEventsMode> <sendEventsMode></sendEventsMode>
<calibrationMatrix></calibrationMatrix> <calibrationMatrix></calibrationMatrix>
<scrollFactor>1.0</scrollFactor> <scrollFactor>1.0</scrollFactor>
@ -1244,19 +1245,24 @@ Note: To rotate touch events with output rotation, use the libinput
The default method depends on the touchpad hardware. The default method depends on the touchpad hardware.
*<libinput><device><scrollMethod>* [none|twofinger|edge] *<libinput><device><scrollMethod>* [none|twofinger|edge|onbutton]
Configure the method by which physical movements on a touchpad are Configure the method by which physical movements are mapped to scroll events.
mapped to scroll events.
The scroll methods available are: The scroll methods available are:
- *twofinger* - Scroll by two fingers being placed on the surface of the - *twofinger* - Scroll by two fingers being placed on the surface of the
touchpad, then moving those fingers vertically or horizontally. touchpad, then moving those fingers vertically or horizontally.
- *edge* - Scroll by moving a single finger along the right edge - *edge* - Scroll by moving a single finger along the right edge
(vertical scroll) or bottom edge (horizontal scroll). (vertical scroll) or bottom edge (horizontal scroll).
- *onbutton* - Scroll by pressing a button.
- *none* - No scroll events will be produced. - *none* - No scroll events will be produced.
The default method depends on the touchpad hardware. The default method depends on the touchpad hardware.
*<libinput><device><scrollButton>* [button]
Set the button used for the *onbutton* scroll method.
*button* is the decimal form of a value from `linux/input-event-codes.h`.
*<libinput><device><sendEventsMode>* [yes|no|disabledOnExternalMouse] *<libinput><device><sendEventsMode>* [yes|no|disabledOnExternalMouse]
Optionally enable or disable sending any device events. Optionally enable or disable sending any device events.

View file

@ -592,7 +592,7 @@
- accelProfile [flat|adaptive] - accelProfile [flat|adaptive]
- tapButtonMap [lrm|lmr] - tapButtonMap [lrm|lmr]
- clickMethod [none|buttonAreas|clickfinger] - clickMethod [none|buttonAreas|clickfinger]
- scrollMethod [twoFinger|edge|none] - scrollMethod [twoFinger|edge|onbutton|none]
- sendEventsMode [yes|no|disabledOnExternalMouse] - sendEventsMode [yes|no|disabledOnExternalMouse]
- calibrationMatrix [six float values split by space] - calibrationMatrix [six float values split by space]
- scrollFactor [float] - scrollFactor [float]
@ -618,6 +618,7 @@
<!-- <disableWhileTyping>yes</disableWhileTyping> --> <!-- <disableWhileTyping>yes</disableWhileTyping> -->
<!-- <clickMethod>buttonAreas</clickMethod> --> <!-- <clickMethod>buttonAreas</clickMethod> -->
<!-- <scrollMethod>twofinger</scrollMethod> --> <!-- <scrollMethod>twofinger</scrollMethod> -->
<!-- <scrollButton>274</scrollButton> -->
<!-- <sendEventsMode>yes</sendEventsMode> --> <!-- <sendEventsMode>yes</sendEventsMode> -->
<!-- <calibrationMatrix>1 0 0 0 1 0</calibrationMatrix> --> <!-- <calibrationMatrix>1 0 0 0 1 0</calibrationMatrix> -->
<scrollFactor>1.0</scrollFactor> <scrollFactor>1.0</scrollFactor>

View file

@ -31,6 +31,7 @@ struct libinput_category {
int dwt; /* -1 or libinput_config_dwt_state */ int dwt; /* -1 or libinput_config_dwt_state */
int click_method; /* -1 or libinput_config_click_method */ int click_method; /* -1 or libinput_config_click_method */
int scroll_method; /* -1 or libinput_config_scroll_method */ int scroll_method; /* -1 or libinput_config_scroll_method */
int scroll_button; /* -1 or a button from linux/input_event_codes.h */
int send_events_mode; /* -1 or libinput_config_send_events_mode */ int send_events_mode; /* -1 or libinput_config_send_events_mode */
bool have_calibration_matrix; bool have_calibration_matrix;
double scroll_factor; double scroll_factor;

View file

@ -25,6 +25,7 @@ libinput_category_init(struct libinput_category *l)
l->dwt = -1; l->dwt = -1;
l->click_method = -1; l->click_method = -1;
l->scroll_method = -1; l->scroll_method = -1;
l->scroll_button = -1;
l->send_events_mode = -1; l->send_events_mode = -1;
l->have_calibration_matrix = false; l->have_calibration_matrix = false;
l->scroll_factor = 1.0; l->scroll_factor = 1.0;

View file

@ -891,9 +891,19 @@ fill_libinput_category(xmlNode *node)
} else if (!strcasecmp(content, "twofinger")) { } else if (!strcasecmp(content, "twofinger")) {
category->scroll_method = category->scroll_method =
LIBINPUT_CONFIG_SCROLL_2FG; LIBINPUT_CONFIG_SCROLL_2FG;
} else if (!strcasecmp(content, "onbutton")) {
category->scroll_method =
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
} else { } else {
wlr_log(WLR_ERROR, "invalid scrollMethod"); wlr_log(WLR_ERROR, "invalid scrollMethod");
} }
} else if (!strcasecmp(key, "scrollButton")) {
int button = atoi(content);
if (button != 0) {
category->scroll_button = button;
} else {
wlr_log(WLR_ERROR, "invalid scrollButton");
}
} else if (!strcasecmp(key, "sendEventsMode")) { } else if (!strcasecmp(key, "sendEventsMode")) {
category->send_events_mode = category->send_events_mode =
get_send_events_mode(content); get_send_events_mode(content);

View file

@ -328,6 +328,16 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
libinput_device_config_scroll_set_method(libinput_dev, dc->scroll_method); libinput_device_config_scroll_set_method(libinput_dev, dc->scroll_method);
} }
libinput_device_config_scroll_set_button(libinput_dev,
libinput_device_config_scroll_get_default_button(libinput_dev));
if (dc->scroll_button < 0) {
wlr_log(WLR_INFO, "scroll button not configured");
} else {
wlr_log(WLR_INFO, "scroll button configured (%d)",
dc->scroll_button);
libinput_device_config_scroll_set_button(libinput_dev, dc->scroll_button);
}
libinput_device_config_send_events_set_mode(libinput_dev, libinput_device_config_send_events_set_mode(libinput_dev,
libinput_device_config_send_events_get_default_mode(libinput_dev)); libinput_device_config_send_events_get_default_mode(libinput_dev));
if ((dc->send_events_mode != LIBINPUT_CONFIG_SEND_EVENTS_ENABLED if ((dc->send_events_mode != LIBINPUT_CONFIG_SEND_EVENTS_ENABLED