diff options
author | Simon Ser <contact@emersion.fr> | 2024-02-29 12:08:02 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2024-02-29 12:08:02 +0100 |
commit | ee70932422718809da88700536d4a7ddde024813 (patch) | |
tree | 25012f050cabcdf6e9c7175b1872e0f1ff332fa2 /backend/libinput/backend.c | |
parent | 488a23c16908a83041cf28e134a6f149d831598d (diff) |
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.
Diffstat (limited to 'backend/libinput/backend.c')
-rw-r--r-- | backend/libinput/backend.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c index 97f17244..bea999fd 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -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; +} |