aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/evas/canvas/evas_focus.c
diff options
context:
space:
mode:
authorGuilherme Iscaro <iscaro@profusion.mobi>2016-11-18 13:00:34 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-11-24 19:18:47 -0200
commitb77f0086f5502edacfb71277bbb024247ca6f4b1 (patch)
treeba9a0351d230d4682aa4a2b365f88a3663b2799a /src/lib/evas/canvas/evas_focus.c
parentEvas: Use events to set canvas focus in/out. (diff)
downloadefl-b77f0086f5502edacfb71277bbb024247ca6f4b1.tar.gz
Efl.Canvas: Use Efl.Input.Focus as event info for object,focus.in/out.
Diffstat (limited to 'src/lib/evas/canvas/evas_focus.c')
-rw-r--r--src/lib/evas/canvas/evas_focus.c73
1 files changed, 48 insertions, 25 deletions
diff --git a/src/lib/evas/canvas/evas_focus.c b/src/lib/evas/canvas/evas_focus.c
index 3245867fee..d65422a2b1 100644
--- a/src/lib/evas/canvas/evas_focus.c
+++ b/src/lib/evas/canvas/evas_focus.c
@@ -1,5 +1,9 @@
+#define EFL_INTERNAL_UNSTABLE
+#define EFL_INPUT_EVENT_PROTECTED
+
#include "evas_common_private.h"
#include "evas_private.h"
+#include "interfaces/efl_common_internal.h"
/* private calls */
@@ -59,26 +63,56 @@ _current_focus_get(Eo *evas_obj, Efl_Input_Device *key)
return eina_hash_find(edata->focused_objects, &key);
}
-static void
-_evas_object_unfocus(Evas_Object_Protected_Data *obj, Efl_Input_Device *seat)
+void
+_evas_focus_dispatch_event(Evas_Object_Protected_Data *obj, Efl_Input_Device *seat, Eina_Bool in)
{
- obj->focused_by_seats = eina_list_remove(obj->focused_by_seats, seat);
- _evas_focus_set(obj->object, seat, EINA_FALSE);
+ Efl_Input_Focus_Data *ev_data;
+ Efl_Input_Focus *evt;
+ Evas_Callback_Type cb_evas, cb_obj_evas;
+ const Efl_Event_Description *efl_object_focus_event, *efl_object_focus_device_event;
+
+ evt = efl_input_instance_get(EFL_INPUT_FOCUS_CLASS, NULL, (void **) &ev_data);
+ if (!evt) return;
+
+ ev_data->device = efl_ref(seat);
+ ev_data->object = obj->object;
+ ev_data->timestamp = time(NULL);
+
+ if (in)
+ {
+ cb_obj_evas = EVAS_CALLBACK_FOCUS_IN;
+ cb_evas = EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN;
+ efl_object_focus_event = EFL_CANVAS_OBJECT_EVENT_FOCUS_IN;
+ efl_object_focus_device_event = EFL_CANVAS_OBJECT_EVENT_FOCUS_DEVICE_IN;
+ }
+ else
+ {
+ cb_obj_evas = EVAS_CALLBACK_FOCUS_OUT;
+ cb_evas = EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT;
+ efl_object_focus_event = EFL_CANVAS_OBJECT_EVENT_FOCUS_OUT;
+ efl_object_focus_device_event = EFL_CANVAS_OBJECT_EVENT_FOCUS_DEVICE_OUT;
+ }
- //Legacy events...
if (seat == obj->layer->evas->default_seat)
{
evas_object_event_callback_call(obj->object, obj,
- EVAS_CALLBACK_FOCUS_OUT,
+ cb_obj_evas,
NULL, _evas_object_event_new(),
- EFL_CANVAS_OBJECT_EVENT_FOCUS_OUT);
- evas_event_callback_call(obj->layer->evas->evas,
- EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
- obj->object);
+ efl_object_focus_event);
}
- efl_event_callback_call(obj->object,
- EFL_CANVAS_OBJECT_EVENT_FOCUS_DEVICE_OUT,
- seat);
+ evas_event_callback_call(obj->layer->evas->evas,
+ cb_evas, evt);
+ efl_event_callback_call(obj->object, efl_object_focus_device_event, seat);
+ efl_del(evt);
+}
+
+static void
+_evas_object_unfocus(Evas_Object_Protected_Data *obj, Efl_Input_Device *seat)
+{
+ obj->focused_by_seats = eina_list_remove(obj->focused_by_seats, seat);
+ _evas_focus_set(obj->object, seat, EINA_FALSE);
+
+ _evas_focus_dispatch_event(obj, seat, EINA_FALSE);
_evas_post_event_callback_call(obj->layer->evas->evas,
obj->layer->evas);
}
@@ -161,18 +195,7 @@ _efl_canvas_object_seat_focus_add(Eo *eo_obj,
obj->focused_by_seats = eina_list_append(obj->focused_by_seats, seat);
_evas_focus_set(eo_obj, seat, EINA_TRUE);
- //Legacy events...
- if (seat == _default_seat_get(eo_obj))
- {
- evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_FOCUS_IN,
- NULL, _evas_object_event_new(),
- EFL_CANVAS_OBJECT_EVENT_FOCUS_IN);
- evas_event_callback_call(obj->layer->evas->evas,
- EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN, eo_obj);
- }
-
- efl_event_callback_call(eo_obj,
- EFL_CANVAS_OBJECT_EVENT_FOCUS_DEVICE_IN, seat);
+ _evas_focus_dispatch_event(obj, seat, EINA_TRUE);
end:
_evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas);
return EINA_TRUE;