Evas: Add seat_event_filter_set()/get() API.
With this new API one can block or unblock keyboard, mouse and focus events that was originated from a seat. This is useful to create applications that wants to establish some kind of seat segregation.
This commit is contained in:
parent
eef89ceb3a
commit
ddfc98359f
|
@ -666,5 +666,7 @@ abstract Efl.Canvas.Object (Efl.Object, Efl.Gfx, Efl.Gfx.Stack, Efl.Animator,
|
|||
Efl.Gfx.Size.Hint.hint_weight.get;
|
||||
Efl.Gfx.Map.map_enable.set;
|
||||
Efl.Gfx.Map.map_enable.get;
|
||||
Efl.Input.Interface.seat_event_filter.set;
|
||||
Efl.Input.Interface.seat_event_filter.get;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,22 @@ interface Efl.Input.Interface ()
|
|||
}
|
||||
return: iterator<const(Efl.Input.Pointer)>; [[Iterator to pointer positions]]
|
||||
}
|
||||
@property seat_event_filter {
|
||||
set {
|
||||
[[Add or remove a given seat to the filter list. If the filter list is empty this object
|
||||
will report mouse, keyboard and focus events from any seat, otherwise those events will
|
||||
only be reported if the event comes from a seat that is in the list.]]
|
||||
}
|
||||
get {
|
||||
[[Check if input events from a given seat is enabled.]]
|
||||
}
|
||||
keys {
|
||||
seat: Efl.Input.Device; [[The seat to act on.]]
|
||||
}
|
||||
values {
|
||||
enable: bool; [[$true to enable events for a seat or $false otherwise.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
events {
|
||||
pointer,move: Efl.Input.Pointer; [[Main pointer move (current and previous positions are known).]]
|
||||
|
|
|
@ -887,6 +887,52 @@ evas_object_del(Evas_Object *eo_obj)
|
|||
efl_del(eo_obj);
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_efl_canvas_object_efl_input_interface_seat_event_filter_get(Eo *eo_obj EINA_UNUSED,
|
||||
Evas_Object_Protected_Data *obj,
|
||||
Efl_Input_Device *seat)
|
||||
{
|
||||
//If the list is empty this object accept events from any seat.
|
||||
if (!obj->events_whitelist)
|
||||
return EINA_TRUE;
|
||||
return eina_list_data_find(obj->events_whitelist, seat) ?
|
||||
EINA_TRUE : EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_whitelist_events_device_remove_cb(void *data, const Efl_Event *event)
|
||||
{
|
||||
Evas_Object_Protected_Data *obj = data;
|
||||
obj->events_whitelist = eina_list_remove(obj->events_whitelist,
|
||||
event->object);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_canvas_object_efl_input_interface_seat_event_filter_set(Eo *eo_obj,
|
||||
Evas_Object_Protected_Data *obj,
|
||||
Efl_Input_Device *seat,
|
||||
Eina_Bool add)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(seat);
|
||||
|
||||
if (efl_input_device_type_get(seat) != EFL_INPUT_DEVICE_CLASS_SEAT) return;
|
||||
if (add)
|
||||
{
|
||||
if (eina_list_data_find(obj->events_whitelist, seat)) return;
|
||||
if (efl_canvas_object_seat_focus_check(eo_obj, seat))
|
||||
efl_canvas_object_seat_focus_del(eo_obj, seat);
|
||||
obj->events_whitelist = eina_list_append(obj->events_whitelist, seat);
|
||||
efl_event_callback_add(seat, EFL_EVENT_DEL,
|
||||
_whitelist_events_device_remove_cb, obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->events_whitelist = eina_list_remove(obj->events_whitelist, seat);
|
||||
efl_event_callback_del(seat, EFL_EVENT_DEL,
|
||||
_whitelist_events_device_remove_cb, obj);
|
||||
}
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_canvas_object_efl_object_destructor(Eo *eo_obj, Evas_Object_Protected_Data *obj)
|
||||
{
|
||||
|
@ -914,6 +960,8 @@ _efl_canvas_object_efl_object_destructor(Eo *eo_obj, Evas_Object_Protected_Data
|
|||
evas_object_event_callback_call(eo_obj, obj, EVAS_CALLBACK_DEL, NULL, _evas_object_event_new(), NULL);
|
||||
if ((obj->layer) && (obj->layer->evas))
|
||||
_evas_post_event_callback_call(obj->layer->evas->evas, obj->layer->evas);
|
||||
EINA_LIST_FREE(obj->events_whitelist, dev)
|
||||
efl_event_callback_del(dev, EFL_EVENT_DEL, _whitelist_events_device_remove_cb, obj);
|
||||
if (obj->name) evas_object_name_set(eo_obj, NULL);
|
||||
if (!obj->layer)
|
||||
{
|
||||
|
|
|
@ -1116,6 +1116,12 @@ struct _Evas_Object_Protected_Data
|
|||
Eina_List *grabs;
|
||||
|
||||
Eina_Inlist *callbacks;
|
||||
/*
|
||||
The list below contain the seats (Efl.Input.Devices) which this
|
||||
object allows events to be reported (Mouse, Keybord and focus events).
|
||||
If this list is empty, this object will allow events from any seat.
|
||||
*/
|
||||
Eina_List *events_whitelist;
|
||||
|
||||
struct {
|
||||
Eina_List *clipees;
|
||||
|
|
Loading…
Reference in New Issue