forked from enlightenment/efl
evas/smart: inhibit evas-internal smart callbacks when there are no subscribers
Summary: we know these ahead of time since they're hardcoded, so we can block their emission just like we do for eo events ref T8321 Depends on D10354 Reviewers: cedric Reviewed By: cedric Subscribers: bu5hm4n, cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8321 Differential Revision: https://phab.enlightenment.org/D10355
This commit is contained in:
parent
8218fb0e20
commit
3175690466
|
@ -10,6 +10,7 @@ EVAS_MEMPOOL(_mp_pc);
|
|||
extern Eina_Hash* signals_hash_table;
|
||||
|
||||
/* Legacy events, do not use anywhere */
|
||||
void _evas_object_smart_callback_call_internal(Evas_Object *eo_obj, const Efl_Event_Description *efl_event_desc);
|
||||
static const Efl_Event_Description _EVAS_OBJECT_EVENT_FREE = EFL_EVENT_DESCRIPTION("free");
|
||||
static const Efl_Event_Description _EVAS_OBJECT_EVENT_DEL = EFL_EVENT_DESCRIPTION("del");
|
||||
#define EVAS_OBJECT_EVENT_FREE (&(_EVAS_OBJECT_EVENT_FREE))
|
||||
|
@ -347,17 +348,6 @@ evas_event_callback_call(Evas *eo_e, Evas_Callback_Type type, void *event_info)
|
|||
efl_event_callback_legacy_call(eo_e, _legacy_evas_callback_table(type), event_info);
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_smart_callback_legacy_git_er_done(Evas_Object *eo_obj, const Efl_Event_Description *efl_event_desc)
|
||||
{
|
||||
if (efl_event_desc == EFL_GFX_ENTITY_EVENT_POSITION_CHANGED)
|
||||
evas_object_smart_callback_call(eo_obj, "move", NULL);
|
||||
else if (efl_event_desc == EFL_GFX_ENTITY_EVENT_SIZE_CHANGED)
|
||||
evas_object_smart_callback_call(eo_obj, "resize", NULL);
|
||||
else if (efl_event_desc == EFL_GFX_ENTITY_EVENT_STACKING_CHANGED)
|
||||
evas_object_smart_callback_call(eo_obj, "restack", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_callback_legacy_smart_compatibility_do_it(Evas_Object *eo_obj, const Efl_Event_Description *efl_event_desc, void *event_info)
|
||||
{
|
||||
|
@ -408,7 +398,8 @@ evas_object_event_callback_call(Evas_Object *eo_obj, Evas_Object_Protected_Data
|
|||
type == EVAS_CALLBACK_MULTI_UP)
|
||||
_efl_canvas_gesture_manager_filter_event(e->gesture_manager, eo_obj, event_info);
|
||||
|
||||
_evas_smart_callback_legacy_git_er_done(eo_obj, efl_event_desc);
|
||||
if (obj->is_smart)
|
||||
_evas_object_smart_callback_call_internal(eo_obj, efl_event_desc);
|
||||
|
||||
if (!_evas_object_callback_has_by_type(obj, type))
|
||||
goto nothing_here;
|
||||
|
|
|
@ -51,6 +51,9 @@ struct _Evas_Smart_Data
|
|||
Eina_Bool clipped : 1; /* If true, smart clipped */
|
||||
Eina_Bool data_nofree : 1; /* If true, do NOT free the data */
|
||||
Eina_Bool constructed : 1; /* constructor finished */
|
||||
Eina_Bool cb_move : 1; /* has "move" cb added */
|
||||
Eina_Bool cb_resize : 1; /* has "resize" cb added */
|
||||
Eina_Bool cb_restack : 1; /* has "restack" cb added */
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
@ -983,6 +986,35 @@ evas_object_smart_callback_add(Evas_Object *eo_obj, const char *event, Evas_Smar
|
|||
EVAS_CALLBACK_PRIORITY_DEFAULT, func, data);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_cb_check(Evas_Smart_Data *o, const char *event)
|
||||
{
|
||||
if (!o->cb_move)
|
||||
{
|
||||
if (eina_streq(event, "move"))
|
||||
{
|
||||
o->cb_move = EINA_TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!o->cb_resize)
|
||||
{
|
||||
if (eina_streq(event, "resize"))
|
||||
{
|
||||
o->cb_resize = EINA_TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!o->cb_restack)
|
||||
{
|
||||
if (eina_streq(event, "restack"))
|
||||
{
|
||||
o->cb_restack = EINA_TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_object_smart_callback_priority_add(Evas_Object *eo_obj, const char *event, Evas_Callback_Priority priority, Evas_Smart_Cb func, const void *data)
|
||||
{
|
||||
|
@ -996,6 +1028,7 @@ evas_object_smart_callback_priority_add(Evas_Object *eo_obj, const char *event,
|
|||
cb_info->func = func;
|
||||
cb_info->data = (void *)data;
|
||||
cb_info->event = eo_desc;
|
||||
_smart_cb_check(o, event);
|
||||
|
||||
o->callbacks = eina_inlist_append(o->callbacks,
|
||||
EINA_INLIST_GET(cb_info));
|
||||
|
@ -1069,6 +1102,33 @@ evas_object_smart_callback_call(Evas_Object *eo_obj, const char *event, void *ev
|
|||
efl_event_callback_legacy_call(eo_obj, eo_desc, event_info);
|
||||
}
|
||||
|
||||
void
|
||||
_evas_object_smart_callback_call_internal(Evas_Object *eo_obj, const Efl_Event_Description *efl_event_desc)
|
||||
{
|
||||
const char *event = NULL;
|
||||
EVAS_OBJECT_SMART_GET_OR_RETURN(eo_obj);
|
||||
|
||||
if (efl_event_desc == EFL_GFX_ENTITY_EVENT_POSITION_CHANGED)
|
||||
{
|
||||
if (!o->cb_move) return;
|
||||
event = "move";
|
||||
}
|
||||
else if (efl_event_desc == EFL_GFX_ENTITY_EVENT_SIZE_CHANGED)
|
||||
{
|
||||
if (!o->cb_resize) return;
|
||||
event = "resize";
|
||||
}
|
||||
else if (efl_event_desc == EFL_GFX_ENTITY_EVENT_STACKING_CHANGED)
|
||||
{
|
||||
if (!o->cb_restack) return;
|
||||
event = "restack";
|
||||
}
|
||||
else //invalidate
|
||||
return;
|
||||
const Efl_Event_Description *eo_desc = efl_object_legacy_only_event_description_get(event);
|
||||
efl_event_callback_legacy_call(eo_obj, eo_desc, NULL);
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_object_smart_callbacks_descriptions_set(Eo *eo_obj, const Evas_Smart_Cb_Description *descriptions)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue