evas_events: fix wrong event listening

EFL_EVENT_FOCUS_IN is wrong here, EFL_EVENT_FOCUS_IN is called on object
that received object focus. Not canvas focus, however, the code in the
callback there seems to be mainly for canvas focus handling.

Additionally, in evas_events, the event handler that was listening for
the canvas focus in / out events expected a event type, which is also
not correct, because the canvas focus in / out does not have one. In
order to catch such errors later more easily, there is now a safety
check, so we really fetched the correct seat.

Reviewed-by: YeongJong Lee <yj34.lee@samsung.com>
Differential Revision: https://phab.enlightenment.org/D9191
This commit is contained in:
Marcel Hollerbach 2019-06-27 08:13:04 +02:00
parent 7b8766698a
commit d3dbd5a5cd
6 changed files with 40 additions and 11 deletions

View File

@ -4245,22 +4245,20 @@ _evas_canvas_event_key_cb(void *data, const Efl_Event *event)
static void
_evas_canvas_event_focus_cb(void *data, const Efl_Event *event)
{
Efl_Input_Device *seat = efl_input_device_get(event->info);
Efl_Input_Device *seat = efl_canvas_scene_seat_default_get(event->object);
Evas_Public_Data *e = data;
if (event->desc == EFL_EVENT_FOCUS_IN)
EINA_SAFETY_ON_NULL_RETURN(seat);
if (event->desc == EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_IN)
{
if (eina_list_data_find(e->focused_by, seat)) return;
e->focused_by = eina_list_append(e->focused_by, seat);
evas_event_callback_call(e->evas, EVAS_CALLBACK_CANVAS_FOCUS_IN,
event->info);
}
else
{
if (!eina_list_data_find(e->focused_by, seat)) return;
e->focused_by = eina_list_remove(e->focused_by, seat);
evas_event_callback_call(e->evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT,
event->info);
}
}
@ -4279,8 +4277,8 @@ EFL_CALLBACKS_ARRAY_DEFINE(_evas_canvas_event_pointer_callbacks,
{ EFL_EVENT_FINGER_UP, _evas_canvas_event_pointer_cb },
{ EFL_EVENT_KEY_DOWN, _evas_canvas_event_key_cb },
{ EFL_EVENT_KEY_UP, _evas_canvas_event_key_cb },
{ EFL_EVENT_FOCUS_IN, _evas_canvas_event_focus_cb },
{ EFL_EVENT_FOCUS_OUT, _evas_canvas_event_focus_cb })
{ EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_IN, _evas_canvas_event_focus_cb },
{ EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_OUT, _evas_canvas_event_focus_cb })
void
_evas_canvas_event_init(Evas *eo_e, Evas_Public_Data *e)

View File

@ -857,9 +857,9 @@ static void
_evas_canvas_focus_inout_dispatch(Eo *eo_e, Evas_Device *seat EINA_UNUSED,
Eina_Bool in)
{
efl_event_callback_call(eo_e,
in ? EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_IN : EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_OUT,
NULL);
efl_event_callback_legacy_call(eo_e,
in ? EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_IN : EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_OUT,
NULL);
}
EOLIAN static void

View File

@ -10,6 +10,7 @@
static const Efl_Test_Case etc[] = {
{ "Evas", evas_test_init },
{ "Evas Focus", evas_test_focus },
{ "Evas New", evas_test_new },
{ "Object", evas_test_object },
{ "Object Textblock", evas_test_textblock },

View File

@ -4,6 +4,7 @@
#include <check.h>
#include "../efl_check.h"
void evas_test_init(TCase *tc);
void evas_test_focus(TCase *tc);
void evas_test_new(TCase *tc);
void evas_test_object(TCase *tc);
void evas_test_textblock(TCase *tc);

View File

@ -0,0 +1,28 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <Evas.h>
#include "evas_suite.h"
EFL_START_TEST(evas_focus)
{
Evas *evas = evas_new();
evas_output_method_set(evas, evas_render_method_lookup("buffer"));
evas_focus_in(evas);
ck_assert_int_eq(evas_focus_state_get(evas), EINA_TRUE);
evas_focus_out(evas);
ck_assert_int_eq(evas_focus_state_get(evas), EINA_FALSE);
evas_focus_out(evas);
ck_assert_int_eq(evas_focus_state_get(evas), EINA_FALSE);
}
EFL_END_TEST
void evas_test_focus(TCase *tc)
{
tcase_add_test(tc, evas_focus);
}

View File

@ -14,6 +14,7 @@ evas_suite_src = [
'evas_test_mask.c',
'evas_test_evasgl.c',
'evas_test_matrix.c',
'evas_test_focus.c',
'evas_tests_helpers.h',
'evas_suite.h'
]