diff --git a/src/libeis-client.c b/src/libeis-client.c index 7cbe3cc..101271f 100644 --- a/src/libeis-client.c +++ b/src/libeis-client.c @@ -202,7 +202,7 @@ client_new_device(struct eis_client *client, static int client_pointer_rel(struct eis_client *client, uint32_t deviceid, - int32_t x, int32_t y) + double x, double y) { struct eis_device *device; diff --git a/src/libeis-device.c b/src/libeis-device.c index 7a81dc0..0604158 100644 --- a/src/libeis-device.c +++ b/src/libeis-device.c @@ -192,7 +192,7 @@ eis_device_keyboard_get_keymap(struct eis_device *device) int eis_device_pointer_rel(struct eis_device *device, - int x, int y) + double x, double y) { if (!eis_device_has_capability(device, EIS_DEVICE_CAP_POINTER)) return -EINVAL; diff --git a/src/libeis-private.h b/src/libeis-private.h index a12956d..c0d835f 100644 --- a/src/libeis-private.h +++ b/src/libeis-private.h @@ -119,7 +119,7 @@ struct eis_event { union { struct { - int dx, dy; /* relative motion */ + double dx, dy; /* relative motion */ uint32_t button; bool button_is_press; } pointer; @@ -183,7 +183,8 @@ eis_device_keyboard_set_keymap(struct eis_device *device, int eis_device_pointer_rel(struct eis_device *device, - int x, int y); + double x, double y); + int eis_device_pointer_button(struct eis_device *device, uint32_t button, bool state); diff --git a/test/test-ei.c b/test/test-ei.c index 1e3f72e..d110c13 100644 --- a/test/test-ei.c +++ b/test/test-ei.c @@ -422,6 +422,54 @@ MUNIT_TEST(test_ei_device_add_zero_caps) return MUNIT_OK; } +MUNIT_TEST(test_ei_device_pointer_rel) +{ + _cleanup_peck_ struct peck *peck = peck_new(); + _cleanup_ei_device_ struct ei_device *device = NULL; + + peck_enable_eis_behavior(peck, PECK_EIS_BEHAVIOR_ACCEPT_ALL); + peck_enable_ei_behavior(peck, PECK_EI_BEHAVIOR_AUTODEVICES); + peck_dispatch_until_stable(peck); + + with_client(peck) { + device = ei_device_new(ei); + munit_assert_not_null(device); + ei_device_configure_name(device, __func__); + + ei_device_configure_capability(device, EI_DEVICE_CAP_POINTER); + ei_device_add(device); + } + + peck_dispatch_until_stable(peck); + + with_client(peck) { + ei_device_pointer_motion(device, 1, 2); + ei_device_pointer_motion(device, 0.3, 1.4); + ei_device_pointer_motion(device, 100, 200); + } + + peck_dispatch_until_stable(peck); + + with_server(peck) { + _cleanup_eis_event_ struct eis_event *first = + peck_eis_next_event(eis, EIS_EVENT_POINTER_MOTION); + munit_assert_double_equal(eis_event_pointer_get_dx(first), 1.0, 2 /* precision */); + munit_assert_double_equal(eis_event_pointer_get_dy(first), 2.0, 2 /* precision */); + + _cleanup_eis_event_ struct eis_event *second = + peck_eis_next_event(eis, EIS_EVENT_POINTER_MOTION); + munit_assert_double_equal(eis_event_pointer_get_dx(second), 0.3, 2 /* precision */); + munit_assert_double_equal(eis_event_pointer_get_dy(second), 1.4, 2 /* precision */); + + _cleanup_eis_event_ struct eis_event *third = + peck_eis_next_event(eis, EIS_EVENT_POINTER_MOTION); + munit_assert_double_equal(eis_event_pointer_get_dx(third), 100, 2 /* precision */); + munit_assert_double_equal(eis_event_pointer_get_dy(third), 200, 2 /* precision */); + } + + return MUNIT_OK; +} + int main(int argc, char **argv) {