Evas: Use events to flag canvas focus in/out.

This commit is contained in:
Guilherme Iscaro 2016-11-17 17:30:58 -02:00 committed by Bruno Dilly
parent ed9c635152
commit ded24d80ed
2 changed files with 45 additions and 8 deletions

View File

@ -3528,6 +3528,25 @@ _evas_canvas_event_key_cb(void *data, const Efl_Event *event)
ev->evas_done = EINA_TRUE;
}
static void
_evas_canvas_event_focus_cb(void *data, const Efl_Event *event)
{
Evas_Public_Data *e = data;
if (event->desc == EFL_EVENT_FOCUS_IN)
{
if (e->focus) return;
e->focus = 1;
evas_event_callback_call(e->evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, NULL);
}
else
{
if (!e->focus) return;
e->focus = 0;
evas_event_callback_call(e->evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, NULL);
}
}
// note: "hold" event comes from above (elm), not below (ecore)
EFL_CALLBACKS_ARRAY_DEFINE(_evas_canvas_event_pointer_callbacks,
{ EFL_EVENT_POINTER_MOVE, _evas_canvas_event_pointer_cb },
@ -3542,7 +3561,9 @@ EFL_CALLBACKS_ARRAY_DEFINE(_evas_canvas_event_pointer_callbacks,
{ EFL_EVENT_FINGER_DOWN, _evas_canvas_event_pointer_cb },
{ 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_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 })
void
_evas_canvas_event_init(Evas *eo_e, Evas_Public_Data *e)

View File

@ -1,5 +1,5 @@
#define EVAS_CANVAS_BETA
#define EFL_INPUT_EVENT_PROTECTED
#include "evas_common_private.h"
#include "evas_private.h"
//#include "evas_cs.h"
@ -13,6 +13,9 @@
#include <Ecore.h>
#define EFL_INTERNAL_UNSTABLE
#include "interfaces/efl_common_internal.h"
#define MY_CLASS EVAS_CANVAS_CLASS
#ifdef LKDEBUG
@ -529,20 +532,33 @@ _evas_canvas_data_attach_get(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e)
return e->attach_data;
}
static void
_evas_canvas_focus_inout_dispatch(Eo *eo_e, Evas_Public_Data *e, Eina_Bool in)
{
Efl_Input_Focus_Data *ev_data;
Efl_Input_Focus *evt;
evt = efl_input_instance_get(EFL_INPUT_FOCUS_CLASS, eo_e, (void **) &ev_data);
if (!evt) return;
ev_data->device = efl_ref(e->default_seat);
ev_data->timestamp = time(NULL);
efl_event_callback_call(eo_e,
in ? EFL_EVENT_FOCUS_IN : EFL_EVENT_FOCUS_OUT,
evt);
efl_del(evt);
}
EOLIAN static void
_evas_canvas_focus_in(Eo *eo_e, Evas_Public_Data *e)
{
if (e->focus) return;
e->focus = 1;
evas_event_callback_call(eo_e, EVAS_CALLBACK_CANVAS_FOCUS_IN, NULL);
_evas_canvas_focus_inout_dispatch(eo_e, e, EINA_TRUE);
}
EOLIAN static void
_evas_canvas_focus_out(Eo *eo_e, Evas_Public_Data *e)
{
if (!e->focus) return;
e->focus = 0;
evas_event_callback_call(eo_e, EVAS_CALLBACK_CANVAS_FOCUS_OUT, NULL);
_evas_canvas_focus_inout_dispatch(eo_e, e, EINA_FALSE);
}
EOLIAN static Eina_Bool