aboutsummaryrefslogtreecommitdiff
path: root/backend/libinput/events.c
diff options
context:
space:
mode:
authorSimon Zeni <simon@bl4ckb0ne.ca>2022-02-24 11:00:11 -0500
committerKirill Primak <vyivel@eclair.cafe>2022-03-02 18:18:05 +0000
commitc8456086a164fd62c26fe3f3ade5f1e59d25eda0 (patch)
tree46956351eb341cd1a943dbe082d9dd6b0a16e69a /backend/libinput/events.c
parent4f4dd9522378f4d62a47ee9b1472378c9960b2f2 (diff)
backend/libinput: rework tablet interface
The wlr_libinput_device owns its wlr_tablet and its associated wlr_tablet_tools
Diffstat (limited to 'backend/libinput/events.c')
-rw-r--r--backend/libinput/events.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/backend/libinput/events.c b/backend/libinput/events.c
index 14678dbd..76e7709c 100644
--- a/backend/libinput/events.c
+++ b/backend/libinput/events.c
@@ -49,6 +49,9 @@ void destroy_libinput_input_device(struct wlr_libinput_input_device *dev)
if (dev->touch.impl) {
wlr_touch_destroy(&dev->touch);
}
+ if (dev->tablet.impl) {
+ wlr_tablet_destroy(&dev->tablet);
+ }
}
libinput_device_unref(dev->handle);
@@ -162,6 +165,14 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
dev_used = true;
}
+ if (libinput_device_has_capability(libinput_dev,
+ LIBINPUT_DEVICE_CAP_TABLET_TOOL)) {
+ init_device_tablet(dev);
+ wlr_signal_emit_safe(&backend->backend.events.new_input,
+ &dev->tablet.base);
+ dev_used = true;
+ }
+
if (dev_used) {
wl_list_insert(&backend->devices, &dev->link);
return;
@@ -177,20 +188,6 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
}
wl_list_init(wlr_devices);
- if (libinput_device_has_capability(libinput_dev,
- LIBINPUT_DEVICE_CAP_TABLET_TOOL)) {
- struct wlr_input_device *wlr_dev = allocate_device(backend,
- libinput_dev, wlr_devices, WLR_INPUT_DEVICE_TABLET_TOOL);
- if (!wlr_dev) {
- goto fail;
- }
- wlr_dev->tablet = create_libinput_tablet(libinput_dev);
- if (!wlr_dev->tablet) {
- free(wlr_dev);
- goto fail;
- }
- wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
- }
if (libinput_device_has_capability(
libinput_dev, LIBINPUT_DEVICE_CAP_TABLET_PAD)) {
struct wlr_input_device *wlr_dev = allocate_device(backend,
@@ -316,16 +313,16 @@ void handle_libinput_event(struct wlr_libinput_backend *backend,
handle_touch_frame(event, &dev->touch);
break;
case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
- handle_tablet_tool_axis(event, libinput_dev);
+ handle_tablet_tool_axis(event, &dev->tablet);
break;
case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY:
- handle_tablet_tool_proximity(event, libinput_dev);
+ handle_tablet_tool_proximity(event, &dev->tablet);
break;
case LIBINPUT_EVENT_TABLET_TOOL_TIP:
- handle_tablet_tool_tip(event, libinput_dev);
+ handle_tablet_tool_tip(event, &dev->tablet);
break;
case LIBINPUT_EVENT_TABLET_TOOL_BUTTON:
- handle_tablet_tool_button(event, libinput_dev);
+ handle_tablet_tool_button(event, &dev->tablet);
break;
case LIBINPUT_EVENT_TABLET_PAD_BUTTON:
handle_tablet_pad_button(event, libinput_dev);