From c7ead75ae758dba7814055138faa8811f7a4cf35 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Wed, 17 Feb 2016 14:54:10 +0900 Subject: [PATCH] ecore-wl: save the values of aux_hint in Ecore_Wl_Window this patch is for re-sending the values of aux_hint in case wl_surface is recreated. Change-Id: Ib45a68b036173a1d98f1c9d36ef1a1788d99c025 --- src/lib/ecore_wayland/ecore_wl_private.h | 2 + src/lib/ecore_wayland/ecore_wl_window.c | 71 ++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/src/lib/ecore_wayland/ecore_wl_private.h b/src/lib/ecore_wayland/ecore_wl_private.h index ef4d60c..726e355 100644 --- a/src/lib/ecore_wayland/ecore_wl_private.h +++ b/src/lib/ecore_wayland/ecore_wl_private.h @@ -152,6 +152,8 @@ struct _Ecore_Wl_Window unsigned int serial; } tz_rot; + Eina_Hash *aux_hints; + struct xdg_surface *xdg_surface; struct xdg_popup *xdg_popup; Eina_Bool visible : 1; diff --git a/src/lib/ecore_wayland/ecore_wl_window.c b/src/lib/ecore_wayland/ecore_wl_window.c index 748f3d9..0d8b38e 100644 --- a/src/lib/ecore_wayland/ecore_wl_window.c +++ b/src/lib/ecore_wayland/ecore_wl_window.c @@ -7,6 +7,13 @@ #include "session-recovery-client-protocol.h" #include +typedef struct +{ + Eina_Stringshare *hint; + Eina_Stringshare *val; + int id; +} Aux_Hint_Item; + /* local function prototypes */ static void _ecore_wl_window_cb_ping(void *data EINA_UNUSED, struct wl_shell_surface *shell_surface, unsigned int serial); static void _ecore_wl_window_cb_configure(void *data, struct wl_shell_surface *shell_surface EINA_UNUSED, unsigned int edges, int w, int h); @@ -98,6 +105,25 @@ _ecore_wl_window_hash_get(void) return _windows; } +static void +_ecore_wl_window_aux_hints_init(Ecore_Wl_Window *win) +{ + Eina_Iterator *itr; + Aux_Hint_Item *it; + + if (!win->aux_hints) + return; + + itr = eina_hash_iterator_data_new(win->aux_hints); + EINA_ITERATOR_FOREACH(itr, it) + { + tizen_policy_add_aux_hint(_ecore_wl_disp->wl.tz_policy, + win->surface, + it->id, it->hint, it->val); + } + eina_iterator_free(itr); +} + void _ecore_wl_window_shell_surface_init(Ecore_Wl_Window *win) { @@ -320,6 +346,8 @@ _ecore_wl_window_shell_surface_init(Ecore_Wl_Window *win) _ecore_wl_window_show_send(win); win->visible = EINA_TRUE; } + + _ecore_wl_window_aux_hints_init(win); } EAPI Ecore_Wl_Window * @@ -369,8 +397,12 @@ void _ecore_wl_window_aux_hint_free(Ecore_Wl_Window *win) { char *supported; + EINA_LIST_FREE(win->supported_aux_hints, supported) if (supported) eina_stringshare_del(supported); + + eina_hash_free(win->aux_hints); + win->aux_hints = NULL; } EAPI void @@ -1989,11 +2021,39 @@ ecore_wl_window_aux_hints_supported_get(Ecore_Wl_Window *win) return res; } +static void +_cb_aux_hint_item_free(void *data) +{ + Aux_Hint_Item *it; + + it = data; + if (EINA_UNLIKELY(!it)) + return; + + eina_stringshare_del(it->hint); + eina_stringshare_del(it->val); + + free(it); +} + EAPI void ecore_wl_window_aux_hint_add(Ecore_Wl_Window *win, int id, const char *hint, const char *val) { + Aux_Hint_Item *it; + LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!win) return; + + if (!win->aux_hints) + win->aux_hints = eina_hash_string_superfast_new(_cb_aux_hint_item_free); + + it = calloc(1, sizeof(Aux_Hint_Item)); + it->id = id; + it->hint = eina_stringshare_add(hint); + it->val = eina_stringshare_add(val); + + eina_hash_add(win->aux_hints, _ecore_wl_window_id_str_get(id), it); + if ((win->surface) && (_ecore_wl_disp->wl.tz_policy)) tizen_policy_add_aux_hint(_ecore_wl_disp->wl.tz_policy, win->surface, id, hint, val); } @@ -2001,8 +2061,15 @@ ecore_wl_window_aux_hint_add(Ecore_Wl_Window *win, int id, const char *hint, con EAPI void ecore_wl_window_aux_hint_change(Ecore_Wl_Window *win, int id, const char *val) { + Aux_Hint_Item *it; + LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!win) return; + if (!win->aux_hints) return; + + it = eina_hash_find(win->aux_hints, _ecore_wl_window_id_str_get(id)); + eina_stringshare_replace(&it->val, val); + if ((win->surface) && (_ecore_wl_disp->wl.tz_policy)) tizen_policy_change_aux_hint(_ecore_wl_disp->wl.tz_policy, win->surface, id, val); } @@ -2012,6 +2079,10 @@ ecore_wl_window_aux_hint_del(Ecore_Wl_Window *win, int id) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!win) return; + if (!win->aux_hints) return; + + eina_hash_del_by_key(win->aux_hints, _ecore_wl_window_id_str_get(id)); + if ((win->surface) && (_ecore_wl_disp->wl.tz_policy)) tizen_policy_del_aux_hint(_ecore_wl_disp->wl.tz_policy, win->surface, id); } -- 2.7.4