elm_object: Restore child_can_focus 67/201267/5
authorYeongjong Lee <yj34.lee@samsung.com>
Tue, 12 Mar 2019 04:15:49 +0000 (13:15 +0900)
committerYeongJong Lee <yj34.lee@samsung.com>
Tue, 2 Apr 2019 03:44:33 +0000 (03:44 +0000)
child_can_focus is needed for legacy focus.

@tizen_fix

Change-Id: Ifa36e5065af4b0a9d7ccc9983bae0be144d4daa2

src/lib/elementary/efl_ui_widget.c
src/lib/elementary/elm_widget.h

index 3b68822..9a604b4 100644 (file)
@@ -235,7 +235,10 @@ static inline Eina_Bool
 _is_focusable(Evas_Object *obj)
 {
    API_ENTRY return EINA_FALSE;
-   return sd->can_focus || (sd->logical.child_count > 0);
+//TIZEN_ONLY(20190312): Restore child_can_focus
+   //return sd->can_focus || (sd->logical.child_count > 0);
+   return sd->can_focus || (sd->child_can_focus);
+//
 }
 
 static inline Eina_Bool
@@ -1563,6 +1566,25 @@ _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);
+
+//TIZEN_ONLY(20190312): Restore child_can_focus
+        /* 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
      {
@@ -1677,6 +1699,39 @@ _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);
           }
+
+//TIZEN_ONLY(20190312): Restore child_can_focus
+        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_atspi_enabled() && !sd->on_destroy)
           {
              Efl_Access_Object *aparent;
@@ -1794,10 +1849,49 @@ _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)
      {
+//TIZEN_ONLY(20190312): Restore child_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
      {
+//TIZEN_ONLY(20190312): Restore child_can_focus
+        // 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))
@@ -1816,7 +1910,10 @@ 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->logical.child_count > 0;
+//TIZEN_ONLY(20190312): Restore child_can_focus
+   //return sd->logical.child_count > 0;
+   return sd->child_can_focus;
+//
 }
 
 /**
index d144d96..0a10e5f 100644 (file)
@@ -420,6 +420,7 @@ 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;