mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-04 06:10:14 +01:00
eis: pointer motion is in doubles, not ints
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
c0aad25ae9
commit
a89309558a
4 changed files with 53 additions and 4 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue