summaryrefslogtreecommitdiff
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
parentccecfb05a65d2c501b9ce77aa8a11d53e5484aa8 (diff)
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,
2044} 2044}
2045 2045
2046static void 2046static void
2047_elm_win_evas_object_focus_in(void *data, 2047_evas_event_focus_object_cb(void *data, const Efl_Event *ev)
2048 Evas *e EINA_UNUSED,
2049 void *event_info)
2050{ 2048{
2051 Eo *object = event_info;
2052 Eo *win = data; 2049 Eo *win = data;
2053 2050
2054 _elm_win_throttle_ok = EINA_TRUE; 2051 if (ev->desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN)
2055 efl_event_callback_call(win, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN, object); 2052 _elm_win_throttle_ok = EINA_TRUE;
2056}
2057
2058static void
2059_elm_win_evas_object_focus_out(void *data,
2060 Evas *e EINA_UNUSED,
2061 void *event_info)
2062{
2063 Eo *object = event_info;
2064 Eo *win = data;
2065 2053
2066 efl_event_callback_call(win, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT, object); 2054 efl_event_callback_call(win, ev->desc, ev->info);
2067} 2055}
2068 2056
2069static void 2057static void
@@ -2190,14 +2178,14 @@ _win_event_add_cb(void *data, const Efl_Event *ev)
2190 else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN) 2178 else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN)
2191 { 2179 {
2192 if (!(sd->event_forward.object_focus_in++)) 2180 if (!(sd->event_forward.object_focus_in++))
2193 evas_event_callback_add(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN, 2181 efl_event_callback_add(sd->evas, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN,
2194 _elm_win_evas_object_focus_in, win); 2182 _evas_event_focus_object_cb, win);
2195 } 2183 }
2196 else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT) 2184 else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT)
2197 { 2185 {
2198 if (!(sd->event_forward.object_focus_out++)) 2186 if (!(sd->event_forward.object_focus_out++))
2199 evas_event_callback_add(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT, 2187 efl_event_callback_add(sd->evas, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT,
2200 _elm_win_evas_object_focus_out, win); 2188 _evas_event_focus_object_cb, win);
2201 } 2189 }
2202 else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_DEVICE_CHANGED) 2190 else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_DEVICE_CHANGED)
2203 { 2191 {
@@ -2321,14 +2309,14 @@ _win_event_del_cb(void *data, const Efl_Event *ev)
2321 else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN) 2309 else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN)
2322 { 2310 {
2323 if (!(--sd->event_forward.object_focus_in)) 2311 if (!(--sd->event_forward.object_focus_in))
2324 evas_event_callback_del_full(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN, 2312 efl_event_callback_del(sd->evas, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN,
2325 _elm_win_evas_object_focus_in, win); 2313 _evas_event_focus_object_cb, win);
2326 } 2314 }
2327 else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT) 2315 else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT)
2328 { 2316 {
2329 if (!(--sd->event_forward.object_focus_out)) 2317 if (!(--sd->event_forward.object_focus_out))
2330 evas_event_callback_del_full(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT, 2318 efl_event_callback_del(sd->evas, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT,
2331 _elm_win_evas_object_focus_out, win); 2319 _evas_event_focus_object_cb, win);
2332 } 2320 }
2333 else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_DEVICE_CHANGED) 2321 else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_DEVICE_CHANGED)
2334 { 2322 {
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)
51 efl_unref(win1); 51 efl_unref(win1);
52} 52}
53EFL_END_TEST 53EFL_END_TEST
54
55static void
56_check_focus_event(void *data, const Efl_Event *ev)
57{
58 void **tmp = data;
59
60 *tmp = efl_input_focus_object_get(ev->info);
61}
62
63EFL_START_TEST(efl_ui_win_test_object_focus)
64{
65 Efl_Ui_Win *win1;
66
67 void *win1_focus_in = NULL;
68 void *win1_focus_out = NULL;
69
70 win1 = efl_new(EFL_UI_WIN_CLASS);
71
72 efl_event_callback_add(win1, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN, _check_focus_event, &win1_focus_in);
73 efl_event_callback_add(win1, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT, _check_focus_event, &win1_focus_out);
74
75 Eo *r1 = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(win1));
76 efl_canvas_object_seat_focus_add(r1, NULL);
77 ck_assert_ptr_eq(win1_focus_in, r1);
78 ck_assert_ptr_eq(win1_focus_out, NULL);
79 win1_focus_in = NULL;
80 win1_focus_out = NULL;
81
82 Eo *r2 = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(win1));
83 efl_canvas_object_seat_focus_add(r2, NULL);
84 ck_assert_ptr_eq(win1_focus_in, r2);
85 ck_assert_ptr_eq(win1_focus_out, r1);
86 win1_focus_in = NULL;
87 win1_focus_out = NULL;
88
89 efl_canvas_object_seat_focus_del(r2, NULL);
90 ck_assert_ptr_eq(win1_focus_in, NULL);
91 ck_assert_ptr_eq(win1_focus_out, r2);
92
93 efl_unref(win1);
94}
95EFL_END_TEST
96
54void 97void
55efl_ui_test_win(TCase *tc) 98efl_ui_test_win(TCase *tc)
56{ 99{
57 tcase_add_test(tc, efl_ui_win_test_scene_focus); 100 tcase_add_test(tc, efl_ui_win_test_scene_focus);
101 tcase_add_test(tc, efl_ui_win_test_object_focus);
58} 102}