[PATCH libinput 6/7] evdev: sync the initial state for absolute pointer devices
Peter Hutterer
peter.hutterer at who-t.net
Tue May 19 15:52:37 PDT 2015
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev.c | 2 ++
test/pointer.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+)
diff --git a/src/evdev.c b/src/evdev.c
index 48c969d..f710d85 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1865,6 +1865,8 @@ evdev_configure_device(struct evdev_device *device)
device->abs.fake_resolution = 1;
device->abs.absinfo_x = libevdev_get_abs_info(evdev, ABS_X);
device->abs.absinfo_y = libevdev_get_abs_info(evdev, ABS_Y);
+ device->abs.point.x = device->abs.absinfo_x->value;
+ device->abs.point.y = device->abs.absinfo_y->value;
if (evdev_is_fake_mt_device(device)) {
udev_tags &= ~EVDEV_UDEV_TAG_TOUCHSCREEN;
diff --git a/test/pointer.c b/test/pointer.c
index cbc3802..9eebedd 100644
--- a/test/pointer.c
+++ b/test/pointer.c
@@ -170,6 +170,61 @@ START_TEST(pointer_motion_absolute)
}
END_TEST
+START_TEST(pointer_absolute_initial_state)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *libinput1, *libinput2;
+ struct libinput_event *ev1, *ev2;
+ struct libinput_event_pointer *p1, *p2;
+ int axis = _i; /* looped test */
+
+ dev = litest_current_device();
+ libinput1 = dev->libinput;
+ litest_touch_down(dev, 0, 40, 60);
+ litest_touch_up(dev, 0);
+
+ /* device is now on some x/y value */
+ litest_drain_events(libinput1);
+
+ libinput2 = litest_create_context();
+ libinput_path_add_device(libinput2,
+ libevdev_uinput_get_devnode(dev->uinput));
+ litest_drain_events(libinput2);
+
+ if (axis == ABS_X)
+ litest_touch_down(dev, 0, 40, 70);
+ else
+ litest_touch_down(dev, 0, 70, 60);
+ litest_touch_up(dev, 0);
+
+ litest_wait_for_event(libinput1);
+ litest_wait_for_event(libinput2);
+
+ while (libinput_next_event_type(libinput1)) {
+ ev1 = libinput_get_event(libinput1);
+ ev2 = libinput_get_event(libinput2);
+
+ ck_assert_int_eq(libinput_event_get_type(ev1),
+ LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
+ ck_assert_int_eq(libinput_event_get_type(ev1),
+ libinput_event_get_type(ev2));
+
+ p1 = libinput_event_get_pointer_event(ev1);
+ p2 = libinput_event_get_pointer_event(ev2);
+
+ ck_assert_int_eq(libinput_event_pointer_get_absolute_x(p1),
+ libinput_event_pointer_get_absolute_x(p2));
+ ck_assert_int_eq(libinput_event_pointer_get_absolute_y(p1),
+ libinput_event_pointer_get_absolute_y(p2));
+
+ libinput_event_destroy(ev1);
+ libinput_event_destroy(ev2);
+ }
+
+ libinput_unref(libinput2);
+}
+END_TEST
+
static void
test_unaccel_event(struct litest_device *dev, int dx, int dy)
{
@@ -1263,6 +1318,8 @@ END_TEST
int main (int argc, char **argv)
{
+ struct range axis_range = {ABS_X, ABS_Y + 1};
+
litest_add("pointer:motion", pointer_motion_relative, LITEST_RELATIVE, LITEST_ANY);
litest_add("pointer:motion", pointer_motion_absolute, LITEST_ABSOLUTE, LITEST_ANY);
litest_add("pointer:motion", pointer_motion_unaccel, LITEST_RELATIVE, LITEST_ANY);
@@ -1300,5 +1357,7 @@ int main (int argc, char **argv)
litest_add("pointer:middlebutton", middlebutton_default_touchpad, LITEST_TOUCHPAD, LITEST_CLICKPAD);
litest_add("pointer:middlebutton", middlebutton_default_disabled, LITEST_ANY, LITEST_BUTTON);
+ litest_add_ranged("pointer:state", pointer_absolute_initial_state, LITEST_ABSOLUTE, LITEST_ANY, &axis_range);
+
return litest_run(argc, argv);
}
--
2.3.5
More information about the wayland-devel
mailing list