cedric pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=3a885cd6c72e7fb94c46f45bd900b8c2dcf26768

commit 3a885cd6c72e7fb94c46f45bd900b8c2dcf26768
Author: Lukasz Stanislawski <l.stanisl...@samsung.com>
Date:   Fri Oct 30 07:22:05 2015 +0100

    widget: update child_can_focus flag on focusability change
    
    Summary:
    Previously child_can_focus flag could be only updated when
    child is deleted from object's subobject list. This patch
    additionally updates child_can_focus flag when focusability
    is changed with elm_widget_focus_can_set function.
    
    Patch solves child_can_focus issue in similar situations:
    
    elm_icon_add(layout);
    elm_object_content_set(layout, icon);
    elm_widget_child_can_focus_get(layout); // returns EINA_TRUE
    
    icon = elm_icon_add(win);
    elm_object_content_set(layout, icon);
    elm_widget_child_can_focus_get(layout); // returns EINA_FALSE
    
    @fix
    
    Reviewers: cedric, stefan_schmidt
    
    Subscribers: seoz
    
    Differential Revision: https://phab.enlightenment.org/D3237
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/lib/elm_main.c   |  2 --
 src/lib/elm_widget.c | 23 +++++++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c
index d436274..faa8624 100644
--- a/src/lib/elm_main.c
+++ b/src/lib/elm_main.c
@@ -1380,8 +1380,6 @@ elm_object_focus_allow_set(Evas_Object *obj,
 {
    EINA_SAFETY_ON_NULL_RETURN(obj);
    elm_widget_can_focus_set(obj, enable);
-/*FIXME: According to the elm_object_focus_allow_get(), child_can_focus field
-of the parent should be updated. Otherwise, the checking of it's child focus 
allow states should not be in elm_object_focus_allow_get() */
 }
 
 EAPI Eina_Bool
diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c
index 65d049a..832ea1e 100644
--- a/src/lib/elm_widget.c
+++ b/src/lib/elm_widget.c
@@ -1401,6 +1401,29 @@ _elm_widget_can_focus_set(Eo *obj, Elm_Widget_Smart_Data 
*sd, Eina_Bool can_focu
      }
    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;
+          }
         eo_do(obj, eo_event_callback_array_del(focus_callbacks(), NULL));
      }
 }

-- 


Reply via email to