[PATCH libinput 1/3] evdev: any scroll device must have CAP_POINTER

Peter Hutterer peter.hutterer at who-t.net
Sun Apr 12 17:23:45 PDT 2015


Follow-up to e2f61b8fb74a06b86abd02caa4cdfde5edc53a32.

Scroll events are sent through the pointer interface, so we must set the
capability. Otherwise a caller may not have the required bits set up and is a
bit surprised by events coming out of an interface the device doesn't actually
have (xf86-input-libinput crashes when this happens).

Reported-by: Hans de Goede <hdegoede at redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c   |  4 +++-
 test/device.c | 13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/evdev.c b/src/evdev.c
index 243cd22..bcc2958 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1700,8 +1700,10 @@ evdev_configure_device(struct evdev_device *device)
 
 		/* want natural-scroll config option */
 		if (libevdev_has_event_code(evdev, EV_REL, REL_WHEEL) ||
-		    libevdev_has_event_code(evdev, EV_REL, REL_HWHEEL))
+		    libevdev_has_event_code(evdev, EV_REL, REL_HWHEEL)) {
 			device->scroll.natural_scrolling_enabled = true;
+			device->seat_caps |= EVDEV_DEVICE_POINTER;
+		}
 	}
 
 	if (udev_tags & EVDEV_UDEV_TAG_TOUCHSCREEN) {
diff --git a/test/device.c b/test/device.c
index cf9885a..ed3c2e0 100644
--- a/test/device.c
+++ b/test/device.c
@@ -979,6 +979,17 @@ START_TEST(abs_mt_device_missing_res)
 
 }
 END_TEST
+
+START_TEST(device_wheel_only)
+{
+	struct litest_device *dev = litest_current_device();
+	struct libinput_device *device = dev->libinput_device;
+
+	ck_assert(libinput_device_has_capability(device,
+						 LIBINPUT_DEVICE_CAP_POINTER));
+}
+END_TEST
+
 int main (int argc, char **argv)
 {
 	litest_add("device:sendevents", device_sendevents_config, LITEST_ANY, LITEST_TOUCHPAD);
@@ -1016,5 +1027,7 @@ int main (int argc, char **argv)
 	litest_add_no_device("device:invalid devices", abs_device_missing_res);
 	litest_add_no_device("device:invalid devices", abs_mt_device_missing_res);
 
+	litest_add("device:wheel", device_wheel_only, LITEST_WHEEL, LITEST_RELATIVE|LITEST_ABSOLUTE);
+
 	return litest_run(argc, argv);
 }
-- 
2.3.4



More information about the wayland-devel mailing list