mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01: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
4 changed files with 15 additions and 4 deletions
|
@ -16,8 +16,11 @@ struct wlr_switch *create_libinput_switch(
|
||||||
wlr_log(WLR_ERROR, "Unable to allocate wlr_switch");
|
wlr_log(WLR_ERROR, "Unable to allocate wlr_switch");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
wlr_switch_init(wlr_switch, NULL);
|
const char *name = libinput_device_get_name(libinput_dev);
|
||||||
wlr_log(WLR_DEBUG, "Created switch for device %s", 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;
|
return wlr_switch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ struct wlr_switch_impl {
|
||||||
};
|
};
|
||||||
|
|
||||||
void wlr_switch_init(struct wlr_switch *switch_device,
|
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);
|
void wlr_switch_destroy(struct wlr_switch *switch_device);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
struct wlr_switch_impl;
|
struct wlr_switch_impl;
|
||||||
|
|
||||||
struct wlr_switch {
|
struct wlr_switch {
|
||||||
|
struct wlr_input_device base;
|
||||||
|
|
||||||
struct wlr_switch_impl *impl;
|
struct wlr_switch_impl *impl;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wayland-server-core.h>
|
#include <wayland-server-core.h>
|
||||||
|
#include <wlr/interfaces/wlr_input_device.h>
|
||||||
#include <wlr/interfaces/wlr_switch.h>
|
#include <wlr/interfaces/wlr_switch.h>
|
||||||
#include <wlr/types/wlr_switch.h>
|
#include <wlr/types/wlr_switch.h>
|
||||||
|
|
||||||
void wlr_switch_init(struct wlr_switch *switch_device,
|
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;
|
switch_device->impl = impl;
|
||||||
wl_signal_init(&switch_device->events.toggle);
|
wl_signal_init(&switch_device->events.toggle);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +19,7 @@ void wlr_switch_destroy(struct wlr_switch *switch_device) {
|
||||||
if (!switch_device) {
|
if (!switch_device) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
wlr_input_device_finish(&switch_device->base);
|
||||||
if (switch_device->impl && switch_device->impl->destroy) {
|
if (switch_device->impl && switch_device->impl->destroy) {
|
||||||
switch_device->impl->destroy(switch_device);
|
switch_device->impl->destroy(switch_device);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue