summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-10-14 09:29:37 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-10-14 09:29:37 -0400
commit3175690466bc441c3fb2b55145fb0985b0e97f10 (patch)
tree379a42a403caaff902084ca09d16f446de0e1080
parent8218fb0e2030c49ed92acd7431f57ef41d367ab7 (diff)
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
-rw-r--r--src/lib/evas/canvas/evas_callbacks.c15
-rw-r--r--src/lib/evas/canvas/evas_object_smart.c60
2 files changed, 63 insertions, 12 deletions
diff --git a/src/lib/evas/canvas/evas_callbacks.c b/src/lib/evas/canvas/evas_callbacks.c
index 1f86f63..65b78f2 100644
--- a/src/lib/evas/canvas/evas_callbacks.c
+++ b/src/lib/evas/canvas/evas_callbacks.c
@@ -10,6 +10,7 @@ EVAS_MEMPOOL(_mp_pc);
10extern Eina_Hash* signals_hash_table; 10extern Eina_Hash* signals_hash_table;
11 11
12/* Legacy events, do not use anywhere */ 12/* Legacy events, do not use anywhere */
13void _evas_object_smart_callback_call_internal(Evas_Object *eo_obj, const Efl_Event_Description *efl_event_desc);
13static const Efl_Event_Description _EVAS_OBJECT_EVENT_FREE = EFL_EVENT_DESCRIPTION("free"); 14static const Efl_Event_Description _EVAS_OBJECT_EVENT_FREE = EFL_EVENT_DESCRIPTION("free");
14static const Efl_Event_Description _EVAS_OBJECT_EVENT_DEL = EFL_EVENT_DESCRIPTION("del"); 15static const Efl_Event_Description _EVAS_OBJECT_EVENT_DEL = EFL_EVENT_DESCRIPTION("del");
15#define EVAS_OBJECT_EVENT_FREE (&(_EVAS_OBJECT_EVENT_FREE)) 16#define EVAS_OBJECT_EVENT_FREE (&(_EVAS_OBJECT_EVENT_FREE))
@@ -348,17 +349,6 @@ evas_event_callback_call(Evas *eo_e, Evas_Callback_Type type, void *event_info)
348} 349}
349 350
350static void 351static void
351_evas_smart_callback_legacy_git_er_done(Evas_Object *eo_obj, const Efl_Event_Description *efl_event_desc)
352{
353 if (efl_event_desc == EFL_GFX_ENTITY_EVENT_POSITION_CHANGED)
354 evas_object_smart_callback_call(eo_obj, "move", NULL);
355 else if (efl_event_desc == EFL_GFX_ENTITY_EVENT_SIZE_CHANGED)
356 evas_object_smart_callback_call(eo_obj, "resize", NULL);
357 else if (efl_event_desc == EFL_GFX_ENTITY_EVENT_STACKING_CHANGED)
358 evas_object_smart_callback_call(eo_obj, "restack", NULL);
359}
360
361static void
362_evas_callback_legacy_smart_compatibility_do_it(Evas_Object *eo_obj, const Efl_Event_Description *efl_event_desc, void *event_info) 352_evas_callback_legacy_smart_compatibility_do_it(Evas_Object *eo_obj, const Efl_Event_Description *efl_event_desc, void *event_info)
363{ 353{
364 /* this is inverted: the base call is the legacy compat and this is the new event */ 354 /* this is inverted: the base call is the legacy compat and this is the new event */
@@ -408,7 +398,8 @@ evas_object_event_callback_call(Evas_Object *eo_obj, Evas_Object_Protected_Data
408 type == EVAS_CALLBACK_MULTI_UP) 398 type == EVAS_CALLBACK_MULTI_UP)
409 _efl_canvas_gesture_manager_filter_event(e->gesture_manager, eo_obj, event_info); 399 _efl_canvas_gesture_manager_filter_event(e->gesture_manager, eo_obj, event_info);
410 400
411 _evas_smart_callback_legacy_git_er_done(eo_obj, efl_event_desc); 401 if (obj->is_smart)
402 _evas_object_smart_callback_call_internal(eo_obj, efl_event_desc);
412 403
413 if (!_evas_object_callback_has_by_type(obj, type)) 404 if (!_evas_object_callback_has_by_type(obj, type))
414 goto nothing_here; 405 goto nothing_here;
diff --git a/src/lib/evas/canvas/evas_object_smart.c b/src/lib/evas/canvas/evas_object_smart.c
index 3e5cba9..7950545 100644
--- a/src/lib/evas/canvas/evas_object_smart.c
+++ b/src/lib/evas/canvas/evas_object_smart.c
@@ -51,6 +51,9 @@ struct _Evas_Smart_Data
51 Eina_Bool clipped : 1; /* If true, smart clipped */ 51 Eina_Bool clipped : 1; /* If true, smart clipped */
52 Eina_Bool data_nofree : 1; /* If true, do NOT free the data */ 52 Eina_Bool data_nofree : 1; /* If true, do NOT free the data */
53 Eina_Bool constructed : 1; /* constructor finished */ 53 Eina_Bool constructed : 1; /* constructor finished */
54 Eina_Bool cb_move : 1; /* has "move" cb added */
55 Eina_Bool cb_resize : 1; /* has "resize" cb added */
56 Eina_Bool cb_restack : 1; /* has "restack" cb added */
54}; 57};
55 58
56typedef struct 59typedef struct
@@ -983,6 +986,35 @@ evas_object_smart_callback_add(Evas_Object *eo_obj, const char *event, Evas_Smar
983 EVAS_CALLBACK_PRIORITY_DEFAULT, func, data); 986 EVAS_CALLBACK_PRIORITY_DEFAULT, func, data);
984} 987}
985 988
989static void
990_smart_cb_check(Evas_Smart_Data *o, const char *event)
991{
992 if (!o->cb_move)
993 {
994 if (eina_streq(event, "move"))
995 {
996 o->cb_move = EINA_TRUE;
997 return;
998 }
999 }
1000 if (!o->cb_resize)
1001 {
1002 if (eina_streq(event, "resize"))
1003 {
1004 o->cb_resize = EINA_TRUE;
1005 return;
1006 }
1007 }
1008 if (!o->cb_restack)
1009 {
1010 if (eina_streq(event, "restack"))
1011 {
1012 o->cb_restack = EINA_TRUE;
1013 return;
1014 }
1015 }
1016}
1017
986EAPI void 1018EAPI void
987evas_object_smart_callback_priority_add(Evas_Object *eo_obj, const char *event, Evas_Callback_Priority priority, Evas_Smart_Cb func, const void *data) 1019evas_object_smart_callback_priority_add(Evas_Object *eo_obj, const char *event, Evas_Callback_Priority priority, Evas_Smart_Cb func, const void *data)
988{ 1020{
@@ -996,6 +1028,7 @@ evas_object_smart_callback_priority_add(Evas_Object *eo_obj, const char *event,
996 cb_info->func = func; 1028 cb_info->func = func;
997 cb_info->data = (void *)data; 1029 cb_info->data = (void *)data;
998 cb_info->event = eo_desc; 1030 cb_info->event = eo_desc;
1031 _smart_cb_check(o, event);
999 1032
1000 o->callbacks = eina_inlist_append(o->callbacks, 1033 o->callbacks = eina_inlist_append(o->callbacks,
1001 EINA_INLIST_GET(cb_info)); 1034 EINA_INLIST_GET(cb_info));
@@ -1069,6 +1102,33 @@ evas_object_smart_callback_call(Evas_Object *eo_obj, const char *event, void *ev
1069 efl_event_callback_legacy_call(eo_obj, eo_desc, event_info); 1102 efl_event_callback_legacy_call(eo_obj, eo_desc, event_info);
1070} 1103}
1071 1104
1105void
1106_evas_object_smart_callback_call_internal(Evas_Object *eo_obj, const Efl_Event_Description *efl_event_desc)
1107{
1108 const char *event = NULL;
1109 EVAS_OBJECT_SMART_GET_OR_RETURN(eo_obj);
1110
1111 if (efl_event_desc == EFL_GFX_ENTITY_EVENT_POSITION_CHANGED)
1112 {
1113 if (!o->cb_move) return;
1114 event = "move";
1115 }
1116 else if (efl_event_desc == EFL_GFX_ENTITY_EVENT_SIZE_CHANGED)
1117 {
1118 if (!o->cb_resize) return;
1119 event = "resize";
1120 }
1121 else if (efl_event_desc == EFL_GFX_ENTITY_EVENT_STACKING_CHANGED)
1122 {
1123 if (!o->cb_restack) return;
1124 event = "restack";
1125 }
1126 else //invalidate
1127 return;
1128 const Efl_Event_Description *eo_desc = efl_object_legacy_only_event_description_get(event);
1129 efl_event_callback_legacy_call(eo_obj, eo_desc, NULL);
1130}
1131
1072EAPI Eina_Bool 1132EAPI Eina_Bool
1073evas_object_smart_callbacks_descriptions_set(Eo *eo_obj, const Evas_Smart_Cb_Description *descriptions) 1133evas_object_smart_callbacks_descriptions_set(Eo *eo_obj, const Evas_Smart_Cb_Description *descriptions)
1074{ 1134{