mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-01 22:58:38 -04:00
backend/libinput: rework pointer interface
The wlr_libinput_input_device now owns its wlr_pointer, instead of creating a new wlr_libinput_input_device for it
This commit is contained in:
parent
5eefda1ffe
commit
d60cdad3ea
4 changed files with 104 additions and 169 deletions
|
|
@ -40,6 +40,9 @@ void destroy_libinput_input_device(struct wlr_libinput_input_device *dev)
|
|||
if (dev->keyboard.impl) {
|
||||
wlr_keyboard_destroy(&dev->keyboard);
|
||||
}
|
||||
if (dev->pointer.impl) {
|
||||
wlr_pointer_destroy(&dev->pointer);
|
||||
}
|
||||
}
|
||||
|
||||
libinput_device_unref(dev->handle);
|
||||
|
|
@ -127,6 +130,15 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
|
|||
dev_used = true;
|
||||
}
|
||||
|
||||
if (libinput_device_has_capability(
|
||||
libinput_dev, LIBINPUT_DEVICE_CAP_POINTER)) {
|
||||
init_device_pointer(dev);
|
||||
|
||||
wlr_signal_emit_safe(&backend->backend.events.new_input,
|
||||
&dev->pointer.base);
|
||||
|
||||
dev_used = true;
|
||||
}
|
||||
|
||||
if (dev_used) {
|
||||
wl_list_insert(&backend->devices, &dev->link);
|
||||
|
|
@ -143,20 +155,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_POINTER)) {
|
||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||
libinput_dev, wlr_devices, WLR_INPUT_DEVICE_POINTER);
|
||||
if (!wlr_dev) {
|
||||
goto fail;
|
||||
}
|
||||
wlr_dev->pointer = create_libinput_pointer(libinput_dev);
|
||||
if (!wlr_dev->pointer) {
|
||||
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_TOUCH)) {
|
||||
struct wlr_input_device *wlr_dev = allocate_device(backend,
|
||||
|
|
@ -297,16 +295,16 @@ void handle_libinput_event(struct wlr_libinput_backend *backend,
|
|||
handle_keyboard_key(event, &dev->keyboard);
|
||||
break;
|
||||
case LIBINPUT_EVENT_POINTER_MOTION:
|
||||
handle_pointer_motion(event, libinput_dev);
|
||||
handle_pointer_motion(event, &dev->pointer);
|
||||
break;
|
||||
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
|
||||
handle_pointer_motion_abs(event, libinput_dev);
|
||||
handle_pointer_motion_abs(event, &dev->pointer);
|
||||
break;
|
||||
case LIBINPUT_EVENT_POINTER_BUTTON:
|
||||
handle_pointer_button(event, libinput_dev);
|
||||
handle_pointer_button(event, &dev->pointer);
|
||||
break;
|
||||
case LIBINPUT_EVENT_POINTER_AXIS:
|
||||
handle_pointer_axis(event, libinput_dev);
|
||||
handle_pointer_axis(event, &dev->pointer);
|
||||
break;
|
||||
case LIBINPUT_EVENT_TOUCH_DOWN:
|
||||
handle_touch_down(event, libinput_dev);
|
||||
|
|
@ -348,29 +346,29 @@ void handle_libinput_event(struct wlr_libinput_backend *backend,
|
|||
handle_switch_toggle(event, libinput_dev);
|
||||
break;
|
||||
case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN:
|
||||
handle_pointer_swipe_begin(event, libinput_dev);
|
||||
handle_pointer_swipe_begin(event, &dev->pointer);
|
||||
break;
|
||||
case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
|
||||
handle_pointer_swipe_update(event, libinput_dev);
|
||||
handle_pointer_swipe_update(event, &dev->pointer);
|
||||
break;
|
||||
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
|
||||
handle_pointer_swipe_end(event, libinput_dev);
|
||||
handle_pointer_swipe_end(event, &dev->pointer);
|
||||
break;
|
||||
case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN:
|
||||
handle_pointer_pinch_begin(event, libinput_dev);
|
||||
handle_pointer_pinch_begin(event, &dev->pointer);
|
||||
break;
|
||||
case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
|
||||
handle_pointer_pinch_update(event, libinput_dev);
|
||||
handle_pointer_pinch_update(event, &dev->pointer);
|
||||
break;
|
||||
case LIBINPUT_EVENT_GESTURE_PINCH_END:
|
||||
handle_pointer_pinch_end(event, libinput_dev);
|
||||
handle_pointer_pinch_end(event, &dev->pointer);
|
||||
break;
|
||||
#if LIBINPUT_HAS_HOLD_GESTURES
|
||||
case LIBINPUT_EVENT_GESTURE_HOLD_BEGIN:
|
||||
handle_pointer_hold_begin(event, libinput_dev);
|
||||
handle_pointer_hold_begin(event, &dev->pointer);
|
||||
break;
|
||||
case LIBINPUT_EVENT_GESTURE_HOLD_END:
|
||||
handle_pointer_hold_end(event, libinput_dev);
|
||||
handle_pointer_hold_end(event, &dev->pointer);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue