]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add scroll method libinput option
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Tue, 27 May 2025 12:19:21 +0000 (14:19 +0200)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Wed, 28 May 2025 05:43:51 +0000 (14:43 +0900)
<libinput>
  <device>
    <scrollMethod>none|twofinger|edge</scrollMethod>
  </device>
</libinput>

Fixes: #2766
docs/labwc-config.5.scd
docs/rc.xml.all
include/config/libinput.h
src/config/libinput.c
src/config/rcxml.c
src/seat.c

index a6c1e90b4ba010fddffa94987127c7a1b3b1885b..99414da1985035ff70c8ffa7cf63cdd091f036d8 100644 (file)
@@ -941,6 +941,7 @@ extending outward from the snapped edge.
     <middleEmulation></middleEmulation>
     <disableWhileTyping></disableWhileTyping>
     <clickMethod></clickMethod>
+    <scrollMethod></scrollMethod>
     <sendEventsMode></sendEventsMode>
     <calibrationMatrix></calibrationMatrix>
     <scrollFactor>1.0</scrollFactor>
@@ -1035,6 +1036,19 @@ extending outward from the snapped edge.
 
        The default method depends on the touchpad hardware.
 
+*<libinput><device><scrollMethod>* [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.
+
 *<libinput><device><sendEventsMode>* [yes|no|disabledOnExternalMouse]
        Optionally enable or disable sending any device events.
 
index 8d825f66b976a8637e2271465807232b144cd38f..b45252232e9277d810b602cd510ad61b73d10a90 100644 (file)
       <middleEmulation></middleEmulation>
       <disableWhileTyping></disableWhileTyping>
       <clickMethod></clickMethod>
+      <scrollMethod></scrollMethod>
       <sendEventsMode></sendEventsMode>
       <calibrationMatrix></calibrationMatrix>
       <scrollFactor>1.0</scrollFactor>
index 94a99a3a0c5dce04b81727c3f5bd3e5155dc2c7a..a891a33fc4eeae80da7a72c3189c61f504549f0f 100644 (file)
@@ -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;
index 42ec647afa6a808394cd06259ff0e347716a33eb..04b0a2b5af398da8b8525dd5f634e181ad1cb236 100644 (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;
index 08bdfe579247b6c16fdf2decd424d77914a25f9b..eab3f65b95af876ec5a431c0dbaeae546fbcc079 100644 (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);
index 09729f38c4da529d42ba4b3d8a9a033898d7cb28..a88a37d1501e467994f0ce36cbf249ab2384843e 100644 (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)