[Genlist/Gengrid/List] Add workaround codes
authorTae-Hwan Kim <the81.kim@samsung.com>
Fri, 14 Jun 2013 04:53:56 +0000 (13:53 +0900)
committerSungho Kwak <sungho1.kwak@samsung.com>
Thu, 20 Jun 2013 12:31:21 +0000 (21:31 +0900)
There exist applications whih do not use elm_win such as
livebox.
So I add workaround codes. But focus will not work for those
applications.

Change-Id: I5cd000e1f0782b646a18cd2e83e0357fc3351de0

src/lib/elm_gengrid.c
src/lib/elm_genlist.c
src/lib/elm_list.c

index 11890d7..b555fc1 100644 (file)
@@ -793,6 +793,22 @@ _access_widget_item_register(Elm_Gen_Item *it)
    _elm_access_activate_callback_set(ai, _access_activate_cb, it);
 }
 
+// FIXME: There are applications which do not use elm_win as top widget.
+// This is workaround! Those could not use focus!
+static Eina_Bool _focus_enabled(Evas_Object *obj)
+{
+   if (!elm_widget_focus_get(obj)) return EINA_FALSE;
+
+   const Evas_Object *win = elm_widget_top_get(obj);
+   const char *type = evas_object_type_get(win);
+
+   if (type && !strcmp(type, "elm_win"))
+     {
+        return elm_win_focus_highlight_enabled_get(win);
+     }
+   return EINA_FALSE;
+}
+
 static void
 _item_realize(Elm_Gen_Item *it)
 {
@@ -923,9 +939,7 @@ _item_realize(Elm_Gen_Item *it)
         if (it->selected)
           edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
 
-        if (elm_widget_focus_get(ELM_WIDGET_DATA(GG_IT(it)->wsd)->obj) &&
-            elm_win_focus_highlight_enabled_get
-            (elm_widget_top_get(ELM_WIDGET_DATA(GG_IT(it)->wsd)->obj)))
+        if (_focus_enabled(ELM_WIDGET_DATA(GG_IT(it)->wsd)->obj))
           {
              if (GG_IT(it)->wsd->focused)
                 edje_object_signal_emit (VIEW(GG_IT(it)->wsd->focused), "elm,state,focused", "elm");
@@ -1816,8 +1830,7 @@ static void _gengrid_item_focused(Elm_Gen_Item *it)
                                   ELM_GENLIST_ITEM_SCROLLTO_IN);
      }
 
-   if (elm_win_focus_highlight_enabled_get
-       (elm_widget_top_get(ELM_WIDGET_DATA(sd)->obj)))
+   if (_focus_enabled(ELM_WIDGET_DATA(sd)->obj))
      edje_object_signal_emit
        (VIEW(it), "elm,state,focused", "elm");
 
@@ -2242,7 +2255,7 @@ _elm_gengrid_smart_on_focus(Evas_Object *obj)
 
    if (elm_widget_focus_get(obj))
      {
-        if (elm_win_focus_highlight_enabled_get(elm_widget_top_get(obj)))
+        if (_focus_enabled(obj))
           {
              if (sd->focused)
                 _gengrid_item_focused(sd->focused);
index bbf7e87..1af01b1 100644 (file)
@@ -1626,6 +1626,22 @@ _item_min_calc(Elm_Gen_Item *it, Eina_Bool *width_changed, Eina_Bool *height_cha
    it->item->mincalcd = EINA_TRUE;
 }
 
+// FIXME: There are applications which do not use elm_win as top widget.
+// This is workaround! Those could not use focus!
+static Eina_Bool _focus_enabled(Evas_Object *obj)
+{
+   if (!elm_widget_focus_get(obj)) return EINA_FALSE;
+
+   const Evas_Object *win = elm_widget_top_get(obj);
+   const char *type = evas_object_type_get(win);
+
+   if (type && !strcmp(type, "elm_win"))
+     {
+        return elm_win_focus_highlight_enabled_get(win);
+     }
+   return EINA_FALSE;
+}
+
 static void
 _item_realize(Elm_Gen_Item *it,
               int in,
@@ -1839,9 +1855,7 @@ _item_realize(Elm_Gen_Item *it,
           }
      }
 
-   if (elm_widget_focus_get(ELM_WIDGET_DATA(GL_IT(it)->wsd)->obj) &&
-       elm_win_focus_highlight_enabled_get
-       (elm_widget_top_get(ELM_WIDGET_DATA(GL_IT(it)->wsd)->obj)))
+   if (_focus_enabled(ELM_WIDGET_DATA(GL_IT(it)->wsd)->obj))
      {
         if (GL_IT(it)->wsd->focused)
            edje_object_signal_emit (VIEW(GL_IT(it)->wsd->focused), "elm,state,focused", "elm");
@@ -2553,8 +2567,7 @@ static void _item_focused(Elm_Gen_Item *it)
                                   ELM_GENLIST_ITEM_SCROLLTO_IN);
      }
 
-   if (elm_win_focus_highlight_enabled_get
-       (elm_widget_top_get(ELM_WIDGET_DATA(sd)->obj)))
+   if (_focus_enabled(ELM_WIDGET_DATA(GL_IT(it)->wsd)->obj))
      {
         if (it->deco_all_view)
           edje_object_signal_emit
@@ -2996,7 +3009,7 @@ _elm_genlist_smart_on_focus(Evas_Object *obj)
    if (sd->select_on_focus_enabled) return EINA_TRUE;
    if (elm_widget_focus_get(obj))
      {
-        if (elm_win_focus_highlight_enabled_get(elm_widget_top_get(obj)))
+        if (_focus_enabled(obj))
           {
              if (sd->focused)
                _item_focused(sd->focused);
index 9511e3d..b6d8daf 100644 (file)
@@ -208,6 +208,22 @@ _item_single_select_down(Elm_List_Smart_Data *sd)
    return EINA_TRUE;
 }
 
+// FIXME: There are applications which do not use elm_win as top widget.
+// This is workaround! Those could not use focus!
+static Eina_Bool _focus_enabled(Evas_Object *obj)
+{
+   if (!elm_widget_focus_get(obj)) return EINA_FALSE;
+
+   const Evas_Object *win = elm_widget_top_get(obj);
+   const char *type = evas_object_type_get(win);
+
+   if (type && !strcmp(type, "elm_win"))
+     {
+        return elm_win_focus_highlight_enabled_get(win);
+     }
+   return EINA_FALSE;
+}
+
 static void _item_focused(Elm_List_Item *it)
 {
    if (!it) return;
@@ -221,8 +237,7 @@ static void _item_focused(Elm_List_Item *it)
         elm_list_item_bring_in((Elm_Object_Item *)it);
      }
 
-   if (elm_win_focus_highlight_enabled_get
-       (elm_widget_top_get(ELM_WIDGET_DATA(sd)->obj)))
+   if (_focus_enabled(ELM_WIDGET_DATA(sd)->obj))
      edje_object_signal_emit
        (VIEW(it), "elm,state,focused", "elm");
 
@@ -1005,7 +1020,7 @@ _elm_list_smart_on_focus(Evas_Object *obj)
    if (sd->select_on_focus_enabled) return EINA_TRUE;
    if (elm_widget_focus_get(obj))
      {
-        if (elm_win_focus_highlight_enabled_get(elm_widget_top_get(obj)))
+        if (_focus_enabled(obj))
           {
              if (sd->focused)
                _item_focused((Elm_List_Item *)sd->focused);