genlist: fix on focus item search logic to make include content also in current viewport
authorSangHyeon Lee <sh10233.lee@samsung.com>
Mon, 26 Dec 2016 11:40:19 +0000 (20:40 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Mon, 2 Jan 2017 05:37:12 +0000 (14:37 +0900)
Change-Id: Icdfd466b9a07e360a7aa6c0b1ea657b63fe0ae5b
Signed-off-by: SangHyeon Lee <sh10233.lee@samsung.com>
src/mobile_lib/elm_genlist.c

index 4ae01a1fe768f5d8b3cb1a245ae52daf48d3d065..5b8fa06a25215fada57dda142f2746032eab4521 100644 (file)
@@ -3897,16 +3897,30 @@ _elm_genlist_elm_widget_on_focus(Eo *obj, Elm_Genlist_Data *sd, Elm_Object_Item
                        Elm_Gen_Item *tmp = eina_list_data_get(itb->items);
                        while(tmp && tmp->item->block == itb)
                          {
-                            if ((_item_focusable_search(&tmp, 1)) && (tmp->realized))
+                            if (tmp->realized)
                               {
+                                 Evas_Object *old = tmp;
                                  Evas_Coord x, y, w, h, sx, sy, sw, sh;
                                  evas_object_geometry_get(VIEW(tmp), &x, &y, &w, &h);
                                  evas_object_geometry_get(obj, &sx, &sy, &sw, &sh);
-                                 /* Item is included viewport */
-                                 if (ELM_RECTS_INCLUDE(sx, sy, sw, sh, x, y, w, h))
+                                 /* Item is included viewport and focusable */
+                                 if ((ELM_RECTS_INCLUDE(sx, sy, sw, sh, x, y, w, h)) &&
+                                     (_item_focusable_search(&tmp, 1)))
                                    {
-                                      elm_object_item_focus_set(EO_OBJ(tmp), EINA_TRUE);
-                                      goto success;
+                                      Eina_Bool include = EINA_TRUE;
+                                      if (old != tmp && tmp->realized)
+                                        {
+                                           evas_object_geometry_get(VIEW(tmp), &x, &y, &w, &h);
+                                           evas_object_geometry_get(obj, &sx, &sy, &sw, &sh);
+                                           include = ELM_RECTS_INCLUDE(sx, sy, sw, sh, x, y, w, h);
+                                        }
+                                      else if (!tmp->realized) include = EINA_FALSE;
+
+                                      if (include)
+                                        {
+                                           elm_object_item_focus_set(EO_OBJ(tmp), EINA_TRUE);
+                                           goto success;
+                                        }
                                    }
                               }