From 13337c2583d089909dd2c872fcfa9cab11e9eb70 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Wed, 11 May 2016 09:07:48 -0400 Subject: [PATCH] ecore-drm2: Add API functions needed to port Ecore_Evas drm This patch adds 2 new API functions which are required by Ecore_Evas in order for it to function with drm. These API functions allow for restricting pointer movement, and for setting the window id which will be used when sending input events Signed-off-by: Chris Michael --- src/lib/ecore_drm2/Ecore_Drm2.h | 35 +++++++++++++++++++++++++ src/lib/ecore_drm2/ecore_drm2_device.c | 33 +++++++++++++++++++++++ src/lib/ecore_drm2/ecore_drm2_outputs.c | 19 ++++++++++++++ 3 files changed, 87 insertions(+) diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h index af69c8d60c..480b373617 100644 --- a/src/lib/ecore_drm2/Ecore_Drm2.h +++ b/src/lib/ecore_drm2/Ecore_Drm2.h @@ -205,6 +205,29 @@ EAPI void ecore_drm2_device_pointer_xy_get(Ecore_Drm2_Device *device, int *x, in */ EAPI void ecore_drm2_device_pointer_warp(Ecore_Drm2_Device *device, int x, int y); +/** + * Set which window is to be used for input events + * + * @param device + * @param window + * + * @ingroup Ecore_Drm2_Device_Group + * @since 1.18 + */ +EAPI void ecore_drm2_device_window_set(Ecore_Drm2_Device *device, unsigned int window); + +/** + * Set maximium position that pointer device is allowed to move + * + * @param device + * @param w + * @param h + * + * @ingroup Ecore_Drm2_Device_Group + * @since 1.18 + */ +EAPI void ecore_drm2_device_pointer_max_set(Ecore_Drm2_Device *device, int w, int h); + /** * @defgroup Ecore_Drm2_Output_Group Drm output functions * @@ -356,6 +379,18 @@ EAPI Ecore_Drm2_Fb *ecore_drm2_output_next_fb_get(Ecore_Drm2_Output *output); */ EAPI void ecore_drm2_output_next_fb_set(Ecore_Drm2_Output *output, Ecore_Drm2_Fb *fb); +/** + * Get the size of the crtc for a given output + * + * @param output + * @param *w + * @param *h + * + * @ingroup Ecore_Drm2_Output_Group + * @since 1.18 + */ +EAPI void ecore_drm2_output_crtc_size_get(Ecore_Drm2_Output *output, int *w, int *h); + /** * @defgroup Ecore_Drm2_Fb_Group Drm framebuffer functions * diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c b/src/lib/ecore_drm2/ecore_drm2_device.c index 9e7d7a6063..4b3afea2b1 100644 --- a/src/lib/ecore_drm2/ecore_drm2_device.c +++ b/src/lib/ecore_drm2/ecore_drm2_device.c @@ -226,3 +226,36 @@ ecore_drm2_device_pointer_warp(Ecore_Drm2_Device *device, int x, int y) elput_input_pointer_xy_set(device->em, NULL, x, y); } + +EAPI void +ecore_drm2_device_window_set(Ecore_Drm2_Device *device, unsigned int window) +{ + const Eina_List *seats, *l; + const Eina_List *devs, *ll; + Elput_Seat *seat; + Elput_Device *dev; + + EINA_SAFETY_ON_NULL_RETURN(device); + EINA_SAFETY_ON_NULL_RETURN(device->em); + + seats = elput_manager_seats_get(device->em); + if (!seats) return; + + EINA_LIST_FOREACH(seats, l, seat) + { + devs = elput_input_devices_get(seat); + if (!devs) continue; + + EINA_LIST_FOREACH(devs, ll, dev) + elput_device_window_set(dev, window); + } +} + +EAPI void +ecore_drm2_device_pointer_max_set(Ecore_Drm2_Device *device, int w, int h) +{ + EINA_SAFETY_ON_NULL_RETURN(device); + EINA_SAFETY_ON_NULL_RETURN(device->em); + + elput_input_pointer_max_set(device->em, w, h); +} diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c b/src/lib/ecore_drm2/ecore_drm2_outputs.c index 6443ecaf1a..9922cd7f82 100644 --- a/src/lib/ecore_drm2/ecore_drm2_outputs.c +++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c @@ -898,3 +898,22 @@ ecore_drm2_output_next_fb_set(Ecore_Drm2_Output *output, Ecore_Drm2_Fb *fb) EINA_SAFETY_ON_NULL_RETURN(output); output->next = fb; } + +EAPI void +ecore_drm2_output_crtc_size_get(Ecore_Drm2_Output *output, int *w, int *h) +{ + drmModeCrtcPtr crtc; + + if (w) *w = 0; + if (h) *h = 0; + + EINA_SAFETY_ON_NULL_RETURN(output); + + crtc = drmModeGetCrtc(output->fd, output->crtc_id); + if (!crtc) return; + + if (w) *w = crtc->width; + if (h) *h = crtc->height; + + drmModeFreeCrtc(crtc); +}