types/wlr_switch: add base wlr_input_device

wlr_switch owns its wlr_input_device. It will be initialized when the
switch is initialized, and finished when the switch is destroyed.
This commit is contained in:
Simon Zeni 2022-01-31 10:53:58 -05:00 committed by Kirill Primak
parent d5480efc7a
commit 0f3b38365d
4 changed files with 15 additions and 4 deletions

View file

@ -1,11 +1,16 @@
#include <stdlib.h>
#include <string.h>
#include <wayland-server-core.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_switch.h>
#include <wlr/types/wlr_switch.h>
void wlr_switch_init(struct wlr_switch *switch_device,
struct wlr_switch_impl *impl) {
struct wlr_switch_impl *impl, const char *name) {
wlr_input_device_init(&switch_device->base, WLR_INPUT_DEVICE_SWITCH, NULL,
name);
switch_device->base.switch_device = switch_device;
switch_device->impl = impl;
wl_signal_init(&switch_device->events.toggle);
}
@ -14,6 +19,7 @@ void wlr_switch_destroy(struct wlr_switch *switch_device) {
if (!switch_device) {
return;
}
wlr_input_device_finish(&switch_device->base);
if (switch_device->impl && switch_device->impl->destroy) {
switch_device->impl->destroy(switch_device);
} else {