mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-31 22:25:21 -04:00
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.
This commit is contained in:
parent
d750c5ac67
commit
4f4dd95223
4 changed files with 63 additions and 87 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue