[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

libinput: Changes to 'debian-unstable'



 configure.ac                       |    4 -
 debian/changelog                   |    6 ++
 src/evdev-mt-touchpad.c            |   20 +++++++
 src/evdev.c                        |   46 +++++++++++++++++
 src/evdev.h                        |    4 +
 src/libinput-util.c                |   97 ++++++++++++++++++++++++++++++++-----
 src/libinput-util.h                |   75 ++++++++++++++++++++++++----
 src/path.c                         |    2 
 src/udev-seat.c                    |   26 ---------
 test/misc.c                        |   95 ++++++++++++++++++++++++++++++++++++
 test/touchpad.c                    |   24 +++++++++
 udev/90-libinput-model-quirks.hwdb |    4 +
 12 files changed, 350 insertions(+), 53 deletions(-)

New commits:
commit c0df42d4780d19d539bd33deee75addf17079d21
Author: Timo Aaltonen <tjaalton@debian.org>
Date:   Thu Dec 8 16:18:31 2016 +0200

    release to sid

diff --git a/debian/changelog b/debian/changelog
index 188419a..ba59dcf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,8 @@
-libinput (1.5.3-1) UNRELEASED; urgency=medium
+libinput (1.5.3-1) unstable; urgency=medium
 
   * New upstream release.
 
- -- Timo Aaltonen <tjaalton@debian.org>  Thu, 08 Dec 2016 16:16:58 +0200
+ -- Timo Aaltonen <tjaalton@debian.org>  Thu, 08 Dec 2016 16:18:19 +0200
 
 libinput (1.5.2-1) unstable; urgency=medium
 

commit 578ecc62f68b1a6c2659ccd244db61e24f711731
Author: Timo Aaltonen <tjaalton@debian.org>
Date:   Thu Dec 8 16:18:13 2016 +0200

    update changelog

diff --git a/debian/changelog b/debian/changelog
index 4390058..188419a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+libinput (1.5.3-1) UNRELEASED; urgency=medium
+
+  * New upstream release.
+
+ -- Timo Aaltonen <tjaalton@debian.org>  Thu, 08 Dec 2016 16:16:58 +0200
+
 libinput (1.5.2-1) unstable; urgency=medium
 
   * New upstream release.

commit 4e485470475fe120e398e49beb30e46b3a73f5c8
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Dec 7 14:23:34 2016 +1000

    libinput 1.5.3
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index 7c13a4e..b30a6fd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ AC_PREREQ([2.64])
 
 m4_define([libinput_major_version], [1])
 m4_define([libinput_minor_version], [5])
-m4_define([libinput_micro_version], [2])
+m4_define([libinput_micro_version], [3])
 m4_define([libinput_version],
           [libinput_major_version.libinput_minor_version.libinput_micro_version])
 
@@ -35,7 +35,7 @@ AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
 # b) If interfaces have been changed or added, but binary compatibility has
 #    been preserved, change to C+1:0:A+1
 # c) If the interface is the same as the previous version, change to C:R+1:A
-LIBINPUT_LT_VERSION=20:3:10
+LIBINPUT_LT_VERSION=20:4:10
 AC_SUBST(LIBINPUT_LT_VERSION)
 
 AM_SILENT_RULES([yes])

commit 9835acf7c76c2fb393b87e33585d917f7d056469
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Dec 5 13:39:42 2016 +1000

    touchpad: sync BTN_TOOL_FINGER state on init
    
    The Elantech touchpad on my Asus Vivobook doesn't release BTN_TOOL_FINGER on
    up. If the touchpad was used before libinput initializes, the kernel filters
    the event because its state is already set. We never receive it and keep
    ignoring all events until the first switch to BTN_TOOL_DOUBLETAP and back.
    
    On touchpad init sync the BTN_TOOL_FINGER state and set it accordingly. This
    is the only event that can be legitimately down on init. We don't care about
    BTN_TOUCH because ignoring an ongoing touch on init is generally a good idea
    and we can ignore any multifinger gesture as well.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    (cherry picked from commit 5552a6f145b9cb9d8e00f2fdf25e0acb75fe6c72)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index af2a2cd..05e2ae5 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -1829,6 +1829,14 @@ tp_init_slots(struct tp_dispatch *tp,
 	for (i = 1; i < tp->num_slots; i++)
 		tp_sync_touch(tp, device, &tp->touches[i], i);
 
+	/* Some touchpads don't reset BTN_TOOL_FINGER on touch up and only
+	 * change to/from it when BTN_TOOL_DOUBLETAP is set. This causes us
+	 * to ignore the first touches events until a two-finger gesture is
+	 * performed.
+	 */
+	if (libevdev_get_event_value(device->evdev, EV_KEY, BTN_TOOL_FINGER))
+		tp_fake_finger_set(tp, BTN_TOOL_FINGER, 1);
+
 	return true;
 }
 
diff --git a/test/touchpad.c b/test/touchpad.c
index cdc261b..5b6f0a4 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -4365,6 +4365,29 @@ START_TEST(touchpad_slot_swap)
 }
 END_TEST
 
+START_TEST(touchpad_finger_always_down)
+{
+	struct litest_device *dev = litest_current_device();
+	struct libinput *li;
+
+	/* Set BTN_TOOL_FINGER before a new context is initialized */
+	litest_event(dev, EV_KEY, BTN_TOOL_FINGER, 1);
+	litest_event(dev, EV_SYN, SYN_REPORT, 0);
+
+	li = litest_create_context();
+	libinput_path_add_device(li,
+				 libevdev_uinput_get_devnode(dev->uinput));
+	litest_drain_events(li);
+
+	litest_touch_down(dev, 0, 50, 50);
+	litest_touch_move_to(dev, 0, 50, 50, 70, 50, 10, 0);
+
+	litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION);
+
+	libinput_unref(li);
+}
+END_TEST
+
 START_TEST(touchpad_time_usec)
 {
 	struct litest_device *dev = litest_current_device();
@@ -4742,6 +4765,7 @@ litest_setup_tests_touchpad(void)
 
 	litest_add_for_device("touchpad:bugs", touchpad_tool_tripletap_touch_count, LITEST_SYNAPTICS_TOPBUTTONPAD);
 	litest_add_for_device("touchpad:bugs", touchpad_slot_swap, LITEST_SYNAPTICS_TOPBUTTONPAD);
+	litest_add_for_device("touchpad:bugs", touchpad_finger_always_down, LITEST_SYNAPTICS_TOPBUTTONPAD);
 
 	litest_add("touchpad:time", touchpad_time_usec, LITEST_TOUCHPAD, LITEST_ANY);
 

commit 2d2b38aec4dc763c5c7a0b23862aeaa777f488bb
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Nov 2 09:40:42 2016 +1000

    touchpad: add a quirk for the HP Pavilion dm4
    
    This touchpad has cursor jumps for 2-finger scrolling that also affects the
    single-finger emulation. So disable any multitouch bits on this device and
    disallow the 2-finger scroll method. This still allows for 2-finger
    tapping/clicking.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=91135
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    (cherry picked from commit 996b845d68cfa23b7f8a8f9da1bbc40527da562b)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 7b8514c..af2a2cd 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -1795,8 +1795,12 @@ tp_init_slots(struct tp_dispatch *tp,
 	 * If three fingers are set down in the same frame, one slot has the
 	 * coordinates 0/0 and may not get updated for several frames.
 	 * See https://bugzilla.redhat.com/show_bug.cgi?id=1295073
+	 *
+	 * The HP Pavilion DM4 touchpad has random jumps in slots, including
+	 * for single-finger movement. See fdo bug 91135
 	 */
-	if (tp->semi_mt) {
+	if (tp->semi_mt ||
+	    device->model_flags & EVDEV_MODEL_HP_PAVILION_DM4_TOUCHPAD) {
 		tp->num_slots = 1;
 		tp->slot = 0;
 		tp->has_mt = false;
@@ -1899,6 +1903,12 @@ tp_scroll_get_methods(struct tp_dispatch *tp)
 {
 	uint32_t methods = LIBINPUT_CONFIG_SCROLL_EDGE;
 
+	/* Any movement with more than one finger has random cursor
+	 * jumps. Don't allow for 2fg scrolling on this device, see
+	 * fdo bug 91135 */
+	if (tp->device->model_flags & EVDEV_MODEL_HP_PAVILION_DM4_TOUCHPAD)
+		return LIBINPUT_CONFIG_SCROLL_EDGE;
+
 	if (tp->ntouches >= 2)
 		methods |= LIBINPUT_CONFIG_SCROLL_2FG;
 
diff --git a/src/evdev.c b/src/evdev.c
index 1e3cc90..b29c328 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2180,6 +2180,7 @@ evdev_read_model_flags(struct evdev_device *device)
 		MODEL(HP8510_TOUCHPAD),
 		MODEL(HP6910_TOUCHPAD),
 		MODEL(HP_ZBOOK_STUDIO_G3),
+		MODEL(HP_PAVILION_DM4_TOUCHPAD),
 #undef MODEL
 		{ "ID_INPUT_TRACKBALL", EVDEV_MODEL_TRACKBALL },
 		{ NULL, EVDEV_MODEL_DEFAULT },
diff --git a/src/evdev.h b/src/evdev.h
index 3ad385e..73b4774 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -122,6 +122,7 @@ enum evdev_device_model {
 	EVDEV_MODEL_HP8510_TOUCHPAD = (1 << 21),
 	EVDEV_MODEL_HP6910_TOUCHPAD = (1 << 22),
 	EVDEV_MODEL_HP_ZBOOK_STUDIO_G3 = (1 << 23),
+	EVDEV_MODEL_HP_PAVILION_DM4_TOUCHPAD = (1 << 24),
 };
 
 struct mt_slot {
diff --git a/udev/90-libinput-model-quirks.hwdb b/udev/90-libinput-model-quirks.hwdb
index 347a229..eb74f61 100644
--- a/udev/90-libinput-model-quirks.hwdb
+++ b/udev/90-libinput-model-quirks.hwdb
@@ -99,6 +99,10 @@ libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnHewlett-Packard:*pnHPCompaq6910
 libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnHewlett-Packard:*pnHPCompaq8510w*
  LIBINPUT_MODEL_HP8510_TOUCHPAD=1
 
+# HP Pavillion dm4
+libinput:name:SynPS/2 Synaptics TouchPad:dmi:*svnHewlett-Packard:*pnHPPaviliondm4NotebookPC*
+ LIBINPUT_MODEL_HP_PAVILION_DM4_TOUCHPAD=1
+
 # HP Stream 11
 libinput:name:SYN1EDE:00 06CB:7442:dmi:*svnHewlett-Packard:pnHPStreamNotebookPC11*
  LIBINPUT_MODEL_HP_STREAM11_TOUCHPAD=1

commit 8e6d3301b8ba928f5e8732ccd0ca48d55ea01436
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Nov 25 16:27:17 2016 +1000

    evdev: use safe_atod to convert the matrix values
    
    Avoids parsing issues when we're in different locales
    
    https://bugs.freedesktop.org/show_bug.cgi?id=98828
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    (cherry picked from commit 98793f6b435abf8c17b84102de1d7c59ba8e3f54)

diff --git a/src/evdev.c b/src/evdev.c
index 620588d..1e3cc90 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2980,7 +2980,8 @@ evdev_read_calibration_prop(struct evdev_device *device)
 {
 	const char *calibration_values;
 	float calibration[6];
-	int nread;
+	int idx;
+	char **strv;
 
 	calibration_values =
 		udev_device_get_property_value(device->udev_device,
@@ -2992,17 +2993,22 @@ evdev_read_calibration_prop(struct evdev_device *device)
 	if (!device->abs.absinfo_x || !device->abs.absinfo_y)
 		return;
 
-	nread = sscanf(calibration_values,
-		       "%f %f %f %f %f %f",
-		       &calibration[0],
-		       &calibration[1],
-		       &calibration[2],
-		       &calibration[3],
-		       &calibration[4],
-		       &calibration[5]);
-	if (nread != 6)
+	strv = strv_from_string(calibration_values, " ");
+	if (!strv)
 		return;
 
+	for (idx = 0; idx < 6; idx++) {
+		double v;
+		if (strv[idx] == NULL || !safe_atod(strv[idx], &v)) {
+			strv_free(strv);
+			return;
+		}
+
+		calibration[idx] = v;
+	}
+
+	strv_free(strv);
+
 	evdev_device_set_default_calibration(device, calibration);
 	log_info(evdev_libinput_context(device),
 		 "Applying calibration: %f %f %f %f %f %f\n",

commit 5181be6cbce01ca371d4ec13ca216d59725f092d
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Nov 25 16:12:10 2016 +1000

    util: add a helper function to split a string into substrings
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    (cherry picked from commit 33100fe88d7872c0c2af429256349af43a82ae27)

diff --git a/src/libinput-util.c b/src/libinput-util.c
index 4cf310b..a0b423b 100644
--- a/src/libinput-util.c
+++ b/src/libinput-util.c
@@ -285,3 +285,85 @@ parse_dimension_property(const char *prop, size_t *w, size_t *h)
 	*h = (size_t)y;
 	return true;
 }
+
+/**
+ * Return the next word in a string pointed to by state before the first
+ * separator character. Call repeatedly to tokenize a whole string.
+ *
+ * @param state Current state
+ * @param len String length of the word returned
+ * @param separators List of separator characters
+ *
+ * @return The first word in *state, NOT null-terminated
+ */
+static const char *
+next_word(const char **state, size_t *len, const char *separators)
+{
+	const char *next = *state;
+	size_t l;
+
+	if (!*next)
+		return NULL;
+
+	next += strspn(next, separators);
+	if (!*next) {
+		*state = next;
+		return NULL;
+	}
+
+	l = strcspn(next, separators);
+	*state = next + l;
+	*len = l;
+
+	return next;
+}
+
+/**
+ * Return a null-terminated string array with the tokens in the input
+ * string, e.g. "one two\tthree" with a separator list of " \t" will return
+ * an array [ "one", "two", "three", NULL ].
+ *
+ * Use strv_free() to free the array.
+ *
+ * @param in Input string
+ * @param separators List of separator characters
+ *
+ * @return A null-terminated string array or NULL on errors
+ */
+char **
+strv_from_string(const char *in, const char *separators)
+{
+	const char *s, *word;
+	char **strv = NULL;
+	int nelems = 0, idx;
+	size_t l;
+
+	assert(in != NULL);
+
+	s = in;
+	while ((word = next_word(&s, &l, separators)) != NULL)
+	       nelems++;
+
+	if (nelems == 0)
+		return NULL;
+
+	nelems++; /* NULL-terminated */
+	strv = zalloc(nelems * sizeof *strv);
+	if (!strv)
+		return NULL;
+
+	idx = 0;
+
+	s = in;
+	while ((word = next_word(&s, &l, separators)) != NULL) {
+		char *copy = strndup(word, l);
+		if (!copy) {
+			strv_free(strv);
+			return NULL;
+		}
+
+		strv[idx++] = copy;
+	}
+
+	return strv;
+}
diff --git a/src/libinput-util.h b/src/libinput-util.h
index 9b10e7d..3fd3747 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -456,4 +456,22 @@ safe_atod(const char *str, double *val)
 	return true;
 }
 
+char **strv_from_string(const char *string, const char *separator);
+
+static inline void
+strv_free(char **strv) {
+	char **s = strv;
+
+	if (!strv)
+		return;
+
+	while (*s != NULL) {
+		free(*s);
+		*s = (char*)0x1; /* detect use-after-free */
+		s++;
+	}
+
+	free (strv);
+}
+
 #endif /* LIBINPUT_UTIL_H */
diff --git a/test/misc.c b/test/misc.c
index 9c07fac..e320155 100644
--- a/test/misc.c
+++ b/test/misc.c
@@ -910,6 +910,50 @@ START_TEST(safe_atod_test)
 }
 END_TEST
 
+struct strsplit_test {
+	const char *string;
+	const char *delim;
+	const char *results[10];
+};
+
+START_TEST(strsplit_test)
+{
+	struct strsplit_test tests[] = {
+		{ "one two three", " ", { "one", "two", "three", NULL } },
+		{ "one", " ", { "one", NULL } },
+		{ "one two ", " ", { "one", "two", NULL } },
+		{ "one  two", " ", { "one", "two", NULL } },
+		{ " one two", " ", { "one", "two", NULL } },
+		{ "one", "\t \r", { "one", NULL } },
+		{ "one two three", " t", { "one", "wo", "hree", NULL } },
+		{ " one two three", "te", { " on", " ", "wo ", "hr", NULL } },
+		{ "one", "ne", { "o", NULL } },
+		{ "onene", "ne", { "o", NULL } },
+		{ NULL, NULL, { NULL }}
+	};
+	struct strsplit_test *t = tests;
+
+	while (t->string) {
+		char **strv;
+		int idx = 0;
+		strv = strv_from_string(t->string, t->delim);
+		while (t->results[idx]) {
+			ck_assert_str_eq(t->results[idx], strv[idx]);
+			idx++;
+		}
+		ck_assert_ptr_eq(strv[idx], NULL);
+		strv_free(strv);
+		t++;
+	}
+
+	/* Special cases */
+	ck_assert_ptr_eq(strv_from_string("", " "), NULL);
+	ck_assert_ptr_eq(strv_from_string(" ", " "), NULL);
+	ck_assert_ptr_eq(strv_from_string("     ", " "), NULL);
+	ck_assert_ptr_eq(strv_from_string("oneoneone", "one"), NULL);
+}
+END_TEST
+
 static int open_restricted_leak(const char *path, int flags, void *data)
 {
 	return *(int*)data;
@@ -1038,6 +1082,7 @@ litest_setup_tests_misc(void)
 	litest_add_no_device("misc:parser", trackpoint_accel_parser);
 	litest_add_no_device("misc:parser", dimension_prop_parser);
 	litest_add_no_device("misc:parser", safe_atod_test);
+	litest_add_no_device("misc:parser", strsplit_test);
 	litest_add_no_device("misc:time", time_conversion);
 
 	litest_add_no_device("misc:fd", fd_no_event_leak);

commit ed4d674ca259bf5287dde8474b197c1a3e91695f
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Nov 24 10:51:26 2016 +1000

    util: add safe_atod for locale-independent conversion
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    (cherry picked from commit d6020d7ab28de5d5c6ad3e8db948d6366fb758b3)

diff --git a/src/libinput-util.c b/src/libinput-util.c
index 6c051c3..4cf310b 100644
--- a/src/libinput-util.c
+++ b/src/libinput-util.c
@@ -248,21 +248,10 @@ parse_mouse_wheel_click_angle_property(const char *prop)
 double
 parse_trackpoint_accel_property(const char *prop)
 {
-	locale_t c_locale;
 	double accel;
-	char *endp;
 
-	/* Create a "C" locale to force strtod to use '.' as separator */
-	c_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0);
-	if (c_locale == (locale_t)0)
-		return 0.0;
-
-	accel = strtod_l(prop, &endp, c_locale);
-
-	freelocale(c_locale);
-
-	if (*endp != '\0')
-		return 0.0;
+	if (!safe_atod(prop, &accel))
+		accel = 0.0;
 
 	return accel;
 }
diff --git a/src/libinput-util.h b/src/libinput-util.h
index a42643d..9b10e7d 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -30,6 +30,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <limits.h>
+#include <locale.h>
 #include <math.h>
 #include <stdarg.h>
 #include <stdbool.h>
@@ -427,4 +428,32 @@ safe_atoi(const char *str, int *val)
 	return true;
 }
 
+static inline bool
+safe_atod(const char *str, double *val)
+{
+	char *endptr;
+	double v;
+	locale_t c_locale;
+
+	/* Create a "C" locale to force strtod to use '.' as separator */
+	c_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0);
+	if (c_locale == (locale_t)0)
+		return false;
+
+	errno = 0;
+	v = strtod_l(str, &endptr, c_locale);
+	freelocale(c_locale);
+	if (errno > 0)
+		return false;
+	if (str == endptr)
+		return false;
+	if (*str != '\0' && *endptr != '\0')
+		return false;
+	if (isnan(v) || isinf(v))
+		return false;
+
+	*val = v;
+	return true;
+}
+
 #endif /* LIBINPUT_UTIL_H */
diff --git a/test/misc.c b/test/misc.c
index 4afd4d0..9c07fac 100644
--- a/test/misc.c
+++ b/test/misc.c
@@ -861,6 +861,55 @@ START_TEST(time_conversion)
 }
 END_TEST
 
+struct atod_test {
+	char *str;
+	bool success;
+	double val;
+};
+
+START_TEST(safe_atod_test)
+{
+	struct atod_test tests[] = {
+		{ "10", true, 10 },
+		{ "20", true, 20 },
+		{ "-1", true, -1 },
+		{ "2147483647", true, 2147483647 },
+		{ "-2147483648", true, -2147483648 },
+		{ "4294967295", true, 4294967295 },
+		{ "0x0", true, 0 },
+		{ "0x10", true, 0x10 },
+		{ "0xaf", true, 0xaf },
+		{ "x80", false, 0 },
+		{ "0.0", true, 0.0 },
+		{ "0.1", true, 0.1 },
+		{ "1.2", true, 1.2 },
+		{ "-324.9", true, -324.9 },
+		{ "9324.9", true, 9324.9 },
+		{ "NAN", false, 0 },
+		{ "INFINITY", false, 0 },
+		{ "-10x10", false, 0 },
+		{ "1x-99", false, 0 },
+		{ "", false, 0 },
+		{ "abd", false, 0 },
+		{ "xabd", false, 0 },
+		{ "0x0x", false, 0 },
+		{ NULL, false, 0 }
+	};
+	double v;
+	bool success;
+
+	for (int i = 0; tests[i].str != NULL; i++) {
+		v = 0xad;
+		success = safe_atod(tests[i].str, &v);
+		ck_assert(success == tests[i].success);
+		if (success)
+			ck_assert_int_eq(v, tests[i].val);
+		else
+			ck_assert_int_eq(v, 0xad);
+	}
+}
+END_TEST
+
 static int open_restricted_leak(const char *path, int flags, void *data)
 {
 	return *(int*)data;
@@ -988,6 +1037,7 @@ litest_setup_tests_misc(void)
 	litest_add_no_device("misc:parser", wheel_click_count_parser);
 	litest_add_no_device("misc:parser", trackpoint_accel_parser);
 	litest_add_no_device("misc:parser", dimension_prop_parser);
+	litest_add_no_device("misc:parser", safe_atod_test);
 	litest_add_no_device("misc:time", time_conversion);
 
 	litest_add_no_device("misc:fd", fd_no_event_leak);

commit bfff1ab3ef269600e92beea1c36007880a6a5f70
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Nov 25 13:58:39 2016 +1000

    path: read the calibration prop on startup
    
    We were reading this property in the udev backend, but not in the path
    backend.
    
    Reported-by: Thomas Olszak <olszak.tomasz@gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    (cherry picked from commit 21f0e2e3b7e826de34cbdd5e719b5653d9fbc74c)

diff --git a/src/path.c b/src/path.c
index b14d8b6..0f5d089 100644
--- a/src/path.c
+++ b/src/path.c
@@ -171,6 +171,8 @@ path_device_enable(struct path_input *input,
 		goto out;
 	}
 
+	evdev_read_calibration_prop(device);
+
 out:
 	free(seat_name);
 	free(seat_logical_name);

commit 84c12a8a631ba93df46c159c5991e19081f9abda
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Nov 25 13:54:35 2016 +1000

    evdev: move reading the calibration prop into a helper function
    
    No functional changes.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    (cherry picked from commit 50e4a1fada655a9b21c66440d90e79ce404de5fd)

diff --git a/src/evdev.c b/src/evdev.c
index 6a34e37..620588d 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2975,6 +2975,45 @@ evdev_device_calibrate(struct evdev_device *device,
 	matrix_mult(&device->abs.calibration, &transform, &scale);
 }
 
+void
+evdev_read_calibration_prop(struct evdev_device *device)
+{
+	const char *calibration_values;
+	float calibration[6];
+	int nread;
+
+	calibration_values =
+		udev_device_get_property_value(device->udev_device,
+					       "LIBINPUT_CALIBRATION_MATRIX");
+
+	if (calibration_values == NULL)
+		return;
+
+	if (!device->abs.absinfo_x || !device->abs.absinfo_y)
+		return;
+
+	nread = sscanf(calibration_values,
+		       "%f %f %f %f %f %f",
+		       &calibration[0],
+		       &calibration[1],
+		       &calibration[2],
+		       &calibration[3],
+		       &calibration[4],
+		       &calibration[5]);
+	if (nread != 6)
+		return;
+
+	evdev_device_set_default_calibration(device, calibration);
+	log_info(evdev_libinput_context(device),
+		 "Applying calibration: %f %f %f %f %f %f\n",
+		 calibration[0],
+		 calibration[1],
+		 calibration[2],
+		 calibration[3],
+		 calibration[4],
+		 calibration[5]);
+}
+
 bool
 evdev_device_has_capability(struct evdev_device *device,
 			    enum libinput_device_capability capability)
diff --git a/src/evdev.h b/src/evdev.h
index 0888600..3ad385e 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -338,6 +338,9 @@ evdev_init_calibration(struct evdev_device *device,
 		        struct libinput_device_config_calibration *calibration);
 
 void
+evdev_read_calibration_prop(struct evdev_device *device);
+
+void
 evdev_device_init_pointer_acceleration(struct evdev_device *device,
 				       struct motion_filter *filter);
 
diff --git a/src/udev-seat.c b/src/udev-seat.c
index 6bf85de..cdeb7fd 100644
--- a/src/udev-seat.c
+++ b/src/udev-seat.c
@@ -51,8 +51,6 @@ device_added(struct udev_device *udev_device,
 	struct evdev_device *device;
 	const char *devnode;
 	const char *device_seat, *output_name;
-	const char *calibration_values;
-	float calibration[6];
 	struct udev_seat *seat;
 
 	device_seat = udev_device_get_property_value(udev_device, "ID_SEAT");
@@ -94,29 +92,7 @@ device_added(struct udev_device *udev_device,
 		return 0;
 	}
 
-	calibration_values =
-		udev_device_get_property_value(udev_device,
-					       "LIBINPUT_CALIBRATION_MATRIX");
-
-	if (device->abs.absinfo_x && device->abs.absinfo_y &&
-	    calibration_values && sscanf(calibration_values,
-					 "%f %f %f %f %f %f",
-					 &calibration[0],
-					 &calibration[1],
-					 &calibration[2],
-					 &calibration[3],
-					 &calibration[4],
-					 &calibration[5]) == 6) {
-		evdev_device_set_default_calibration(device, calibration);
-		log_info(&input->base,
-			 "Applying calibration: %f %f %f %f %f %f\n",
-			 calibration[0],
-			 calibration[1],
-			 calibration[2],
-			 calibration[3],
-			 calibration[4],
-			 calibration[5]);
-	}
+	evdev_read_calibration_prop(device);
 
 	output_name = udev_device_get_property_value(udev_device, "WL_OUTPUT");
 	if (output_name)

commit 690dd44121e22b14085cae98eb965ac53ca2f2db
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Nov 24 10:48:39 2016 +1000

    util: if errno is nonzero, exit early from safe_atoi
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 13428f5d82a25c1f56fa247d4a201f805d80fde6)

diff --git a/src/libinput-util.h b/src/libinput-util.h
index 6c9afdc..a42643d 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -28,6 +28,7 @@
 #include "config.h"
 
 #include <assert.h>
+#include <errno.h>
 #include <limits.h>
 #include <math.h>
 #include <stdarg.h>
@@ -410,7 +411,10 @@ safe_atoi(const char *str, int *val)
 	char *endptr;
 	long v;
 
+	errno = 0;
 	v = strtol(str, &endptr, 10);
+	if (errno > 0)
+		return false;
 	if (str == endptr)
 		return false;
 	if (*str != '\0' && *endptr != '\0')

commit 59d1ed9466c7902bf1ae452091a43f3254620c2e
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Nov 24 10:51:05 2016 +1000

    util: fix include order
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 4a5dcbf69b8109cccb4d968a191b4d247677e574)

diff --git a/src/libinput-util.h b/src/libinput-util.h
index 441a41b..6c9afdc 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -28,7 +28,6 @@
 #include "config.h"
 
 #include <assert.h>
-#include <unistd.h>
 #include <limits.h>
 #include <math.h>
 #include <stdarg.h>
@@ -36,6 +35,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
+#include <unistd.h>
 
 #include "libinput.h"
 

commit 67a875d752d24bd16f3877cef167be4c5d816121
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Nov 24 10:47:47 2016 +1000

    util: fix indentation for safe_atoi
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 3168d86223ab62b8c20f42e1db2f510140aaf6d5)

diff --git a/src/libinput-util.h b/src/libinput-util.h
index b7bef80..441a41b 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -407,20 +407,20 @@ us2ms(uint64_t us)
 static inline bool
 safe_atoi(const char *str, int *val)
 {
-        char *endptr;
-        long v;
+	char *endptr;
+	long v;
 
-        v = strtol(str, &endptr, 10);
-        if (str == endptr)
-                return false;
-        if (*str != '\0' && *endptr != '\0')
-                return false;
+	v = strtol(str, &endptr, 10);
+	if (str == endptr)
+		return false;
+	if (*str != '\0' && *endptr != '\0')
+		return false;
 
-        if (v > INT_MAX || v < INT_MIN)
-                return false;
+	if (v > INT_MAX || v < INT_MIN)
+		return false;
 
-        *val = v;
-        return true;
+	*val = v;
+	return true;
 }
 
 #endif /* LIBINPUT_UTIL_H */


Reply to: