]> git.mdlowis.com Git - proto/labwc.git/commitdiff
partial libinput configuration
authorARDiDo <90479315+ARDiDo@users.noreply.github.com>
Sat, 9 Oct 2021 13:10:26 +0000 (09:10 -0400)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 10 Oct 2021 10:34:48 +0000 (11:34 +0100)
include/config/rcxml.h
src/config/rcxml.c
src/seat.c

index 72bea661534e4a8a0514c8de462cc85a568cd8a2..2ab7904e55a339f0071e6c2cb6f5457cc395e559 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <wayland-server-core.h>
+#include <libinput.h>
 
 #include "common/buf.h"
 
@@ -21,6 +22,13 @@ struct rcxml {
        struct wl_list keybinds;
        struct wl_list mousebinds;
        long doubleclick_time; /* in ms */
+       float pointer_speed;
+       int natural_scroll;
+       int left_handed;
+       enum libinput_config_tap_state tap;
+       enum libinput_config_accel_profile accel_profile;
+       enum libinput_config_middle_emulation_state middle_emu;
+       enum libinput_config_dwt_state dwt;
 };
 
 extern struct rcxml rc;
index 8b0aa82161b948a377cd45b5026e205765915ffb..afd504f94add18dc387e9d9f5450f406d01b4748 100644 (file)
@@ -113,6 +113,21 @@ get_bool(const char *s)
        return false;
 }
 
+static enum libinput_config_accel_profile
+get_accel_profile(const char *s)
+{
+       if (!s) {
+               return LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
+       }
+       if (!strcasecmp(s, "flat")) {
+               return LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
+       }
+       if (!strcasecmp(s, "adaptive")) {
+               return LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
+       }
+       return LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
+}
+
 static void
 fill_font(char *nodename, char *content, enum font_place place)
 {
@@ -238,6 +253,24 @@ entry(xmlNode *node, char *nodename, char *content)
                }
        } else if (!strcasecmp(nodename, "name.context.mouse")) {
                current_mouse_context = content;
+       } else if (!strcasecmp(nodename, "PointerSpeed.libinput")) {
+               rc.pointer_speed = atof(content);
+       } else if (!strcasecmp(nodename, "NaturalScroll.libinput")) {
+               rc.natural_scroll = get_bool(content) ? 1 : 0;
+       } else if (!strcasecmp(nodename, "LeftHanded.libinput")) {
+               rc.left_handed = get_bool(content) ? 1 : 0;
+       } else if (!strcasecmp(nodename, "Tap.libinput")) {
+               rc.tap = get_bool(content) ? LIBINPUT_CONFIG_TAP_ENABLED :
+                               LIBINPUT_CONFIG_TAP_DISABLED;
+       } else if (!strcasecmp(nodename, "MiddleEmulation.libinput")) {
+               rc.middle_emu = get_bool(content) ? 
+                               LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED : 
+                               LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
+       } else if (!strcasecmp(nodename, "DisableWhileTyping.libinput")) {
+               rc.dwt = get_bool(content) ? LIBINPUT_CONFIG_DWT_ENABLED :
+                               LIBINPUT_CONFIG_DWT_DISABLED;
+       } else if (!strcasecmp(nodename, "AccelerationProfile.libinput")) {
+               rc.accel_profile = get_accel_profile(content);
        }
 }
 
@@ -322,6 +355,13 @@ rcxml_init()
        rc.font_size_activewindow = 10;
        rc.font_size_menuitem = 10;
        rc.doubleclick_time = 500;
+       rc.pointer_speed = -2;
+       rc.natural_scroll = -1;
+       rc.left_handed = -1;
+       rc.tap = LIBINPUT_CONFIG_TAP_ENABLED;
+       rc.accel_profile = -1;
+       rc.middle_emu = -1;
+       rc.dwt = -1;
 }
 
 static struct {
index a5e832397a6b6e5e5f4664dfa8c651a1d372b922..ba40f5d24a7ba7aa5cfef22681e7a13255ce2897 100644 (file)
@@ -29,12 +29,62 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
                wlr_log(WLR_ERROR, "no libinput_dev");
                return;
        }
+
        if (libinput_device_config_tap_get_finger_count(libinput_dev) <= 0) {
-               return;
+               wlr_log(WLR_INFO, "tap unavailable");
+       } else {
+               wlr_log(WLR_INFO, "tap configured");
+               libinput_device_config_tap_set_enabled(libinput_dev, rc.tap);
+       }
+
+       if (libinput_device_config_scroll_has_natural_scroll(libinput_dev) <= 0
+               || rc.natural_scroll < 0) {
+               wlr_log(WLR_INFO, "natural scroll not configured");
+       } else {
+               wlr_log(WLR_INFO, "natural scroll configured");
+               libinput_device_config_scroll_set_natural_scroll_enabled(
+                       libinput_dev, rc.natural_scroll);
+       }
+
+       if (libinput_device_config_left_handed_is_available(libinput_dev) <= 0
+               || rc.left_handed < 0) {
+               wlr_log(WLR_INFO, "left-handed mode not configured");
+       } else {
+               wlr_log(WLR_INFO, "left-handed mode configured");
+               libinput_device_config_left_handed_set(libinput_dev,
+                       rc.left_handed);
+       }
+
+       if (libinput_device_config_accel_is_available(libinput_dev) == 0) {
+               wlr_log(WLR_INFO, "pointer acceleration unavailable");
+       } else {
+               wlr_log(WLR_INFO, "pointer acceleration configured");
+               if (rc.pointer_speed > -1) {
+                       libinput_device_config_accel_set_speed(libinput_dev, 
+                               rc.pointer_speed);
+               }
+               if (rc.accel_profile > 0) {
+                       libinput_device_config_accel_set_profile(libinput_dev,
+                               rc.accel_profile);
+               }
+       }
+
+       if (libinput_device_config_middle_emulation_is_available(libinput_dev)
+                       == 0 || rc.dwt < 0)  {
+               wlr_log(WLR_INFO, "middle emulation not configured");
+       } else {
+               wlr_log(WLR_INFO, "middle emulation configured");
+               libinput_device_config_middle_emulation_set_enabled(
+                       libinput_dev, rc.middle_emu);
+       }
+
+       if (libinput_device_config_dwt_is_available(libinput_dev) == 0
+               || rc.dwt < 0) {
+               wlr_log(WLR_INFO, "dwt not configured");
+       } else {
+               wlr_log(WLR_INFO, "dwt configured");
+               libinput_device_config_dwt_set_enabled(libinput_dev, rc.dwt);
        }
-       wlr_log(WLR_INFO, "tap enabled");
-       libinput_device_config_tap_set_enabled(libinput_dev,
-               LIBINPUT_CONFIG_TAP_ENABLED);
 }
 
 void