2022-06-20 16:57:29 +02:00
|
|
|
#include <assert.h>
|
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>
|
2018-11-15 00:24:55 +01:00
|
|
|
#include <wlr/interfaces/wlr_switch.h>
|
|
|
|
#include <wlr/types/wlr_switch.h>
|
|
|
|
|
2022-03-03 15:43:38 +01:00
|
|
|
#include "interfaces/wlr_input_device.h"
|
|
|
|
|
2022-06-20 16:57:29 +02:00
|
|
|
struct wlr_switch *wlr_switch_from_input_device(
|
|
|
|
struct wlr_input_device *input_device) {
|
|
|
|
assert(input_device->type == WLR_INPUT_DEVICE_SWITCH);
|
|
|
|
return wl_container_of(input_device, (struct wlr_switch *)NULL, base);
|
|
|
|
}
|
|
|
|
|
2019-03-19 23:41:20 +01:00
|
|
|
void wlr_switch_init(struct wlr_switch *switch_device,
|
2022-02-09 21:53:42 +01:00
|
|
|
const struct wlr_switch_impl *impl, const char *name) {
|
2022-04-26 09:43:54 +02:00
|
|
|
memset(switch_device, 0, sizeof(*switch_device));
|
2022-02-09 22:14:56 +01:00
|
|
|
wlr_input_device_init(&switch_device->base, WLR_INPUT_DEVICE_SWITCH, name);
|
2022-01-31 16:53:58 +01:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-03-02 20:17:31 +01:00
|
|
|
void wlr_switch_finish(struct wlr_switch *switch_device) {
|
2022-01-31 16:53:58 +01:00
|
|
|
wlr_input_device_finish(&switch_device->base);
|
2018-11-15 00:24:55 +01:00
|
|
|
}
|