diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index ed76983ea1..10928ed092 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -312,4 +312,18 @@ EAPI Eina_Stringshare *ecore_drm_output_model_get(Ecore_Drm_Output *output); */ EAPI Eina_Stringshare *ecore_drm_output_make_get(Ecore_Drm_Output *output); +/** + * Get the pointer position of Ecore_Drm_Device + * + * This function will give the pointer position of Ecore_Drm_Device + * + * @param dev The Ecore_Drm_Device to get pointer position for + * @param *x The parameter in which output x co-ordinate is stored + * @param *y The parameter in which output y co-ordinate is stored + * + * @ingroup Ecore_Drm_Device_Group + * @since 1.14 + */ +EAPI void ecore_drm_device_pointer_xy_get(Ecore_Drm_Device *dev, int *x, int *y); + #endif diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c index 5d0c0bcfe2..89c6b86485 100644 --- a/src/lib/ecore_drm/ecore_drm_device.c +++ b/src/lib/ecore_drm/ecore_drm_device.c @@ -470,3 +470,32 @@ ecore_drm_device_name_get(Ecore_Drm_Device *dev) return dev->drm.name; } + +EAPI void +ecore_drm_device_pointer_xy_get(Ecore_Drm_Device *dev, int *x, int *y) +{ + Ecore_Drm_Seat *seat; + Ecore_Drm_Evdev *edev; + Eina_List *l, *ll; + + if (x) *x = 0; + if (y) *y = 0; + + /* check for valid device */ + if ((!dev) || (dev->drm.fd < 0)) return; + + EINA_LIST_FOREACH(dev->seats, l, seat) + { + EINA_LIST_FOREACH(seat->devices, ll, edev) + { + if (!libinput_device_has_capability(edev->device, + LIBINPUT_DEVICE_CAP_POINTER)) + continue; + + if (x) *x = edev->mouse.dx; + if (y) *y = edev->mouse.dy; + + return; + } + } +}