diff --git a/backend/libinput/switch.c b/backend/libinput/switch.c index a9c33d3a..9562e185 100644 --- a/backend/libinput/switch.c +++ b/backend/libinput/switch.c @@ -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; } diff --git a/include/wlr/interfaces/wlr_switch.h b/include/wlr/interfaces/wlr_switch.h index 83a1365b..cce55f98 100644 --- a/include/wlr/interfaces/wlr_switch.h +++ b/include/wlr/interfaces/wlr_switch.h @@ -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 diff --git a/include/wlr/types/wlr_switch.h b/include/wlr/types/wlr_switch.h index 93db04c5..a0b9562f 100644 --- a/include/wlr/types/wlr_switch.h +++ b/include/wlr/types/wlr_switch.h @@ -16,6 +16,8 @@ struct wlr_switch_impl; struct wlr_switch { + struct wlr_input_device base; + struct wlr_switch_impl *impl; struct { diff --git a/types/wlr_switch.c b/types/wlr_switch.c index 248997a0..44a004e2 100644 --- a/types/wlr_switch.c +++ b/types/wlr_switch.c @@ -1,11 +1,16 @@ #include #include #include +#include #include #include 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 {