elm_hover: migrate to new focus system
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>
Tue, 20 Dec 2016 16:28:36 +0000 (17:28 +0100)
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>
Thu, 20 Apr 2017 12:38:58 +0000 (14:38 +0200)
the hover will set itself as redirect once it is visible. And unset
itself once it is hidden.

src/lib/elementary/elm_hover.c
src/lib/elementary/elm_hover.eo
src/lib/elementary/elm_widget_hover.h

index f39711f..d6d1f52 100644 (file)
@@ -646,14 +646,20 @@ _elm_hover_efl_gfx_size_set(Eo *obj, Elm_Hover_Data *_pd EINA_UNUSED, Evas_Coord
 }
 
 EOLIAN static void
-_elm_hover_efl_gfx_visible_set(Eo *obj, Elm_Hover_Data *_pd EINA_UNUSED, Eina_Bool vis)
+_elm_hover_efl_gfx_visible_set(Eo *obj, Elm_Hover_Data *pd, Eina_Bool vis)
 {
    if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, vis))
      return;
 
    efl_gfx_visible_set(efl_super(obj, MY_CLASS), vis);
 
-   if (vis) _hov_show_do(obj);
+   if (vis)
+     {
+        _hov_show_do(obj);
+        //we just set ourself as redirect in the next upper manager
+        pd->redirected = efl_ui_focus_user_manager_get(pd->target);
+        efl_ui_focus_manager_redirect_set(pd->redirected, obj);
+     }
    else
      {
         // for backward compatibility
@@ -661,6 +667,9 @@ _elm_hover_efl_gfx_visible_set(Eo *obj, Elm_Hover_Data *_pd EINA_UNUSED, Eina_Bo
 
         if (!eina_streq(dismissstr, "on"))
           _hide_signals_emit(obj);
+
+        efl_ui_focus_manager_redirect_set(pd->redirected, NULL);
+        pd->redirected = NULL;
      }
 }
 
@@ -679,13 +688,19 @@ elm_hover_add(Evas_Object *parent)
 }
 
 EOLIAN static Eo *
-_elm_hover_efl_object_constructor(Eo *obj, Elm_Hover_Data *_pd EINA_UNUSED)
+_elm_hover_efl_object_constructor(Eo *obj, Elm_Hover_Data *pd)
 {
    obj = efl_constructor(efl_super(obj, MY_CLASS));
    efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
    evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
    elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_POPUP_MENU);
 
+   pd->manager = efl_add(EFL_UI_FOCUS_MANAGER_CLASS, NULL,
+    efl_ui_focus_manager_root_set(efl_added, obj)
+   );
+
+   efl_composite_attach(obj, pd->manager);
+
    return obj;
 }
 
@@ -716,8 +731,8 @@ _elm_hover_target_set(Eo *obj, Elm_Hover_Data *sd, Evas_Object *target)
         elm_widget_hover_object_set(target, obj);
         elm_layout_sizing_eval(obj);
      }
-}
 
+}
 EAPI void
 elm_hover_parent_set(Evas_Object *obj,
                      Evas_Object *parent)
index ec9e77e..49c5568 100644 (file)
@@ -7,7 +7,7 @@ enum Elm.Hover.Axis
    both [[ELM_HOVER_AXIS_BOTH -- both.]]
 }
 
-class Elm.Hover (Elm.Layout, Efl.Ui.Clickable, Elm.Interface.Atspi_Widget_Action)
+class Elm.Hover (Elm.Layout, Efl.Ui.Clickable, Elm.Interface.Atspi_Widget_Action, Efl.Ui.Focus.Manager)
 {
    [[Elementary hover class]]
    legacy_prefix: elm_hover;
index 25fbe25..05b531c 100644 (file)
@@ -46,6 +46,8 @@ struct _Elm_Hover_Data
                               sizeof(_content_aliases[0]) - 1];
 
    Eina_Bool             on_del : 1;
+   Efl_Ui_Focus_Manager *manager;
+   Efl_Ui_Focus_Manager *redirected;
 };
 
 /**