efl_ui_focus_parent_provider_gen: do not accidently flatten the widgets
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Tue, 12 Jun 2018 08:40:38 +0000 (10:40 +0200)
committerJongmin Lee <jm105.lee@samsung.com>
Wed, 13 Jun 2018 23:50:57 +0000 (08:50 +0900)
in the provider we accidently flattend out the widget history by
returning the wrong parent. However, this flattening code was required
for the element focus code of the two generic widgets, so the item is
found for every widget, in every subtree.

src/lib/elementary/efl_ui_focus_parent_provider_gen.c
src/lib/elementary/efl_ui_focus_parent_provider_gen.eo
src/lib/elementary/elm_gengrid.c
src/lib/elementary/elm_genlist.c

index 8fc0134..4d76023 100644 (file)
@@ -52,6 +52,26 @@ _efl_ui_focus_parent_provider_gen_efl_ui_focus_parent_provider_find_logical_pare
    Elm_Widget_Item *item, *above_gengrid = widget;
    Efl_Ui_Widget *parent = elm_widget_parent_widget_get(widget);
 
+   if (parent == pd->container)
+     {
+        item = eina_hash_find(pd->map, &above_gengrid);
+        efl_ui_focus_object_prepare_logical(pd->container);
+
+        if (item)
+          return item;
+     }
+
+   // We dont have a map entry
+   return efl_ui_focus_parent_provider_find_logical_parent(pd->provider, widget);
+}
+
+EOLIAN static Efl_Ui_Widget*
+_efl_ui_focus_parent_provider_gen_item_fetch(Eo *obj, Efl_Ui_Focus_Parent_Provider_Gen_Data *pd, Efl_Ui_Widget *widget)
+{
+   //first check if this item is in the map
+   Elm_Widget_Item *item, *above_gengrid = widget;
+   Efl_Ui_Widget *parent = elm_widget_parent_widget_get(widget);
+
    //move forward so we get the last widget above the gengrid level,
    //this may be the widget out of the map
    while (parent && parent != pd->container)
@@ -64,12 +84,7 @@ _efl_ui_focus_parent_provider_gen_efl_ui_focus_parent_provider_find_logical_pare
 
    efl_ui_focus_object_prepare_logical(pd->container);
 
-   if (item)
-     return item;
-
-   // We dont have a map entry
-   return efl_ui_focus_parent_provider_find_logical_parent(pd->provider, widget);
+   return item;
 }
 
-
 #include "efl_ui_focus_parent_provider_gen.eo.c"
index eee12ca..4959fac 100644 (file)
@@ -13,6 +13,13 @@ class Efl.Ui.Focus.Parent_Provider_Gen(Efl.Object, Efl.Ui.Focus.Parent_Provider)
             container : Efl.Ui.Widget; [[Container widget]]
          }
       }
+      item_fetch {
+         [[Fetch the item where the item is a subchild from]]
+         params {
+            widget : Efl.Ui.Widget;
+         }
+         return : Efl.Ui.Widget;
+      }
    }
    implements {
       Efl.Ui.Focus.Parent_Provider.find_logical_parent;
index 38215b4..56f25a0 100644 (file)
@@ -5289,20 +5289,16 @@ _gengrid_element_focused(void *data, const Efl_Event *ev)
 
    if (!focused) return;
 
-   if (efl_isa(focused, EFL_UI_FOCUS_COMPOSITION_ADAPTER_CLASS))
-     item = efl_parent_get(focused);
-   else
-     item = efl_ui_focus_parent_provider_find_logical_parent(pd->provider, focused);
+   item = efl_ui_focus_parent_provider_gen_item_fetch(pd->provider, focused);
+
+   EINA_SAFETY_ON_FALSE_RETURN(efl_isa(item, ELM_GENGRID_ITEM_CLASS));
 
-   if (efl_isa(item, ELM_GENGRID_ITEM_CLASS))
+   _elm_gengrid_item_focused(item);
+   _all_items_deselect(pd);
+   if (!_elm_config->item_select_on_focus_disable)
      {
-        _elm_gengrid_item_focused(item);
-        _all_items_deselect(pd);
-        if (!_elm_config->item_select_on_focus_disable)
-          {
-             elm_gengrid_item_selected_set(item, EINA_TRUE);
-             elm_gengrid_item_bring_in(item, ELM_GENGRID_ITEM_SCROLLTO_MIDDLE);
-          }
+        elm_gengrid_item_selected_set(item, EINA_TRUE);
+        elm_gengrid_item_bring_in(item, ELM_GENGRID_ITEM_SCROLLTO_MIDDLE);
      }
 }
 
index da31ed1..f4a82a1 100644 (file)
@@ -6190,15 +6190,10 @@ _genlist_element_focused(void *data, const Efl_Event *ev)
 
    if (!focused) return;
 
-   if (efl_isa(focused, EFL_UI_FOCUS_COMPOSITION_ADAPTER_CLASS))
-     item = efl_parent_get(focused);
-   else
-     item = efl_ui_focus_parent_provider_find_logical_parent(pd->provider, focused);
+   item = efl_ui_focus_parent_provider_gen_item_fetch(pd->provider, focused);
 
-   if (efl_isa(item, ELM_GENLIST_ITEM_CLASS))
-     {
-        elm_object_item_focus_set(item, EINA_TRUE);
-     }
+   EINA_SAFETY_ON_FALSE_RETURN(efl_isa(item, ELM_GENLIST_ITEM_CLASS));
+   elm_object_item_focus_set(item, EINA_TRUE);
 }
 
 EOLIAN static Eo *