interface/wlr_tablet_tool: rework destroy sequence

The destroy callback in wlr_tablet_tool_impl has been removed. The function
`wlr_tablet_tool_finish` has been introduced to clean up the resources owned by
a wlr_tablet_tool.

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

The field `name` has been added to the wlr_tablet_tool_impl to be able to
identify a given wlr_tablet_tool device.
This commit is contained in:
Simon Zeni 2022-03-02 15:58:44 -05:00 committed by Kirill Primak
parent a5b032cb1e
commit 8d3cb94b41
8 changed files with 34 additions and 41 deletions

View file

@ -2,7 +2,6 @@
#include <stdlib.h>
#include <string.h>
#include <wayland-server-core.h>
#include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/interfaces/wlr_touch.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/util/log.h>
@ -49,7 +48,7 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) {
wlr_touch_destroy(dev->touch);
break;
case WLR_INPUT_DEVICE_TABLET_TOOL:
wlr_tablet_destroy(dev->tablet);
wlr_log(WLR_ERROR, "wlr_tablet_tool will not be destroyed");
break;
case WLR_INPUT_DEVICE_TABLET_PAD:
wlr_log(WLR_ERROR, "wlr_tablet_pad will not be destroyed");

View file

@ -17,21 +17,12 @@ void wlr_tablet_init(struct wlr_tablet *tablet,
wl_array_init(&tablet->paths);
}
void wlr_tablet_destroy(struct wlr_tablet *tablet) {
if (!tablet) {
return;
}
void wlr_tablet_finish(struct wlr_tablet *tablet) {
wlr_input_device_finish(&tablet->base);
char **path_ptr;
wl_array_for_each(path_ptr, &tablet->paths) {
free(*path_ptr);
}
wl_array_release(&tablet->paths);
wlr_input_device_finish(&tablet->base);
if (tablet->impl && tablet->impl->destroy) {
tablet->impl->destroy(tablet);
} else {
free(tablet);
}
}