diff --git a/README.md b/README.md
index 384f1de..d009fbf 100644
--- a/README.md
+++ b/README.md
@@ -12,9 +12,10 @@ contributing.](https://github.com/wizbright/waybox/blob/master/CONTRIBUTING.md)
### Dependencies
* [Meson](https://mesonbuild.com/)
-* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots/)
-* [libxml2](http://xmlsoft.org/)
* [Wayland](https://wayland.freedesktop.org/)
+* [libinput](http://www.freedesktop.org/wiki/Software/libinput)
+* [libxml2](http://xmlsoft.org/)
+* [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots/)
* [xkbcommon](https://xkbcommon.org/)
### Build instructions
diff --git a/data/rc.xml b/data/rc.xml
index d3bb8fb..2f6ce06 100644
--- a/data/rc.xml
+++ b/data/rc.xml
@@ -9,15 +9,15 @@
0
-
+
-
+ -->
@@ -42,25 +42,16 @@
-
-
-
-
-
+
+
-
-
-
-
-
+
+
-
-
-
-
-
+
+
@@ -115,4 +106,25 @@
+
+
+
+
+
diff --git a/meson.build b/meson.build
index 3cc5c5c..22065cc 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,7 @@
project(
'Waybox',
'c',
- version: '0.2.1',
+ version: '0.2.2',
license: 'MIT',
meson_version: '>=0.52.0',
default_options: [
@@ -25,6 +25,7 @@ cc = meson.get_compiler('c')
# Adding include directory
inc_dir = include_directories('include')
+libinput = dependency('libinput', version: '>=1.21.0')
libxml2 = dependency('libxml-2.0')
wlroots = dependency('wlroots', version: '>=0.16.0')
wayland_server = dependency('wayland-server', version: '>=1.15')
diff --git a/waybox/config.c b/waybox/config.c
index 10452e7..7958c49 100644
--- a/waybox/config.c
+++ b/waybox/config.c
@@ -166,15 +166,34 @@ bool init_config(struct wb_server *server) {
wlr_log(WLR_INFO, "%s", _("Couldn't register the namespace"));
}
- config->keyboard_layout.use_config = parse_xpath_expr("//ob:keyboard//ob:keyboardLayout", ctxt) != NULL;
-
+ config->keyboard_layout.use_config = parse_xpath_expr("//ob:keyboard//ob:xkb", ctxt) != NULL;
if (config->keyboard_layout.use_config) {
- config->keyboard_layout.layout = parse_xpath_expr("//ob:keyboard//ob:keyboardLayout//ob:layout", ctxt);
- config->keyboard_layout.model = parse_xpath_expr("//ob:keyboard//ob:keyboardLayout//ob:model", ctxt);
- config->keyboard_layout.options = parse_xpath_expr("//ob:keyboard//ob:keyboardLayout//ob:options", ctxt);
- config->keyboard_layout.rules = parse_xpath_expr("//ob:keyboard//ob:keyboardLayout//ob:rules", ctxt);
- config->keyboard_layout.variant = parse_xpath_expr("//ob:keyboard//ob:keyboardLayout//ob:variant", ctxt);
+ config->keyboard_layout.layout = parse_xpath_expr("//ob:keyboard//ob:xkb//ob:layout", ctxt);
+ config->keyboard_layout.model = parse_xpath_expr("//ob:keyboard//ob:xkb//ob:model", ctxt);
+ config->keyboard_layout.options = parse_xpath_expr("//ob:keyboard//ob:xkb//ob:options", ctxt);
+ config->keyboard_layout.rules = parse_xpath_expr("//ob:keyboard//ob:xkb//ob:rules", ctxt);
+ config->keyboard_layout.variant = parse_xpath_expr("//ob:keyboard//ob:xkb//ob:variant", ctxt);
}
+
+ config->libinput_config.use_config = parse_xpath_expr("//ob:mouse//ob:libinput", ctxt) != NULL;
+ if (config->libinput_config.use_config) {
+ config->libinput_config.accel_profile = parse_xpath_expr("//ob:mouse//ob:libinput/ob:accelProfile", ctxt);
+ config->libinput_config.accel_speed = parse_xpath_expr("//ob:mouse//ob:libinput/ob:accelSpeed", ctxt);
+ config->libinput_config.calibration_matrix = parse_xpath_expr("//ob:mouse//ob:libinput/ob:calibrationMatrix", ctxt);
+ config->libinput_config.click_method = parse_xpath_expr("//ob:mouse//ob:libinput/ob:clickMethod", ctxt);
+ config->libinput_config.dwt = parse_xpath_expr("//ob:mouse//ob:libinput/ob:disableWhileTyping", ctxt);
+ config->libinput_config.dwtp = parse_xpath_expr("//ob:mouse//ob:libinput/ob:disableWhileTrackpointing", ctxt);
+ config->libinput_config.left_handed = parse_xpath_expr("//ob:mouse//ob:libinput/ob:leftHanded", ctxt);
+ config->libinput_config.middle_emulation = parse_xpath_expr("//ob:mouse//ob:libinput/ob:middleEmulation", ctxt);
+ config->libinput_config.natural_scroll = parse_xpath_expr("//ob:mouse//ob:libinput/ob:naturalScroll", ctxt);
+ config->libinput_config.scroll_button_lock = parse_xpath_expr("//ob:mouse//ob:libinput/ob:scrollButtonLock", ctxt);
+ config->libinput_config.scroll_method = parse_xpath_expr("//ob:mouse//ob:libinput/ob:scrollMethod", ctxt);
+ config->libinput_config.tap = parse_xpath_expr("//ob:mouse//ob:libinput/ob:tap", ctxt);
+ config->libinput_config.tap_button_map = parse_xpath_expr("//ob:mouse//ob:libinput/ob:tapButtonMap", ctxt);
+ config->libinput_config.tap_drag = parse_xpath_expr("//ob:mouse//ob:libinput/ob:tapDrag", ctxt);
+ config->libinput_config.tap_drag = parse_xpath_expr("//ob:mouse//ob:libinput/ob:tapDragLock", ctxt);
+ }
+
if (!parse_key_bindings(config, ctxt)) {
xmlFreeDoc(doc);
return false;
diff --git a/waybox/config.h b/waybox/config.h
index 82cca4d..b3375ae 100644
--- a/waybox/config.h
+++ b/waybox/config.h
@@ -27,6 +27,25 @@ struct wb_config {
bool use_config;
} keyboard_layout;
+ struct {
+ char *accel_profile;
+ char *accel_speed;
+ char *calibration_matrix;
+ char *click_method;
+ char *dwt;
+ char *dwtp;
+ char *left_handed;
+ char *middle_emulation;
+ char *natural_scroll;
+ char *scroll_button_lock;
+ char *scroll_method;
+ char *tap;
+ char *tap_button_map;
+ char *tap_drag;
+ char *tap_drag_lock;
+
+ bool use_config;
+ } libinput_config;
struct {
int bottom;
int left;
diff --git a/waybox/meson.build b/waybox/meson.build
index ff91dd8..e6280e9 100644
--- a/waybox/meson.build
+++ b/waybox/meson.build
@@ -11,6 +11,7 @@ wb_src = files(
)
wb_dep = [
+ libinput,
libxml2,
wayland_server,
wlroots,
diff --git a/waybox/seat.c b/waybox/seat.c
index 03c3d0e..b6f5f1d 100644
--- a/waybox/seat.c
+++ b/waybox/seat.c
@@ -1,5 +1,6 @@
#include
+#include
#include
#include
@@ -250,6 +251,103 @@ static void handle_new_keyboard(struct wb_server *server,
wl_list_insert(&server->seat->keyboards, &keyboard->link);
}
+static bool libinput_config_get_enabled(char *config) {
+ return strcmp(config, "disabled") != 0;
+}
+
+static void handle_new_pointer(struct wb_server *server, struct wlr_input_device *device) {
+ struct wb_config *config = server->config;
+ if (wlr_input_device_is_libinput(device) && config->libinput_config.use_config) {
+ struct libinput_device *libinput_handle =
+ wlr_libinput_get_device_handle(device);
+
+ if (config->libinput_config.accel_profile) {
+ enum libinput_config_accel_profile accel_profile =
+ LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
+ if (strcmp(config->libinput_config.accel_profile, "flat") == 0)
+ accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT;
+ else if (strcmp(config->libinput_config.accel_profile, "none") == 0)
+ accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
+ libinput_device_config_accel_set_profile(libinput_handle, accel_profile);
+ }
+ if (config->libinput_config.accel_speed) {
+ double accel_speed = strtod(config->libinput_config.accel_speed, NULL);
+ libinput_device_config_accel_set_speed(libinput_handle, accel_speed);
+ }
+ if (config->libinput_config.calibration_matrix) {
+ float matrix[6];
+ unsigned short i = 0;
+ while ((matrix[i] = strtod(strtok(config->libinput_config.calibration_matrix, " "), NULL) && i < 6)) {
+ config->libinput_config.calibration_matrix = NULL;
+ i++;
+ }
+ libinput_device_config_calibration_set_matrix(libinput_handle, matrix);
+ }
+ if (config->libinput_config.click_method) {
+ enum libinput_config_click_method click_method = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
+ if (strcmp(config->libinput_config.click_method, "clickfinger") == 0)
+ click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
+ else if (strcmp(config->libinput_config.scroll_method, "none") == 0)
+ click_method = LIBINPUT_CONFIG_CLICK_METHOD_NONE;
+ libinput_device_config_click_set_method(libinput_handle, click_method);
+ }
+ if (config->libinput_config.dwt) {
+ libinput_device_config_dwt_set_enabled(libinput_handle,
+ libinput_config_get_enabled(config->libinput_config.dwt));
+ }
+ if (config->libinput_config.dwtp) {
+ libinput_device_config_dwtp_set_enabled(libinput_handle,
+ libinput_config_get_enabled(config->libinput_config.dwtp));
+ }
+ if (config->libinput_config.left_handed) {
+ libinput_device_config_left_handed_set(libinput_handle,
+ libinput_config_get_enabled(config->libinput_config.left_handed));
+ }
+ if (config->libinput_config.middle_emulation) {
+ libinput_device_config_middle_emulation_set_enabled(libinput_handle,
+ libinput_config_get_enabled(config->libinput_config.middle_emulation));
+ }
+ if (config->libinput_config.natural_scroll) {
+ libinput_device_config_scroll_set_natural_scroll_enabled(libinput_handle,
+ libinput_config_get_enabled(config->libinput_config.natural_scroll));
+ }
+ if (config->libinput_config.scroll_button_lock) {
+ libinput_device_config_scroll_set_button_lock(libinput_handle,
+ libinput_config_get_enabled(config->libinput_config.scroll_button_lock));
+ }
+ if (config->libinput_config.scroll_method) {
+ enum libinput_config_scroll_method scroll_method = LIBINPUT_CONFIG_SCROLL_2FG;
+ if (strcmp(config->libinput_config.scroll_method, "edge") == 0)
+ scroll_method = LIBINPUT_CONFIG_SCROLL_EDGE;
+ else if (strcmp(config->libinput_config.scroll_method, "none") == 0)
+ scroll_method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
+ else if (strcmp(config->libinput_config.scroll_method, "button") == 0)
+ scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
+ libinput_device_config_scroll_set_method(libinput_handle, scroll_method);
+ }
+ if (config->libinput_config.tap) {
+ libinput_device_config_tap_set_enabled(libinput_handle,
+ libinput_config_get_enabled(config->libinput_config.tap));
+ }
+ if (config->libinput_config.tap_button_map) {
+ enum libinput_config_tap_button_map map = LIBINPUT_CONFIG_TAP_MAP_LRM;
+ if (strcmp(config->libinput_config.tap_button_map, "lmr") == 0)
+ map = LIBINPUT_CONFIG_TAP_MAP_LMR;
+ libinput_device_config_tap_set_button_map(libinput_handle, map);
+ }
+ if (config->libinput_config.tap_drag) {
+ libinput_device_config_tap_set_drag_enabled(libinput_handle,
+ libinput_config_get_enabled(config->libinput_config.tap_drag));
+ };
+ if (config->libinput_config.tap_drag_lock) {
+ libinput_device_config_tap_set_drag_lock_enabled(libinput_handle,
+ libinput_config_get_enabled(config->libinput_config.tap_drag_lock));
+ };
+ }
+
+ wlr_cursor_attach_input_device(server->cursor->cursor, device);
+}
+
static void new_input_notify(struct wl_listener *listener, void *data) {
struct wlr_input_device *device = data;
struct wb_server *server = wl_container_of(listener, server, new_input);
@@ -260,7 +358,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
break;
case WLR_INPUT_DEVICE_POINTER:
wlr_log(WLR_INFO, "%s: %s", _("New pointer detected"), device->name);
- wlr_cursor_attach_input_device(server->cursor->cursor, device);
+ handle_new_pointer(server, device);
break;
default:
wlr_log(WLR_INFO, "%s: %s", _("Unsupported input device detected"), device->name);