From: Chris Michael Date: Wed, 7 Jun 2017 14:46:44 +0000 (-0400) Subject: ecore-wl2: Add API function to find an output for given window X-Git-Tag: upstream/1.20.0~739 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=70a345005b13bd25460e33d038bccb2a459f1725;p=platform%2Fupstream%2Fefl.git 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 --- diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 516c9bc..6647b85 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 70f3e80..672a69b 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; +}