From: Seunghun Lee Date: Mon, 9 Jun 2025 03:23:54 +0000 (+0900) Subject: hints: Clean up X-Git-Tag: accepted/tizen/unified/20250612.024607~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7448b85f9cd80292a1ff59e95760ab9a99385def;p=platform%2Fupstream%2Fenlightenment.git hints: Clean up This commit adds hint related static functions to improve readability. Change-Id: I58f1fa5398386e70f22b8374ad096964105425c7 --- diff --git a/src/bin/windowmgr/e_hints.c b/src/bin/windowmgr/e_hints.c index 1a5874fa04..b7c4a97652 100644 --- a/src/bin/windowmgr/e_hints.c +++ b/src/bin/windowmgr/e_hints.c @@ -316,6 +316,58 @@ e_aux_hint_surface_ec_try_get(E_Aux_Hint_Surface *surface) return surface->ec; } +static E_Comp_Wl_Aux_Hint * +_e_aux_hint_create(int32_t id, const char *hint_name, const char *value) +{ + E_Comp_Wl_Aux_Hint *hint; + + hint = E_NEW(E_Comp_Wl_Aux_Hint, 1); + if (!hint) + return NULL; + + hint->id = id; + hint->hint = eina_stringshare_add(hint_name); + hint->val = eina_stringshare_add(value); + hint->changed = true; + + return hint; +} + +static void +_e_aux_hint_destroy(E_Comp_Wl_Aux_Hint *hint) +{ + if (hint->hint) eina_stringshare_del(hint->hint); + if (hint->val) eina_stringshare_del(hint->val); + free(hint); +} + +static void +_e_aux_hint_replace(E_Comp_Wl_Aux_Hint *hint, const char *hint_name, const char *value) +{ + eina_stringshare_del(hint->hint); + eina_stringshare_del(hint->val); + + hint->hint = eina_stringshare_add(hint_name); + hint->val = eina_stringshare_add(value); + hint->changed = true; + hint->deleted = false; +} + +static bool +_e_aux_hint_value_set(E_Comp_Wl_Aux_Hint *hint, const char *value) +{ + if ((!hint->val) || + (strcmp(hint->val, value) == 0)) + return false; + + eina_stringshare_del(hint->val); + hint->val = eina_stringshare_add(value); + hint->changed = true; + hint->deleted = false; + + return true; +} + EINTERN bool e_aux_hint_surface_hint_add(E_Aux_Hint_Surface *surface, int32_t id, const char *name, const char *value) { @@ -328,15 +380,10 @@ e_aux_hint_surface_hint_add(E_Aux_Hint_Surface *surface, int32_t id, const char { if (!e_util_strcmp(hint->hint, name)) { - if (strcmp(hint->val, value) != 0) + if (_e_aux_hint_value_set(hint, value)) { ELOGF("HINTS", "AUX_HINT |Change [%d:%s:%s -> %s]", surface->ec, id, hint->hint, hint->val, value); - eina_stringshare_del(hint->val); - - hint->val = eina_stringshare_add(value); - hint->changed = true; - hint->deleted = false; surface->changed = true; } } @@ -347,31 +394,19 @@ e_aux_hint_surface_hint_add(E_Aux_Hint_Surface *surface, int32_t id, const char ELOGF("HINTS", "AUX_HINT |Replace [%d:%s:%s -> %s:%s]", surface->ec, id, hint->hint, hint->val, name, value); - eina_stringshare_del(hint->hint); - eina_stringshare_del(hint->val); - - hint->hint = eina_stringshare_add(name); - hint->val = eina_stringshare_add(value); - hint->changed = true; - hint->deleted = false; + _e_aux_hint_replace(hint, name, value); surface->changed = true; } goto end; } } - hint = E_NEW(E_Comp_Wl_Aux_Hint, 1); + hint = _e_aux_hint_create(id, name, value); EINA_SAFETY_ON_NULL_RETURN_VAL(hint, false); - memset(hint, 0, sizeof(E_Comp_Wl_Aux_Hint)); - - hint->id = id; - hint->hint = eina_stringshare_add(name); - hint->val = eina_stringshare_add(value); - hint->changed = true; - hint->deleted = false; surface->hints = eina_list_append(surface->hints, hint); - surface->changed = 1; + surface->changed = true; + ELOGF("HINTS", "AUX_HINT |Add [%d:%s:%s]", surface->ec, id, hint->hint, hint->val); end: @@ -388,19 +423,10 @@ e_aux_hint_surface_hint_change(E_Aux_Hint_Surface *surface, int32_t id, const ch { if (hint->id == id) { - if ((hint->val) && (strcmp(hint->val, value) != 0)) - { - ELOGF("COMP", "AUX_HINT |Change [%d:%s:%s -> %s]", surface->ec, - id, hint->hint, hint->val, value); - eina_stringshare_del(hint->val); - hint->val = eina_stringshare_add(value); - hint->changed = true; - surface->changed = true; - } - - if (hint->deleted) - hint->deleted = false; - + ELOGF("COMP", "AUX_HINT |Change [%d:%s:%s -> %s]", surface->ec, + id, hint->hint, hint->val, value); + if (_e_aux_hint_value_set(hint, value)) + surface->changed = true; return true; } } @@ -444,13 +470,11 @@ e_aux_hint_surface_changed_clear(E_Aux_Hint_Surface *surface) if (hint->deleted) { ELOGF("HINTS", "AUX_HINT |Del [%d:%s:%s]", surface->ec, hint->id, hint->hint, hint->val); - if (hint->hint) eina_stringshare_del(hint->hint); - if (hint->val) eina_stringshare_del(hint->val); surface->hints = eina_list_remove_list(surface->hints, l); - E_FREE(hint); + _e_aux_hint_destroy(hint); } } - surface->changed = 0; + surface->changed = false; } EINTERN bool