forked from enlightenment/efl
Efl.Canvas: Use Efl.Input.Focus as event info for object,focus.in/out.
This commit is contained in:
parent
fd6f6c14c1
commit
b77f0086f5
|
@ -162,8 +162,8 @@ interface Efl.Canvas ()
|
|||
events {
|
||||
focus,in: Efl.Input.Focus; [[Called when canvas got focus]]
|
||||
focus,out: Efl.Input.Focus; [[Called when canvas lost focus]]
|
||||
object,focus,in: Efl.Canvas.Object; [[Called when object got focus]]
|
||||
object,focus,out: Efl.Canvas.Object; [[Called when object lost focus]]
|
||||
object,focus,in: Efl.Input.Focus; [[Called when object got focus]]
|
||||
object,focus,out: Efl.Input.Focus; [[Called when object lost focus]]
|
||||
render,pre; [[Called when pre render happens]]
|
||||
render,post; [[Called when post render happens]]
|
||||
device,changed: Efl.Input.Device; [[Called when input device changed]]
|
||||
|
|
|
@ -204,6 +204,9 @@ _eo_evas_cb(void *data, const Efl_Event *event)
|
|||
if (event->desc == EFL_CANVAS_EVENT_FOCUS_IN ||
|
||||
event->desc == EFL_CANVAS_EVENT_FOCUS_OUT)
|
||||
event_info = NULL;
|
||||
else if (event->desc == EFL_CANVAS_EVENT_OBJECT_FOCUS_IN ||
|
||||
event->desc == EFL_CANVAS_EVENT_OBJECT_FOCUS_OUT)
|
||||
event_info = efl_input_focus_object_get(event->info);
|
||||
else
|
||||
event_info = event->info;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
void
|
||||
_evas_focus_dispatch_event(Evas_Object_Protected_Data *obj, Efl_Input_Device *seat, Eina_Bool in)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if (seat == obj->layer->evas->default_seat)
|
||||
{
|
||||
evas_object_event_callback_call(obj->object, obj,
|
||||
cb_obj_evas,
|
||||
NULL, _evas_object_event_new(),
|
||||
efl_object_focus_event);
|
||||
}
|
||||
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);
|
||||
|
||||
//Legacy events...
|
||||
if (seat == obj->layer->evas->default_seat)
|
||||
{
|
||||
evas_object_event_callback_call(obj->object, obj,
|
||||
EVAS_CALLBACK_FOCUS_OUT,
|
||||
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_event_callback_call(obj->object,
|
||||
EFL_CANVAS_OBJECT_EVENT_FOCUS_DEVICE_OUT,
|
||||
seat);
|
||||
_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;
|
||||
|
|
|
@ -706,15 +706,7 @@ _efl_canvas_object_efl_object_destructor(Eo *eo_obj, Evas_Object_Protected_Data
|
|||
efl_event_callback_del(dev, EFL_EVENT_DEL,
|
||||
_evas_focus_device_del_cb, obj);
|
||||
eina_hash_del_by_key(edata->focused_objects, &dev);
|
||||
//default seat - legacy support.
|
||||
if (dev == edata->default_seat)
|
||||
{
|
||||
evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_FOCUS_OUT,
|
||||
NULL, _evas_object_event_new(),
|
||||
EFL_CANVAS_OBJECT_EVENT_FOCUS_OUT);
|
||||
}
|
||||
efl_event_callback_call(eo_obj,
|
||||
EFL_CANVAS_OBJECT_EVENT_FOCUS_DEVICE_OUT, dev);
|
||||
_evas_focus_dispatch_event(obj, dev, EINA_FALSE);
|
||||
if ((obj->layer) && (obj->layer->evas))
|
||||
_evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas);
|
||||
}
|
||||
|
|
|
@ -1945,6 +1945,9 @@ Eina_Bool evas_vg_loader_svg(Evas_Object *vg, const Eina_File *f, const char *ke
|
|||
void *_evas_object_image_surface_get(Evas_Object *eo, Evas_Object_Protected_Data *obj);
|
||||
Eina_Bool _evas_image_proxy_source_clip_get(const Eo *eo_obj);
|
||||
|
||||
void _evas_focus_dispatch_event(Evas_Object_Protected_Data *obj,
|
||||
Efl_Input_Device *seat, Eina_Bool in);
|
||||
|
||||
extern Eina_Cow *evas_object_proxy_cow;
|
||||
extern Eina_Cow *evas_object_map_cow;
|
||||
extern Eina_Cow *evas_object_state_cow;
|
||||
|
|
Loading…
Reference in New Issue