policy:add policy hook feature and client move hook 21/136721/3
authorSungbae Park <sb34.park@samsung.com>
Mon, 3 Jul 2017 04:46:21 +0000 (13:46 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Tue, 4 Jul 2017 08:36:51 +0000 (08:36 +0000)
Signed-off-by: Sungbae Park <sb34.park@samsung.com>
Change-Id: Icc7394c592e4adabf88bd3e108d7d5c35c335d64

src/bin/e_policy.c
src/bin/e_policy.h
src/bin/e_policy_wl.c

index df8f32d5e44d082a3bcfcb3f8ad4cf4b7645d9f6..b681e4f404a76f8de04c4ef675b9d7eb8f44417d 100644 (file)
@@ -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)
 {
index 027ed80c363ea402408010330edc9ed7b67eea33..3c4b940c56c3833788c27a447efec337ee56ac9f 100644 (file)
@@ -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);
index 5a5a23dd455e06819309b3daff7b708bc5727644..a23768e9230095905b7f9d865a9bf2b83eedb0f9 100644 (file)
@@ -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 =