From 54cce990d3fbf607d166294f202b86778709bc7e Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Wed, 4 May 2016 10:43:36 -0400 Subject: [PATCH] elput: Add API function to set pointer position on a given seat Small patch to add an API function that can be used to set the current pointer position on a given seat name. This function (typically) will be used inside an Ecore_Evas to "pointer warp". @feature Signed-off-by: Chris Michael --- src/lib/elput/Elput.h | 13 +++++++++++++ src/lib/elput/elput_evdev.c | 6 ++++++ src/lib/elput/elput_input.c | 34 ++++++++++++++++++++++++++++++++++ src/lib/elput/elput_private.h | 1 + 4 files changed, 54 insertions(+) diff --git a/src/lib/elput/Elput.h b/src/lib/elput/Elput.h index beee6775ed..f3fe16b127 100644 --- a/src/lib/elput/Elput.h +++ b/src/lib/elput/Elput.h @@ -239,6 +239,19 @@ EAPI void elput_input_shutdown(Elput_Manager *manager); */ EAPI void elput_input_pointer_xy_get(Elput_Manager *manager, const char *seat, int *x, int *y); +/** + * Set the pointer position on a given seat + * + * @param manager + * @param seat + * @param x + * @param y + * + * @ingroup Elput_Input_Group + * @since 1.18 + */ +EAPI void elput_input_pointer_xy_set(Elput_Manager *manager, const char *seat, int x, int y); + /** * @defgroup Elput_Device_Group * diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c index 043e7b6064..392a25fc48 100644 --- a/src/lib/elput/elput_evdev.c +++ b/src/lib/elput/elput_evdev.c @@ -1325,6 +1325,12 @@ _evdev_touch_destroy(Elput_Touch *touch) free(touch); } +void +_evdev_pointer_motion_send(Elput_Device *edev) +{ + _pointer_motion_send(edev); +} + Elput_Pointer * _evdev_pointer_get(Elput_Seat *seat) { diff --git a/src/lib/elput/elput_input.c b/src/lib/elput/elput_input.c index c6d22cbf14..d50b023b8a 100644 --- a/src/lib/elput/elput_input.c +++ b/src/lib/elput/elput_input.c @@ -300,3 +300,37 @@ elput_input_pointer_xy_get(Elput_Manager *manager, const char *seat, int *x, int break; } } + +EAPI void +elput_input_pointer_xy_set(Elput_Manager *manager, const char *seat, int x, int y) +{ + Elput_Seat *eseat; + Elput_Device *edev; + Eina_List *l, *ll; + + EINA_SAFETY_ON_NULL_RETURN(manager); + + /* if no seat name is passed in, just use default seat name */ + if (!seat) seat = "seat0"; + + EINA_LIST_FOREACH(manager->input.seats, l, eseat) + { + if (!eseat->ptr) continue; + if ((eseat->name) && (strcmp(eseat->name, seat))) + continue; + + eseat->ptr->x = x; + eseat->ptr->y = y; + eseat->ptr->timestamp = ecore_loop_time_get(); + + EINA_LIST_FOREACH(eseat->devices, ll, edev) + { + if (!libinput_device_has_capability(edev->device, + LIBINPUT_DEVICE_CAP_POINTER)) + continue; + + _evdev_pointer_motion_send(edev); + break; + } + } +} diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h index 3564161375..05ee0b1a37 100644 --- a/src/lib/elput/elput_private.h +++ b/src/lib/elput/elput_private.h @@ -240,6 +240,7 @@ void _evdev_device_destroy(Elput_Device *edev); void _evdev_keyboard_destroy(Elput_Keyboard *kbd); void _evdev_pointer_destroy(Elput_Pointer *ptr); void _evdev_touch_destroy(Elput_Touch *touch); +void _evdev_pointer_motion_send(Elput_Device *edev); Elput_Pointer *_evdev_pointer_get(Elput_Seat *seat); Elput_Keyboard *_evdev_keyboard_get(Elput_Seat *seat);