aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-06-21 09:40:17 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-06-21 09:40:23 -0400
commit0c4c74b5f7779fbf5c6154b8241291041a8d86b7 (patch)
tree54827d91368c08f1db5f97bf8743f7812d2282e8
parentci: make sure we disable the new json evas loader in our jobs (diff)
downloadefl-0c4c74b5f7779fbf5c6154b8241291041a8d86b7.tar.gz
efl_ui_win: fix emitting of object focus events
Summary: the event type was wrong. This is now fixed and works correctly. Reviewers: stefan_schmidt, zmike, segfaultxavi Reviewed By: zmike Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9144
-rw-r--r--src/lib/elementary/efl_ui_win.c36
-rw-r--r--src/tests/elementary/efl_ui_test_win.c44
2 files changed, 56 insertions, 24 deletions
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index ebf381477f..ef3174e00f 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -2044,26 +2044,14 @@ _elm_win_evas_focus_out(void *data,
}
static void
-_elm_win_evas_object_focus_in(void *data,
- Evas *e EINA_UNUSED,
- void *event_info)
+_evas_event_focus_object_cb(void *data, const Efl_Event *ev)
{
- Eo *object = event_info;
Eo *win = data;
- _elm_win_throttle_ok = EINA_TRUE;
- efl_event_callback_call(win, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN, object);
-}
-
-static void
-_elm_win_evas_object_focus_out(void *data,
- Evas *e EINA_UNUSED,
- void *event_info)
-{
- Eo *object = event_info;
- Eo *win = data;
+ if (ev->desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN)
+ _elm_win_throttle_ok = EINA_TRUE;
- efl_event_callback_call(win, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT, object);
+ efl_event_callback_call(win, ev->desc, ev->info);
}
static void
@@ -2190,14 +2178,14 @@ _win_event_add_cb(void *data, const Efl_Event *ev)
else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN)
{
if (!(sd->event_forward.object_focus_in++))
- evas_event_callback_add(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
- _elm_win_evas_object_focus_in, win);
+ efl_event_callback_add(sd->evas, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN,
+ _evas_event_focus_object_cb, win);
}
else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT)
{
if (!(sd->event_forward.object_focus_out++))
- evas_event_callback_add(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
- _elm_win_evas_object_focus_out, win);
+ efl_event_callback_add(sd->evas, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT,
+ _evas_event_focus_object_cb, win);
}
else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_DEVICE_CHANGED)
{
@@ -2321,14 +2309,14 @@ _win_event_del_cb(void *data, const Efl_Event *ev)
else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN)
{
if (!(--sd->event_forward.object_focus_in))
- evas_event_callback_del_full(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
- _elm_win_evas_object_focus_in, win);
+ efl_event_callback_del(sd->evas, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN,
+ _evas_event_focus_object_cb, win);
}
else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT)
{
if (!(--sd->event_forward.object_focus_out))
- evas_event_callback_del_full(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
- _elm_win_evas_object_focus_out, win);
+ efl_event_callback_del(sd->evas, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT,
+ _evas_event_focus_object_cb, win);
}
else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_DEVICE_CHANGED)
{
diff --git a/src/tests/elementary/efl_ui_test_win.c b/src/tests/elementary/efl_ui_test_win.c
index d7deb293f7..1482f14867 100644
--- a/src/tests/elementary/efl_ui_test_win.c
+++ b/src/tests/elementary/efl_ui_test_win.c
@@ -51,8 +51,52 @@ EFL_START_TEST(efl_ui_win_test_scene_focus)
efl_unref(win1);
}
EFL_END_TEST
+
+static void
+_check_focus_event(void *data, const Efl_Event *ev)
+{
+ void **tmp = data;
+
+ *tmp = efl_input_focus_object_get(ev->info);
+}
+
+EFL_START_TEST(efl_ui_win_test_object_focus)
+{
+ Efl_Ui_Win *win1;
+
+ void *win1_focus_in = NULL;
+ void *win1_focus_out = NULL;
+
+ win1 = efl_new(EFL_UI_WIN_CLASS);
+
+ efl_event_callback_add(win1, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN, _check_focus_event, &win1_focus_in);
+ efl_event_callback_add(win1, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT, _check_focus_event, &win1_focus_out);
+
+ Eo *r1 = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(win1));
+ efl_canvas_object_seat_focus_add(r1, NULL);
+ ck_assert_ptr_eq(win1_focus_in, r1);
+ ck_assert_ptr_eq(win1_focus_out, NULL);
+ win1_focus_in = NULL;
+ win1_focus_out = NULL;
+
+ Eo *r2 = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(win1));
+ efl_canvas_object_seat_focus_add(r2, NULL);
+ ck_assert_ptr_eq(win1_focus_in, r2);
+ ck_assert_ptr_eq(win1_focus_out, r1);
+ win1_focus_in = NULL;
+ win1_focus_out = NULL;
+
+ efl_canvas_object_seat_focus_del(r2, NULL);
+ ck_assert_ptr_eq(win1_focus_in, NULL);
+ ck_assert_ptr_eq(win1_focus_out, r2);
+
+ efl_unref(win1);
+}
+EFL_END_TEST
+
void
efl_ui_test_win(TCase *tc)
{
tcase_add_test(tc, efl_ui_win_test_scene_focus);
+ tcase_add_test(tc, efl_ui_win_test_object_focus);
}