summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Iscaro <iscaro@profusion.mobi>2016-11-17 17:30:58 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-11-24 19:18:47 -0200
commitded24d80ed2efe688233145e309dbc59048266fc (patch)
treec01c33ceea0dd0dcd309c3a999a6bee7a0a49eb9
parented9c6351522428d4706249356259e1dddc492bb6 (diff)
downloadefl-ded24d80ed2efe688233145e309dbc59048266fc.tar.gz
Evas: Use events to flag canvas focus in/out.
-rw-r--r--src/lib/evas/canvas/evas_events.c23
-rw-r--r--src/lib/evas/canvas/evas_main.c30
2 files changed, 45 insertions, 8 deletions
diff --git a/src/lib/evas/canvas/evas_events.c b/src/lib/evas/canvas/evas_events.c
index 7d7492ed6c..10782b6f38 100644
--- a/src/lib/evas/canvas/evas_events.c
+++ b/src/lib/evas/canvas/evas_events.c
@@ -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)
diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index 48048cf047..4174602bb5 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -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