From: Sungbae Park Date: Mon, 3 Jul 2017 04:46:21 +0000 (+0900) Subject: policy:add policy hook feature and client move hook X-Git-Tag: submit/tizen/20170705.010527~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=01ca7c67317d4c72aeebb53ae3d1eff32fb6037a;p=platform%2Fupstream%2Fenlightenment.git policy:add policy hook feature and client move hook Signed-off-by: Sungbae Park Change-Id: Icc7394c592e4adabf88bd3e108d7d5c35c335d64 --- diff --git a/src/bin/e_policy.c b/src/bin/e_policy.c index df8f32d5e4..b681e4f404 100644 --- a/src/bin/e_policy.c +++ b/src/bin/e_policy.c @@ -30,6 +30,13 @@ static Eina_List *hooks_cp = NULL; static Ecore_Idle_Enterer *_e_pol_idle_enterer = NULL; static Eina_Bool _e_pol_changed_vis = EINA_FALSE; static Eina_List *_e_pol_changed_zone = NULL; +static int _e_policy_hooks_delete = 0; +static int _e_policy_hooks_walking = 0; + +static Eina_Inlist *_e_policy_hooks[] = +{ + [E_POLICY_HOOK_CLIENT_POSITION_SET] = NULL, +}; static E_Policy_Client *_e_policy_client_add(E_Client *ec); static void _e_policy_client_del(E_Policy_Client *pc); @@ -2025,6 +2032,71 @@ e_policy_interceptor_del(E_Policy_Interceptor *pi) _e_policy_interceptors_delete++; } +E_API E_Policy_Hook * +e_policy_hook_add(E_Policy_Hook_Point hookpoint, E_Policy_Hook_Cb func, const void *data) +{ + E_Policy_Hook *ph; + + EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_POLICY_HOOK_LAST, NULL); + ph = E_NEW(E_Policy_Hook, 1); + if (!ph) return NULL; + ph->hookpoint = hookpoint; + ph->func = func; + ph->data = (void*)data; + _e_policy_hooks[hookpoint] = eina_inlist_append(_e_policy_hooks[hookpoint], EINA_INLIST_GET(ph)); + return ph; +} + +E_API void +e_policy_hook_del(E_Policy_Hook *ph) +{ + ph->delete_me = 1; + if (_e_policy_hooks_walking == 0) + { + _e_policy_hooks[ph->hookpoint] = eina_inlist_remove(_e_policy_hooks[ph->hookpoint], EINA_INLIST_GET(ph)); + free(ph); + } + else + _e_policy_hooks_delete++; +} + +static void +_e_policy_hooks_clean(void) +{ + Eina_Inlist *l; + E_Policy_Hook *ph; + unsigned int x; + + for (x = 0; x < E_POLICY_HOOK_LAST; x++) + { + EINA_INLIST_FOREACH_SAFE(_e_policy_hooks[x], l, ph) + { + if (!ph->delete_me) continue; + _e_policy_hooks[x] = eina_inlist_remove(_e_policy_hooks[x], EINA_INLIST_GET(ph)); + free(ph); + } + } +} + +E_API Eina_Bool +e_policy_hook_call(E_Policy_Hook_Point hookpoint, E_Client *ec) +{ + E_Policy_Hook *ch; + + e_object_ref(E_OBJECT(ec)); + _e_policy_hooks_walking++; + + EINA_INLIST_FOREACH(_e_policy_hooks[hookpoint], ch) + { + if (ch->delete_me) continue; + ch->func(ch->data, ec); + } + _e_policy_hooks_walking--; + if ((_e_policy_hooks_walking == 0) && (_e_policy_hooks_delete > 0)) + _e_policy_hooks_clean(); + return !!e_object_unref(E_OBJECT(ec)); +} + E_API void e_policy_allow_user_geometry_set(E_Client *ec, Eina_Bool set) { diff --git a/src/bin/e_policy.h b/src/bin/e_policy.h index 027ed80c36..3c4b940c56 100644 --- a/src/bin/e_policy.h +++ b/src/bin/e_policy.h @@ -8,6 +8,7 @@ typedef struct _E_Policy_Config E_Policy_Config; typedef struct _E_Policy E_Policy; typedef struct _E_Policy_System_Info E_Policy_System_Info; typedef struct _E_Policy_Interceptor E_Policy_Interceptor; +typedef struct _E_Policy_Hook E_Policy_Hook; typedef enum _E_Policy_Intercept_Point { @@ -18,11 +19,28 @@ typedef enum _E_Policy_Intercept_Point E_POLICY_INTERCEPT_LAST, } E_Policy_Intercept_Point; +typedef enum _E_Policy_Hook_Point +{ + E_POLICY_HOOK_CLIENT_POSITION_SET, + E_POLICY_HOOK_LAST +} E_Policy_Hook_Point; + typedef Eina_Bool (*E_Policy_Intercept_Cb)(void *data, E_Client *ec, va_list list); +typedef void (*E_Policy_Hook_Cb)(void *data, E_Client *ec); # else # ifndef E_POLICY_H # define E_POLICY_H + +struct _E_Policy_Hook +{ + EINA_INLIST; + E_Policy_Hook_Point hookpoint; + E_Policy_Hook_Cb func; + void *data; + unsigned char delete_me : 1; +}; + struct _E_Policy_Desk { E_Desk *desk; @@ -177,6 +195,9 @@ E_API void e_policy_aux_message_send_from_int(E_Client *ec, const char *key E_API E_Policy_Interceptor *e_policy_interceptor_add(E_Policy_Intercept_Point ipoint, E_Policy_Intercept_Cb func, const void *data); E_API void e_policy_interceptor_del(E_Policy_Interceptor *pi); +E_API E_Policy_Hook *e_policy_hook_add(E_Policy_Hook_Point hookpoint, E_Policy_Hook_Cb func, const void *data); +E_API void e_policy_hook_del(E_Policy_Hook *hook); +E_API Eina_Bool e_policy_hook_call(E_Policy_Hook_Point hookpoint, E_Client *ec); E_API void e_policy_allow_user_geometry_set(E_Client *ec, Eina_Bool set); E_API void e_policy_deferred_job(void); diff --git a/src/bin/e_policy_wl.c b/src/bin/e_policy_wl.c index 5a5a23dd45..a23768e923 100644 --- a/src/bin/e_policy_wl.c +++ b/src/bin/e_policy_wl.c @@ -1263,6 +1263,8 @@ _tzpos_iface_cb_set(struct wl_client *client EINA_UNUSED, struct wl_resource *re ec->changes.tz_position = 1; EC_CHANGED(ec); } + + e_policy_hook_call(E_POLICY_HOOK_CLIENT_POSITION_SET, ec); } static const struct tizen_position_interface _tzpos_iface =