summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2018-07-05 15:09:21 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-07-05 15:09:21 -0400
commit7a8ff655c8c26afafadbf98d86d2bccb8c6ca3f2 (patch)
tree2b0e383787ac79b2b3b53918ee2fe9d0878c2a00
parent11147284fef1830ad7143714a04f3620a93ffba3 (diff)
downloadefl-7a8ff655c8c26afafadbf98d86d2bccb8c6ca3f2.tar.gz
elm_popup: ensure focus is emitted on this object
Summary: This mirrors the focus property from the notify to the one from popup. This is needed to establish legacy behaviour, as earlier popup was able to get focus. ref T6707 Depends on D6510 Reviewers: zmike, devilhorns Reviewed By: zmike Subscribers: cedric, #committers Tags: #efl Maniphest Tasks: T6707 Differential Revision: https://phab.enlightenment.org/D6511
-rw-r--r--src/lib/elementary/elc_popup.c13
-rw-r--r--src/tests/elementary/elm_test_popup.c30
2 files changed, 43 insertions, 0 deletions
diff --git a/src/lib/elementary/elc_popup.c b/src/lib/elementary/elc_popup.c
index 47a0dc1c35..504e45bba4 100644
--- a/src/lib/elementary/elc_popup.c
+++ b/src/lib/elementary/elc_popup.c
@@ -224,6 +224,17 @@ _items_remove(Elm_Popup_Data *sd)
sd->items = NULL;
}
+static void
+_focus_changed_popup(void *data, const Efl_Event *ev)
+{
+ //mirror property
+ efl_ui_focus_object_focus_set(data, efl_ui_focus_object_focus_get(ev->object));
+}
+
+EFL_CALLBACKS_ARRAY_DEFINE(composition_cb,
+ { EFL_UI_FOCUS_OBJECT_EVENT_FOCUS_CHANGED, _focus_changed_popup },
+)
+
EOLIAN static void
_elm_popup_efl_canvas_group_group_del(Eo *obj, Elm_Popup_Data *sd)
{
@@ -237,6 +248,7 @@ _elm_popup_efl_canvas_group_group_del(Eo *obj, Elm_Popup_Data *sd)
evas_object_event_callback_del
(sd->content, EVAS_CALLBACK_DEL, _on_content_del);
evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, _on_show);
+ efl_event_callback_array_del(sd->notify, composition_cb(), obj);
sd->last_button_number = 0;
@@ -1425,6 +1437,7 @@ _elm_popup_efl_canvas_group_group_add(Eo *obj, Elm_Popup_Data *priv)
elm_object_mirrored_set(priv->notify, elm_object_mirrored_get(obj));
evas_object_event_callback_add(priv->notify, EVAS_CALLBACK_RESIZE, _notify_resize_cb, obj);
+ efl_event_callback_array_add(priv->notify, composition_cb(), obj);
priv->main_layout = elm_layout_add(obj);
if (!elm_layout_theme_set(priv->main_layout, "popup", "base",
diff --git a/src/tests/elementary/elm_test_popup.c b/src/tests/elementary/elm_test_popup.c
index 4defd3ecae..e288bab9a9 100644
--- a/src/tests/elementary/elm_test_popup.c
+++ b/src/tests/elementary/elm_test_popup.c
@@ -41,8 +41,38 @@ EFL_START_TEST (elm_atspi_role_get)
}
EFL_END_TEST
+static void
+_focus_cb(void *data, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ *((Eina_Bool*)data) = EINA_TRUE;
+}
+
+
+EFL_START_TEST (elm_popup_focus_get)
+{
+ Evas_Object *win, *popup;
+ Eina_Bool focused = EINA_FALSE;
+
+ win = win_add(NULL, "popup", ELM_WIN_BASIC);
+
+ popup = elm_popup_add(win);
+ elm_popup_scrollable_set(popup, EINA_TRUE);
+ elm_object_text_set(popup, "This Popup has content area and "
+ "timeout value is 3 seconds");
+ elm_popup_timeout_set(popup, 3.0);
+ evas_object_smart_callback_add(popup, "focused", _focus_cb, &focused);
+
+ // popup show should be called after adding all the contents and the buttons
+ // of popup to set the focus into popup's contents correctly.
+ evas_object_show(popup);
+ ck_assert(focused);
+}
+EFL_END_TEST
+
void elm_test_popup(TCase *tc)
{
+ tcase_add_test(tc, elm_popup_focus_get);
tcase_add_test(tc, elm_popup_legacy_type_check);
tcase_add_test(tc, elm_atspi_role_get);
}