From ee70932422718809da88700536d4a7ddde024813 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 29 Feb 2024 12:08:02 +0100 Subject: 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. --- backend/libinput/backend.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'backend/libinput/backend.c') 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; +} -- cgit v1.2.3