[PATCH libinput 1/3] Add msleep() helper function

Peter Hutterer peter.hutterer at who-t.net
Sun Jun 22 16:36:32 PDT 2014


For those whose eyes struggle to focus on 5 zeros in a row, or those just sick
of forgetting one zero and wondering why things don't work.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/libinput-util.h |  8 ++++++++
 test/touchpad.c     | 12 ++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/libinput-util.h b/src/libinput-util.h
index 11c4f5c..2558a3d 100644
--- a/src/libinput-util.h
+++ b/src/libinput-util.h
@@ -23,6 +23,8 @@
 #ifndef LIBINPUT_UTIL_H
 #define LIBINPUT_UTIL_H
 
+#include <unistd.h>
+
 #include "libinput.h"
 
 void
@@ -84,4 +86,10 @@ zalloc(size_t size)
 	return calloc(1, size);
 }
 
+static inline void
+msleep(unsigned int ms)
+{
+	usleep(ms * 1000);
+}
+
 #endif /* LIBINPUT_UTIL_H */
diff --git a/test/touchpad.c b/test/touchpad.c
index 3565833..690e105 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -125,7 +125,7 @@ START_TEST(touchpad_1fg_tap)
 
 	assert_button_event(li, BTN_LEFT,
 			    LIBINPUT_BUTTON_STATE_PRESSED);
-	usleep(300000); /* tap-n-drag timeout */
+	msleep(300); /* tap-n-drag timeout */
 	assert_button_event(li, BTN_LEFT,
 			    LIBINPUT_BUTTON_STATE_RELEASED);
 
@@ -177,7 +177,7 @@ START_TEST(touchpad_1fg_tap_n_drag)
 
 	ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
 
-	usleep(300000); /* tap-n-drag timeout */
+	msleep(300); /* tap-n-drag timeout */
 
 	assert_button_event(li, BTN_LEFT,
 			    LIBINPUT_BUTTON_STATE_RELEASED);
@@ -202,7 +202,7 @@ START_TEST(touchpad_2fg_tap)
 
 	assert_button_event(li, BTN_RIGHT,
 			    LIBINPUT_BUTTON_STATE_PRESSED);
-	usleep(300000); /* tap-n-drag timeout */
+	msleep(300); /* tap-n-drag timeout */
 	assert_button_event(li, BTN_RIGHT,
 			    LIBINPUT_BUTTON_STATE_RELEASED);
 
@@ -681,7 +681,7 @@ START_TEST(clickpad_softbutton_left_1st_fg_move)
 	/* move out of the area, then wait for softbutton timer */
 	litest_touch_move_to(dev, 0, 20, 90, 90, 20, 10);
 	libinput_dispatch(li);
-	usleep(400000);
+	msleep(400);
 	libinput_dispatch(li);
 	litest_drain_events(li);
 
@@ -982,13 +982,13 @@ START_TEST(clickpad_topsoftbuttons_move_out_ignore)
 
 	litest_touch_down(dev, 0, 50, 5);
 	libinput_dispatch(li);
-	usleep(200000);
+	msleep(200);
 	libinput_dispatch(li);
 	litest_assert_empty_queue(li);
 
 	litest_touch_move_to(dev, 0, 50, 5, 80, 90, 20);
 	libinput_dispatch(li);
-	usleep(400000);
+	msleep(400);
 	libinput_dispatch(li);
 
 	litest_event(dev, EV_KEY, BTN_LEFT, 1);
-- 
1.9.3



More information about the wayland-devel mailing list