From 899a85bcf567c0d6ff72eaa149acca18826ddd02 Mon Sep 17 00:00:00 2001 From: "Junseok, Kim" Date: Wed, 21 Apr 2021 11:25:06 +0900 Subject: [PATCH] ecore_wl2_window: added new aux_hint_generate API We added new APIs for handling the aux_hint as below. API added - int ecore_wl2_window_aux_hint_generate(Ecore_Wl2_Window *win, const char *hint, const char *val); - int ecore_wl2_window_aux_hint_id_get(Ecore_Wl2_Window *win, const char *hint); - const char *ecore_wl2_window_aux_hint_value_get(Ecore_Wl2_Window *win, int id); The ecore_wl2_window_aux_hint_generate works similar as ecore_wl2_window_aux_hint_add, however, this API is no need to give an ID. It is assigned automatically in this function. The ecore_wl2_window_aux_hint_id_get returns hint ID corresponding to the "hint" parameter. The ecore_wl2_window_aux_hint_val_get returns hint value corresponding to the "id" parameter. Change-Id: I3bec6844c6f2ce7d5105c5792961cb8bae144480 Signed-off-by: Junseok, Kim --- src/lib/ecore_wl2/Ecore_Wl2.h | 48 ++++++++++++++ src/lib/ecore_wl2/ecore_wl2_window.c | 119 +++++++++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index c3bcef8..14c0b9f 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -2281,6 +2281,54 @@ EAPI void ecore_wl2_window_rotation_geometry_set(Ecore_Wl2_Window *win, int rot, EAPI void ecore_wl2_window_rotation_changed_callback_set(Ecore_Wl2_Window *win, void *data, void (*func)(Ecore_Wl2_Window *win, int rot, Eina_Bool resize, int w, int h, void *data)); // +// TIZEN_ONLY(20210330): support aux_hint generate +/** + * @internal + * + * Generate a auxiliary hint to a given window + * It generates auxiliary hint ID in function and return the ID. + * If there is already exist auxiliary hint that have the same name with "hint" parameter, + * then change value of the hint and return exist hint's ID. + * + * @param win The window to add auxiliary hint + * @param hint The name of hint to add + * @param val The value of hint to add + * + * @return Hint ID on success, -1 on failure + * + * @ingroup Ecore_Wl2_Window_Group + */ +EAPI int ecore_wl2_window_aux_hint_generate(Ecore_Wl2_Window *win, const char *hint, const char *val); + +/** + * @internal + * + * Get the hint ID of a given window + * + * @param win The window to get auxiliary hint ID + * @param hint The name of hint to get ID + * + * @return Hint ID on success, -1 on failure + * + * @ingroup Ecore_Wl2_Window_Group + */ +EAPI int ecore_wl2_window_aux_hint_id_get(Ecore_Wl2_Window *win, const char *hint); + +/** + * @internal + * + * Get the hint value of a given window + * + * @param win The window to get auxiliary hint value + * @param id The ID of hint to get hint value + * + * @return Hint value on success, NULL on failure + * + * @ingroup Ecore_Wl2_Window_Group + */ +EAPI const char *ecore_wl2_window_aux_hint_value_get(Ecore_Wl2_Window *win, int id); +// END OF TIZEN_ONLY + /** * @internal * diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c index 7233edf..4152dfc 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c @@ -2682,6 +2682,26 @@ _ecore_wl2_window_aux_hint_get_by_id(Ecore_Wl2_Window *win, int id) return NULL; } +static Ecore_Wl2_Window_Aux_Hint * +_ecore_wl2_window_aux_hint_get_by_hint(Ecore_Wl2_Window *win, const char *hint) +{ + Ecore_Wl2_Window_Aux_Hint *ewah = NULL; + Eina_List *l = NULL; + size_t hint_len = 0; + + EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL); + + hint_len = strlen(hint); + EINA_LIST_REVERSE_FOREACH(win->aux_hints, l, ewah) + { + if ((strlen(ewah->hint) == hint_len) && + !strncmp(ewah->hint, hint, hint_len)) + return ewah; + } + + return NULL; +} + static Eina_Bool _ecore_wl2_window_aux_hint_list_add(Ecore_Wl2_Window *win, int id, const char *hint, const char *val) { @@ -2736,6 +2756,105 @@ _ecore_wl2_window_aux_hint_list_del(Ecore_Wl2_Window *win, Ecore_Wl2_Window_Aux_ } // END OF TIZEN_ONLY +// TIZEN_ONLY(20210330): support aux hint generate +static int +_cb_aux_hint_sort(const void *data1, const void *data2) +{ + const Ecore_Wl2_Window_Aux_Hint *ewah1 = (const Ecore_Wl2_Window_Aux_Hint *) data1; + const Ecore_Wl2_Window_Aux_Hint *ewah2 = (const Ecore_Wl2_Window_Aux_Hint *) data2; + + if (!ewah1 || !ewah2) return 0; + + if (ewah1->id > ewah2->id) return 1; + else if (ewah1->id == ewah2->id) return 0; + else return -1; +} + +static int +_ecore_wl2_window_aux_hint_id_assign(Ecore_Wl2_Window *win) +{ + Ecore_Wl2_Window_Aux_Hint *ewah = NULL; + Eina_List *ewah_sorted_list = NULL, *l = NULL; + int id = 0; + + ewah_sorted_list = eina_list_clone(win->aux_hints); + ewah_sorted_list = eina_list_sort(ewah_sorted_list, 0, _cb_aux_hint_sort); + + EINA_LIST_FOREACH(ewah_sorted_list, l, ewah) + { + if (id < 0) return -1; + if (ewah->id < 0) continue; + + if (ewah->id == id) + { + id++; + continue; + } + else + break; + } + + eina_list_free(ewah_sorted_list); + + return id; +} + +EAPI int +ecore_wl2_window_aux_hint_generate(Ecore_Wl2_Window *win, const char *hint, const char *val) +{ + Ecore_Wl2_Window_Aux_Hint *ewah = NULL; + int id = -1; + + EINA_SAFETY_ON_NULL_RETURN_VAL(win, -1); + + ewah = _ecore_wl2_window_aux_hint_get_by_hint(win, hint); + if (ewah) + { + ecore_wl2_window_aux_hint_change(win, ewah->id, val); + return ewah->id; + } + + id = _ecore_wl2_window_aux_hint_id_assign(win); + if (id < 0) return -1; + + if (!_ecore_wl2_window_aux_hint_list_add(win, id, hint, val)) + return -1; + + // add aux hint + if ((win->surface) && (win->display->wl.tz_policy)) + tizen_policy_add_aux_hint(win->display->wl.tz_policy, win->surface, id, hint, val); + + if ((!win->surface) || (!win->display->wl.efl_aux_hints)) return id; + + efl_aux_hints_add_aux_hint(win->display->wl.efl_aux_hints, win->surface, id, hint, val); + ecore_wl2_display_flush(win->display); + + return id; +} + +EAPI int +ecore_wl2_window_aux_hint_id_get(Ecore_Wl2_Window *win, const char *hint) +{ + Ecore_Wl2_Window_Aux_Hint *ewah = NULL; + + ewah = _ecore_wl2_window_aux_hint_get_by_hint(win, hint); + if (ewah) + return ewah->id; + return -1; +} + +EAPI const char * +ecore_wl2_window_aux_hint_value_get(Ecore_Wl2_Window *win, int id) +{ + Ecore_Wl2_Window_Aux_Hint *ewah = NULL; + + ewah = _ecore_wl2_window_aux_hint_get_by_id(win, id); + if (ewah) + return ewah->val; + return NULL; +} +// END OF TIZEN_ONLY + EAPI Eina_List * ecore_wl2_window_aux_hints_supported_get(Ecore_Wl2_Window *win) { -- 2.7.4