From 2551ef8871d78a43acbbbac765919ea4f48821f9 Mon Sep 17 00:00:00 2001 From: emersion Date: Sun, 29 Apr 2018 12:15:54 +0100 Subject: [PATCH] input-device: add output_name field, populate it from libinput --- backend/libinput/events.c | 5 +++++ include/wlr/types/wlr_input_device.h | 5 +++-- types/wlr_input_device.c | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/libinput/events.c b/backend/libinput/events.c index ace21a89..2e4b7f84 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -1,3 +1,4 @@ +#define _POSIX_C_SOURCE 200809L #include #include #include @@ -48,6 +49,10 @@ static struct wlr_input_device *allocate_device( struct wlr_input_device *wlr_dev = &wlr_libinput_dev->wlr_input_device; libinput_device_get_size(libinput_dev, &wlr_dev->width_mm, &wlr_dev->height_mm); + const char *output_name = libinput_device_get_output_name(libinput_dev); + if (output_name != NULL) { + wlr_dev->output_name = strdup(output_name); + } wl_list_insert(wlr_devices, &wlr_dev->link); wlr_libinput_dev->handle = libinput_dev; libinput_device_ref(libinput_dev); diff --git a/include/wlr/types/wlr_input_device.h b/include/wlr/types/wlr_input_device.h index d65172c1..5cf26b65 100644 --- a/include/wlr/types/wlr_input_device.h +++ b/include/wlr/types/wlr_input_device.h @@ -11,7 +11,7 @@ enum wlr_input_device_type { WLR_INPUT_DEVICE_POINTER, WLR_INPUT_DEVICE_TOUCH, WLR_INPUT_DEVICE_TABLET_TOOL, - WLR_INPUT_DEVICE_TABLET_PAD + WLR_INPUT_DEVICE_TABLET_PAD, }; /* Note: these are circular dependencies */ @@ -27,10 +27,11 @@ struct wlr_input_device { const struct wlr_input_device_impl *impl; enum wlr_input_device_type type; - int vendor, product; + unsigned int vendor, product; char *name; // Or 0 if not applicable to this device double width_mm, height_mm; + char *output_name; /* wlr_input_device.type determines which of these is valid */ union { diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index 713d911a..3056c0f4 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -56,6 +56,7 @@ void wlr_input_device_destroy(struct wlr_input_device *dev) { } } free(dev->name); + free(dev->output_name); if (dev->impl && dev->impl->destroy) { dev->impl->destroy(dev); } else {