drop libevdev dependency

This commit is contained in:
illiliti 2022-11-30 04:53:36 +03:00
parent d41f11e6bd
commit 7fd06a62c8
10 changed files with 13 additions and 64 deletions

View file

@ -5,6 +5,7 @@
#include <wlr/types/wlr_pointer_constraints_v1.h>
#include <wlr/types/wlr_pointer_gestures_v1.h>
#include <wlr/types/wlr_compositor.h>
#include <linux/input.h>
#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

View file

@ -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

View file

@ -1,4 +1,3 @@
#include <libevdev/libevdev.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
@ -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;

View file

@ -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);
}

View file

@ -1,5 +1,4 @@
#define _POSIX_C_SOURCE 200809L
#include <libevdev/libevdev.h>
#include <linux/input-event-codes.h>
#include <string.h>
#include <strings.h>

View file

@ -1,4 +1,3 @@
#include <libevdev/libevdev.h>
#include "sway/config.h"
#include "sway/commands.h"
#include "sway/input/cursor.h"

View file

@ -1,7 +1,6 @@
#define _POSIX_C_SOURCE 200809L
#include <assert.h>
#include <math.h>
#include <libevdev/libevdev.h>
#include <linux/input-event-codes.h>
#include <errno.h>
#include <time.h>
@ -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;

View file

@ -1,6 +1,5 @@
#define _POSIX_C_SOURCE 200809L
#include <float.h>
#include <libevdev/libevdev.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_tablet_v2.h>
#include <wlr/types/wlr_xcursor_manager.h>

View file

@ -1,7 +1,6 @@
#include <ctype.h>
#include <float.h>
#include <json.h>
#include <libevdev/libevdev.h>
#include <stdio.h>
#include <wlr/config.h>
#include <wlr/types/wlr_content_type_v1.h>

View file

@ -214,7 +214,6 @@ sway_deps = [
cairo,
drm,
jsonc,
libevdev,
libinput,
libudev,
math,