diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 22fdab556..dcf46bee8 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -21,7 +21,7 @@ void destroy_libinput_input_device(struct wlr_libinput_input_device *dev) { wlr_pointer_finish(&dev->pointer); } if (dev->switch_device.impl) { - wlr_switch_destroy(&dev->switch_device); + wlr_switch_finish(&dev->switch_device); } if (dev->touch.impl) { wlr_touch_destroy(&dev->touch); diff --git a/backend/libinput/switch.c b/backend/libinput/switch.c index f2d5409b8..586ec0c80 100644 --- a/backend/libinput/switch.c +++ b/backend/libinput/switch.c @@ -4,12 +4,8 @@ #include "backend/libinput.h" #include "util/signal.h" -static void switch_destroy(struct wlr_switch *wlr_switch) { - /* wlr_switch belongs to the wlr_libinput_input_device */ -} - const struct wlr_switch_impl libinput_switch_impl = { - .destroy = switch_destroy, + .name = "libinput-switch", }; void init_device_switch(struct wlr_libinput_input_device *dev) { diff --git a/backend/wayland/seat.c b/backend/wayland/seat.c index 1edd0f2c0..02d4d874c 100644 --- a/backend/wayland/seat.c +++ b/backend/wayland/seat.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -555,6 +556,9 @@ void destroy_wl_input_device(struct wlr_wl_input_device *dev) { /* Owned by wlr_wl_pointer */ pointer_destroy(wlr_dev->pointer); break; + case WLR_INPUT_DEVICE_SWITCH: + wlr_switch_finish(wlr_dev->switch_device); + break; default: wlr_input_device_destroy(wlr_dev); break; diff --git a/include/wlr/interfaces/wlr_switch.h b/include/wlr/interfaces/wlr_switch.h index fbf5e6cb9..793ed25c2 100644 --- a/include/wlr/interfaces/wlr_switch.h +++ b/include/wlr/interfaces/wlr_switch.h @@ -12,11 +12,11 @@ #include struct wlr_switch_impl { - void (*destroy)(struct wlr_switch *switch_device); + const char *name; }; void wlr_switch_init(struct wlr_switch *switch_device, const struct wlr_switch_impl *impl, const char *name); -void wlr_switch_destroy(struct wlr_switch *switch_device); +void wlr_switch_finish(struct wlr_switch *switch_device); #endif diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index 6bf42de97..7a323df34 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include @@ -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); diff --git a/types/wlr_switch.c b/types/wlr_switch.c index 42611da96..b6972eea3 100644 --- a/types/wlr_switch.c +++ b/types/wlr_switch.c @@ -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); - } }