eo: enable priority with event forwarder.

Note: Their isn't any ability to do something like a static array of
events at the moment. It might lead to large memory being used when it
wouldn't be necessary. If that was the case, we could fix it, but it
would require a lot of dynamic hash operation I think.

Reviewed-by: Marcel Hollerbach <marcel-hollerbach@t-online.de>
Differential Revision: https://phab.enlightenment.org/D7482
This commit is contained in:
Cedric BAIL 2018-12-12 14:07:52 -08:00 committed by Cedric BAIL
parent e9a434df9b
commit dfd09ec7e4
3 changed files with 28 additions and 14 deletions

View File

@ -2063,6 +2063,19 @@ EAPI int efl_callbacks_cmp(const Efl_Callback_Array_Item *a, const Efl_Callback_
efl_event_callback_array_priority_add(obj, array, \
EFL_CALLBACK_PRIORITY_DEFAULT, data)
/**
* @def efl_event_callback_forwarder_add(obj, desc, new_obj)
* @brief Add an event callback forwarder for an event and an object.
*
* @param[in] obj The object.
* @param[in] desc The description of the event to listen to
* @param[in] new_obj The object to emit events from
*
* @ingroup Efl_Object
*/
#define efl_event_callback_forwarder_add(obj, desc, new_obj) efl_event_callback_forwarder_priority_add(obj, desc, EFL_CALLBACK_PRIORITY_DEFAULT, new_obj)
/**
* @def Replace the previous Eo pointer with new content.
*

View File

@ -229,18 +229,19 @@ abstract Efl.Object
under certain conditions to block a certain event.
]]
}
event_callback_forwarder_add {
event_callback_forwarder_priority_add {
[[Add an event callback forwarder for an event and an object.]]
params {
@cref desc: Efl.Event_Description; [[The description of the event to listen to]]
@in new_obj: Efl.Object; [[The object to emit events from]]
@in priority: short; [[The priority at which to insert the callback handler.]]
@in new_obj: Efl.Object @nonull; [[The object to emit events from]]
}
}
event_callback_forwarder_del {
[[Remove an event callback forwarder for an event and an object.]]
params {
@cref desc: Efl.Event_Description; [[The description of the event to listen to]]
@in new_obj: Efl.Object; [[The object to emit events from]]
@in new_obj: Efl.Object @nonull; [[The object to emit events from]]
}
}
children_iterator_new {

View File

@ -1806,25 +1806,25 @@ _efl_event_forwarder_callback(void *data, const Efl_Event *event)
}
}
/* FIXME: Change default priority? Maybe call later? */
EOLIAN static void
_efl_object_event_callback_forwarder_add(Eo *obj, Efl_Object_Data *pd EINA_UNUSED,
const Efl_Event_Description *desc,
Eo *new_obj)
_efl_object_event_callback_forwarder_priority_add(Eo *obj, Efl_Object_Data *pd EINA_UNUSED,
const Efl_Event_Description *desc,
short priority,
Eo *new_obj)
{
EO_OBJ_POINTER_RETURN(new_obj, new_data);
EO_OBJ_DONE(new_obj);
/* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */
efl_event_callback_add(obj, desc, _efl_event_forwarder_callback, new_obj);
efl_event_callback_priority_add(obj, desc, priority, _efl_event_forwarder_callback, new_obj);
}
EOLIAN static void
_efl_object_event_callback_forwarder_del(Eo *obj, Efl_Object_Data *pd EINA_UNUSED,
const Efl_Event_Description *desc,
Eo *new_obj)
const Efl_Event_Description *desc,
Eo *new_obj)
{
/* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */
EO_OBJ_POINTER_RETURN(new_obj, new_data);
EO_OBJ_DONE(new_obj);
efl_event_callback_del(obj, desc, _efl_event_forwarder_callback, new_obj);
}