forked from enlightenment/efl
efl_input_device: add function for determining if a device has pointer caps
this is useful when attempting to manage devices @feature
This commit is contained in:
parent
839e45e49b
commit
9572e9189d
|
@ -98,6 +98,7 @@ struct _Efl_Input_Device_Data
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
Efl_Input_Device_Class klass;
|
Efl_Input_Device_Class klass;
|
||||||
Efl_Input_Device_Sub_Class subclass;
|
Efl_Input_Device_Sub_Class subclass;
|
||||||
|
unsigned int pointer_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Efl_Input_Hold_Data
|
struct _Efl_Input_Hold_Data
|
||||||
|
|
|
@ -19,6 +19,22 @@ struct _Child_Device_Iterator
|
||||||
Eo *object;
|
Eo *object;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_is_pointer(Efl_Input_Device_Data *pd)
|
||||||
|
{
|
||||||
|
return (pd->klass == EFL_INPUT_DEVICE_CLASS_MOUSE ||
|
||||||
|
pd->klass == EFL_INPUT_DEVICE_CLASS_TOUCH ||
|
||||||
|
pd->klass == EFL_INPUT_DEVICE_CLASS_PEN ||
|
||||||
|
pd->klass == EFL_INPUT_DEVICE_CLASS_WAND);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_seat_pointers_update(Efl_Input_Device_Data *seat, Efl_Input_Device_Data *dev)
|
||||||
|
{
|
||||||
|
if (seat && _is_pointer(dev))
|
||||||
|
seat->pointer_count++;
|
||||||
|
}
|
||||||
|
|
||||||
EOLIAN static Efl_Object *
|
EOLIAN static Efl_Object *
|
||||||
_efl_input_device_efl_object_constructor(Eo *obj, Efl_Input_Device_Data *pd)
|
_efl_input_device_efl_object_constructor(Eo *obj, Efl_Input_Device_Data *pd)
|
||||||
{
|
{
|
||||||
|
@ -43,6 +59,8 @@ _efl_input_device_efl_object_destructor(Eo *obj, Efl_Input_Device_Data *pd)
|
||||||
{
|
{
|
||||||
Efl_Input_Device_Data *p = efl_data_scope_get(pd->parent, EFL_INPUT_DEVICE_CLASS);
|
Efl_Input_Device_Data *p = efl_data_scope_get(pd->parent, EFL_INPUT_DEVICE_CLASS);
|
||||||
p->children = eina_list_remove(p->children, obj);
|
p->children = eina_list_remove(p->children, obj);
|
||||||
|
if (_is_pointer(pd))
|
||||||
|
p->pointer_count--;
|
||||||
}
|
}
|
||||||
efl_unref(pd->source);
|
efl_unref(pd->source);
|
||||||
|
|
||||||
|
@ -52,7 +70,10 @@ _efl_input_device_efl_object_destructor(Eo *obj, Efl_Input_Device_Data *pd)
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_efl_input_device_device_type_set(Eo *obj EINA_UNUSED, Efl_Input_Device_Data *pd, Efl_Input_Device_Class klass)
|
_efl_input_device_device_type_set(Eo *obj EINA_UNUSED, Efl_Input_Device_Data *pd, Efl_Input_Device_Class klass)
|
||||||
{
|
{
|
||||||
pd->klass= klass;
|
EINA_SAFETY_ON_TRUE_RETURN(pd->klass);
|
||||||
|
pd->klass = klass;
|
||||||
|
if (klass != EFL_INPUT_DEVICE_CLASS_SEAT)
|
||||||
|
_seat_pointers_update(efl_data_scope_get(pd->parent, EFL_INPUT_DEVICE_CLASS), pd);
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Efl_Input_Device_Class
|
EOLIAN static Efl_Input_Device_Class
|
||||||
|
@ -163,6 +184,7 @@ _efl_input_device_parent_set(Eo *obj, Efl_Input_Device_Data *pd, Efl_Input_Devic
|
||||||
{
|
{
|
||||||
Efl_Input_Device_Data *p = efl_data_scope_get(parent, EFL_INPUT_DEVICE_CLASS);
|
Efl_Input_Device_Data *p = efl_data_scope_get(parent, EFL_INPUT_DEVICE_CLASS);
|
||||||
p->children = eina_list_append(p->children, obj);
|
p->children = eina_list_append(p->children, obj);
|
||||||
|
_seat_pointers_update(p, pd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,4 +234,12 @@ _efl_input_device_children_iterate(Eo *obj, Efl_Input_Device_Data *pd)
|
||||||
return &it->iterator;
|
return &it->iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EOLIAN static unsigned int
|
||||||
|
_efl_input_device_has_pointer_caps(Eo *obj EINA_UNUSED, Efl_Input_Device_Data *pd)
|
||||||
|
{
|
||||||
|
if (pd->klass == EFL_INPUT_DEVICE_CLASS_SEAT)
|
||||||
|
return pd->pointer_count;
|
||||||
|
return _is_pointer(pd);
|
||||||
|
}
|
||||||
|
|
||||||
#include "interfaces/efl_input_device.eo.c"
|
#include "interfaces/efl_input_device.eo.c"
|
||||||
|
|
|
@ -120,6 +120,17 @@ class Efl.Input.Device (Efl.Object)
|
||||||
]]
|
]]
|
||||||
return: own(free(iterator<const(Efl.Input.Device)>, eina_iterator_free));
|
return: own(free(iterator<const(Efl.Input.Device)>, eina_iterator_free));
|
||||||
}
|
}
|
||||||
|
has_pointer_caps {
|
||||||
|
[[Determine whether a device has pointer capabilities.
|
||||||
|
|
||||||
|
Returns 1 for Mouse, Touch, Pen, Pointer, and Wand type devices.
|
||||||
|
|
||||||
|
If a seat device is passed, returns the number of pointer devices in the seat.
|
||||||
|
|
||||||
|
@since 1.20
|
||||||
|
]]
|
||||||
|
return: uint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
implements {
|
implements {
|
||||||
Efl.Object.constructor;
|
Efl.Object.constructor;
|
||||||
|
|
Loading…
Reference in New Issue