interface/wlr_switch: rework destroy sequence

The destroy callback in wlr_switch_impl has been removed. The function
`wlr_switch_finish` has been introduced to clean up the resources owned by a
wlr_switch.

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

The field `name` has been added to the wlr_switch_impl to be able to identify
a given wlr_switch device.
This commit is contained in:
Simon Zeni 2022-03-02 14:17:31 -05:00 committed by Kirill Primak
parent 51cd3c0726
commit 0d2be496a8
6 changed files with 10 additions and 19 deletions

View file

@ -2,7 +2,6 @@
#include <stdlib.h>
#include <string.h>
#include <wayland-server-core.h>
#include <wlr/interfaces/wlr_switch.h>
#include <wlr/interfaces/wlr_tablet_pad.h>
#include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/interfaces/wlr_touch.h>
@ -45,7 +44,7 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) {
wlr_log(WLR_ERROR, "wlr_pointer will not be destroyed");
break;
case WLR_INPUT_DEVICE_SWITCH:
wlr_switch_destroy(dev->switch_device);
wlr_log(WLR_ERROR, "wlr_switch will not be destroyed");
break;
case WLR_INPUT_DEVICE_TOUCH:
wlr_touch_destroy(dev->touch);

View file

@ -13,14 +13,6 @@ void wlr_switch_init(struct wlr_switch *switch_device,
wl_signal_init(&switch_device->events.toggle);
}
void wlr_switch_destroy(struct wlr_switch *switch_device) {
if (!switch_device) {
return;
}
void wlr_switch_finish(struct wlr_switch *switch_device) {
wlr_input_device_finish(&switch_device->base);
if (switch_device->impl && switch_device->impl->destroy) {
switch_device->impl->destroy(switch_device);
} else {
free(switch_device);
}
}