summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2017-06-07 10:46:44 -0400
committerChris Michael <cp.michael@samsung.com>2017-06-07 11:09:58 -0400
commit70a345005b13bd25460e33d038bccb2a459f1725 (patch)
tree03ef30dee79744c6e4b9063148119ba19144e460
parenta9e0148c62f7d15a4962eef0192ccf46db1dea38 (diff)
downloadefl-70a345005b13bd25460e33d038bccb2a459f1725.tar.gz
ecore-wl2: Add API function to find an output for given window
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>
-rw-r--r--src/lib/ecore_wl2/Ecore_Wl2.h12
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_window.c41
2 files changed, 53 insertions, 0 deletions
diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h
index 516c9bcae9..6647b855a4 100644
--- a/src/lib/ecore_wl2/Ecore_Wl2.h
+++ b/src/lib/ecore_wl2/Ecore_Wl2.h
@@ -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
*
diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c
index 70f3e80da8..672a69b065 100644
--- a/src/lib/ecore_wl2/ecore_wl2_window.c
+++ b/src/lib/ecore_wl2/ecore_wl2_window.c
@@ -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;
+}