efl_ui_win: port to new focus api!
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>
Tue, 26 Sep 2017 23:07:20 +0000 (01:07 +0200)
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>
Tue, 10 Oct 2017 17:28:48 +0000 (19:28 +0200)
src/lib/elementary/efl_ui_win.c
src/lib/elementary/efl_ui_win.eo

index 9f39bc4..1b341ff 100644 (file)
@@ -1223,23 +1223,14 @@ _elm_win_focus_in(Ecore_Evas *ee)
    ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
    if (sd->type != ELM_WIN_FAKE)
      {
-        if (!elm_obj_widget_focus_order_get(obj))
+        Efl_Ui_Focus_Manager *man = sd->obj;
+        while(efl_ui_focus_manager_redirect_get(man))
           {
-             elm_obj_widget_focus_steal(obj, NULL);
+             man = efl_ui_focus_manager_redirect_get(man);
           }
-        else
-          {
-             Evas_Object *newest = NULL;
-             unsigned int newest_focus_order = 0;
 
-             newest = elm_widget_newest_focus_order_get
-                (obj, &newest_focus_order, EINA_TRUE);
-             if (newest &&
-                 (_elm_widget_onscreen_is(newest) || (newest == obj)))
-               elm_obj_widget_focus_restore(obj);
-             else
-               evas_object_focus_set(obj, EINA_TRUE);
-          }
+        Evas_Object *focused = efl_ui_focus_manager_focus_get(man);
+        elm_obj_widget_on_focus_update(focused, NULL);
      }
 
    evas_object_smart_callback_call(obj, SIG_FOCUS_IN, NULL);
@@ -1635,68 +1626,6 @@ _elm_win_state_change(Ecore_Evas *ee)
 }
 
 EOLIAN static Eina_Bool
-_efl_ui_win_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *_pd EINA_UNUSED)
-{
-   return EINA_TRUE;
-}
-
-EOLIAN static Eina_Bool
-_efl_ui_win_elm_widget_focus_next(Eo *obj, Efl_Ui_Win_Data *_pd EINA_UNUSED, Elm_Focus_Direction dir, Evas_Object **next, Elm_Object_Item **next_item)
-{
-   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
-
-   const Eina_List *items;
-   void *(*list_data_get)(const Eina_List *list);
-
-   /* Focus chain */
-   if (wd->subobjs)
-     {
-        if (!(items = elm_obj_widget_focus_custom_chain_get(obj)))
-          {
-             items = wd->subobjs;
-             if (!items)
-               return EINA_FALSE;
-          }
-        list_data_get = eina_list_data_get;
-
-        elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next, next_item);
-
-        if (*next) return EINA_TRUE;
-     }
-   *next = (Evas_Object *)obj;
-   return EINA_FALSE;
-}
-
-EOLIAN static Eina_Bool
-_efl_ui_win_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *_pd EINA_UNUSED)
-{
-   return EINA_TRUE;
-}
-
-EOLIAN static Eina_Bool
-_efl_ui_win_elm_widget_focus_direction(Eo *obj, Efl_Ui_Win_Data *_pd EINA_UNUSED, const Evas_Object *base, double degree, Evas_Object **direction, Elm_Object_Item **direction_item, double *weight)
-{
-   const Eina_List *items;
-   void *(*list_data_get)(const Eina_List *list);
-
-   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
-
-   /* Focus chain */
-   if (wd->subobjs)
-     {
-        if (!(items = elm_obj_widget_focus_custom_chain_get(obj)))
-          items = wd->subobjs;
-
-        list_data_get = eina_list_data_get;
-
-        return elm_widget_focus_list_direction_get
-                 (obj, base, items, list_data_get, degree, direction, direction_item, weight);
-     }
-
-   return EINA_FALSE;
-}
-
-EOLIAN static Eina_Bool
 _efl_ui_win_elm_widget_on_focus_update(Eo *obj, Efl_Ui_Win_Data *sd, Elm_Object_Item *item EINA_UNUSED)
 {
    if (!elm_obj_widget_on_focus_update(efl_super(obj, MY_CLASS), NULL))
@@ -2758,7 +2687,8 @@ _win_img_hide(void *data,
               Evas_Object *obj EINA_UNUSED,
               void *event_info EINA_UNUSED)
 {
-   elm_obj_widget_focus_hide_handle(data);
+   Efl_Ui_Win *real_win = elm_widget_top_get(data);
+   efl_ui_focus_manager_redirect_set(real_win, NULL);
 }
 
 static void
@@ -2778,7 +2708,9 @@ _win_img_focus_in(void *data,
                   Evas_Object *obj EINA_UNUSED,
                   void *event_info EINA_UNUSED)
 {
-   elm_obj_widget_focus_steal(data, NULL);
+   Efl_Ui_Win *real_win = elm_widget_top_get(data);
+   efl_ui_focus_manager_redirect_set(real_win, data);
+   efl_ui_focus_manager_focus_set(data, efl_ui_focus_manager_root_get(data));
 }
 
 static void
@@ -2787,7 +2719,8 @@ _win_img_focus_out(void *data,
                    Evas_Object *obj EINA_UNUSED,
                    void *event_info EINA_UNUSED)
 {
-   elm_obj_widget_focused_object_clear(data);
+   Efl_Ui_Win *real_win = elm_widget_top_get(data);
+   efl_ui_focus_manager_redirect_set(real_win, NULL);
 }
 
 static void
@@ -3679,11 +3612,7 @@ _elm_win_translate(void)
 void
 _elm_win_focus_reconfigure(void)
 {
-   const Eina_List *l;
-   Evas_Object *obj;
-
-   EINA_LIST_FOREACH(_elm_win_list, l, obj)
-     elm_obj_widget_focus_reconfigure(obj);
+   /* FOCUS-FIXME */
 }
 
 #ifdef HAVE_ELEMENTARY_X
@@ -5041,6 +4970,8 @@ _elm_win_finalize_internal(Eo *obj, Efl_Ui_Win_Data *sd, const char *name, Elm_W
    efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
    evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
 
+   evas_object_focus_set(obj, EINA_TRUE);
+
    if (getenv("ELM_FIRST_FRAME"))
      evas_event_callback_add(ecore_evas_get(tmp_sd.ee), EVAS_CALLBACK_RENDER_POST,
                              _elm_win_first_frame_do, getenv("ELM_FIRST_FRAME"));
@@ -6692,12 +6623,20 @@ _on_atspi_bus_connected(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUS
         efl_access_window_created_signal_emit(win);
         if (elm_win_focus_get(win))
           {
+             Evas_Object *target;
              efl_access_window_activated_signal_emit(win);
              /** Reemit focused event to inform atspi clients about currently
               * focused object **/
-             unsigned int order = 0;
-             Evas_Object *target;
-             target = elm_widget_newest_focus_order_get(win, &order, EINA_TRUE);
+             {
+                Efl_Ui_Focus_Manager *m;
+
+                m = win;
+
+                while (efl_ui_focus_manager_redirect_get(m))
+                  m = efl_ui_focus_manager_redirect_get(m);
+
+                target = efl_ui_focus_manager_focus_get(m);
+             }
              if (target)
                elm_interface_atspi_accessible_state_changed_signal_emit(target, ELM_ATSPI_STATE_FOCUSED, EINA_TRUE);
           }
index 73f2715..cd0807e 100644 (file)
@@ -822,10 +822,6 @@ class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Efl.Access.Window,
       Efl.Gfx.Stack.raise; [[Places the window at the top of the stack, so
                              that it's not covered by any other window.]]
       Efl.Gfx.Stack.lower; [[This action is ignored by the Window.]]
-      Elm.Widget.focus_direction;
-      Elm.Widget.focus_next_manager_is;
-      Elm.Widget.focus_direction_manager_is;
-      Elm.Widget.focus_next;
       Elm.Widget.theme_apply;
       Elm.Widget.focus { get; }
       Elm.Widget.focus_highlight_style { get; set; }