interface/wlr_tablet_pad: rework destroy sequence

The destroy callback in wlr_tablet_pad_impl has been removed. The function
`wlr_tablet_pad_finish` has been introduced to clean up the resources owned by a
wlr_tablet_pad.

`wlr_input_device_destroy` no longer destroys the wlr_tablet_pad, attempting to
destroy a wlr_tablet_pad will result in a no-op.

The field `name` has been added to the wlr_tablet_pad_impl to be able to identify
a given wlr_tablet_pad device.
This commit is contained in:
Simon Zeni 2022-03-02 15:11:25 -05:00 committed by Kirill Primak
parent 0d2be496a8
commit a5b032cb1e
8 changed files with 51 additions and 50 deletions

View file

@ -2,7 +2,6 @@
#include <stdlib.h>
#include <string.h>
#include <wayland-server-core.h>
#include <wlr/interfaces/wlr_tablet_pad.h>
#include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/interfaces/wlr_touch.h>
#include <wlr/types/wlr_input_device.h>
@ -53,7 +52,7 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) {
wlr_tablet_destroy(dev->tablet);
break;
case WLR_INPUT_DEVICE_TABLET_PAD:
wlr_tablet_pad_destroy(dev->tablet_pad);
wlr_log(WLR_ERROR, "wlr_tablet_pad will not be destroyed");
break;
}
} else {

View file

@ -3,6 +3,7 @@
#include <wayland-server-core.h>
#include <wlr/interfaces/wlr_tablet_pad.h>
#include <wlr/types/wlr_tablet_pad.h>
#include <wlr/util/log.h>
void wlr_tablet_pad_init(struct wlr_tablet_pad *pad,
const struct wlr_tablet_pad_impl *impl, const char *name) {
@ -19,10 +20,8 @@ void wlr_tablet_pad_init(struct wlr_tablet_pad *pad,
wl_array_init(&pad->paths);
}
void wlr_tablet_pad_destroy(struct wlr_tablet_pad *pad) {
if (!pad) {
return;
}
void wlr_tablet_pad_finish(struct wlr_tablet_pad *pad) {
wlr_input_device_finish(&pad->base);
char **path_ptr;
wl_array_for_each(path_ptr, &pad->paths) {
@ -30,10 +29,8 @@ 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 {
free(pad);
/* TODO: wlr_tablet_pad should own its wlr_tablet_pad_group */
if (!wl_list_empty(&pad->groups)) {
wlr_log(WLR_ERROR, "wlr_tablet_pad groups is not empty");
}
}