[*][focus] Focus should be controlled only when canvas gets focus(63240,63245)
authorWooHyun Jung <wh0705.jung@samsung.com>
Mon, 7 Nov 2011 02:11:14 +0000 (11:11 +0900)
committerWooHyun Jung <wh0705.jung@samsung.com>
Tue, 8 Nov 2011 01:47:56 +0000 (10:47 +0900)
Change-Id: Ibcd20482859284c278e2416714a4628e296e1fb3

src/lib/elm_priv.h
src/lib/elm_widget.c
src/lib/elm_win.c

index c91f2b4..4a86c94 100644 (file)
@@ -271,6 +271,8 @@ const void         *_elm_module_symbol_get(Elm_Module *m, const char *name);
 
 void                _elm_widget_type_clear(void);
 void                _elm_widget_focus_region_show(const Evas_Object *obj);
+void                _elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused);
+Eina_Bool           _elm_widget_top_win_focused_get(const Evas_Object *obj);
 
 void                _elm_unneed_ethumb(void);
 
index 4c3916e..e167ea5 100644 (file)
@@ -102,6 +102,7 @@ struct _Smart_Data
    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;
    Eina_Bool    highlight_ignore : 1;
    Eina_Bool    highlight_in_theme : 1;
@@ -368,12 +369,13 @@ _parent_focus(Evas_Object *obj)
 
    focus_order++;
    sd->focus_order = focus_order;
-   sd->focused = EINA_TRUE;
-   if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
-   if (sd->focus_func) sd->focus_func(obj);
-
-   _elm_widget_focus_region_show(obj);
-
+   if (sd->top_win_focused)
+     {
+        sd->focused = EINA_TRUE;
+        if (sd->on_focus_func) sd->on_focus_func(sd->on_focus_data, obj);
+        if (sd->focus_func) sd->focus_func(obj);
+        _elm_widget_focus_region_show(obj);
+     }
    sd->focus_order_on_calc = EINA_FALSE;
 }
 
@@ -908,6 +910,7 @@ elm_widget_sub_object_add(Evas_Object *obj,
              if (sd2->parent_obj)
                elm_widget_sub_object_del(sd2->parent_obj, sobj);
              sd2->parent_obj = obj;
+             sd2->top_win_focused = sd->top_win_focused;
              if (!sd->child_can_focus && (_is_focusable(sobj)))
                sd->child_can_focus = EINA_TRUE;
           }
@@ -1060,7 +1063,11 @@ elm_widget_resize_object_set(Evas_Object *obj,
         if (_elm_widget_is(sd->resize_obj))
           {
              Smart_Data *sd2 = evas_object_smart_data_get(sd->resize_obj);
-             if (sd2) sd2->parent_obj = obj;
+             if (sd2)
+               {
+                  sd2->parent_obj = obj;
+                  sd2->top_win_focused = sd->top_win_focused;
+               }
              evas_object_event_callback_add(sobj, EVAS_CALLBACK_HIDE,
                                             _sub_obj_hide, sd);
           }
@@ -1934,6 +1941,30 @@ elm_widget_focus_restore(Evas_Object *obj)
      }
 }
 
+void
+_elm_widget_top_win_focused_set(Evas_Object *obj, Eina_Bool top_win_focused)
+{
+   const Eina_List *l;
+   Evas_Object *child;
+   API_ENTRY return;
+
+   if (sd->top_win_focused == top_win_focused) return;
+   if (sd->resize_obj)
+     _elm_widget_top_win_focused_set(sd->resize_obj, top_win_focused);
+   EINA_LIST_FOREACH(sd->subobjs, l, child)
+     {
+        _elm_widget_top_win_focused_set(child, top_win_focused);
+     }
+   sd->top_win_focused = top_win_focused;
+}
+
+Eina_Bool
+_elm_widget_top_win_focused_get(const Evas_Object *obj)
+{
+   API_ENTRY return EINA_FALSE;
+   return sd->top_win_focused;
+}
+
 EAPI void
 elm_widget_activate(Evas_Object *obj)
 {
index 587ac98..ef54bc2 100644 (file)
@@ -26,6 +26,7 @@ struct _Elm_Win
    } shot;
    Eina_Bool autodel : 1;
    int *autodel_clear, rot;
+   int show_count;
    struct {
       int x, y;
    } screen;
@@ -306,7 +307,13 @@ _elm_win_focus_in(Ecore_Evas *ee)
    if (!obj) return;
    win = elm_widget_data_get(obj);
    if (!win) return;
-   if (!elm_widget_focus_get(win->win_obj))
+   _elm_widget_top_win_focused_set(win->win_obj, EINA_TRUE);
+   if (win->show_count == 1)
+     {
+        elm_object_focus(win->win_obj);
+        win->show_count++;
+     }
+   else
      elm_widget_focus_restore(win->win_obj);
    evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_IN, NULL);
    win->focus_highlight.cur.visible = EINA_TRUE;
@@ -330,6 +337,7 @@ _elm_win_focus_out(Ecore_Evas *ee)
    win = elm_widget_data_get(obj);
    if (!win) return;
    elm_object_unfocus(win->win_obj);
+   _elm_widget_top_win_focused_set(win->win_obj, EINA_FALSE);
    evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_OUT, NULL);
    win->focus_highlight.cur.visible = EINA_FALSE;
    _elm_win_focus_highlight_reconfigure_job_start(win);
@@ -413,11 +421,11 @@ _deferred_ecore_evas_free(void *data)
 }
 
 static void
-_elm_win_obj_callback_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+_elm_win_obj_callback_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
 {
    Elm_Win *win = data;
 
-   elm_object_focus(obj);
+   if (!win->show_count) win->show_count++;
    if (win->shot.info) _shot_handle(win);
 }