mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-26 22:55:58 +01:00
backend/libinput: add assertions
This commit is contained in:
parent
bc34486c04
commit
7bcf0d9599
6 changed files with 94 additions and 52 deletions
|
@ -7,6 +7,12 @@
|
||||||
#include "backend/libinput.h"
|
#include "backend/libinput.h"
|
||||||
#include "util/signal.h"
|
#include "util/signal.h"
|
||||||
|
|
||||||
|
static struct wlr_libinput_backend *get_libinput_backend_from_backend(
|
||||||
|
struct wlr_backend *wlr_backend) {
|
||||||
|
assert(wlr_backend_is_libinput(wlr_backend));
|
||||||
|
return (struct wlr_libinput_backend *)wlr_backend;
|
||||||
|
}
|
||||||
|
|
||||||
static int libinput_open_restricted(const char *path,
|
static int libinput_open_restricted(const char *path,
|
||||||
int flags, void *_backend) {
|
int flags, void *_backend) {
|
||||||
struct wlr_libinput_backend *backend = _backend;
|
struct wlr_libinput_backend *backend = _backend;
|
||||||
|
@ -43,9 +49,9 @@ static void log_libinput(struct libinput *libinput_context,
|
||||||
_wlr_vlog(WLR_ERROR, fmt, args);
|
_wlr_vlog(WLR_ERROR, fmt, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool backend_start(struct wlr_backend *_backend) {
|
static bool backend_start(struct wlr_backend *wlr_backend) {
|
||||||
struct wlr_libinput_backend *backend =
|
struct wlr_libinput_backend *backend =
|
||||||
(struct wlr_libinput_backend *)_backend;
|
get_libinput_backend_from_backend(wlr_backend);
|
||||||
wlr_log(WLR_DEBUG, "Initializing libinput");
|
wlr_log(WLR_DEBUG, "Initializing libinput");
|
||||||
|
|
||||||
backend->libinput_context = libinput_udev_create_context(&libinput_impl,
|
backend->libinput_context = libinput_udev_create_context(&libinput_impl,
|
||||||
|
@ -101,7 +107,7 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct wlr_libinput_backend *backend =
|
struct wlr_libinput_backend *backend =
|
||||||
(struct wlr_libinput_backend *)wlr_backend;
|
get_libinput_backend_from_backend(wlr_backend);
|
||||||
|
|
||||||
for (size_t i = 0; i < backend->wlr_device_lists.length; i++) {
|
for (size_t i = 0; i < backend->wlr_device_lists.length; i++) {
|
||||||
struct wl_list *wlr_devices = backend->wlr_device_lists.items[i];
|
struct wl_list *wlr_devices = backend->wlr_device_lists.items[i];
|
||||||
|
@ -158,9 +164,8 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,
|
struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,
|
||||||
struct wlr_session *session) {
|
struct wlr_session *session) {
|
||||||
assert(display && session);
|
struct wlr_libinput_backend *backend =
|
||||||
|
calloc(1, sizeof(struct wlr_libinput_backend));
|
||||||
struct wlr_libinput_backend *backend = calloc(1, sizeof(struct wlr_libinput_backend));
|
|
||||||
if (!backend) {
|
if (!backend) {
|
||||||
wlr_log(WLR_ERROR, "Allocation failed: %s", strerror(errno));
|
wlr_log(WLR_ERROR, "Allocation failed: %s", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -187,8 +192,10 @@ error_backend:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct libinput_device *wlr_libinput_get_device_handle(struct wlr_input_device *_dev) {
|
struct libinput_device *wlr_libinput_get_device_handle(
|
||||||
struct wlr_libinput_input_device *dev = (struct wlr_libinput_input_device *)_dev;
|
struct wlr_input_device *wlr_dev) {
|
||||||
|
struct wlr_libinput_input_device *dev =
|
||||||
|
(struct wlr_libinput_input_device *)wlr_dev;
|
||||||
return dev->handle;
|
return dev->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,12 @@
|
||||||
#include "backend/libinput.h"
|
#include "backend/libinput.h"
|
||||||
#include "util/signal.h"
|
#include "util/signal.h"
|
||||||
|
|
||||||
|
struct wlr_libinput_input_device *get_libinput_device_from_device(
|
||||||
|
struct wlr_input_device *wlr_dev) {
|
||||||
|
assert(wlr_input_device_is_libinput(wlr_dev));
|
||||||
|
return (struct wlr_libinput_input_device *)wlr_dev;
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_input_device *get_appropriate_device(
|
struct wlr_input_device *get_appropriate_device(
|
||||||
enum wlr_input_device_type desired_type,
|
enum wlr_input_device_type desired_type,
|
||||||
struct libinput_device *libinput_dev) {
|
struct libinput_device *libinput_dev) {
|
||||||
|
@ -25,8 +31,9 @@ struct wlr_input_device *get_appropriate_device(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void input_device_destroy(struct wlr_input_device *_dev) {
|
static void input_device_destroy(struct wlr_input_device *wlr_dev) {
|
||||||
struct wlr_libinput_input_device *dev = (struct wlr_libinput_input_device *)_dev;
|
struct wlr_libinput_input_device *dev =
|
||||||
|
get_libinput_device_from_device(wlr_dev);
|
||||||
libinput_device_unref(dev->handle);
|
libinput_device_unref(dev->handle);
|
||||||
wl_list_remove(&dev->wlr_input_device.link);
|
wl_list_remove(&dev->wlr_input_device.link);
|
||||||
free(dev);
|
free(dev);
|
||||||
|
@ -37,16 +44,18 @@ static const struct wlr_input_device_impl input_device_impl = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct wlr_input_device *allocate_device(
|
static struct wlr_input_device *allocate_device(
|
||||||
struct wlr_libinput_backend *backend, struct libinput_device *libinput_dev,
|
struct wlr_libinput_backend *backend,
|
||||||
struct wl_list *wlr_devices, enum wlr_input_device_type type) {
|
struct libinput_device *libinput_dev, struct wl_list *wlr_devices,
|
||||||
|
enum wlr_input_device_type type) {
|
||||||
int vendor = libinput_device_get_id_vendor(libinput_dev);
|
int vendor = libinput_device_get_id_vendor(libinput_dev);
|
||||||
int product = libinput_device_get_id_product(libinput_dev);
|
int product = libinput_device_get_id_product(libinput_dev);
|
||||||
const char *name = libinput_device_get_name(libinput_dev);
|
const char *name = libinput_device_get_name(libinput_dev);
|
||||||
struct wlr_libinput_input_device *wlr_libinput_dev;
|
struct wlr_libinput_input_device *dev =
|
||||||
if (!(wlr_libinput_dev = calloc(1, sizeof(struct wlr_libinput_input_device)))) {
|
calloc(1, sizeof(struct wlr_libinput_input_device));
|
||||||
|
if (dev == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
struct wlr_input_device *wlr_dev = &wlr_libinput_dev->wlr_input_device;
|
struct wlr_input_device *wlr_dev = &dev->wlr_input_device;
|
||||||
libinput_device_get_size(libinput_dev,
|
libinput_device_get_size(libinput_dev,
|
||||||
&wlr_dev->width_mm, &wlr_dev->height_mm);
|
&wlr_dev->width_mm, &wlr_dev->height_mm);
|
||||||
const char *output_name = libinput_device_get_output_name(libinput_dev);
|
const char *output_name = libinput_device_get_output_name(libinput_dev);
|
||||||
|
@ -54,7 +63,7 @@ static struct wlr_input_device *allocate_device(
|
||||||
wlr_dev->output_name = strdup(output_name);
|
wlr_dev->output_name = strdup(output_name);
|
||||||
}
|
}
|
||||||
wl_list_insert(wlr_devices, &wlr_dev->link);
|
wl_list_insert(wlr_devices, &wlr_dev->link);
|
||||||
wlr_libinput_dev->handle = libinput_dev;
|
dev->handle = libinput_dev;
|
||||||
libinput_device_ref(libinput_dev);
|
libinput_device_ref(libinput_dev);
|
||||||
wlr_input_device_init(wlr_dev, type, &input_device_impl,
|
wlr_input_device_init(wlr_dev, type, &input_device_impl,
|
||||||
name, vendor, product);
|
name, vendor, product);
|
||||||
|
@ -67,7 +76,6 @@ bool wlr_input_device_is_libinput(struct wlr_input_device *wlr_dev) {
|
||||||
|
|
||||||
static void handle_device_added(struct wlr_libinput_backend *backend,
|
static void handle_device_added(struct wlr_libinput_backend *backend,
|
||||||
struct libinput_device *libinput_dev) {
|
struct libinput_device *libinput_dev) {
|
||||||
assert(backend && libinput_dev);
|
|
||||||
/*
|
/*
|
||||||
* Note: the wlr API exposes only devices with a single capability, because
|
* Note: the wlr API exposes only devices with a single capability, because
|
||||||
* that meshes better with how Wayland does things and is a bit simpler.
|
* that meshes better with how Wayland does things and is a bit simpler.
|
||||||
|
@ -85,7 +93,8 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
||||||
wl_list_init(wlr_devices);
|
wl_list_init(wlr_devices);
|
||||||
wlr_log(WLR_DEBUG, "Added %s [%d:%d]", name, vendor, product);
|
wlr_log(WLR_DEBUG, "Added %s [%d:%d]", name, vendor, product);
|
||||||
|
|
||||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) {
|
if (libinput_device_has_capability(
|
||||||
|
libinput_dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) {
|
||||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||||
libinput_dev, wlr_devices, WLR_INPUT_DEVICE_KEYBOARD);
|
libinput_dev, wlr_devices, WLR_INPUT_DEVICE_KEYBOARD);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
|
@ -98,7 +107,8 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
||||||
}
|
}
|
||||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
||||||
}
|
}
|
||||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_POINTER)) {
|
if (libinput_device_has_capability(
|
||||||
|
libinput_dev, LIBINPUT_DEVICE_CAP_POINTER)) {
|
||||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||||
libinput_dev, wlr_devices, WLR_INPUT_DEVICE_POINTER);
|
libinput_dev, wlr_devices, WLR_INPUT_DEVICE_POINTER);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
|
@ -111,7 +121,8 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
||||||
}
|
}
|
||||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
||||||
}
|
}
|
||||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TOUCH)) {
|
if (libinput_device_has_capability(
|
||||||
|
libinput_dev, LIBINPUT_DEVICE_CAP_TOUCH)) {
|
||||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||||
libinput_dev, wlr_devices, WLR_INPUT_DEVICE_TOUCH);
|
libinput_dev, wlr_devices, WLR_INPUT_DEVICE_TOUCH);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
|
@ -124,7 +135,8 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
||||||
}
|
}
|
||||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
||||||
}
|
}
|
||||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TABLET_TOOL)) {
|
if (libinput_device_has_capability(libinput_dev,
|
||||||
|
LIBINPUT_DEVICE_CAP_TABLET_TOOL)) {
|
||||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||||
libinput_dev, wlr_devices, WLR_INPUT_DEVICE_TABLET_TOOL);
|
libinput_dev, wlr_devices, WLR_INPUT_DEVICE_TABLET_TOOL);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
|
@ -137,7 +149,8 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
||||||
}
|
}
|
||||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
||||||
}
|
}
|
||||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TABLET_PAD)) {
|
if (libinput_device_has_capability(
|
||||||
|
libinput_dev, LIBINPUT_DEVICE_CAP_TABLET_PAD)) {
|
||||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||||
libinput_dev, wlr_devices, WLR_INPUT_DEVICE_TABLET_PAD);
|
libinput_dev, wlr_devices, WLR_INPUT_DEVICE_TABLET_PAD);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
|
@ -150,14 +163,16 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
||||||
}
|
}
|
||||||
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
|
||||||
}
|
}
|
||||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_GESTURE)) {
|
if (libinput_device_has_capability(
|
||||||
|
libinput_dev, LIBINPUT_DEVICE_CAP_GESTURE)) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_SWITCH)) {
|
if (libinput_device_has_capability(
|
||||||
|
libinput_dev, LIBINPUT_DEVICE_CAP_SWITCH)) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_list_length(wlr_devices) > 0) {
|
if (!wl_list_empty(wlr_devices)) {
|
||||||
libinput_device_set_user_data(libinput_dev, wlr_devices);
|
libinput_device_set_user_data(libinput_dev, wlr_devices);
|
||||||
wlr_list_push(&backend->wlr_device_lists, wlr_devices);
|
wlr_list_push(&backend->wlr_device_lists, wlr_devices);
|
||||||
} else {
|
} else {
|
||||||
|
@ -199,7 +214,6 @@ static void handle_device_removed(struct wlr_libinput_backend *backend,
|
||||||
|
|
||||||
void handle_libinput_event(struct wlr_libinput_backend *backend,
|
void handle_libinput_event(struct wlr_libinput_backend *backend,
|
||||||
struct libinput_event *event) {
|
struct libinput_event *event) {
|
||||||
assert(backend && event);
|
|
||||||
struct libinput_device *libinput_dev = libinput_event_get_device(event);
|
struct libinput_device *libinput_dev = libinput_event_get_device(event);
|
||||||
enum libinput_event_type event_type = libinput_event_get_type(event);
|
enum libinput_event_type event_type = libinput_event_get_type(event);
|
||||||
switch (event_type) {
|
switch (event_type) {
|
||||||
|
|
|
@ -12,35 +12,43 @@ struct wlr_libinput_keyboard {
|
||||||
struct libinput_device *libinput_dev;
|
struct libinput_device *libinput_dev;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct wlr_keyboard_impl impl;
|
||||||
|
|
||||||
|
static struct wlr_libinput_keyboard *get_libinput_keyboard_from_keyboard(
|
||||||
|
struct wlr_keyboard *wlr_kb) {
|
||||||
|
assert(wlr_kb->impl == &impl);
|
||||||
|
return (struct wlr_libinput_keyboard *)wlr_kb;
|
||||||
|
}
|
||||||
|
|
||||||
static void keyboard_set_leds(struct wlr_keyboard *wlr_kb, uint32_t leds) {
|
static void keyboard_set_leds(struct wlr_keyboard *wlr_kb, uint32_t leds) {
|
||||||
struct wlr_libinput_keyboard *wlr_libinput_kb =
|
struct wlr_libinput_keyboard *kb =
|
||||||
(struct wlr_libinput_keyboard *)wlr_kb;
|
get_libinput_keyboard_from_keyboard(wlr_kb);
|
||||||
libinput_device_led_update(wlr_libinput_kb->libinput_dev, leds);
|
libinput_device_led_update(kb->libinput_dev, leds);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keyboard_destroy(struct wlr_keyboard *wlr_kb) {
|
static void keyboard_destroy(struct wlr_keyboard *wlr_kb) {
|
||||||
struct wlr_libinput_keyboard *wlr_libinput_kb =
|
struct wlr_libinput_keyboard *kb =
|
||||||
(struct wlr_libinput_keyboard *)wlr_kb;
|
get_libinput_keyboard_from_keyboard(wlr_kb);
|
||||||
libinput_device_unref(wlr_libinput_kb->libinput_dev);
|
libinput_device_unref(kb->libinput_dev);
|
||||||
free(wlr_libinput_kb);
|
free(kb);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_keyboard_impl impl = {
|
static const struct wlr_keyboard_impl impl = {
|
||||||
.destroy = keyboard_destroy,
|
.destroy = keyboard_destroy,
|
||||||
.led_update = keyboard_set_leds
|
.led_update = keyboard_set_leds
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_keyboard *create_libinput_keyboard(
|
struct wlr_keyboard *create_libinput_keyboard(
|
||||||
struct libinput_device *libinput_dev) {
|
struct libinput_device *libinput_dev) {
|
||||||
assert(libinput_dev);
|
struct wlr_libinput_keyboard *kb =
|
||||||
struct wlr_libinput_keyboard *wlr_libinput_kb;
|
calloc(1, sizeof(struct wlr_libinput_keyboard));
|
||||||
if (!(wlr_libinput_kb= calloc(1, sizeof(struct wlr_libinput_keyboard)))) {
|
if (kb == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
wlr_libinput_kb->libinput_dev = libinput_dev;
|
kb->libinput_dev = libinput_dev;
|
||||||
libinput_device_ref(libinput_dev);
|
libinput_device_ref(libinput_dev);
|
||||||
libinput_device_led_update(libinput_dev, 0);
|
libinput_device_led_update(libinput_dev, 0);
|
||||||
struct wlr_keyboard *wlr_kb = &wlr_libinput_kb->wlr_keyboard;
|
struct wlr_keyboard *wlr_kb = &kb->wlr_keyboard;
|
||||||
wlr_keyboard_init(wlr_kb, &impl);
|
wlr_keyboard_init(wlr_kb, &impl);
|
||||||
return wlr_kb;
|
return wlr_kb;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +58,8 @@ void handle_keyboard_key(struct libinput_event *event,
|
||||||
struct wlr_input_device *wlr_dev =
|
struct wlr_input_device *wlr_dev =
|
||||||
get_appropriate_device(WLR_INPUT_DEVICE_KEYBOARD, libinput_dev);
|
get_appropriate_device(WLR_INPUT_DEVICE_KEYBOARD, libinput_dev);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
wlr_log(WLR_DEBUG, "Got a keyboard event for a device with no keyboards?");
|
wlr_log(WLR_DEBUG,
|
||||||
|
"Got a keyboard event for a device with no keyboards?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct libinput_event_keyboard *kbevent =
|
struct libinput_event_keyboard *kbevent =
|
||||||
|
|
|
@ -69,7 +69,8 @@ static void add_pad_group_from_libinput(struct wlr_tablet_pad *pad,
|
||||||
struct wlr_tablet_pad *create_libinput_tablet_pad(
|
struct wlr_tablet_pad *create_libinput_tablet_pad(
|
||||||
struct libinput_device *libinput_dev) {
|
struct libinput_device *libinput_dev) {
|
||||||
assert(libinput_dev);
|
assert(libinput_dev);
|
||||||
struct wlr_tablet_pad *wlr_tablet_pad = calloc(1, sizeof(struct wlr_tablet_pad));
|
struct wlr_tablet_pad *wlr_tablet_pad =
|
||||||
|
calloc(1, sizeof(struct wlr_tablet_pad));
|
||||||
if (!wlr_tablet_pad) {
|
if (!wlr_tablet_pad) {
|
||||||
wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_pad");
|
wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_pad");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -101,7 +102,8 @@ void handle_tablet_pad_button(struct libinput_event *event,
|
||||||
struct wlr_input_device *wlr_dev =
|
struct wlr_input_device *wlr_dev =
|
||||||
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_PAD, libinput_dev);
|
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_PAD, libinput_dev);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
wlr_log(WLR_DEBUG, "Got a tablet pad event for a device with no tablet pad?");
|
wlr_log(WLR_DEBUG,
|
||||||
|
"Got a tablet pad event for a device with no tablet pad?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct libinput_event_tablet_pad *pevent =
|
struct libinput_event_tablet_pad *pevent =
|
||||||
|
@ -129,7 +131,8 @@ void handle_tablet_pad_ring(struct libinput_event *event,
|
||||||
struct wlr_input_device *wlr_dev =
|
struct wlr_input_device *wlr_dev =
|
||||||
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_PAD, libinput_dev);
|
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_PAD, libinput_dev);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
wlr_log(WLR_DEBUG, "Got a tablet pad event for a device with no tablet pad?");
|
wlr_log(WLR_DEBUG,
|
||||||
|
"Got a tablet pad event for a device with no tablet pad?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct libinput_event_tablet_pad *pevent =
|
struct libinput_event_tablet_pad *pevent =
|
||||||
|
@ -156,7 +159,8 @@ void handle_tablet_pad_strip(struct libinput_event *event,
|
||||||
struct wlr_input_device *wlr_dev =
|
struct wlr_input_device *wlr_dev =
|
||||||
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_PAD, libinput_dev);
|
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_PAD, libinput_dev);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
wlr_log(WLR_DEBUG, "Got a tablet pad event for a device with no tablet pad?");
|
wlr_log(WLR_DEBUG,
|
||||||
|
"Got a tablet pad event for a device with no tablet pad?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct libinput_event_tablet_pad *pevent =
|
struct libinput_event_tablet_pad *pevent =
|
||||||
|
|
|
@ -156,7 +156,8 @@ static struct wlr_libinput_tablet_tool *get_wlr_tablet_tool(
|
||||||
static void ensure_tool_reference(struct wlr_libinput_tablet_tool *tool,
|
static void ensure_tool_reference(struct wlr_libinput_tablet_tool *tool,
|
||||||
struct wlr_tablet *wlr_dev) {
|
struct wlr_tablet *wlr_dev) {
|
||||||
assert(tablet_is_libinput(wlr_dev));
|
assert(tablet_is_libinput(wlr_dev));
|
||||||
struct wlr_libinput_tablet *tablet = wl_container_of(wlr_dev, tablet, wlr_tablet);
|
struct wlr_libinput_tablet *tablet =
|
||||||
|
wl_container_of(wlr_dev, tablet, wlr_tablet);
|
||||||
|
|
||||||
struct tablet_tool_list_elem *pos;
|
struct tablet_tool_list_elem *pos;
|
||||||
wl_list_for_each(pos, &tablet->tools, link) {
|
wl_list_for_each(pos, &tablet->tools, link) {
|
||||||
|
@ -188,7 +189,8 @@ void handle_tablet_tool_axis(struct libinput_event *event,
|
||||||
struct wlr_input_device *wlr_dev =
|
struct wlr_input_device *wlr_dev =
|
||||||
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_TOOL, libinput_dev);
|
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_TOOL, libinput_dev);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
wlr_log(WLR_DEBUG, "Got a tablet tool event for a device with no tablet tools?");
|
wlr_log(WLR_DEBUG,
|
||||||
|
"Got a tablet tool event for a device with no tablet tools?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct libinput_event_tablet_tool *tevent =
|
struct libinput_event_tablet_tool *tevent =
|
||||||
|
@ -248,7 +250,8 @@ void handle_tablet_tool_proximity(struct libinput_event *event,
|
||||||
struct wlr_input_device *wlr_dev =
|
struct wlr_input_device *wlr_dev =
|
||||||
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_TOOL, libinput_dev);
|
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_TOOL, libinput_dev);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
wlr_log(WLR_DEBUG, "Got a tablet tool event for a device with no tablet tools?");
|
wlr_log(WLR_DEBUG,
|
||||||
|
"Got a tablet tool event for a device with no tablet tools?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct libinput_event_tablet_tool *tevent =
|
struct libinput_event_tablet_tool *tevent =
|
||||||
|
@ -272,14 +275,16 @@ void handle_tablet_tool_proximity(struct libinput_event *event,
|
||||||
}
|
}
|
||||||
wlr_signal_emit_safe(&wlr_dev->tablet->events.proximity, &wlr_event);
|
wlr_signal_emit_safe(&wlr_dev->tablet->events.proximity, &wlr_event);
|
||||||
|
|
||||||
if (libinput_event_tablet_tool_get_proximity_state(tevent) == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN) {
|
if (libinput_event_tablet_tool_get_proximity_state(tevent) ==
|
||||||
|
LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN) {
|
||||||
handle_tablet_tool_axis(event, libinput_dev);
|
handle_tablet_tool_axis(event, libinput_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the tool is not unique, libinput will not find it again after the
|
// If the tool is not unique, libinput will not find it again after the
|
||||||
// proximity out, so we should destroy it
|
// proximity out, so we should destroy it
|
||||||
if (!tool->unique &&
|
if (!tool->unique &&
|
||||||
libinput_event_tablet_tool_get_proximity_state(tevent) == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT) {
|
libinput_event_tablet_tool_get_proximity_state(tevent) ==
|
||||||
|
LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT) {
|
||||||
// The tool isn't unique, it can't be on multiple tablets
|
// The tool isn't unique, it can't be on multiple tablets
|
||||||
assert(tool->pad_refs == 1);
|
assert(tool->pad_refs == 1);
|
||||||
assert(tablet_is_libinput(wlr_dev->tablet));
|
assert(tablet_is_libinput(wlr_dev->tablet));
|
||||||
|
@ -305,7 +310,8 @@ void handle_tablet_tool_tip(struct libinput_event *event,
|
||||||
struct wlr_input_device *wlr_dev =
|
struct wlr_input_device *wlr_dev =
|
||||||
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_TOOL, libinput_dev);
|
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_TOOL, libinput_dev);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
wlr_log(WLR_DEBUG, "Got a tablet tool event for a device with no tablet tools?");
|
wlr_log(WLR_DEBUG,
|
||||||
|
"Got a tablet tool event for a device with no tablet tools?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handle_tablet_tool_axis(event, libinput_dev);
|
handle_tablet_tool_axis(event, libinput_dev);
|
||||||
|
@ -336,7 +342,8 @@ void handle_tablet_tool_button(struct libinput_event *event,
|
||||||
struct wlr_input_device *wlr_dev =
|
struct wlr_input_device *wlr_dev =
|
||||||
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_TOOL, libinput_dev);
|
get_appropriate_device(WLR_INPUT_DEVICE_TABLET_TOOL, libinput_dev);
|
||||||
if (!wlr_dev) {
|
if (!wlr_dev) {
|
||||||
wlr_log(WLR_DEBUG, "Got a tablet tool event for a device with no tablet tools?");
|
wlr_log(WLR_DEBUG,
|
||||||
|
"Got a tablet tool event for a device with no tablet tools?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handle_tablet_tool_axis(event, libinput_dev);
|
handle_tablet_tool_axis(event, libinput_dev);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <libinput.h>
|
#include <libinput.h>
|
||||||
#include <wayland-server-core.h>
|
#include <wayland-server-core.h>
|
||||||
#include <wlr/backend/interface.h>
|
#include <wlr/backend/interface.h>
|
||||||
|
#include <wlr/backend/libinput.h>
|
||||||
#include <wlr/interfaces/wlr_input_device.h>
|
#include <wlr/interfaces/wlr_input_device.h>
|
||||||
#include <wlr/types/wlr_input_device.h>
|
#include <wlr/types/wlr_input_device.h>
|
||||||
#include <wlr/types/wlr_list.h>
|
#include <wlr/types/wlr_list.h>
|
||||||
|
|
Loading…
Reference in a new issue