From f65e26a06b969cd1e641edfd2162fd78bece1335 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Fri, 11 Oct 2019 09:42:34 -0400 Subject: [PATCH] efl_ui_focus_object: do not emit focus_geometry_changed when not needed Summary: this is emitted a lot of times, which costs time. Most of the time they are however not needed. With this commit, these events are not emitted anymore. ref T8321 Reviewers: zmike, cedric Reviewed By: zmike, cedric Subscribers: #reviewers, #committers Tags: #efl Maniphest Tasks: T8321 Differential Revision: https://phab.enlightenment.org/D10348 --- src/lib/elementary/efl_ui_focus_object.c | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/lib/elementary/efl_ui_focus_object.c b/src/lib/elementary/efl_ui_focus_object.c index 92f8578..3c02b8c 100644 --- a/src/lib/elementary/efl_ui_focus_object.c +++ b/src/lib/elementary/efl_ui_focus_object.c @@ -7,10 +7,13 @@ #include #include "elm_priv.h" +#define MY_CLASS EFL_UI_FOCUS_OBJECT_MIXIN + typedef struct { Eina_Bool old_focus; Eina_Bool ongoing_prepare_call; Eina_Bool child_focus; + Eina_Bool focus_geom_changed; } Efl_Ui_Focus_Object_Data; EOLIAN static void @@ -65,5 +68,51 @@ _efl_ui_focus_object_child_focus_get(const Eo *obj EINA_UNUSED, Efl_Ui_Focus_Obj } +EOLIAN static Eina_Bool +_efl_ui_focus_object_efl_object_event_callback_priority_add(Eo *obj, Efl_Ui_Focus_Object_Data *pd, + const Efl_Event_Description *desc, + Efl_Callback_Priority priority, + Efl_Event_Cb func, + const void *user_data) +{ + if (desc == EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_GEOMETRY_CHANGED) + { + pd->focus_geom_changed = EINA_TRUE; + } + + return efl_event_callback_priority_add(efl_super(obj, MY_CLASS), desc, priority, func, user_data); +} + +EOLIAN static Eina_Bool +_efl_ui_focus_object_efl_object_event_callback_array_priority_add(Eo *obj, Efl_Ui_Focus_Object_Data *pd, + const Efl_Callback_Array_Item *array, + Efl_Callback_Priority priority, + const void *user_data) +{ + for (int i = 0; array[i].desc; ++i) + { + if (array[i].desc == EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_GEOMETRY_CHANGED) + { + pd->focus_geom_changed = EINA_TRUE; + } + } + return efl_event_callback_array_priority_add(efl_super(obj, MY_CLASS), array, priority, user_data); +} + + +EOLIAN static Eina_Bool +_efl_ui_focus_object_efl_object_event_callback_call(Eo *obj, Efl_Ui_Focus_Object_Data *pd, + const Efl_Event_Description *desc, + void *event_info) +{ + if (desc == EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_GEOMETRY_CHANGED && !pd->focus_geom_changed) + return EINA_TRUE; + return efl_event_callback_call(efl_super(obj, MY_CLASS), desc, event_info); +} + +#define EFL_UI_FOCUS_OBJECT_EXTRA_OPS \ + EFL_OBJECT_OP_FUNC(efl_event_callback_priority_add, _efl_ui_focus_object_efl_object_event_callback_priority_add), \ + EFL_OBJECT_OP_FUNC(efl_event_callback_array_priority_add, _efl_ui_focus_object_efl_object_event_callback_array_priority_add), \ + EFL_OBJECT_OP_FUNC(efl_event_callback_call, _efl_ui_focus_object_efl_object_event_callback_call) \ #include "efl_ui_focus_object.eo.c" -- 2.7.4