zmike pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=e96d18b0462b77d051424d6ff510c5d5e3c3140b

commit e96d18b0462b77d051424d6ff510c5d5e3c3140b
Author: Mike Blumenkrantz <zm...@samsung.com>
Date:   Mon Oct 14 09:29:23 2019 -0400

    evas/callbacks: emit hardcoded legacy smart callbacks always
    
    Summary:
    these are not strictly related to the event callback types and should not
    have their emission tied to the corresponding event
    
    also add unit test to verify all of these
    
    @fix
    
    Reviewers: cedric
    
    Reviewed By: cedric
    
    Subscribers: bu5hm4n, cedric, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D10353
---
 src/lib/evas/canvas/evas_callbacks.c | 11 +++++++++--
 src/tests/evas/evas_test_callbacks.c | 25 +++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/lib/evas/canvas/evas_callbacks.c 
b/src/lib/evas/canvas/evas_callbacks.c
index 35ef78aef2..1f86f63168 100644
--- a/src/lib/evas/canvas/evas_callbacks.c
+++ b/src/lib/evas/canvas/evas_callbacks.c
@@ -348,7 +348,7 @@ evas_event_callback_call(Evas *eo_e, Evas_Callback_Type 
type, void *event_info)
 }
 
 static void
-_evas_callback_legacy_smart_compatibility_do_it(Evas_Object *eo_obj, const 
Efl_Event_Description *efl_event_desc, void *event_info)
+_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);
@@ -356,8 +356,13 @@ 
_evas_callback_legacy_smart_compatibility_do_it(Evas_Object *eo_obj, const Efl_E
      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)
+{
    /* this is inverted: the base call is the legacy compat and this is the new 
event */
-   else if ((efl_event_desc == EFL_GFX_ENTITY_EVENT_SHOW) || (efl_event_desc 
== EFL_GFX_ENTITY_EVENT_HIDE))
+   if ((efl_event_desc == EFL_GFX_ENTITY_EVENT_SHOW) || (efl_event_desc == 
EFL_GFX_ENTITY_EVENT_HIDE))
      efl_event_callback_call(eo_obj, EFL_GFX_ENTITY_EVENT_VISIBILITY_CHANGED, 
event_info);
    else if ((efl_event_desc == EFL_GFX_IMAGE_EVENT_IMAGE_PRELOAD) || 
(efl_event_desc == EFL_GFX_IMAGE_EVENT_IMAGE_UNLOAD))
      efl_event_callback_call(eo_obj, 
EFL_GFX_IMAGE_EVENT_IMAGE_PRELOAD_STATE_CHANGED, event_info);
@@ -403,6 +408,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 (!_evas_object_callback_has_by_type(obj, type))
      goto nothing_here;
 
diff --git a/src/tests/evas/evas_test_callbacks.c 
b/src/tests/evas/evas_test_callbacks.c
index 0b61ca55a2..58da305657 100644
--- a/src/tests/evas/evas_test_callbacks.c
+++ b/src/tests/evas/evas_test_callbacks.c
@@ -145,8 +145,33 @@ EFL_START_TEST(evas_event_callbacks_priority)
 }
 EFL_END_TEST
 
+static void
+_smart_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info 
EINA_UNUSED)
+{
+   int *called = data;
+
+   (*called)++;
+}
+
+EFL_START_TEST(evas_event_callbacks_smart)
+{
+   int called = 0;
+   Eo *box;
+   START_CALLBACK_TEST();
+   box = evas_object_box_add(evas);
+   evas_object_smart_callback_add(box, "move", _smart_cb, &called);
+   evas_object_smart_callback_add(box, "resize", _smart_cb, &called);
+   evas_object_smart_callback_add(box, "restack", _smart_cb, &called);
+   evas_object_geometry_set(box, 1, 1, 10, 10);
+   evas_object_layer_set(box, 10);
+   ck_assert_int_eq(called, 3);
+   END_CALLBACK_TEST();
+}
+EFL_END_TEST
+
 void evas_test_callbacks(TCase *tc)
 {
    tcase_add_test(tc, evas_object_event_callbacks_priority);
    tcase_add_test(tc, evas_event_callbacks_priority);
+   tcase_add_test(tc, evas_event_callbacks_smart);
 }

-- 


Reply via email to