mirror of
https://github.com/labwc/labwc.git
synced 2025-11-01 22:58:47 -04:00
partial libinput configuration
This commit is contained in:
parent
6a00166cff
commit
3dc4c02c54
3 changed files with 102 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
58
src/seat.c
58
src/seat.c
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue