ecore-drm: Add API function to find an output at given coordinates
authorChris Michael <cp.michael@samsung.com>
Wed, 8 Apr 2015 14:41:26 +0000 (10:41 -0400)
committerStefan Schmidt <s.schmidt@samsung.com>
Fri, 10 Apr 2015 09:09:50 +0000 (11:09 +0200)
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 <cp.michael@samsung.com>
src/lib/ecore_drm/Ecore_Drm.h
src/lib/ecore_drm/ecore_drm_device.c

index 8d1320e..92ffc02 100644 (file)
@@ -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.
index 275c9d0..4053752 100644 (file)
@@ -5,6 +5,10 @@
 #include "ecore_drm_private.h"
 #include <dlfcn.h>
 
+#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;
+}