From e11be98ed05b695d9dc6f662b1f957eca28c2160 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Wed, 8 Apr 2015 10:41:26 -0400 Subject: [PATCH] ecore-drm: Add API function to find an output at given coordinates Summary: This commit adds an API function that can be used to find an output given an x/y coordinate pair. @feature Signed-off-by: Chris Michael --- src/lib/ecore_drm/Ecore_Drm.h | 18 ++++++++++++++++++ src/lib/ecore_drm/ecore_drm_device.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index 8d1320e..92ffc02 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -341,6 +341,7 @@ EAPI const char *ecore_drm_device_name_get(Ecore_Drm_Device *dev); * which includes creating dumb buffers to render into * * @param dev The Ecore_Drm_Device to setup for software rendering + * * @return EINA_TRUE on success, EINA_FALSE on failure * * @ingroup Ecore_Drm_Device_Group @@ -349,6 +350,23 @@ EAPI const char *ecore_drm_device_name_get(Ecore_Drm_Device *dev); EAPI Eina_Bool ecore_drm_device_software_setup(Ecore_Drm_Device *dev); /** + * Find an Ecore_Drm_Output at the given coordinates + * + * This function will loop all the existing outputs in Ecore_Drm_Device and + * return an output if one exists that encapsulates the given coordinates. + * + * @param dev The Ecore_Drm_Device to search + * @param x The x coordinate + * @param y The y coordinate + * + * @return An Ecore_Drm_Output if one exists at these coordinates or NULL + * + * @ingroup Ecore_Drm_Device_Group + * @since 1.15 + */ +EAPI Ecore_Drm_Output *ecore_drm_device_output_find(Ecore_Drm_Device *dev, int x, int y); + +/** * Open a tty for use * * @param dev The Ecore_Drm_Device that this tty will belong to. diff --git a/src/lib/ecore_drm/ecore_drm_device.c b/src/lib/ecore_drm/ecore_drm_device.c index 275c9d0..4053752 100644 --- a/src/lib/ecore_drm/ecore_drm_device.c +++ b/src/lib/ecore_drm/ecore_drm_device.c @@ -5,6 +5,10 @@ #include "ecore_drm_private.h" #include +#define INSIDE(x, y, xx, yy, ww, hh) \ + (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && \ + ((x) >= (xx)) && ((y) >= (yy))) + static Eina_List *drm_devices; static void @@ -480,3 +484,32 @@ err: } return EINA_FALSE; } + +EAPI Ecore_Drm_Output * +ecore_drm_device_output_find(Ecore_Drm_Device *dev, int x, int y) +{ + Ecore_Drm_Output *output; + Eina_List *l; + + EINA_SAFETY_ON_NULL_RETURN_VAL(dev, NULL); + + EINA_LIST_FOREACH(dev->outputs, l, output) + { + int ox = 0, oy = 0; + int ow = 0, oh = 0; + + if (!output->cloned) + { + ox = output->x; + oy = output->y; + } + + ow = output->current_mode->width; + oh = output->current_mode->height; + + if (INSIDE(x, y, ox, oy, ow, oh)) + return output; + } + + return NULL; +} -- 2.7.4