efl_ui_widget: add a place to share data

this introduces a shared place to all widgets. The shared pointer is
allocated in the window, as the window outlifes every widget that is
part of it.

This struct will be later used for further optimizations like:

1. There are really heavy focus operations which are only needed for
gengrid/genlst, there is no point in executing them if there is no
gen**** added to the window object. So we can skip the custom
parent_provider logic that is only introduced for gengrid / genlist.

2. Legacy focus APIs must do list walks, which means, on every focus
operation we always have to walk the full list up to the parent, which
is annoying and slow, as we *most of the time* do not use legacy focus
API.

This list can be continued, the above two cases are fixed in the next
revisions.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D9642
This commit is contained in:
Marcel Hollerbach 2019-08-20 08:58:52 +02:00 committed by Cedric BAIL
parent 10501b170f
commit aa2d94f901
4 changed files with 33 additions and 6 deletions

View File

@ -4768,12 +4768,8 @@ EOLIAN static Eo *
_efl_ui_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
{
sd->on_create = EINA_TRUE;
sd->window = efl_provider_find(efl_parent_get(obj), EFL_UI_WIN_CLASS);
_efl_ui_focus_event_redirector(obj, obj);
efl_canvas_group_clipped_set(obj, EINA_FALSE);
obj = efl_constructor(efl_super(obj, MY_CLASS));
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
if (!efl_isa(obj, EFL_UI_WIN_CLASS))
{
Eo *parent = efl_parent_get(obj);
@ -4783,14 +4779,27 @@ _efl_ui_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UN
"Elementary widget's parent should be an elementary widget.",
parent, evas_object_type_get(parent));
}
ELM_WIDGET_DATA_GET(parent, parent_sd);
sd->shared_win_data = parent_sd->shared_win_data;
efl_ui_widget_sub_object_add(parent, obj);
}
else
{
sd->shared_win_data = efl_ui_win_shared_data_get(obj);
}
_efl_ui_focus_event_redirector(obj, obj);
efl_canvas_group_clipped_set(obj, EINA_FALSE);
obj = efl_constructor(efl_super(obj, MY_CLASS));
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
sd->on_create = EINA_FALSE;
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_UNKNOWN);
EINA_SAFETY_ON_NULL_RETURN_VAL(sd->shared_win_data, NULL);
return obj;
}

View File

@ -269,6 +269,7 @@ struct _Efl_Ui_Win_Data
Eina_Bool bg_must_swallow_init : 1;
Eina_Bool ctor : 1; /**< legacy constructor: elm_win~add */
} legacy;
Efl_Ui_Shared_Win_Data spd;
Eina_Value exit_on_close;
@ -9441,3 +9442,12 @@ elm_win_focus_highlight_style_get(const Efl_Ui_Win *obj)
{
return efl_ui_win_focus_highlight_style_get(obj);
}
EAPI Efl_Ui_Shared_Win_Data*
efl_ui_win_shared_data_get(Efl_Ui_Win *obj)
{
Efl_Ui_Win_Data *pd = efl_data_scope_safe_get(obj, MY_CLASS);
EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL);
return &pd->spd;
}

View File

@ -1041,4 +1041,11 @@ void efl_ui_scroll_connector_bind(Eo *obj, Eo *manager);
*/
void efl_ui_scroll_connector_unbind(Eo *obj);
typedef struct
{
} Efl_Ui_Shared_Win_Data;
Efl_Ui_Shared_Win_Data* efl_ui_win_shared_data_get(Efl_Ui_Win *win);
#endif

View File

@ -391,6 +391,7 @@ typedef struct _Elm_Widget_Smart_Data
Eina_Hash *view_lookup;
Eina_Bool registered : 1;
} properties;
void *shared_win_data;
Eina_Bool scroll_x_locked : 1;
Eina_Bool scroll_y_locked : 1;