From 9930929dbba5436ce5e408ecf1bac2893f1ab3be Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Fri, 9 Jun 2017 10:08:06 -0400 Subject: [PATCH] ecore-wl2: Add API to return window available rotations @feature Signed-off-by: Chris Michael --- src/lib/ecore_wl2/Ecore_Wl2.h | 14 ++++++++++++++ src/lib/ecore_wl2/ecore_wl2_window.c | 25 +++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 8bd591ca5a..f3a8ddd402 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -1053,6 +1053,20 @@ EAPI int ecore_wl2_window_preferred_rotation_get(Ecore_Wl2_Window *window); */ EAPI void ecore_wl2_window_available_rotations_set(Ecore_Wl2_Window *window, const int *rots, unsigned int count); +/** + * Get a windows available rotations + * + * @param window + * @param rots + * @param count + * + * @return EINA_TRUE on success, EINA_FALSE otherwise + * + * @ingroup Ecore_Wl2_Window_Group + * @since 1.20 + */ +EAPI Eina_Bool ecore_wl2_window_available_rotations_get(Ecore_Wl2_Window *window, int **rots, unsigned int count); + /** * @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 29e3eae1dd..08b56ffe08 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c @@ -1263,3 +1263,28 @@ ecore_wl2_window_available_rotations_set(Ecore_Wl2_Window *window, const int *ro window->wm_rot.count = count; window->wm_rot.available_rots = rots; } + +EAPI Eina_Bool +ecore_wl2_window_available_rotations_get(Ecore_Wl2_Window *window, int **rots, unsigned int count) +{ + int i = 0; + int *val = NULL; + + EINA_SAFETY_ON_NULL_RETURN_VAL(window, EINA_FALSE); + + *count = window->wm_rot.count; + + if (window->wm_rot.count >= 1) + { + val = calloc(window->wm_rot.count, sizeof(int)); + if (!val) return EINA_FALSE; + + for (; i < window->wm_rot.count; i++) + val[i] = ((int *)window->wm_rot.available_rots)[i]; + + *rots = val; + return EINA_TRUE; + } + + return EINA_FALSE; +}