mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-04 20:55:58 +01:00
backend/libinput: use NULL to indicate missing device name
libinput guarantees that the name is non-NULL, and an empty string if unset. However wlroots uses NULL to indicate that an input device name is unset.
This commit is contained in:
parent
488a23c169
commit
ee70932422
8 changed files with 17 additions and 6 deletions
|
@ -233,3 +233,13 @@ struct libinput_device *wlr_libinput_get_device_handle(
|
|||
uint32_t usec_to_msec(uint64_t usec) {
|
||||
return (uint32_t)(usec / 1000);
|
||||
}
|
||||
|
||||
const char *get_libinput_device_name(struct libinput_device *device) {
|
||||
// libinput guarantees that the name is non-NULL, and an empty string if
|
||||
// unset. However wlroots uses NULL to indicate that the name is unset.
|
||||
const char *name = libinput_device_get_name(device);
|
||||
if (name[0] == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ const struct wlr_keyboard_impl libinput_keyboard_impl = {
|
|||
};
|
||||
|
||||
void init_device_keyboard(struct wlr_libinput_input_device *dev) {
|
||||
const char *name = libinput_device_get_name(dev->handle);
|
||||
const char *name = get_libinput_device_name(dev->handle);
|
||||
struct wlr_keyboard *wlr_kb = &dev->keyboard;
|
||||
wlr_keyboard_init(wlr_kb, &libinput_keyboard_impl, name);
|
||||
wlr_kb->base.vendor = libinput_device_get_id_vendor(dev->handle);
|
||||
|
|
|
@ -8,7 +8,7 @@ const struct wlr_pointer_impl libinput_pointer_impl = {
|
|||
};
|
||||
|
||||
void init_device_pointer(struct wlr_libinput_input_device *dev) {
|
||||
const char *name = libinput_device_get_name(dev->handle);
|
||||
const char *name = get_libinput_device_name(dev->handle);
|
||||
struct wlr_pointer *wlr_pointer = &dev->pointer;
|
||||
wlr_pointer_init(wlr_pointer, &libinput_pointer_impl, name);
|
||||
wlr_pointer->base.vendor = libinput_device_get_id_vendor(dev->handle);
|
||||
|
|
|
@ -8,7 +8,7 @@ const struct wlr_switch_impl libinput_switch_impl = {
|
|||
};
|
||||
|
||||
void init_device_switch(struct wlr_libinput_input_device *dev) {
|
||||
const char *name = libinput_device_get_name(dev->handle);
|
||||
const char *name = get_libinput_device_name(dev->handle);
|
||||
struct wlr_switch *wlr_switch = &dev->switch_device;
|
||||
wlr_switch_init(wlr_switch, &libinput_switch_impl, name);
|
||||
wlr_switch->base.vendor = libinput_device_get_id_vendor(dev->handle);
|
||||
|
|
|
@ -90,7 +90,7 @@ group_fail:
|
|||
|
||||
void init_device_tablet_pad(struct wlr_libinput_input_device *dev) {
|
||||
struct libinput_device *handle = dev->handle;
|
||||
const char *name = libinput_device_get_name(handle);
|
||||
const char *name = get_libinput_device_name(handle);
|
||||
struct wlr_tablet_pad *wlr_tablet_pad = &dev->tablet_pad;
|
||||
wlr_tablet_pad_init(wlr_tablet_pad, &libinput_tablet_pad_impl, name);
|
||||
wlr_tablet_pad->base.vendor = libinput_device_get_id_vendor(handle);
|
||||
|
|
|
@ -17,7 +17,7 @@ const struct wlr_tablet_impl libinput_tablet_impl = {
|
|||
};
|
||||
|
||||
void init_device_tablet(struct wlr_libinput_input_device *dev) {
|
||||
const char *name = libinput_device_get_name(dev->handle);
|
||||
const char *name = get_libinput_device_name(dev->handle);
|
||||
struct wlr_tablet *wlr_tablet = &dev->tablet;
|
||||
wlr_tablet_init(wlr_tablet, &libinput_tablet_impl, name);
|
||||
wlr_tablet->base.vendor = libinput_device_get_id_vendor(dev->handle);
|
||||
|
|
|
@ -8,7 +8,7 @@ const struct wlr_touch_impl libinput_touch_impl = {
|
|||
};
|
||||
|
||||
void init_device_touch(struct wlr_libinput_input_device *dev) {
|
||||
const char *name = libinput_device_get_name(dev->handle);
|
||||
const char *name = get_libinput_device_name(dev->handle);
|
||||
struct wlr_touch *wlr_touch = &dev->touch;
|
||||
wlr_touch_init(wlr_touch, &libinput_touch_impl, name);
|
||||
wlr_touch->base.vendor = libinput_device_get_id_vendor(dev->handle);
|
||||
|
|
|
@ -48,6 +48,7 @@ void handle_libinput_event(struct wlr_libinput_backend *state,
|
|||
struct libinput_event *event);
|
||||
|
||||
void destroy_libinput_input_device(struct wlr_libinput_input_device *dev);
|
||||
const char *get_libinput_device_name(struct libinput_device *device);
|
||||
|
||||
extern const struct wlr_keyboard_impl libinput_keyboard_impl;
|
||||
extern const struct wlr_pointer_impl libinput_pointer_impl;
|
||||
|
|
Loading…
Reference in a new issue