efl_ui_widget: add implementation for finding the window
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Tue, 26 Mar 2019 08:59:16 +0000 (09:59 +0100)
committerJunsuChoi <jsuya.choi@samsung.com>
Tue, 2 Apr 2019 04:24:20 +0000 (13:24 +0900)
the problem with the previous implementation (just redirect the calls to
the widget_parent then to the efl_parent is that after invalidate its
impossible to find the window where the widget is in. However, there are
cases where we want to have access to the window of the widget, for
example, to invalidate focus highlight etc..
The window of a widget is always constant, and cannot be changed (as the
evas object cannot hop accross different evas)

Reviewed-by: Jaehyun Cho <jae_hyun.cho@samsung.com>
Differential Revision: https://phab.enlightenment.org/D8475

src/lib/elementary/efl_ui_widget.c
src/lib/elementary/elm_widget.h
src/tests/elementary/efl_ui_test_widget.c

index 025b78b..3591d8c 100644 (file)
@@ -5528,6 +5528,8 @@ EOLIAN static Eo *
 _efl_ui_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
 {
    sd->on_create = EINA_TRUE;
+   sd->window = efl_provider_find(efl_parent_get(obj), EFL_UI_WIN_CLASS);
+   _efl_ui_focus_event_redirector(obj, obj);
    efl_canvas_group_clipped_set(obj, EINA_FALSE);
    obj = efl_constructor(efl_super(obj, MY_CLASS));
    efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
@@ -5975,6 +5977,13 @@ _efl_ui_widget_efl_object_provider_find(const Eo *obj, Elm_Widget_Smart_Data *pd
    if ((klass == EFL_CONFIG_INTERFACE) || (klass == EFL_CONFIG_GLOBAL_CLASS))
      return _efl_config_obj;
 
+   if (klass == EFL_UI_WIN_CLASS)
+     {
+        if (pd->window)
+          return pd->window;
+        //let the parent_obj lookup handle this
+     }
+
    if (klass == EFL_ACCESS_OBJECT_MIXIN)
      return (Eo*)obj;
 
index 4433adc..343a5d8 100644 (file)
@@ -332,6 +332,7 @@ typedef struct _Elm_Widget_Smart_Data
    Evas_Object                  *resize_obj; /**< an unique object for each widget that shows the look of a widget. Resize object's geometry is same as the widget. This resize object is different from that of window's resize object. */
    Evas_Object                  *hover_obj;
    Evas_Object                  *bg;
+   Evas_Object                  *window;
    Eina_List                    *tooltips, *cursors;
    //TIZEN_ONLY(20180607): Restore legacy focus
    Evas_Object                  *focus_previous, *focus_next;
index aa99299..a49eefe 100644 (file)
@@ -340,6 +340,18 @@ _setup(void)
    eina_log_abort_on_critical_set(1);
 }
 
+EFL_START_TEST(efl_ui_test_widget_win_provider_find)
+{
+   State s;
+
+   _small_ui(&s);
+   ck_assert_ptr_eq(efl_provider_find(s.btn1, EFL_UI_WIN_CLASS), s.win);
+   efl_ui_widget_sub_object_del(s.box, s.btn1);
+   ck_assert_ptr_eq(efl_ui_widget_parent_get(s.btn1), NULL);
+   ck_assert_ptr_eq(efl_provider_find(s.btn1, EFL_UI_WIN_CLASS), s.win);
+}
+EFL_END_TEST
+
 void efl_ui_test_widget(TCase *tc)
 {
    tcase_add_checked_fixture(tc, _setup, _shutdown);
@@ -353,4 +365,5 @@ void efl_ui_test_widget(TCase *tc)
    tcase_add_test(tc, efl_ui_test_widget_parent_relation);
    tcase_add_test(tc, efl_ui_test_widget_disabled_parent);
    tcase_add_test(tc, efl_ui_test_widget_disabled_behaviour);
+   tcase_add_test(tc, efl_ui_test_widget_win_provider_find);
 }