[PATCH libinput 4/5] Don't init pointer acceleration on absolute devices

Peter Hutterer peter.hutterer at who-t.net
Mon Feb 2 17:07:05 PST 2015


Note: touchpads have a different backend, we never get here in that case. This
only applies to true absolute pointer devices.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c    |  3 ++-
 test/pointer.c | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/evdev.c b/src/evdev.c
index b2b8cbf..6e318dc 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1473,7 +1473,8 @@ evdev_configure_device(struct evdev_device *device)
 		has_keyboard = 1;
 
 	if ((has_abs || has_rel) && has_button) {
-		if (evdev_device_init_pointer_acceleration(device) == -1)
+		if (has_rel &&
+		    evdev_device_init_pointer_acceleration(device) == -1)
 			return -1;
 
 		device->seat_caps |= EVDEV_DEVICE_POINTER;
diff --git a/test/pointer.c b/test/pointer.c
index 9a91231..9a1e9d6 100644
--- a/test/pointer.c
+++ b/test/pointer.c
@@ -770,6 +770,31 @@ START_TEST(pointer_accel_defaults)
 }
 END_TEST
 
+START_TEST(pointer_accel_defaults_absolute)
+{
+	struct litest_device *dev = litest_current_device();
+	struct libinput_device *device = dev->libinput_device;
+	enum libinput_config_status status;
+	double speed;
+
+	ck_assert(!libinput_device_config_accel_is_available(device));
+	ck_assert(libinput_device_config_accel_get_default_speed(device) == 0.0);
+	ck_assert(libinput_device_config_accel_get_speed(device) == 0.0);
+
+	for (speed = -2.0; speed <= 2.0; speed += 0.2) {
+		status = libinput_device_config_accel_set_speed(device,
+								speed);
+		if (speed >= -1.0 && speed <= 1.0)
+			ck_assert_int_eq(status,
+					 LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
+		else
+			ck_assert_int_eq(status,
+					 LIBINPUT_CONFIG_STATUS_INVALID);
+		ck_assert(libinput_device_config_accel_get_speed(device) == 0.0);
+	}
+}
+END_TEST
+
 int main (int argc, char **argv) {
 
 	litest_add("pointer:motion", pointer_motion_relative, LITEST_RELATIVE, LITEST_ANY);
@@ -793,6 +818,7 @@ int main (int argc, char **argv) {
 	litest_add("pointer:left-handed", pointer_left_handed_during_click_multiple_buttons, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
 
 	litest_add("pointer:accel", pointer_accel_defaults, LITEST_RELATIVE, LITEST_ANY);
+	litest_add("pointer:accel", pointer_accel_defaults_absolute, LITEST_ABSOLUTE, LITEST_ANY);
 
 	return litest_run(argc, argv);
 }
-- 
2.1.0



More information about the wayland-devel mailing list