mirror of
https://github.com/swaywm/sway.git
synced 2025-02-17 14:54:27 +00:00
drop libevdev dependency
This commit is contained in:
parent
d41f11e6bd
commit
7fd06a62c8
|
@ -5,6 +5,7 @@
|
||||||
#include <wlr/types/wlr_pointer_constraints_v1.h>
|
#include <wlr/types/wlr_pointer_constraints_v1.h>
|
||||||
#include <wlr/types/wlr_pointer_gestures_v1.h>
|
#include <wlr/types/wlr_pointer_gestures_v1.h>
|
||||||
#include <wlr/types/wlr_compositor.h>
|
#include <wlr/types/wlr_compositor.h>
|
||||||
|
#include <linux/input.h>
|
||||||
#include "sway/input/seat.h"
|
#include "sway/input/seat.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
@ -138,6 +139,4 @@ uint32_t get_mouse_bindcode(const char *name, char **error);
|
||||||
// Considers both bindsym and bindcode
|
// Considers both bindsym and bindcode
|
||||||
uint32_t get_mouse_button(const char *name, char **error);
|
uint32_t get_mouse_button(const char *name, char **error);
|
||||||
|
|
||||||
const char *get_mouse_button_name(uint32_t button);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -75,7 +75,6 @@ pangocairo = dependency('pangocairo')
|
||||||
gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
|
gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
|
||||||
pixman = dependency('pixman-1')
|
pixman = dependency('pixman-1')
|
||||||
glesv2 = wlroots_features['gles2_renderer'] ? dependency('glesv2') : null_dep
|
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
|
libinput = wlroots_features['libinput_backend'] ? dependency('libinput', version: '>=1.21.0') : null_dep
|
||||||
xcb = dependency('xcb', required: get_option('xwayland'))
|
xcb = dependency('xcb', required: get_option('xwayland'))
|
||||||
drm_full = dependency('libdrm') # only needed for drm_fourcc.h
|
drm_full = dependency('libdrm') # only needed for drm_fourcc.h
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include <libevdev/libevdev.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
@ -11,7 +10,6 @@
|
||||||
|
|
||||||
static struct cmd_results *binding_add(struct bar_binding *binding,
|
static struct cmd_results *binding_add(struct bar_binding *binding,
|
||||||
list_t *mode_bindings) {
|
list_t *mode_bindings) {
|
||||||
const char *name = get_mouse_button_name(binding->button);
|
|
||||||
bool overwritten = false;
|
bool overwritten = false;
|
||||||
for (int i = 0; i < mode_bindings->length; i++) {
|
for (int i = 0; i < mode_bindings->length; i++) {
|
||||||
struct bar_binding *other = mode_bindings->items[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;
|
overwritten = true;
|
||||||
mode_bindings->items[i] = binding;
|
mode_bindings->items[i] = binding;
|
||||||
free_bar_binding(other);
|
free_bar_binding(other);
|
||||||
sway_log(SWAY_DEBUG, "[bar %s] Updated binding for %u (%s)%s",
|
sway_log(SWAY_DEBUG, "[bar %s] Updated binding for %u%s",
|
||||||
config->current_bar->id, binding->button, name,
|
config->current_bar->id, binding->button,
|
||||||
binding->release ? " - release" : "");
|
binding->release ? " - release" : "");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!overwritten) {
|
if (!overwritten) {
|
||||||
list_add(mode_bindings, binding);
|
list_add(mode_bindings, binding);
|
||||||
sway_log(SWAY_DEBUG, "[bar %s] Added binding for %u (%s)%s",
|
sway_log(SWAY_DEBUG, "[bar %s] Added binding for %u%s",
|
||||||
config->current_bar->id, binding->button, name,
|
config->current_bar->id, binding->button,
|
||||||
binding->release ? " - release" : "");
|
binding->release ? " - release" : "");
|
||||||
}
|
}
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
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,
|
static struct cmd_results *binding_remove(struct bar_binding *binding,
|
||||||
list_t *mode_bindings) {
|
list_t *mode_bindings) {
|
||||||
const char *name = get_mouse_button_name(binding->button);
|
|
||||||
for (int i = 0; i < mode_bindings->length; i++) {
|
for (int i = 0; i < mode_bindings->length; i++) {
|
||||||
struct bar_binding *other = mode_bindings->items[i];
|
struct bar_binding *other = mode_bindings->items[i];
|
||||||
if (other->button == binding->button &&
|
if (other->button == binding->button &&
|
||||||
other->release == binding->release) {
|
other->release == binding->release) {
|
||||||
sway_log(SWAY_DEBUG, "[bar %s] Unbound binding for %u (%s)%s",
|
sway_log(SWAY_DEBUG, "[bar %s] Unbound binding for %u%s",
|
||||||
config->current_bar->id, binding->button, name,
|
config->current_bar->id, binding->button,
|
||||||
binding->release ? " - release" : "");
|
binding->release ? " - release" : "");
|
||||||
free_bar_binding(other);
|
free_bar_binding(other);
|
||||||
free_bar_binding(binding);
|
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 "
|
struct cmd_results *error = cmd_results_new(CMD_FAILURE, "Could not "
|
||||||
"find binding for [bar %s]" " Button %u (%s)%s",
|
"find binding for [bar %s]" " Button %u%s",
|
||||||
config->current_bar->id, binding->button, name,
|
config->current_bar->id, binding->button,
|
||||||
binding->release ? " - release" : "");
|
binding->release ? " - release" : "");
|
||||||
free_bar_binding(binding);
|
free_bar_binding(binding);
|
||||||
return error;
|
return error;
|
||||||
|
|
|
@ -33,7 +33,6 @@ static struct cmd_results *tray_bind(int argc, char **argv, bool code) {
|
||||||
free(binding);
|
free(binding);
|
||||||
return cmd_results_new(CMD_INVALID, "Unknown button %s", argv[0]);
|
return cmd_results_new(CMD_INVALID, "Unknown button %s", argv[0]);
|
||||||
}
|
}
|
||||||
const char *name = get_mouse_button_name(binding->button);
|
|
||||||
|
|
||||||
static const char *commands[] = {
|
static const char *commands[] = {
|
||||||
"ContextMenu",
|
"ContextMenu",
|
||||||
|
@ -66,16 +65,16 @@ static struct cmd_results *tray_bind(int argc, char **argv, bool code) {
|
||||||
free(binding);
|
free(binding);
|
||||||
binding = other;
|
binding = other;
|
||||||
sway_log(SWAY_DEBUG,
|
sway_log(SWAY_DEBUG,
|
||||||
"[bar %s] Updated tray binding for %u (%s) to %s",
|
"[bar %s] Updated tray binding for %u to %s",
|
||||||
config->current_bar->id, binding->button, name,
|
config->current_bar->id, binding->button,
|
||||||
binding->command);
|
binding->command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!overwritten) {
|
if (!overwritten) {
|
||||||
wl_list_insert(&config->current_bar->tray_bindings, &binding->link);
|
wl_list_insert(&config->current_bar->tray_bindings, &binding->link);
|
||||||
sway_log(SWAY_DEBUG, "[bar %s] Added tray binding for %u (%s) to %s",
|
sway_log(SWAY_DEBUG, "[bar %s] Added tray binding for %u to %s",
|
||||||
config->current_bar->id, binding->button, name,
|
config->current_bar->id, binding->button,
|
||||||
binding->command);
|
binding->command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#include <libevdev/libevdev.h>
|
|
||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include <libevdev/libevdev.h>
|
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/input/cursor.h"
|
#include "sway/input/cursor.h"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <libevdev/libevdev.h>
|
|
||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <time.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_UP, SWAY_SCROLL_DOWN, SWAY_SCROLL_LEFT,
|
||||||
SWAY_SCROLL_RIGHT, BTN_SIDE, BTN_EXTRA};
|
SWAY_SCROLL_RIGHT, BTN_SIDE, BTN_EXTRA};
|
||||||
return buttons[number - 1];
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1275,17 +1262,6 @@ uint32_t get_mouse_bindcode(const char *name, char **error) {
|
||||||
*error = strdup("Button event code out of range.");
|
*error = strdup("Button event code out of range.");
|
||||||
return 0;
|
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;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1297,22 +1273,6 @@ uint32_t get_mouse_button(const char *name, char **error) {
|
||||||
return button;
|
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) {
|
static void warp_to_constraint_cursor_hint(struct sway_cursor *cursor) {
|
||||||
struct wlr_pointer_constraint_v1 *constraint = cursor->active_constraint;
|
struct wlr_pointer_constraint_v1 *constraint = cursor->active_constraint;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <libevdev/libevdev.h>
|
|
||||||
#include <wlr/types/wlr_cursor.h>
|
#include <wlr/types/wlr_cursor.h>
|
||||||
#include <wlr/types/wlr_tablet_v2.h>
|
#include <wlr/types/wlr_tablet_v2.h>
|
||||||
#include <wlr/types/wlr_xcursor_manager.h>
|
#include <wlr/types/wlr_xcursor_manager.h>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <json.h>
|
#include <json.h>
|
||||||
#include <libevdev/libevdev.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wlr/config.h>
|
#include <wlr/config.h>
|
||||||
#include <wlr/types/wlr_content_type_v1.h>
|
#include <wlr/types/wlr_content_type_v1.h>
|
||||||
|
|
|
@ -214,7 +214,6 @@ sway_deps = [
|
||||||
cairo,
|
cairo,
|
||||||
drm,
|
drm,
|
||||||
jsonc,
|
jsonc,
|
||||||
libevdev,
|
|
||||||
libinput,
|
libinput,
|
||||||
libudev,
|
libudev,
|
||||||
math,
|
math,
|
||||||
|
|
Loading…
Reference in a new issue