Add scroll method libinput option

<libinput>
  <device>
    <scrollMethod>none|twofinger|edge</scrollMethod>
  </device>
</libinput>

Fixes: #2766
This commit is contained in:
Consolatis 2025-05-27 14:19:21 +02:00 committed by Hiroaki Yamamoto
parent 8ba14891fa
commit fdab272bdc
6 changed files with 41 additions and 0 deletions

View file

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

View file

@ -810,6 +810,19 @@ fill_libinput_category(char *nodename, char *content, struct parser_state *state
} else {
wlr_log(WLR_ERROR, "invalid clickMethod");
}
} else if (!strcasecmp(nodename, "scrollMethod")) {
if (!strcasecmp(content, "none")) {
state->current_libinput_category->scroll_method =
LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
} else if (!strcasecmp(content, "edge")) {
state->current_libinput_category->scroll_method =
LIBINPUT_CONFIG_SCROLL_EDGE;
} else if (!strcasecmp(content, "twofinger")) {
state->current_libinput_category->scroll_method =
LIBINPUT_CONFIG_SCROLL_2FG;
} else {
wlr_log(WLR_ERROR, "invalid scrollMethod");
}
} else if (!strcasecmp(nodename, "sendEventsMode")) {
state->current_libinput_category->send_events_mode =
get_send_events_mode(content);

View file

@ -233,6 +233,17 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
libinput_device_config_click_set_method(libinput_dev, dc->click_method);
}
if (dc->scroll_method < 0) {
wlr_log(WLR_INFO, "scroll method not configured");
} else if (dc->scroll_method != LIBINPUT_CONFIG_SCROLL_NO_SCROLL
&& (libinput_device_config_scroll_get_methods(libinput_dev)
& dc->scroll_method) == 0) {
wlr_log(WLR_INFO, "scroll method not supported");
} else {
wlr_log(WLR_INFO, "scroll method configured");
libinput_device_config_scroll_set_method(libinput_dev, dc->scroll_method);
}
if ((dc->send_events_mode != LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
&& (libinput_device_config_send_events_get_modes(libinput_dev)
& dc->send_events_mode) == 0)