2010/11/29 Tiago Falcão <ti...@profusion.mobi>:
> Some time ago, we created a system to propagate events across the
> Elementary widget tree, done mostly (and for now, only) to propagate
> key events all the way to the top widget (usually, the window). It was
> needed because the normal propagation Evas does works on Smart
> Objects, but the Elementary works doesn't allow to make a smart member
> out of every child of a widget.
>
> This system was internal, but we began to expose it, so the user can
> hook his own callbacks to listen for key events at the window level
> (or anything below), regardless of what widget is focused. This is
> helpful for things like key bindings on an application. The user
> callbacks will be called in case no widget in the tree processed the
> event.

So this will work only for key events, right? not mouse or others?

If yes then the name:
   elm_widget_event_callback_add
is wrong, should be something like:
   elm_widget_key_event_callback_add

DaveMDS

>
> On Mon, Nov 29, 2010 at 2:35 PM, Dave Andreoli <d...@gurumeditation.it> wrote:
>> 2010/11/29 Enlightenment SVN <no-re...@enlightenment.org>:
>>> Log:
>>>  Event Callback
>>
>> Can you please explain better? This will connect every signal?
>>
>> Guys please, write better log, I can't lost 10 minutes per mail
>> to see what you changed
>>
>> DaveMDS
>>
>>> Author:       tiago
>>> Date:         2010-11-29 05:56:30 -0800 (Mon, 29 Nov 2010)
>>> New Revision: 55061
>>>
>>> Modified:
>>>  trunk/TMP/st/elementary/src/bin/test_focus.c 
>>> trunk/TMP/st/elementary/src/lib/Elementary.h.in 
>>> trunk/TMP/st/elementary/src/lib/elm_main.c 
>>> trunk/TMP/st/elementary/src/lib/elm_widget.c 
>>> trunk/TMP/st/elementary/src/lib/elm_widget.h
>>>
>>> Modified: trunk/TMP/st/elementary/src/bin/test_focus.c
>>> ===================================================================
>>> --- trunk/TMP/st/elementary/src/bin/test_focus.c        2010-11-29 13:17:33 
>>> UTC (rev 55060)
>>> +++ trunk/TMP/st/elementary/src/bin/test_focus.c        2010-11-29 13:56:30 
>>> UTC (rev 55061)
>>> @@ -5,6 +5,23 @@
>>>  #endif
>>>  #ifndef ELM_LIB_QUICKLAUNCH
>>>
>>> +static Eina_Bool
>>> +_event(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Object 
>>> *src __UNUSED__, Evas_Callback_Type type, void *event_info)
>>> +{
>>> +   const char *key;
>>> +   if (type == EVAS_CALLBACK_KEY_DOWN)
>>> +     printf ("Key Down:");
>>> +   else if (type == EVAS_CALLBACK_KEY_UP)
>>> +     printf ("Key Up:");
>>> +   else
>>> +     return EINA_FALSE;
>>> +   Evas_Event_Key_Down *ev = event_info;
>>> +   printf("%s\n", ev->key);
>>> +
>>> +   ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
>>> +   return EINA_TRUE;
>>> +}
>>> +
>>>  static void
>>>  _on_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj 
>>> __UNUSED__, void *einfo __UNUSED__)
>>>  {
>>> @@ -31,6 +48,7 @@
>>>    elm_win_title_set(win, "Focus");
>>>    elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
>>>    evas_object_resize(win, 800, 600);
>>> +   elm_object_event_callback_add(win, _event, NULL);
>>>    elm_win_autodel_set(win, EINA_TRUE);
>>>    my_show(win);
>>>
>>> @@ -126,8 +144,10 @@
>>>                        evas_object_size_hint_align_set(bt, EVAS_HINT_FILL,
>>>                                                        EVAS_HINT_FILL);
>>>                        evas_object_size_hint_weight_set(bt, 0.0, 0.0);
>>> +                       elm_object_event_callback_add(bt, _event, NULL);
>>>                        elm_scroller_content_set(sc, bt);
>>>                        my_show(bt);
>>> +                       elm_object_event_callback_del(bt, _event, NULL);
>>>                     }
>>>                }
>>>
>>>
>>> Modified: trunk/TMP/st/elementary/src/lib/Elementary.h.in
>>> ===================================================================
>>> --- trunk/TMP/st/elementary/src/lib/Elementary.h.in     2010-11-29 13:17:33 
>>> UTC (rev 55060)
>>> +++ trunk/TMP/st/elementary/src/lib/Elementary.h.in     2010-11-29 13:56:30 
>>> UTC (rev 55061)
>>> @@ -215,8 +215,9 @@
>>>    *        set on Elm_List_Item, then it is of this type.
>>>    */
>>>    typedef Evas_Object *(*Elm_Tooltip_Item_Content_Cb) (void *data, 
>>> Evas_Object *obj, void *item);
>>> -
>>> -
>>> +
>>> +   typedef Eina_Bool (*Elm_Event_Cb) (void *data, Evas_Object *obj, 
>>> Evas_Object *src, Evas_Callback_Type type, void *event_info);
>>> +
>>>  #ifndef ELM_LIB_QUICKLAUNCH
>>>  #define ELM_MAIN() int main(int argc, char **argv) {elm_init(argc, argv); 
>>> return elm_main(argc, argv);}
>>>  #else
>>> @@ -368,6 +369,9 @@
>>>    EAPI void         elm_object_signal_callback_add(Evas_Object *obj, const 
>>> char *emission, const char *source, void (*func) (void *data, Evas_Object 
>>> *o, const char *emission, const char *source), void *data);
>>>    EAPI void        *elm_object_signal_callback_del(Evas_Object *obj, const 
>>> char *emission, const char *source, void (*func) (void *data, Evas_Object 
>>> *o, const char *emission, const char *source));
>>>
>>> +   EAPI void         elm_object_event_callback_add(Evas_Object *obj, 
>>> Elm_Event_Cb func, const void *data);
>>> +   EAPI void        *elm_object_event_callback_del(Evas_Object *obj, 
>>> Elm_Event_Cb func, const void *data);
>>> +
>>>    EAPI void         elm_coords_finger_size_adjust(int times_w, Evas_Coord 
>>> *w, int times_h, Evas_Coord *h);
>>>
>>>    EAPI double       elm_longpress_timeout_get(void);
>>>
>>> Modified: trunk/TMP/st/elementary/src/lib/elm_main.c
>>> ===================================================================
>>> --- trunk/TMP/st/elementary/src/lib/elm_main.c  2010-11-29 13:17:33 UTC 
>>> (rev 55060)
>>> +++ trunk/TMP/st/elementary/src/lib/elm_main.c  2010-11-29 13:56:30 UTC 
>>> (rev 55061)
>>> @@ -2651,8 +2651,52 @@
>>>     return elm_widget_signal_callback_del(obj, emission, source, func);
>>>  }
>>>
>>> +/**
>>> + * Add a callback for a event emitted by widget or their children.
>>> + *
>>> + * This function connects a callback function to any key_down key_up event
>>> + * emitted by the @p obj or their children.
>>> + * This only will be called if no other callback has consumed the event.
>>> + * If you want consume the event, and no other get it, func should return
>>> + * EINA_TRUE and put EVAS_EVENT_FLAG_ON_HOLD in event_flags.
>>> + *
>>> + * @warning Accept duplicated callback addition.
>>> + *
>>> + * @param obj The object
>>> + * @param func The callback function to be executed when the event is
>>> + * emitted.
>>> + * @param data Data to pass in to the callback function.
>>> + * @ingroup General
>>> + */
>>> +EAPI void
>>> +elm_object_event_callback_add(Evas_Object *obj, Elm_Event_Cb func, const 
>>> void *data)
>>> +{
>>> +   elm_widget_event_callback_add(obj, func, data);
>>> +}
>>>
>>> +/**
>>> + * Remove a event callback from an widget.
>>> + *
>>> + * This function removes a callback, previoulsy attached to event emission
>>> + * by the @p obj.
>>> + * The parameters func and data must match exactly those passed to
>>> + * a previous call to elm_object_event_callback_add(). The data pointer 
>>> that
>>> + * was passed to this call will be returned.
>>> + *
>>> + * @param obj The object
>>> + * @param func The callback function to be executed when the event is
>>> + * emitted.
>>> + * @param data Data to pass in to the callback function.
>>> + * @return The data pointer
>>> + * @ingroup General
>>> + */
>>> +EAPI void *
>>> +elm_object_event_callback_del(Evas_Object *obj, Elm_Event_Cb func, const 
>>> void *data)
>>> +{
>>> +   return elm_widget_event_callback_del(obj, func, data);
>>> +}
>>>
>>> +
>>>  /**
>>>  * @defgroup Debug Debug
>>>  */
>>>
>>> Modified: trunk/TMP/st/elementary/src/lib/elm_widget.c
>>> ===================================================================
>>> --- trunk/TMP/st/elementary/src/lib/elm_widget.c        2010-11-29 13:17:33 
>>> UTC (rev 55060)
>>> +++ trunk/TMP/st/elementary/src/lib/elm_widget.c        2010-11-29 13:56:30 
>>> UTC (rev 55061)
>>> @@ -12,6 +12,7 @@
>>>
>>>  typedef struct _Smart_Data Smart_Data;
>>>  typedef struct _Edje_Signal_Data Edje_Signal_Data;
>>> +typedef struct _Elm_Event_Cb_Data Elm_Event_Cb_Data;
>>>
>>>  struct _Smart_Data
>>>  {
>>> @@ -77,6 +78,7 @@
>>>    Eina_Bool      disabled : 1;
>>>
>>>    Eina_List     *focus_chain;
>>> +   Eina_List     *event_cb;
>>>  };
>>>
>>>  struct _Edje_Signal_Data
>>> @@ -88,6 +90,11 @@
>>>    void *data;
>>>  };
>>>
>>> +struct _Elm_Event_Cb_Data {
>>> +     Elm_Event_Cb func;
>>> +     const void *data;
>>> +};
>>> +
>>>  /* local subsystem functions */
>>>  static void _smart_reconfigure(Smart_Data *sd);
>>>  static void _smart_add(Evas_Object *obj);
>>> @@ -238,13 +245,7 @@
>>>         break;
>>>      }
>>>
>>> -   if ((event_flags) && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))
>>> -      return;
>>> -
>>> -   if ((sd->event_func) && (sd->event_func(obj, obj, type, event_info)))
>>> -      return;
>>> -
>>> -   elm_widget_parent_event_propagate(obj, type, event_info, event_flags);
>>> +   elm_widget_event_propagate(obj, type, event_info, event_flags);
>>>  }
>>>
>>>  static void
>>> @@ -897,11 +898,40 @@
>>>    return parent;
>>>  }
>>>
>>> +EAPI void
>>> +elm_widget_event_callback_add(Evas_Object *obj, Elm_Event_Cb func, const 
>>> void *data)
>>> +{
>>> +   API_ENTRY return;
>>> +   Elm_Event_Cb_Data *ecb = ELM_NEW(Elm_Event_Cb_Data);
>>> +   ecb->func = func;
>>> +   ecb->data = data;
>>> +   sd->event_cb = eina_list_append(sd->event_cb, ecb);
>>> +}
>>> +
>>> +EAPI void *
>>> +elm_widget_event_callback_del(Evas_Object *obj, Elm_Event_Cb func, const 
>>> void *data)
>>> +{
>>> +   API_ENTRY return NULL;
>>> +   Eina_List *l;
>>> +   Elm_Event_Cb_Data *ecd;
>>> +   EINA_LIST_FOREACH(sd->event_cb, l, ecd)
>>> +      if ((ecd->func == func) && (ecd->data == data))
>>> +        {
>>> +           free(ecd);
>>> +           sd->event_cb = eina_list_remove_list(sd->event_cb, l);
>>> +           return (void *)data;
>>> +        }
>>> +   return NULL;
>>> +}
>>> +
>>>  EAPI Eina_Bool
>>> -elm_widget_parent_event_propagate(Evas_Object *obj, Evas_Callback_Type 
>>> type, void *event_info, Evas_Event_Flags *event_flags)
>>> +elm_widget_event_propagate(Evas_Object *obj, Evas_Callback_Type type, void 
>>> *event_info, Evas_Event_Flags *event_flags)
>>>  {
>>> -   API_ENTRY return EINA_FALSE;
>>> -   Evas_Object *parent = sd->parent_obj;
>>> +   API_ENTRY return EINA_FALSE; //TODO reduce.
>>> +   if (!_elm_widget_is(obj)) return EINA_FALSE;
>>> +   Evas_Object *parent = obj;
>>> +   Elm_Event_Cb_Data *ecd;
>>> +   Eina_List *l, *l_prev;
>>>
>>>    while (parent &&
>>>           (!(event_flags && ((*event_flags) & EVAS_EVENT_FLAG_ON_HOLD))))
>>> @@ -909,8 +939,16 @@
>>>         sd = evas_object_smart_data_get(parent);
>>>         if ((!sd) || (!_elm_widget_is(obj)))
>>>           return EINA_FALSE; //Not Elm Widget
>>> +
>>>         if (sd->event_func && (sd->event_func(parent, obj, type, 
>>> event_info)))
>>>           return EINA_TRUE;
>>> +
>>> +        EINA_LIST_FOREACH_SAFE(sd->event_cb, l, l_prev, ecd)
>>> +          {
>>> +             if (ecd->func((void *)ecd->data, parent, obj, type, 
>>> event_info) ||
>>> +                 (event_flags && ((*event_flags) & 
>>> EVAS_EVENT_FLAG_ON_HOLD)))
>>> +                 return EINA_TRUE;
>>> +          }
>>>         parent = sd->parent_obj;
>>>      }
>>>
>>> @@ -2499,7 +2537,7 @@
>>>    Edje_Signal_Data *esd;
>>>
>>>    INTERNAL_ENTRY;
>>> -
>>> +
>>>    if (sd->del_pre_func) sd->del_pre_func(obj);
>>>    if (sd->resize_obj)
>>>      {
>>> @@ -2531,6 +2569,7 @@
>>>         eina_stringshare_del(esd->source);
>>>         free(esd);
>>>      }
>>> +   eina_list_free(sd->event_cb); /* should be empty anyway */
>>>    if (sd->del_func) sd->del_func(obj);
>>>    if (sd->style) eina_stringshare_del(sd->style);
>>>    if (sd->type) eina_stringshare_del(sd->type);
>>>
>>> Modified: trunk/TMP/st/elementary/src/lib/elm_widget.h
>>> ===================================================================
>>> --- trunk/TMP/st/elementary/src/lib/elm_widget.h        2010-11-29 13:17:33 
>>> UTC (rev 55060)
>>> +++ trunk/TMP/st/elementary/src/lib/elm_widget.h        2010-11-29 13:56:30 
>>> UTC (rev 55061)
>>> @@ -247,7 +247,9 @@
>>>  EAPI Evas_Object     *elm_widget_top_get(const Evas_Object *obj);
>>>  EAPI Eina_Bool        elm_widget_is(const Evas_Object *obj);
>>>  EAPI Evas_Object     *elm_widget_parent_widget_get(const Evas_Object *obj);
>>> -EAPI Eina_Bool        elm_widget_parent_event_propagate(Evas_Object *obj, 
>>> Evas_Callback_Type type, void *event_info, Evas_Event_Flags *event_flags);
>>> +EAPI void             elm_widget_event_callback_add(Evas_Object *obj, 
>>> Elm_Event_Cb func, const void *data);
>>> +EAPI void            *elm_widget_event_callback_del(Evas_Object *obj, 
>>> Elm_Event_Cb func, const void *data);
>>> +EAPI Eina_Bool        elm_widget_event_propagate(Evas_Object *obj, 
>>> Evas_Callback_Type type, void *event_info, Evas_Event_Flags *event_flags);
>>>  EAPI void             elm_widget_focus_custom_chain_set(Evas_Object *obj, 
>>> Eina_List *objs);
>>>  EAPI void             elm_widget_focus_custom_chain_unset(Evas_Object 
>>> *obj);
>>>  EAPI const Eina_List *elm_widget_focus_custom_chain_get(const Evas_Object 
>>> *obj);
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
>>> Tap into the largest installed PC base & get more eyes on your game by
>>> optimizing for Intel(R) Graphics Technology. Get started today with the
>>> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
>>> http://p.sf.net/sfu/intelisp-dev2dev
>>> _______________________________________________
>>> enlightenment-svn mailing list
>>> enlightenment-...@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn
>>>
>>
>> ------------------------------------------------------------------------------
>> Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
>> Tap into the largest installed PC base & get more eyes on your game by
>> optimizing for Intel(R) Graphics Technology. Get started today with the
>> Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
>> http://p.sf.net/sfu/intelisp-dev2dev
>> _______________________________________________
>> enlightenment-devel mailing list
>> enlightenment-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>>
>
>
>
> --
> Tiago Rezende Campos Falcão
> Developer @ ProFUSION Embedded Systems
>

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to