mirror of
https://github.com/wizbright/waybox.git
synced 2025-10-29 05:40:20 -04:00
Added the ability to configure libinput
This commit is contained in:
parent
b4a05ca65b
commit
6c6d0214b4
7 changed files with 180 additions and 29 deletions
|
|
@ -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
|
||||
|
|
|
|||
42
data/rc.xml
42
data/rc.xml
|
|
@ -9,15 +9,15 @@
|
|||
<right>0</right>
|
||||
</margins>
|
||||
<keyboard>
|
||||
<!-- Keyboard layout. See `man xkeyboard-config` for more information -->
|
||||
<!-- XKB configuration. See `man xkeyboard-config` for more information -->
|
||||
<!-- You can use the XKB_* environment variables instead -->
|
||||
<!-- <keyboardLayout>
|
||||
<!-- <xkb>
|
||||
<model>105</model>
|
||||
<layout>us</layout>
|
||||
<options>ctrl:swapcaps,esperanto:dvorak,lv3:ralt_switch_multikey</options>
|
||||
<rules>evdev</rules>
|
||||
<variant>dvorak</variant>
|
||||
</keyboardLayout> -->
|
||||
</xkb> -->
|
||||
<!-- Keybindings for windows -->
|
||||
<keybind key="A-F4">
|
||||
<action name="Close"/>
|
||||
|
|
@ -42,25 +42,16 @@
|
|||
</keybind>
|
||||
<!-- Keybindings for window switching -->
|
||||
<keybind key="A-Tab">
|
||||
<action name="NextWindow">
|
||||
<finalactions>
|
||||
<action name="NextWindow"/>
|
||||
<action name="Unshade"/>
|
||||
</finalactions>
|
||||
</action>
|
||||
</keybind>
|
||||
<keybind key="A-S-ISO_Left_Tab">
|
||||
<action name="PreviousWindow">
|
||||
<finalactions>
|
||||
<action name="PreviousWindow"/>
|
||||
<action name="Unshade"/>
|
||||
</finalactions>
|
||||
</action>
|
||||
</keybind>
|
||||
<keybind key="C-A-Tab">
|
||||
<action name="NextWindow">
|
||||
<finalactions>
|
||||
<action name="NextWindow"/>
|
||||
<action name="Unshade"/>
|
||||
</finalactions>
|
||||
</action>
|
||||
</keybind>
|
||||
<!-- Keybindings for running applications -->
|
||||
<keybind key="W-Return">
|
||||
|
|
@ -115,4 +106,25 @@
|
|||
</action>
|
||||
</keybind>
|
||||
</keyboard>
|
||||
<!-- Configuration for mice and other pointers. <mouse> instead of <pointer> only for backwards compatibility. -->
|
||||
<mouse>
|
||||
<!-- libinput configuration. -->
|
||||
<!-- <libinput>
|
||||
<accelProfile>adaptive</accelProfile>
|
||||
<accelSpeed>0.9</accelSpeed>
|
||||
<calibrationMatrix>0 0 0 0 0 0</calibrationMatrix>
|
||||
<clickMethod>buttonAreas</clickMethod>
|
||||
<disableWhileTrackpointing>enabled</disableWhileTrackpointing>
|
||||
<disableWhileTyping>enabled</disableWhileTyping>
|
||||
<leftHanded>disabled</leftHanded>
|
||||
<middleEmulation>enabled</middleEmulation>
|
||||
<naturalScroll>disabled</naturalScroll>
|
||||
<scrollButtonLock>disabled</scrollButtonLock>
|
||||
<scrollMethod>twofinger</scrollMethod>
|
||||
<tap>enabled</tap>
|
||||
<tapButtonMap>lrm</tapButtonMap>
|
||||
<tapDrag>enabled</tapDrag>
|
||||
<tapDragLock>enabled</tapDragLock>
|
||||
</libinput> -->
|
||||
</mouse>
|
||||
</openbox_config>
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ wb_src = files(
|
|||
)
|
||||
|
||||
wb_dep = [
|
||||
libinput,
|
||||
libxml2,
|
||||
wayland_server,
|
||||
wlroots,
|
||||
|
|
|
|||
100
waybox/seat.c
100
waybox/seat.c
|
|
@ -1,5 +1,6 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <wlr/backend/libinput.h>
|
||||
#include <wlr/types/wlr_primary_selection.h>
|
||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue