From: Derek Foreman Date: Mon, 25 Jan 2016 22:20:18 +0000 (-0600) Subject: ecore_drm: Add pointer warping API X-Git-Tag: upstream/1.20.0~7398 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ddc6962d775345ccb0eb4590486693efb3564075;p=platform%2Fupstream%2Fefl.git ecore_drm: Add pointer warping API Adds a new API: ecore_drm_device_pointer_warp() which warps the pointer to the specified location. All libinput seats with pointers are warped. --- diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index 8d2787b..ca11e96 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -836,6 +836,20 @@ EAPI void ecore_drm_output_gamma_set(Ecore_Drm_Output *output, uint16_t size, ui EAPI void ecore_drm_device_pointer_xy_get(Ecore_Drm_Device *dev, int *x, int *y); /** + * Warp the pointer position of Ecore_Drm_Device + * + * This function will set the pointer position of Ecore_Drm_Device + * + * @param dev The Ecore_Drm_Device to set pointer position for + * @param x The new x co-ordinate + * @param y The new y co-ordinate + * + * @ingroup Ecore_Drm_Device_Group + * @since 1.18 + */ +EAPI void ecore_drm_device_pointer_warp(Ecore_Drm_Device *dev, int x, int y); + +/** * Get the list of drm devices which are allocated. * * @return Eina_List of drm devices, NULL otherwise diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c index 16a7843..95117d2 100644 --- a/src/lib/ecore_drm/ecore_drm_device.c +++ b/src/lib/ecore_drm/ecore_drm_device.c @@ -509,6 +509,30 @@ ecore_drm_device_pointer_xy_get(Ecore_Drm_Device *dev, int *x, int *y) } } +EAPI void +ecore_drm_device_pointer_warp(Ecore_Drm_Device *dev, int x, int y) +{ + Ecore_Drm_Seat *seat; + Ecore_Drm_Evdev *edev; + Eina_List *l, *ll; + + /* check for valid device */ + EINA_SAFETY_ON_TRUE_RETURN((!dev) || (dev->drm.fd < 0)); + 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; + + seat->ptr.dx = seat->ptr.ix = x; + seat->ptr.dy = seat->ptr.iy = y; + _ecore_drm_pointer_motion_post(edev); + } + } +} + EAPI Eina_Bool ecore_drm_device_software_setup(Ecore_Drm_Device *dev) { diff --git a/src/lib/ecore_drm/ecore_drm_evdev.c b/src/lib/ecore_drm/ecore_drm_evdev.c index 35534f5..cf418f3 100644 --- a/src/lib/ecore_drm/ecore_drm_evdev.c +++ b/src/lib/ecore_drm/ecore_drm_evdev.c @@ -399,7 +399,7 @@ _device_pointer_motion(Ecore_Drm_Evdev *edev, struct libinput_event_pointer *eve ev->window = (Ecore_Window)input->dev->window; ev->event_window = (Ecore_Window)input->dev->window; ev->root_window = (Ecore_Window)input->dev->window; - ev->timestamp = libinput_event_pointer_get_time(event); + if (event) ev->timestamp = libinput_event_pointer_get_time(event); ev->same_screen = 1; _device_modifiers_update(edev); @@ -424,6 +424,12 @@ _device_pointer_motion(Ecore_Drm_Evdev *edev, struct libinput_event_pointer *eve ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL); } +void +_ecore_drm_pointer_motion_post(Ecore_Drm_Evdev *edev) +{ + _device_pointer_motion(edev, NULL); +} + static void _device_handle_pointer_motion(struct libinput_device *device, struct libinput_event_pointer *event) { diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h index b4b0fb2..21ec098 100644 --- a/src/lib/ecore_drm/ecore_drm_private.h +++ b/src/lib/ecore_drm/ecore_drm_private.h @@ -283,6 +283,7 @@ void _ecore_drm_tty_restore(Ecore_Drm_Device *dev); Ecore_Drm_Evdev *_ecore_drm_evdev_device_create(Ecore_Drm_Seat *seat, struct libinput_device *device); void _ecore_drm_evdev_device_destroy(Ecore_Drm_Evdev *evdev); Eina_Bool _ecore_drm_evdev_event_process(struct libinput_event *event); +void _ecore_drm_pointer_motion_post(Ecore_Drm_Evdev *evdev); Ecore_Drm_Fb *_ecore_drm_fb_create(Ecore_Drm_Device *dev, int width, int height); void _ecore_drm_fb_destroy(Ecore_Drm_Fb *fb);