elm_gen****: ensure that no focus item is handled correctly
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Fri, 2 Nov 2018 01:17:26 +0000 (02:17 +0100)
committerHermet Park <hermetpark@gmail.com>
Wed, 5 Dec 2018 05:02:34 +0000 (14:02 +0900)
This ensures that on first touch the root dummy element is focused
correctly.

fix T7203

Differential Revision: https://phab.enlightenment.org/D7231

Change-Id: Icaaad4d03b50430e87f2c3d2bb46d5be65d09b70

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

index 4845685..a2ea9fc 100644 (file)
@@ -5246,7 +5246,7 @@ elm_gengrid_add(Evas_Object *parent)
 }
 
 EOLIAN static void
-_elm_gengrid_efl_ui_focus_manager_setup_on_first_touch(Eo *obj, Elm_Gengrid_Data *pd, Efl_Ui_Focus_Direction direction, Efl_Ui_Focus_Object *entry EINA_UNUSED)
+_elm_gengrid_efl_ui_focus_manager_setup_on_first_touch(Eo *obj, Elm_Gengrid_Data *pd, Efl_Ui_Focus_Direction direction, Efl_Ui_Focus_Object *entry)
 {
    Elm_Object_Item *eo_it = NULL;
 
@@ -5254,37 +5254,44 @@ _elm_gengrid_efl_ui_focus_manager_setup_on_first_touch(Eo *obj, Elm_Gengrid_Data
    if (elm_widget_is_legacy(obj)) return;
    //
 
-   if (pd->last_focused_item)
-     eo_it = pd->last_focused_item;
-   else if (pd->last_selected_item)
-     eo_it = pd->last_selected_item;
-   else if (_elm_config->first_item_focus_on_first_focus_in)
+   if (!pd->items)
      {
-        if (direction == EFL_UI_FOCUS_DIRECTION_NEXT)
-          {
-             eo_it = elm_gengrid_first_item_get(obj);
-          }
-        else if (direction == EFL_UI_FOCUS_DIRECTION_PREVIOUS)
+        efl_ui_focus_manager_setup_on_first_touch(efl_super(obj, MY_CLASS), direction, entry);
+     }
+   else
+     {
+        if (pd->last_focused_item)
+          eo_it = pd->last_focused_item;
+        else if (pd->last_selected_item)
+          eo_it = pd->last_selected_item;
+        else if (_elm_config->first_item_focus_on_first_focus_in)
           {
-             eo_it = elm_gengrid_last_item_get(obj);
+             if (direction == EFL_UI_FOCUS_DIRECTION_NEXT)
+               {
+                  eo_it = elm_gengrid_first_item_get(obj);
+               }
+             else if (direction == EFL_UI_FOCUS_DIRECTION_PREVIOUS)
+               {
+                  eo_it = elm_gengrid_last_item_get(obj);
+               }
           }
-     }
 
-   eo_it = _elm_gengrid_nearest_visible_item_get(obj, eo_it);
+        eo_it = _elm_gengrid_nearest_visible_item_get(obj, eo_it);
 
-   if (eo_it)
-     {
-        if (!_elm_config->item_select_on_focus_disable &&
-            eo_it != pd->last_selected_item)
-          elm_gengrid_item_selected_set(eo_it, EINA_TRUE);
+        if (eo_it)
+          {
+             if (!_elm_config->item_select_on_focus_disable &&
+                 eo_it != pd->last_selected_item)
+               elm_gengrid_item_selected_set(eo_it, EINA_TRUE);
+             else
+               efl_ui_focus_manager_focus_set(obj, eo_it);
+          }
         else
-          efl_ui_focus_manager_focus_set(obj, eo_it);
-     }
-   else
-     {
-        //Just set evas focus on the gengrid itself, events will pass on and some element will be taken
-        evas_object_focus_set(obj, EINA_TRUE);
-     }
+          {
+             //Just set evas focus on the gengrid itself, events will pass on and some element will be taken
+             evas_object_focus_set(obj, EINA_TRUE);
+          }
+      }
 }
 
 static void
index 2b1325d..91aa3f8 100644 (file)
@@ -3545,44 +3545,51 @@ _elm_genlist_efl_ui_focus_manager_setup_on_first_touch(Eo *obj, Elm_Genlist_Data
    if (elm_widget_is_legacy(obj)) return;
    //
 
-   if (sd->last_focused_item)
-     eo_it = sd->last_focused_item;
-   else if (sd->last_selected_item)
-     eo_it = sd->last_selected_item;
-   else if (_elm_config->first_item_focus_on_first_focus_in)
+   if (!sd->items)
      {
-        eo_it = elm_genlist_first_item_get(obj);
-        is_sel = EINA_TRUE;
+        efl_ui_focus_manager_setup_on_first_touch(efl_super(obj, MY_CLASS), direction, entry);
      }
-
-   while (eo_it)
+   else
      {
-        ELM_GENLIST_ITEM_DATA_GET(eo_it, it);
-        if ((!_is_no_select(it)) && (!elm_object_item_disabled_get(eo_it)))
-          break;
-        eo_it = EO_OBJ(ELM_GEN_ITEM_NEXT(it));
-     }
+        if (sd->last_focused_item)
+          eo_it = sd->last_focused_item;
+        else if (sd->last_selected_item)
+          eo_it = sd->last_selected_item;
+        else if (_elm_config->first_item_focus_on_first_focus_in)
+          {
+             eo_it = elm_genlist_first_item_get(obj);
+             is_sel = EINA_TRUE;
+          }
+
+        while (eo_it)
+          {
+             ELM_GENLIST_ITEM_DATA_GET(eo_it, it);
+             if ((!_is_no_select(it)) && (!elm_object_item_disabled_get(eo_it)))
+               break;
+             eo_it = EO_OBJ(ELM_GEN_ITEM_NEXT(it));
+          }
 
-   if (eo_it)
-     {
-        eo_it = _elm_genlist_nearest_visible_item_get(obj, eo_it);
         if (eo_it)
           {
-             if (!_elm_config->item_select_on_focus_disable && is_sel)
-               elm_genlist_item_selected_set(eo_it, EINA_TRUE);
-             else
-               elm_object_item_focus_set(eo_it, EINA_TRUE);
-            _elm_widget_focus_highlight_start(obj);
-            //set it again in the manager, there might be the case that the manager focus history and internal item foused logic are in different states
-            if (efl_ui_focus_manager_request_subchild(obj, eo_it))
-              efl_ui_focus_manager_focus_set(obj, eo_it);
+             eo_it = _elm_genlist_nearest_visible_item_get(obj, eo_it);
+             if (eo_it)
+               {
+                  if (!_elm_config->item_select_on_focus_disable && is_sel)
+                    elm_genlist_item_selected_set(eo_it, EINA_TRUE);
+                  else
+                    elm_object_item_focus_set(eo_it, EINA_TRUE);
+                 _elm_widget_focus_highlight_start(obj);
+                 //set it again in the manager, there might be the case that the manager focus history and internal item foused logic are in different states
+                 if (efl_ui_focus_manager_request_subchild(obj, eo_it))
+                   efl_ui_focus_manager_focus_set(obj, eo_it);
+               }
           }
-     }
-   else
-     {
-        //Just set evas focus on the genlist itself, events will pass on and a other element will be taken
-        evas_object_focus_set(obj, EINA_TRUE);
-     }
+        else
+          {
+             //Just set evas focus on the genlist itself, events will pass on and a other element will be taken
+             evas_object_focus_set(obj, EINA_TRUE);
+          }
+      }
 }
 
 EOLIAN static Eina_Bool
@@ -6289,7 +6296,7 @@ _genlist_element_focused(void *data, const Efl_Event *ev)
    Efl_Ui_Widget *focused = efl_ui_focus_manager_focus_get(ev->object);
    Elm_Widget_Item *item;
 
-   if (!focused) return;
+   if (!focused || focused == data) return;
 
    item = efl_ui_focus_parent_provider_gen_item_fetch(pd->provider, focused);