From 7fd06a62c8747a5e05f70dbe68f8b5cbddd4a344 Mon Sep 17 00:00:00 2001 From: illiliti Date: Wed, 30 Nov 2022 04:53:36 +0300 Subject: [PATCH] drop libevdev dependency --- include/sway/input/cursor.h | 3 +-- meson.build | 1 - sway/commands/bar/bind.c | 19 ++++++-------- sway/commands/bar/tray_bind.c | 9 +++---- sway/commands/bind.c | 1 - sway/commands/input/scroll_button.c | 1 - sway/input/cursor.c | 40 ----------------------------- sway/input/seatop_default.c | 1 - sway/ipc-json.c | 1 - sway/meson.build | 1 - 10 files changed, 13 insertions(+), 64 deletions(-) diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 8a2898dd..f9a07ab5 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "sway/input/seat.h" #include "config.h" @@ -138,6 +139,4 @@ uint32_t get_mouse_bindcode(const char *name, char **error); // Considers both bindsym and bindcode uint32_t get_mouse_button(const char *name, char **error); -const char *get_mouse_button_name(uint32_t button); - #endif diff --git a/meson.build b/meson.build index fa008332..cbc03fd0 100644 --- a/meson.build +++ b/meson.build @@ -75,7 +75,6 @@ pangocairo = dependency('pangocairo') gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf')) pixman = dependency('pixman-1') glesv2 = wlroots_features['gles2_renderer'] ? dependency('glesv2') : null_dep -libevdev = dependency('libevdev') libinput = wlroots_features['libinput_backend'] ? dependency('libinput', version: '>=1.21.0') : null_dep xcb = dependency('xcb', required: get_option('xwayland')) drm_full = dependency('libdrm') # only needed for drm_fourcc.h diff --git a/sway/commands/bar/bind.c b/sway/commands/bar/bind.c index b4b5bc45..61053159 100644 --- a/sway/commands/bar/bind.c +++ b/sway/commands/bar/bind.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -11,7 +10,6 @@ static struct cmd_results *binding_add(struct bar_binding *binding, list_t *mode_bindings) { - const char *name = get_mouse_button_name(binding->button); bool overwritten = false; for (int i = 0; i < mode_bindings->length; i++) { struct bar_binding *other = mode_bindings->items[i]; @@ -20,16 +18,16 @@ static struct cmd_results *binding_add(struct bar_binding *binding, overwritten = true; mode_bindings->items[i] = binding; free_bar_binding(other); - sway_log(SWAY_DEBUG, "[bar %s] Updated binding for %u (%s)%s", - config->current_bar->id, binding->button, name, + sway_log(SWAY_DEBUG, "[bar %s] Updated binding for %u%s", + config->current_bar->id, binding->button, binding->release ? " - release" : ""); break; } } if (!overwritten) { list_add(mode_bindings, binding); - sway_log(SWAY_DEBUG, "[bar %s] Added binding for %u (%s)%s", - config->current_bar->id, binding->button, name, + sway_log(SWAY_DEBUG, "[bar %s] Added binding for %u%s", + config->current_bar->id, binding->button, binding->release ? " - release" : ""); } return cmd_results_new(CMD_SUCCESS, NULL); @@ -37,13 +35,12 @@ static struct cmd_results *binding_add(struct bar_binding *binding, static struct cmd_results *binding_remove(struct bar_binding *binding, list_t *mode_bindings) { - const char *name = get_mouse_button_name(binding->button); for (int i = 0; i < mode_bindings->length; i++) { struct bar_binding *other = mode_bindings->items[i]; if (other->button == binding->button && other->release == binding->release) { - sway_log(SWAY_DEBUG, "[bar %s] Unbound binding for %u (%s)%s", - config->current_bar->id, binding->button, name, + sway_log(SWAY_DEBUG, "[bar %s] Unbound binding for %u%s", + config->current_bar->id, binding->button, binding->release ? " - release" : ""); free_bar_binding(other); free_bar_binding(binding); @@ -53,8 +50,8 @@ static struct cmd_results *binding_remove(struct bar_binding *binding, } struct cmd_results *error = cmd_results_new(CMD_FAILURE, "Could not " - "find binding for [bar %s]" " Button %u (%s)%s", - config->current_bar->id, binding->button, name, + "find binding for [bar %s]" " Button %u%s", + config->current_bar->id, binding->button, binding->release ? " - release" : ""); free_bar_binding(binding); return error; diff --git a/sway/commands/bar/tray_bind.c b/sway/commands/bar/tray_bind.c index 243834ba..a71ff0d1 100644 --- a/sway/commands/bar/tray_bind.c +++ b/sway/commands/bar/tray_bind.c @@ -33,7 +33,6 @@ static struct cmd_results *tray_bind(int argc, char **argv, bool code) { free(binding); return cmd_results_new(CMD_INVALID, "Unknown button %s", argv[0]); } - const char *name = get_mouse_button_name(binding->button); static const char *commands[] = { "ContextMenu", @@ -66,16 +65,16 @@ static struct cmd_results *tray_bind(int argc, char **argv, bool code) { free(binding); binding = other; sway_log(SWAY_DEBUG, - "[bar %s] Updated tray binding for %u (%s) to %s", - config->current_bar->id, binding->button, name, + "[bar %s] Updated tray binding for %u to %s", + config->current_bar->id, binding->button, binding->command); break; } } if (!overwritten) { wl_list_insert(&config->current_bar->tray_bindings, &binding->link); - sway_log(SWAY_DEBUG, "[bar %s] Added tray binding for %u (%s) to %s", - config->current_bar->id, binding->button, name, + sway_log(SWAY_DEBUG, "[bar %s] Added tray binding for %u to %s", + config->current_bar->id, binding->button, binding->command); } diff --git a/sway/commands/bind.c b/sway/commands/bind.c index c0b383db..ae868148 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c @@ -1,5 +1,4 @@ #define _POSIX_C_SOURCE 200809L -#include #include #include #include diff --git a/sway/commands/input/scroll_button.c b/sway/commands/input/scroll_button.c index 6b331419..1f3eada2 100644 --- a/sway/commands/input/scroll_button.c +++ b/sway/commands/input/scroll_button.c @@ -1,4 +1,3 @@ -#include #include "sway/config.h" #include "sway/commands.h" #include "sway/input/cursor.h" diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 449aa430..47960bf7 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -1,7 +1,6 @@ #define _POSIX_C_SOURCE 200809L #include #include -#include #include #include #include @@ -1247,18 +1246,6 @@ uint32_t get_mouse_bindsym(const char *name, char **error) { SWAY_SCROLL_UP, SWAY_SCROLL_DOWN, SWAY_SCROLL_LEFT, SWAY_SCROLL_RIGHT, BTN_SIDE, BTN_EXTRA}; return buttons[number - 1]; - } else if (strncmp(name, "BTN_", strlen("BTN_")) == 0) { - // Get event code from name - int code = libevdev_event_code_from_name(EV_KEY, name); - if (code == -1) { - size_t len = snprintf(NULL, 0, "Unknown event %s", name) + 1; - *error = malloc(len); - if (*error) { - snprintf(*error, len, "Unknown event %s", name); - } - return 0; - } - return code; } return 0; } @@ -1275,17 +1262,6 @@ uint32_t get_mouse_bindcode(const char *name, char **error) { *error = strdup("Button event code out of range."); return 0; } - const char *event = libevdev_event_code_get_name(EV_KEY, code); - if (!event || strncmp(event, "BTN_", strlen("BTN_")) != 0) { - size_t len = snprintf(NULL, 0, "Event code %d (%s) is not a button", - code, event ? event : "(null)") + 1; - *error = malloc(len); - if (*error) { - snprintf(*error, len, "Event code %d (%s) is not a button", - code, event ? event : "(null)"); - } - return 0; - } return code; } @@ -1297,22 +1273,6 @@ uint32_t get_mouse_button(const char *name, char **error) { return button; } -const char *get_mouse_button_name(uint32_t button) { - const char *name = libevdev_event_code_get_name(EV_KEY, button); - if (!name) { - if (button == SWAY_SCROLL_UP) { - name = "SWAY_SCROLL_UP"; - } else if (button == SWAY_SCROLL_DOWN) { - name = "SWAY_SCROLL_DOWN"; - } else if (button == SWAY_SCROLL_LEFT) { - name = "SWAY_SCROLL_LEFT"; - } else if (button == SWAY_SCROLL_RIGHT) { - name = "SWAY_SCROLL_RIGHT"; - } - } - return name; -} - static void warp_to_constraint_cursor_hint(struct sway_cursor *cursor) { struct wlr_pointer_constraint_v1 *constraint = cursor->active_constraint; diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index 84acefdf..3efb5784 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -1,6 +1,5 @@ #define _POSIX_C_SOURCE 200809L #include -#include #include #include #include diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 8aa9557e..78a98355 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include diff --git a/sway/meson.build b/sway/meson.build index de10e14f..a9612035 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -214,7 +214,6 @@ sway_deps = [ cairo, drm, jsonc, - libevdev, libinput, libudev, math,