ecore-wl2: Add API function to find an output for given window
authorChris Michael <cp.michael@samsung.com>
Wed, 7 Jun 2017 14:46:44 +0000 (10:46 -0400)
committerChris Michael <cp.michael@samsung.com>
Wed, 7 Jun 2017 15:09:58 +0000 (11:09 -0400)
Small patch which adds an API function that can be used to find the
output where a given window resides.

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/ecore_wl2/Ecore_Wl2.h
src/lib/ecore_wl2/ecore_wl2_window.c

index 516c9bc..6647b85 100644 (file)
@@ -947,6 +947,18 @@ EAPI void ecore_wl2_window_iconified_set(Ecore_Wl2_Window *window, Eina_Bool ico
 EAPI void ecore_wl2_window_type_set(Ecore_Wl2_Window *window, Ecore_Wl2_Window_Type type);
 
 /**
+ * Find the output that a given window is on
+ *
+ * @param window The window to find the output for
+ *
+ * @return An Ecore_Wl2_Output if found, or NULL otherwise
+ *
+ * @ingroup Ecore_Wl2_Window_Group
+ * @since 1.20
+ */
+EAPI Ecore_Wl2_Output *ecore_wl2_window_output_find(Ecore_Wl2_Window *window);
+
+/**
  * @defgroup Ecore_Wl2_Input_Group Wayland Library Input Functions
  * @ingroup Ecore_Wl2_Group
  *
index 70f3e80..672a69b 100644 (file)
@@ -1164,3 +1164,44 @@ ecore_wl2_window_activated_get(const Ecore_Wl2_Window *window)
    EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE);
    return window->focused;
 }
+
+EAPI Ecore_Wl2_Output *
+ecore_wl2_window_output_find(Ecore_Wl2_Window *window)
+{
+   Ecore_Wl2_Output *out;
+   Eina_Inlist *tmp;
+   int x = 0, y = 0;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(window, NULL);
+
+   x = window->geometry.x;
+   y = window->geometry.y;
+
+   EINA_INLIST_FOREACH_SAFE(window->display->outputs, tmp, out)
+     {
+        int ox, oy, ow, oh;
+
+        ox = out->geometry.x;
+        oy = out->geometry.y;
+
+        switch (out->transform)
+          {
+           case WL_OUTPUT_TRANSFORM_90:
+           case WL_OUTPUT_TRANSFORM_270:
+           case WL_OUTPUT_TRANSFORM_FLIPPED_90:
+           case WL_OUTPUT_TRANSFORM_FLIPPED_270:
+             ow = out->geometry.h;
+             oh = out->geometry.w;
+             break;
+           default:
+             ow = out->geometry.w;
+             oh = out->geometry.h;
+             break;
+          }
+
+        if (((x >= ox) && (x < ow)) && ((y >= oy) && (y < oh)))
+          return out;
+     }
+
+   return NULL;
+}