2018-11-15 00:24:55 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2019-07-27 10:53:54 +02:00
|
|
|
#include <wayland-server-core.h>
|
2022-01-31 16:53:58 +01:00
|
|
|
#include <wlr/interfaces/wlr_input_device.h>
|
2018-11-15 00:24:55 +01:00
|
|
|
#include <wlr/interfaces/wlr_switch.h>
|
|
|
|
#include <wlr/types/wlr_switch.h>
|
|
|
|
|
2019-03-19 23:41:20 +01:00
|
|
|
void wlr_switch_init(struct wlr_switch *switch_device,
|
2022-01-31 16:53:58 +01:00
|
|
|
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;
|
|
|
|
|
2019-03-19 23:41:20 +01:00
|
|
|
switch_device->impl = impl;
|
|
|
|
wl_signal_init(&switch_device->events.toggle);
|
2018-11-15 00:24:55 +01:00
|
|
|
}
|
|
|
|
|
2019-03-19 23:41:20 +01:00
|
|
|
void wlr_switch_destroy(struct wlr_switch *switch_device) {
|
|
|
|
if (!switch_device) {
|
2018-11-15 00:24:55 +01:00
|
|
|
return;
|
|
|
|
}
|
2022-01-31 16:53:58 +01:00
|
|
|
wlr_input_device_finish(&switch_device->base);
|
2019-03-19 23:41:20 +01:00
|
|
|
if (switch_device->impl && switch_device->impl->destroy) {
|
|
|
|
switch_device->impl->destroy(switch_device);
|
2018-11-15 00:24:55 +01:00
|
|
|
} else {
|
2019-03-19 23:41:20 +01:00
|
|
|
free(switch_device);
|
2018-11-15 00:24:55 +01:00
|
|
|
}
|
|
|
|
}
|