aboutsummaryrefslogtreecommitdiff
path: root/backend/libinput/events.c
diff options
context:
space:
mode:
authorSimon Zeni <simon@bl4ckb0ne.ca>2022-02-23 13:41:34 -0500
committerKirill Primak <vyivel@eclair.cafe>2022-03-02 18:18:05 +0000
commitd750c5ac676850d93ba7abf0a08476c4535ff1b6 (patch)
tree181187a77e53497b33ab8eddb752bb44c144eb41 /backend/libinput/events.c
parentd60cdad3ea1fed18bbda542b42d3fd7283c88909 (diff)
backend/libinput: rework switch interface
The wlr_libinput_input_device now owns its wlr_switch, instead of creating a new wlr_libinput_input_device for it.
Diffstat (limited to 'backend/libinput/events.c')
-rw-r--r--backend/libinput/events.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/backend/libinput/events.c b/backend/libinput/events.c
index a0563ecd..ad346c4f 100644
--- a/backend/libinput/events.c
+++ b/backend/libinput/events.c
@@ -43,6 +43,9 @@ void destroy_libinput_input_device(struct wlr_libinput_input_device *dev)
if (dev->pointer.impl) {
wlr_pointer_destroy(&dev->pointer);
}
+ if (dev->switch_device.impl) {
+ wlr_switch_destroy(&dev->switch_device);
+ }
}
libinput_device_unref(dev->handle);
@@ -140,6 +143,14 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
dev_used = true;
}
+ if (libinput_device_has_capability(
+ libinput_dev, LIBINPUT_DEVICE_CAP_SWITCH)) {
+ init_device_switch(dev);
+ wlr_signal_emit_safe(&backend->backend.events.new_input,
+ &dev->switch_device.base);
+ dev_used = true;
+ }
+
if (dev_used) {
wl_list_insert(&backend->devices, &dev->link);
return;
@@ -201,20 +212,6 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
libinput_dev, LIBINPUT_DEVICE_CAP_GESTURE)) {
// TODO
}
- if (libinput_device_has_capability(
- libinput_dev, LIBINPUT_DEVICE_CAP_SWITCH)) {
- struct wlr_input_device *wlr_dev = allocate_device(backend,
- libinput_dev, wlr_devices, WLR_INPUT_DEVICE_SWITCH);
- if (!wlr_dev) {
- goto fail;
- }
- wlr_dev->switch_device = create_libinput_switch(libinput_dev);
- if (!wlr_dev->switch_device) {
- free(wlr_dev);
- goto fail;
- }
- wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
- }
if (!wl_list_empty(wlr_devices)) {
struct wl_list **dst = wl_array_add(&backend->wlr_device_lists, sizeof(wlr_devices));
@@ -343,7 +340,7 @@ void handle_libinput_event(struct wlr_libinput_backend *backend,
handle_tablet_pad_strip(event, libinput_dev);
break;
case LIBINPUT_EVENT_SWITCH_TOGGLE:
- handle_switch_toggle(event, libinput_dev);
+ handle_switch_toggle(event, &dev->switch_device);
break;
case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN:
handle_pointer_swipe_begin(event, &dev->pointer);