Use client new/del hook instead of event 21/86321/1
authorMinJeong Kim <minjjj.kim@samsung.com>
Wed, 31 Aug 2016 12:41:05 +0000 (21:41 +0900)
committerMinJeong Kim <minjjj.kim@samsung.com>
Wed, 31 Aug 2016 12:41:05 +0000 (21:41 +0900)
Change-Id: I763ace08b6ec88b796d35cb0e18a49cf2384c682

src/e_mod_effect.c
src/e_mod_effect.h

index 1cc15f5..6e062fb 100644 (file)
@@ -970,15 +970,12 @@ _e_mod_effect_cb_launch(void *data, Evas_Object *obj, const char *signal)
 }
 
 static Eina_Bool
-_e_mod_effect_cb_client_add(void *data, int type, void *event)
+_e_mod_effect_cb_hook_client_new(void *d EINA_UNUSED, E_Client *ec)
 {
-   E_Client *ec;
    E_Effect_Client *efc;
-   E_Event_Client *ev = event;
 
-   if (!_effect) return ECORE_CALLBACK_PASS_ON;
+   if (!_effect) return;
 
-   ec = ev->ec;
    efc = _e_mod_effect_client_get(ec);
    if (!efc)
      {
@@ -986,21 +983,15 @@ _e_mod_effect_cb_client_add(void *data, int type, void *event)
         if (efc)
           eina_hash_add(_effect->clients, &ec, efc);
      }
-
-   return ECORE_CALLBACK_PASS_ON;
 }
 
-static Eina_Bool
-_e_mod_effect_cb_client_remove(void *data, int type, void *event)
+static void
+_e_mod_effect_cb_hook_client_del(void *d EINA_UNUSED, E_Client *ec)
 {
-   E_Client *ec;
    E_Effect_Client *efc = NULL;
-   E_Event_Client *ev = event;
 
    if (!_effect) return ECORE_CALLBACK_PASS_ON;
 
-   ec = ev->ec;
-
    _effect->stack.old = eina_list_remove(_effect->stack.old, ec);
    _effect->stack.cur = eina_list_remove(_effect->stack.cur, ec);
 
@@ -1012,8 +1003,6 @@ _e_mod_effect_cb_client_remove(void *data, int type, void *event)
         if (!efc->animating)
           eina_hash_del_by_key(_effect->clients, &ec);
      }
-
-   return ECORE_CALLBACK_PASS_ON;
 }
 
 static Eina_Bool
@@ -1132,6 +1121,17 @@ _e_mod_effect_cb_client_data_free(void *data)
    free(efc);
 }
 
+#undef E_CLIENT_HOOK_APPEND
+#define E_CLIENT_HOOK_APPEND(l, t, cb, d) \
+  do                                      \
+    {                                     \
+       E_Client_Hook *_h;                 \
+       _h = e_client_hook_add(t, cb, d);  \
+       assert(_h);                        \
+       l = eina_list_append(l, _h);       \
+    }                                     \
+  while (0)
+
 EAPI Eina_Bool
 e_mod_effect_init(void)
 {
@@ -1188,16 +1188,16 @@ e_mod_effect_init(void)
 
    E_LIST_HANDLER_APPEND(effect->event_hdlrs, E_EVENT_CLIENT_BUFFER_CHANGE,
                          _e_mod_effect_cb_client_buffer_change, effect);
-
-   E_LIST_HANDLER_APPEND(effect->event_hdlrs, E_EVENT_CLIENT_ADD,
-                         _e_mod_effect_cb_client_add, effect);
-
-   E_LIST_HANDLER_APPEND(effect->event_hdlrs, E_EVENT_CLIENT_REMOVE,
-                         _e_mod_effect_cb_client_remove, effect);
-
    E_LIST_HANDLER_APPEND(effect->event_hdlrs, E_EVENT_CLIENT_STACK,
                          _e_mod_effect_cb_client_restack, effect);
 
+   E_CLIENT_HOOK_APPEND(effect->hooks_ec,
+                        E_CLIENT_HOOK_NEW_CLIENT,
+                        _e_mod_effect_cb_hook_client_new, effect);
+   E_CLIENT_HOOK_APPEND(effect->hooks_ec,
+                        E_CLIENT_HOOK_DEL,
+                        _e_mod_effect_cb_hook_client_del, effect);
+
    effect->providers =
       eina_list_append(effect->providers,
                        e_comp_object_effect_mover_add(100,
@@ -1252,8 +1252,9 @@ e_mod_effect_shutdown()
    E_FREE_FUNC(_effect->stack.old, eina_list_free);
    E_FREE_FUNC(_effect->stack.cur, eina_list_free);
 
-   E_FREE_LIST(_effect->providers,  e_comp_object_effect_mover_del);
+   E_FREE_LIST(_effect->providers, e_comp_object_effect_mover_del);
    E_FREE_LIST(_effect->event_hdlrs, ecore_event_handler_del);
+   E_FREE_LIST(_effect->hooks_ec, e_client_hook_del);
 
    if (_effect->global)
      wl_global_destroy(_effect->global);
index 26a2553..ab319a9 100644 (file)
@@ -54,6 +54,7 @@ struct _E_Effect
 
    Eina_List *providers;
    Eina_List *event_hdlrs;
+   Eina_List *hooks_ec;
 
    Eina_Hash *clients;