mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-25 07:00:36 +01:00
evdev: sync the initial state for absolute pointer devices
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
4889a0c3c2
commit
180564c780
2 changed files with 61 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -172,6 +172,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)
|
||||
{
|
||||
|
|
@ -1265,6 +1320,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);
|
||||
|
|
@ -1302,5 +1359,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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue