From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Tue, 27 May 2025 12:19:21 +0000 (+0200) Subject: Add scroll method libinput option X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=fdab272bdcbdfd4ae196c2bd188844f73f8bfdfc;p=proto%2Flabwc.git Add scroll method libinput option none|twofinger|edge Fixes: #2766 --- diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index a6c1e90b..99414da1 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -941,6 +941,7 @@ extending outward from the snapped edge. + 1.0 @@ -1035,6 +1036,19 @@ extending outward from the snapped edge. The default method depends on the touchpad hardware. +** [none|twofinger|edge] + Configure the method by which physical movements on a touchpad are + mapped to scroll events. + + The scroll methods available are: + - *twofinger* - Scroll by two fingers being placed on the surface of the + touchpad, then moving those fingers vertically or horizontally. + - *edge* - Scroll by moving a single finger along the right edge + (vertical scroll) or bottom edge (horizontal scroll). + - *none* - No scroll events will be produced. + + The default method depends on the touchpad hardware. + ** [yes|no|disabledOnExternalMouse] Optionally enable or disable sending any device events. diff --git a/docs/rc.xml.all b/docs/rc.xml.all index 8d825f66..b4525223 100644 --- a/docs/rc.xml.all +++ b/docs/rc.xml.all @@ -635,6 +635,7 @@ + 1.0 diff --git a/include/config/libinput.h b/include/config/libinput.h index 94a99a3a..a891a33f 100644 --- a/include/config/libinput.h +++ b/include/config/libinput.h @@ -29,6 +29,7 @@ struct libinput_category { int middle_emu; /* -1 or libinput_config_middle_emulation_state */ int dwt; /* -1 or libinput_config_dwt_state */ int click_method; /* -1 or libinput_config_click_method */ + int scroll_method; /* -1 or libinput_config_scroll_method */ int send_events_mode; /* -1 or libinput_config_send_events_mode */ bool have_calibration_matrix; double scroll_factor; diff --git a/src/config/libinput.c b/src/config/libinput.c index 42ec647a..04b0a2b5 100644 --- a/src/config/libinput.c +++ b/src/config/libinput.c @@ -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; diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 08bdfe57..eab3f65b 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -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); diff --git a/src/seat.c b/src/seat.c index 09729f38..a88a37d1 100644 --- a/src/seat.c +++ b/src/seat.c @@ -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)