diff options
author | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-02-23 14:06:02 -0500 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2022-03-02 18:18:05 +0000 |
commit | 4f4dd9522378f4d62a47ee9b1472378c9960b2f2 (patch) | |
tree | cc69e9030642d3bef7f37cccee209b5a17806994 /backend/libinput/events.c | |
parent | d750c5ac676850d93ba7abf0a08476c4535ff1b6 (diff) |
backend/libinput: rework touch interface
The wlr_libinput_input_device now owns its wlr_touch, instead of creating
a new wlr_libinput_input_device for it.
Diffstat (limited to 'backend/libinput/events.c')
-rw-r--r-- | backend/libinput/events.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/backend/libinput/events.c b/backend/libinput/events.c index ad346c4f..14678dbd 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -46,6 +46,9 @@ void destroy_libinput_input_device(struct wlr_libinput_input_device *dev) if (dev->switch_device.impl) { wlr_switch_destroy(&dev->switch_device); } + if (dev->touch.impl) { + wlr_touch_destroy(&dev->touch); + } } libinput_device_unref(dev->handle); @@ -151,6 +154,14 @@ static void handle_device_added(struct wlr_libinput_backend *backend, dev_used = true; } + if (libinput_device_has_capability( + libinput_dev, LIBINPUT_DEVICE_CAP_TOUCH)) { + init_device_touch(dev); + wlr_signal_emit_safe(&backend->backend.events.new_input, + &dev->touch.base); + dev_used = true; + } + if (dev_used) { wl_list_insert(&backend->devices, &dev->link); return; @@ -166,20 +177,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_TOUCH)) { - struct wlr_input_device *wlr_dev = allocate_device(backend, - libinput_dev, wlr_devices, WLR_INPUT_DEVICE_TOUCH); - if (!wlr_dev) { - goto fail; - } - wlr_dev->touch = create_libinput_touch(libinput_dev); - if (!wlr_dev->touch) { - 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_TOOL)) { struct wlr_input_device *wlr_dev = allocate_device(backend, @@ -304,19 +301,19 @@ void handle_libinput_event(struct wlr_libinput_backend *backend, handle_pointer_axis(event, &dev->pointer); break; case LIBINPUT_EVENT_TOUCH_DOWN: - handle_touch_down(event, libinput_dev); + handle_touch_down(event, &dev->touch); break; case LIBINPUT_EVENT_TOUCH_UP: - handle_touch_up(event, libinput_dev); + handle_touch_up(event, &dev->touch); break; case LIBINPUT_EVENT_TOUCH_MOTION: - handle_touch_motion(event, libinput_dev); + handle_touch_motion(event, &dev->touch); break; case LIBINPUT_EVENT_TOUCH_CANCEL: - handle_touch_cancel(event, libinput_dev); + handle_touch_cancel(event, &dev->touch); break; case LIBINPUT_EVENT_TOUCH_FRAME: - handle_touch_frame(event, libinput_dev); + handle_touch_frame(event, &dev->touch); break; case LIBINPUT_EVENT_TABLET_TOOL_AXIS: handle_tablet_tool_axis(event, libinput_dev); |