efl_ui_widget: child_can_focus is not needed anymore

summary_:
pd->logical.child_count is a counter where focusable children do
register themself in the parent if they can be focused or not. With this
we don't need the updating of this internal flag nor the flag itself anymore.

Depends on D8027

Reviewers: woohyun, cedric, Jaehyun_Cho, zmike, segfaultxavi

Reviewed By: segfaultxavi

Subscribers: #reviewers, #committers

Tags: #efl

Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es>
Differential Revision: https://phab.enlightenment.org/D8030
This commit is contained in:
Marcel Hollerbach 2019-02-27 14:01:16 -05:00
parent 0aaae8208e
commit 665f8877e9
2 changed files with 2 additions and 84 deletions

View File

@ -161,7 +161,7 @@ static inline Eina_Bool
_is_focusable(Evas_Object *obj)
{
API_ENTRY return EINA_FALSE;
return sd->can_focus || (sd->child_can_focus);
return sd->can_focus || (sd->logical.child_count > 0);
}
static inline Eina_Bool
@ -1414,23 +1414,6 @@ _efl_ui_widget_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob
efl_ui_widget_disabled_set(sobj, efl_ui_widget_disabled_get(obj));
_elm_widget_top_win_focused_set(sobj, sd->top_win_focused);
/* update child focusable-ness on self and parents, now that a
* focusable child got in */
if (!sd->child_can_focus && (_is_focusable(sobj)))
{
Elm_Widget_Smart_Data *sdp = sd;
sdp->child_can_focus = EINA_TRUE;
while (sdp->parent_obj)
{
sdp = efl_data_scope_get(sdp->parent_obj, MY_CLASS);
if (sdp->child_can_focus) break;
sdp->child_can_focus = EINA_TRUE;
}
}
}
else
{
@ -1523,35 +1506,6 @@ _efl_ui_widget_widget_sub_object_del(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob
elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
}
if ((sd->child_can_focus) && (_is_focusable(sobj)))
{
Evas_Object *parent = obj;
/* update child focusable-ness on self and parents, now that a
* focusable child is gone */
while (parent)
{
const Eina_List *l;
Evas_Object *subobj;
ELM_WIDGET_DATA_GET(parent, sdp);
sdp->child_can_focus = EINA_FALSE;
EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
{
if ((subobj != sobj) && (_is_focusable(subobj)))
{
sdp->child_can_focus = EINA_TRUE;
break;
}
}
/* break again, child_can_focus went back to
* original value */
if (sdp->child_can_focus) break;
parent = sdp->parent_obj;
}
}
if (_elm_config->atspi_mode && !sd->on_destroy)
{
Efl_Access_Object *aparent;
@ -1655,45 +1609,10 @@ _efl_ui_widget_focus_allow_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool can
sd->can_focus = can_focus;
if (sd->can_focus)
{
/* update child_can_focus of parents */
Evas_Object *o = obj;
for (;;)
{
o = elm_widget_parent_get(o);
if (!o) break;
ELM_WIDGET_DATA_GET(o, sdp);
if (!sdp || sdp->child_can_focus) break;
sdp->child_can_focus = EINA_TRUE;
}
efl_event_callback_array_add(obj, focus_callbacks(), NULL);
}
else
{
// update child_can_focus of parents */
Evas_Object *parent = elm_widget_parent_get(obj);
while (parent)
{
const Eina_List *l;
Evas_Object *subobj;
ELM_WIDGET_DATA_GET(parent, sdp);
sdp->child_can_focus = EINA_FALSE;
EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
{
if (_is_focusable(subobj))
{
sdp->child_can_focus = EINA_TRUE;
break;
}
}
/* break again, child_can_focus went back to
* original value */
if (sdp->child_can_focus) break;
parent = sdp->parent_obj;
}
efl_event_callback_array_del(obj, focus_callbacks(), NULL);
}
if (efl_finalized_get(obj))
@ -1712,7 +1631,7 @@ elm_widget_child_can_focus_get(const Eo *obj)
Elm_Widget_Smart_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
if (!sd) return EINA_FALSE;
return sd->child_can_focus;
return sd->logical.child_count > 0;
}
/**

View File

@ -387,7 +387,6 @@ typedef struct _Elm_Widget_Smart_Data
Eina_Bool scroll_y_locked : 1;
Eina_Bool can_focus : 1;
Eina_Bool child_can_focus : 1;
Eina_Bool focused : 1;
Eina_Bool top_win_focused : 1;
Eina_Bool tree_unfocusable : 1;