Added e_comp_object_intercept_hook feature on e_comp_object 21/33421/1
authorMun, Gwan-gyeong <kk.moon@samsung.com>
Fri, 9 Jan 2015 08:03:47 +0000 (17:03 +0900)
committerMun, Gwan-gyeong <kk.moon@samsung.com>
Fri, 9 Jan 2015 08:03:47 +0000 (17:03 +0900)
Change-Id: I9236a012e27af8ba7356863fb76cebba76497bdf

configure.ac
src/bin/e_comp_object.c
src/bin/e_comp_object.h

index 44230e5ea2259955223b878ca84fe1de40edc8a9..6cda7c8658db6b02f1b4d94bc16bda720f6dffa8 100644 (file)
@@ -603,8 +603,8 @@ PKG_CHECK_MODULES(E_OPEN, [
 ])
 
 e_libs="$E_LIBS $LIBINTL $fnmatch_libs $execinfo_libs"
-e_cflags="-DUSE_E_CONFIG_H $E_CFLAGS -D_F_ZONE_WINDOW_ROTATION_ -D_F_E_VIRTUAL_KEYBOARD_TYPE_ -D_F_E_CLIENT_NEW_CLIENT_POST_HOOK_"
-e_configflags="-DUSE_E_CONFIG_H -D_F_ZONE_WINDOW_ROTATION_ -D_F_E_VIRTUAL_KEYBOARD_TYPE_ -D_F_E_CLIENT_NEW_CLIENT_POST_HOOK_"
+e_cflags="-DUSE_E_CONFIG_H $E_CFLAGS -D_F_ZONE_WINDOW_ROTATION_ -D_F_E_VIRTUAL_KEYBOARD_TYPE_ -D_F_E_CLIENT_NEW_CLIENT_POST_HOOK_ -D_F_E_COMP_OBJECT_INTERCEPT_HOOK_"
+e_configflags="-DUSE_E_CONFIG_H -D_F_ZONE_WINDOW_ROTATION_ -D_F_E_VIRTUAL_KEYBOARD_TYPE_ -D_F_E_CLIENT_NEW_CLIENT_POST_HOOK_ -D_F_E_COMP_OBJECT_INTERCEPT_HOOK_"
 
 AC_SUBST([e_libs])
 AC_SUBST([e_cflags])
index 789d7e834262f9894e22cd379e265418bb883fca..39a1a3ef2a4fe88e1141c8058d606bf982c9d0d7 100644 (file)
@@ -113,12 +113,67 @@ struct E_Comp_Object_Mover
 static Eina_Inlist *_e_comp_object_movers = NULL;
 static Evas_Smart *_e_comp_smart = NULL;
 
+#ifdef _F_E_COMP_OBJECT_INTERCEPT_HOOK_
+static int _e_comp_object_intercept_hooks_delete = 0;
+static int _e_comp_object_intercept_hooks_walking = 0;
+
+static Eina_Inlist *_e_comp_object_intercept_hooks[] =
+{
+   [E_COMP_OBJECT_INTERCEPT_HOOK_SHOW_HELPER] = NULL,
+   [E_COMP_OBJECT_INTERCEPT_HOOK_HIDE] = NULL,
+};
+#endif
+
 /* sekrit functionzzz */
 EINTERN void e_client_focused_set(E_Client *ec);
 
 /* emitted every time a new noteworthy comp object is added */
 EAPI int E_EVENT_COMP_OBJECT_ADD = -1;
 
+#ifdef _F_E_COMP_OBJECT_INTERCEPT_HOOK_
+static void
+_e_comp_object_intercept_hooks_clean(void)
+{
+   Eina_Inlist *l;
+   E_Comp_Object_Intercept_Hook *ch;
+   unsigned int x;
+
+   for (x = 0; x < E_COMP_OBJECT_INTERCEPT_HOOK_LAST; x++)
+     EINA_INLIST_FOREACH_SAFE(_e_comp_object_intercept_hooks[x], l, ch)
+       {
+          if (!ch->delete_me) continue;
+          _e_comp_object_intercept_hooks[x] = eina_inlist_remove(_e_comp_object_intercept_hooks[x], EINA_INLIST_GET(ch));
+          free(ch);
+       }
+}
+
+static Eina_Bool
+_e_comp_object_intercept_hook_call(E_Comp_Object_Intercept_Hook_Point hookpoint, E_Client *ec)
+{
+   E_Comp_Object_Intercept_Hook *ch;
+   Eina_Bool ret = EINA_TRUE;
+
+   e_object_ref(E_OBJECT(ec));
+   _e_comp_object_intercept_hooks_walking++;
+   EINA_INLIST_FOREACH(_e_comp_object_intercept_hooks[hookpoint], ch)
+     {
+        if (ch->delete_me) continue;
+        if (!(ch->func(ch->data, ec)))
+          {
+             ret = EINA_FALSE;
+             break;
+          }
+     }
+   _e_comp_object_intercept_hooks_walking--;
+   if ((_e_comp_object_intercept_hooks_walking == 0) && (_e_comp_object_intercept_hooks_delete > 0))
+     _e_comp_object_intercept_hooks_clean();
+
+   e_object_unref(E_OBJECT(ec));
+
+   return ret;
+}
+#endif
+
 static void
 _e_comp_object_event_free(void *d EINA_UNUSED, void *event)
 {
@@ -1202,6 +1257,10 @@ _e_comp_intercept_hide(void *data, Evas_Object *obj)
 {
    E_Comp_Object *cw = data;
 
+#ifdef _F_E_COMP_OBJECT_INTERCEPT_HOOK_
+   if( !_e_comp_object_intercept_hook_call(E_COMP_OBJECT_INTERCEPT_HOOK_HIDE, cw->ec)) return;
+#endif
+
    if (cw->ec->hidden)
      {
         /* hidden flag = just do it */
@@ -1273,6 +1332,10 @@ _e_comp_intercept_show_helper(E_Comp_Object *cw)
         cw->ec->changes.visible = !cw->ec->hidden;
         cw->ec->visible = 1;
         EC_CHANGED(cw->ec);
+
+#ifdef _F_E_COMP_OBJECT_INTERCEPT_HOOK_
+        if (!_e_comp_object_intercept_hook_call(E_COMP_OBJECT_INTERCEPT_HOOK_SHOW_HELPER, cw->ec)) return;
+#endif
         return;
      }
    if (cw->ec->input_only)
@@ -2247,6 +2310,36 @@ _e_comp_object_util_moveresize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj
      e_comp_shape_queue(e_comp_util_evas_object_comp_get(obj));
 }
 
+#ifdef _F_E_COMP_OBJECT_INTERCEPT_HOOK_
+EAPI E_Comp_Object_Intercept_Hook *
+e_comp_object_intercept_hook_add(E_Comp_Object_Intercept_Hook_Point hookpoint, E_Comp_Object_Intercept_Hook_Cb func, const void *data)
+{
+   E_Comp_Object_Intercept_Hook *ch;
+
+   EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint >= E_COMP_OBJECT_INTERCEPT_HOOK_LAST, NULL);
+   ch = E_NEW(E_Comp_Object_Intercept_Hook, 1);
+   if (!ch) return NULL;
+   ch->hookpoint = hookpoint;
+   ch->func = func;
+   ch->data = (void*)data;
+   _e_comp_object_intercept_hooks[hookpoint] = eina_inlist_append(_e_comp_object_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
+   return ch;
+}
+
+EAPI void
+e_comp_object_intercept_hook_del(E_Comp_Object_Intercept_Hook *ch)
+{
+   ch->delete_me = 1;
+   if (_e_comp_object_intercept_hooks_walking == 0)
+     {
+        _e_comp_object_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_comp_object_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
+        free(ch);
+     }
+   else
+     _e_comp_object_intercept_hooks_delete++;
+}
+#endif
+
 EAPI Evas_Object *
 e_comp_object_util_add(Evas_Object *obj, E_Comp_Object_Type type)
 {
index 4aeaca7859d660bdb45a7ba9ff306aac1141783a..5368102eb17a0dd4e9df85e3644cb6cef4cb3335 100644 (file)
@@ -32,6 +32,27 @@ struct E_Comp_Object_Frame
    Eina_Bool calc : 1; // inset has been calculated
 };
 
+#ifdef _F_E_COMP_OBJECT_INTERCEPT_HOOK_
+typedef struct _E_Comp_Object_Intercept_Hook E_Comp_Object_Intercept_Hook;
+
+typedef enum _E_Comp_Object_Intercept_Hook_Point
+{
+   E_COMP_OBJECT_INTERCEPT_HOOK_SHOW_HELPER,
+   E_COMP_OBJECT_INTERCEPT_HOOK_HIDE,
+   E_COMP_OBJECT_INTERCEPT_HOOK_LAST,
+} E_Comp_Object_Intercept_Hook_Point;
+
+typedef Eina_Bool (*E_Comp_Object_Intercept_Hook_Cb)(void *data, E_Client *ec);
+
+struct _E_Comp_Object_Intercept_Hook
+{
+   EINA_INLIST;
+   E_Comp_Object_Intercept_Hook_Point hookpoint;
+   E_Comp_Object_Intercept_Hook_Cb func;
+   void               *data;
+   unsigned char       delete_me : 1;
+};
+#endif
 
 extern EAPI int E_EVENT_COMP_OBJECT_ADD;
 
@@ -82,6 +103,11 @@ EAPI void e_comp_object_effect_stop(Evas_Object *obj, Edje_Signal_Cb end_cb);
 EAPI E_Comp_Object_Mover *e_comp_object_effect_mover_add(int pri, const char *sig, E_Comp_Object_Mover_Cb provider, const void *data);
 EAPI void e_comp_object_effect_mover_del(E_Comp_Object_Mover *prov);
 
+#ifdef _F_E_COMP_OBJECT_INTERCEPT_HOOK_
+EAPI E_Comp_Object_Intercept_Hook *e_comp_object_intercept_hook_add(E_Comp_Object_Intercept_Hook_Point hookpoint, E_Comp_Object_Intercept_Hook_Cb func, const void *data);
+EAPI void e_comp_object_intercept_hook_del(E_Comp_Object_Intercept_Hook *ch);
+#endif
+
 #endif
 #endif