From a662743610a61df07c6616230e66e78456ecdafb Mon Sep 17 00:00:00 2001 From: Simon Zeni Date: Tue, 1 Feb 2022 10:25:28 -0500 Subject: [PATCH] types/wlr_tablet_pad: add base wlr_input_device wlr_tablet_pad owns its wlr_input_device. It will be initialized when the tablet pad is initialized, and finished when the tablet pad is destroyed. --- backend/libinput/tablet_pad.c | 5 ++++- backend/wayland/tablet_v2.c | 2 +- include/wlr/interfaces/wlr_tablet_pad.h | 2 +- include/wlr/types/wlr_tablet_pad.h | 2 ++ types/wlr_tablet_pad.c | 7 ++++++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/libinput/tablet_pad.c b/backend/libinput/tablet_pad.c index c9ec30ae8..2f1da363d 100644 --- a/backend/libinput/tablet_pad.c +++ b/backend/libinput/tablet_pad.c @@ -75,7 +75,10 @@ struct wlr_tablet_pad *create_libinput_tablet_pad( wlr_log(WLR_ERROR, "Unable to allocate wlr_tablet_pad"); return NULL; } - wlr_tablet_pad_init(wlr_tablet_pad, NULL); + const char *name = libinput_device_get_name(libinput_dev); + wlr_tablet_pad_init(wlr_tablet_pad, NULL, name); + wlr_tablet_pad->base.vendor = libinput_device_get_id_vendor(libinput_dev); + wlr_tablet_pad->base.product = libinput_device_get_id_product(libinput_dev); wlr_tablet_pad->button_count = libinput_device_tablet_pad_get_num_buttons(libinput_dev); diff --git a/backend/wayland/tablet_v2.c b/backend/wayland/tablet_v2.c index cda651011..34056314b 100644 --- a/backend/wayland/tablet_v2.c +++ b/backend/wayland/tablet_v2.c @@ -453,7 +453,7 @@ static void handle_pad_added(void *data, zwp_tablet_pad_v2_destroy(id); return; } - wlr_tablet_pad_init(wlr_dev->tablet_pad, NULL); + wlr_tablet_pad_init(wlr_dev->tablet_pad, NULL, wlr_dev->name); zwp_tablet_pad_v2_add_listener(id, &tablet_pad_listener, dev); } diff --git a/include/wlr/interfaces/wlr_tablet_pad.h b/include/wlr/interfaces/wlr_tablet_pad.h index 86bbe9c39..b35f162e0 100644 --- a/include/wlr/interfaces/wlr_tablet_pad.h +++ b/include/wlr/interfaces/wlr_tablet_pad.h @@ -16,7 +16,7 @@ struct wlr_tablet_pad_impl { }; void wlr_tablet_pad_init(struct wlr_tablet_pad *pad, - struct wlr_tablet_pad_impl *impl); + struct wlr_tablet_pad_impl *impl, const char *name); void wlr_tablet_pad_destroy(struct wlr_tablet_pad *pad); #endif diff --git a/include/wlr/types/wlr_tablet_pad.h b/include/wlr/types/wlr_tablet_pad.h index 6cd1b70e4..f30809cf0 100644 --- a/include/wlr/types/wlr_tablet_pad.h +++ b/include/wlr/types/wlr_tablet_pad.h @@ -22,6 +22,8 @@ struct wlr_tablet_pad_impl; struct wlr_tablet_pad { + struct wlr_input_device base; + struct wlr_tablet_pad_impl *impl; struct { diff --git a/types/wlr_tablet_pad.c b/types/wlr_tablet_pad.c index 2bd996a66..7d5635f79 100644 --- a/types/wlr_tablet_pad.c +++ b/types/wlr_tablet_pad.c @@ -1,11 +1,15 @@ #include #include #include +#include #include #include void wlr_tablet_pad_init(struct wlr_tablet_pad *pad, - struct wlr_tablet_pad_impl *impl) { + struct wlr_tablet_pad_impl *impl, const char *name) { + wlr_input_device_init(&pad->base, WLR_INPUT_DEVICE_TABLET_PAD, NULL, name); + pad->base.tablet_pad = pad; + pad->impl = impl; wl_signal_init(&pad->events.button); wl_signal_init(&pad->events.ring); @@ -27,6 +31,7 @@ void wlr_tablet_pad_destroy(struct wlr_tablet_pad *pad) { } wl_array_release(&pad->paths); + wlr_input_device_finish(&pad->base); if (pad->impl && pad->impl->destroy) { pad->impl->destroy(pad); } else {