mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-25 08:32:30 +00:00
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:
parent
d5480efc7a
commit
0f3b38365d
@ -16,8 +16,11 @@ struct wlr_switch *create_libinput_switch(
|
||||
wlr_log(WLR_ERROR, "Unable to allocate wlr_switch");
|
||||
return NULL;
|
||||
}
|
||||
wlr_switch_init(wlr_switch, NULL);
|
||||
wlr_log(WLR_DEBUG, "Created switch for device %s", libinput_device_get_name(libinput_dev));
|
||||
const char *name = libinput_device_get_name(libinput_dev);
|
||||
wlr_switch_init(wlr_switch, NULL, name);
|
||||
wlr_log(WLR_DEBUG, "Created switch for device %s", name);
|
||||
wlr_switch->base.vendor = libinput_device_get_id_vendor(libinput_dev);
|
||||
wlr_switch->base.product = libinput_device_get_id_product(libinput_dev);
|
||||
return wlr_switch;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ struct wlr_switch_impl {
|
||||
};
|
||||
|
||||
void wlr_switch_init(struct wlr_switch *switch_device,
|
||||
struct wlr_switch_impl *impl);
|
||||
struct wlr_switch_impl *impl, const char *name);
|
||||
void wlr_switch_destroy(struct wlr_switch *switch_device);
|
||||
|
||||
#endif
|
||||
|
@ -16,6 +16,8 @@
|
||||
struct wlr_switch_impl;
|
||||
|
||||
struct wlr_switch {
|
||||
struct wlr_input_device base;
|
||||
|
||||
struct wlr_switch_impl *impl;
|
||||
|
||||
struct {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user