summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-02-27 14:01:16 -0500
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-02-27 20:19:31 +0100
commit665f8877e93aa729a4d2eb8b532e69ad3580435b (patch)
treefe60ad52dc6273d1f3295ca1de2c91669b345241
parent0aaae8208e458a7946376e4dcddf03e071021722 (diff)
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
-rw-r--r--src/lib/elementary/efl_ui_widget.c85
-rw-r--r--src/lib/elementary/elm_widget.h1
2 files changed, 2 insertions, 84 deletions
diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c
index f8ead14608..57564eeea3 100644
--- a/src/lib/elementary/efl_ui_widget.c
+++ b/src/lib/elementary/efl_ui_widget.c
@@ -161,7 +161,7 @@ static inline Eina_Bool
161_is_focusable(Evas_Object *obj) 161_is_focusable(Evas_Object *obj)
162{ 162{
163 API_ENTRY return EINA_FALSE; 163 API_ENTRY return EINA_FALSE;
164 return sd->can_focus || (sd->child_can_focus); 164 return sd->can_focus || (sd->logical.child_count > 0);
165} 165}
166 166
167static inline Eina_Bool 167static inline Eina_Bool
@@ -1414,23 +1414,6 @@ _efl_ui_widget_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob
1414 efl_ui_widget_disabled_set(sobj, efl_ui_widget_disabled_get(obj)); 1414 efl_ui_widget_disabled_set(sobj, efl_ui_widget_disabled_get(obj));
1415 1415
1416 _elm_widget_top_win_focused_set(sobj, sd->top_win_focused); 1416 _elm_widget_top_win_focused_set(sobj, sd->top_win_focused);
1417
1418 /* update child focusable-ness on self and parents, now that a
1419 * focusable child got in */
1420 if (!sd->child_can_focus && (_is_focusable(sobj)))
1421 {
1422 Elm_Widget_Smart_Data *sdp = sd;
1423
1424 sdp->child_can_focus = EINA_TRUE;
1425 while (sdp->parent_obj)
1426 {
1427 sdp = efl_data_scope_get(sdp->parent_obj, MY_CLASS);
1428
1429 if (sdp->child_can_focus) break;
1430
1431 sdp->child_can_focus = EINA_TRUE;
1432 }
1433 }
1434 } 1417 }
1435 else 1418 else
1436 { 1419 {
@@ -1523,35 +1506,6 @@ _efl_ui_widget_widget_sub_object_del(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob
1523 elm_widget_tree_unfocusable_set(sobj, EINA_TRUE); 1506 elm_widget_tree_unfocusable_set(sobj, EINA_TRUE);
1524 elm_widget_tree_unfocusable_set(sobj, EINA_FALSE); 1507 elm_widget_tree_unfocusable_set(sobj, EINA_FALSE);
1525 } 1508 }
1526 if ((sd->child_can_focus) && (_is_focusable(sobj)))
1527 {
1528 Evas_Object *parent = obj;
1529
1530 /* update child focusable-ness on self and parents, now that a
1531 * focusable child is gone */
1532 while (parent)
1533 {
1534 const Eina_List *l;
1535 Evas_Object *subobj;
1536
1537 ELM_WIDGET_DATA_GET(parent, sdp);
1538
1539 sdp->child_can_focus = EINA_FALSE;
1540 EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
1541 {
1542 if ((subobj != sobj) && (_is_focusable(subobj)))
1543 {
1544 sdp->child_can_focus = EINA_TRUE;
1545 break;
1546 }
1547 }
1548
1549 /* break again, child_can_focus went back to
1550 * original value */
1551 if (sdp->child_can_focus) break;
1552 parent = sdp->parent_obj;
1553 }
1554 }
1555 if (_elm_config->atspi_mode && !sd->on_destroy) 1509 if (_elm_config->atspi_mode && !sd->on_destroy)
1556 { 1510 {
1557 Efl_Access_Object *aparent; 1511 Efl_Access_Object *aparent;
@@ -1655,45 +1609,10 @@ _efl_ui_widget_focus_allow_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool can
1655 sd->can_focus = can_focus; 1609 sd->can_focus = can_focus;
1656 if (sd->can_focus) 1610 if (sd->can_focus)
1657 { 1611 {
1658 /* update child_can_focus of parents */
1659 Evas_Object *o = obj;
1660
1661 for (;;)
1662 {
1663 o = elm_widget_parent_get(o);
1664 if (!o) break;
1665 ELM_WIDGET_DATA_GET(o, sdp);
1666 if (!sdp || sdp->child_can_focus) break;
1667 sdp->child_can_focus = EINA_TRUE;
1668 }
1669
1670 efl_event_callback_array_add(obj, focus_callbacks(), NULL); 1612 efl_event_callback_array_add(obj, focus_callbacks(), NULL);
1671 } 1613 }
1672 else 1614 else
1673 { 1615 {
1674 // update child_can_focus of parents */
1675 Evas_Object *parent = elm_widget_parent_get(obj);
1676 while (parent)
1677 {
1678 const Eina_List *l;
1679 Evas_Object *subobj;
1680
1681 ELM_WIDGET_DATA_GET(parent, sdp);
1682
1683 sdp->child_can_focus = EINA_FALSE;
1684 EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
1685 {
1686 if (_is_focusable(subobj))
1687 {
1688 sdp->child_can_focus = EINA_TRUE;
1689 break;
1690 }
1691 }
1692 /* break again, child_can_focus went back to
1693 * original value */
1694 if (sdp->child_can_focus) break;
1695 parent = sdp->parent_obj;
1696 }
1697 efl_event_callback_array_del(obj, focus_callbacks(), NULL); 1616 efl_event_callback_array_del(obj, focus_callbacks(), NULL);
1698 } 1617 }
1699 if (efl_finalized_get(obj)) 1618 if (efl_finalized_get(obj))
@@ -1712,7 +1631,7 @@ elm_widget_child_can_focus_get(const Eo *obj)
1712 Elm_Widget_Smart_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS); 1631 Elm_Widget_Smart_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
1713 if (!sd) return EINA_FALSE; 1632 if (!sd) return EINA_FALSE;
1714 1633
1715 return sd->child_can_focus; 1634 return sd->logical.child_count > 0;
1716} 1635}
1717 1636
1718/** 1637/**
diff --git a/src/lib/elementary/elm_widget.h b/src/lib/elementary/elm_widget.h
index 3763d955ba..e53c3cfef3 100644
--- a/src/lib/elementary/elm_widget.h
+++ b/src/lib/elementary/elm_widget.h
@@ -387,7 +387,6 @@ typedef struct _Elm_Widget_Smart_Data
387 Eina_Bool scroll_y_locked : 1; 387 Eina_Bool scroll_y_locked : 1;
388 388
389 Eina_Bool can_focus : 1; 389 Eina_Bool can_focus : 1;
390 Eina_Bool child_can_focus : 1;
391 Eina_Bool focused : 1; 390 Eina_Bool focused : 1;
392 Eina_Bool top_win_focused : 1; 391 Eina_Bool top_win_focused : 1;
393 Eina_Bool tree_unfocusable : 1; 392 Eina_Bool tree_unfocusable : 1;