summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Iscaro <iscaro@profusion.mobi>2016-11-07 16:44:46 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-12-02 09:57:50 -0200
commitc3ed1d3154a0a3fda0dfb05b428f686422e779a6 (patch)
tree24024907ff0d03dcca46c53e4ff9e055ac9e4edb
parentf442bd74d22899c8b3c0100463fd780958e62a7f (diff)
downloadefl-c3ed1d3154a0a3fda0dfb05b428f686422e779a6.tar.gz
Evas: Add support for per seat modifiers and locks.
This patch introduces possibility to enable key locks and modifers by seat. It's very useful when the user has two keyboards attached to different seats.
-rw-r--r--src/lib/evas/Evas_Common.h55
-rw-r--r--src/lib/evas/canvas/efl_input_key.c11
-rw-r--r--src/lib/evas/canvas/efl_input_pointer.c12
-rw-r--r--src/lib/evas/canvas/evas_canvas.eo93
-rw-r--r--src/lib/evas/canvas/evas_device.c2
-rw-r--r--src/lib/evas/canvas/evas_events.c18
-rw-r--r--src/lib/evas/canvas/evas_key.c164
-rw-r--r--src/lib/evas/canvas/evas_main.c11
-rw-r--r--src/lib/evas/include/evas_private.h6
9 files changed, 294 insertions, 78 deletions
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index 5ae1626c44..2f54174121 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -3449,7 +3449,7 @@ EAPI void evas_language_reinit(void);
* @{
*/
/**
- * Checks the state of a given modifier key, at the time of the
+ * Checks the state of a given modifier of the default seat, at the time of the
* call. If the modifier is set, such as shift being pressed, this
* function returns @c Eina_True.
*
@@ -3465,11 +3465,35 @@ EAPI void evas_language_reinit(void);
* @see evas_key_modifier_get
* @see evas_key_modifier_on
* @see evas_key_modifier_off
+ * @see evas_seat_key_modifier_is_set
*/
EAPI Eina_Bool evas_key_modifier_is_set(const Evas_Modifier *m, const char *keyname) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2);
-
/**
- * Checks the state of a given lock key, at the time of the call. If
+ * Checks the state of a given modifier key of a given seat, at the time of the
+ * call. If the modifier is set, such as shift being pressed, this
+ * function returns @c Eina_True.
+ *
+ * @param m The current modifiers set, as returned by
+ * evas_key_modifier_get().
+ * @param keyname The name of the modifier key to check status for.
+ * @param seat The seat to check if the lock is set. Use @c NULL for the default seat.
+ *
+ * @return @c Eina_True if the modifier key named @p keyname is on, @c
+ * Eina_False otherwise.
+ *
+ * @see evas_key_modifier_add
+ * @see evas_key_modifier_del
+ * @see evas_key_modifier_get
+ * @see evas_key_modifier_on
+ * @see evas_key_modifier_off
+ * @see evas_seat_key_modifier_on
+ * @see evas_seat_key_modifier_off
+ * @see evas_key_modifier_is_set
+ * @since 1.19
+ */
+EAPI Eina_Bool evas_seat_key_modifier_is_set(const Evas_Modifier *m, const char *keyname, const Evas_Device *seat) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2);
+/**
+ * Checks the state of a given lock key of the default seat, at the time of the call. If
* the lock is set, such as caps lock, this function returns @c
* Eina_True.
*
@@ -3484,10 +3508,35 @@ EAPI Eina_Bool evas_key_modifier_is_set(const Evas_Modifier *m, const
* @see evas_key_lock_del
* @see evas_key_lock_on
* @see evas_key_lock_off
+ * @see evas_seat_key_lock_on
+ * @see evas_seat_key_lock_off
+ * @see evas_seat_key_lock_is_set
*/
EAPI Eina_Bool evas_key_lock_is_set(const Evas_Lock *l, const char *keyname) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2);
/**
+ * Checks the state of a given lock key of a given seat, at the time of the call. If
+ * the lock is set, such as caps lock, this function returns @c
+ * Eina_True.
+ *
+ * @param l The current locks set, as returned by evas_key_lock_get().
+ * @param keyname The name of the lock key to check status for.
+ * @param seat The seat to check if the lock is set. Use @c NULL for the default seat.
+ *
+ * @return @c Eina_True if the @p keyname lock key is set, @c
+ * Eina_False otherwise.
+ *
+ * @see evas_key_lock_get
+ * @see evas_key_lock_add
+ * @see evas_key_lock_del
+ * @see evas_key_lock_on
+ * @see evas_key_lock_off
+ * @see evas_key_lock_is_set
+ * @since 1.19
+ */
+EAPI Eina_Bool evas_seat_key_lock_is_set(const Evas_Lock *l, const char *keyname, const Evas_Device *seat) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2);
+
+/**
* @}
*/
diff --git a/src/lib/evas/canvas/efl_input_key.c b/src/lib/evas/canvas/efl_input_key.c
index 387723b9c6..685b6b3b12 100644
--- a/src/lib/evas/canvas/efl_input_key.c
+++ b/src/lib/evas/canvas/efl_input_key.c
@@ -242,15 +242,22 @@ _efl_input_key_efl_input_event_device_get(Eo *obj EINA_UNUSED, Efl_Input_Key_Dat
EOLIAN static Eina_Bool
_efl_input_key_efl_input_state_modifier_enabled_get(Eo *obj EINA_UNUSED, Efl_Input_Key_Data *pd, const char * name)
{
+ Efl_Input_Device *seat;
+
if (!pd->modifiers) return EINA_FALSE;
- return evas_key_modifier_is_set(pd->modifiers, name);
+ seat = efl_input_device_seat_get(pd->device);
+ if (!seat) return EINA_FALSE;
+ return evas_seat_key_modifier_is_set(pd->modifiers, name, seat);
}
EOLIAN static Eina_Bool
_efl_input_key_efl_input_state_lock_enabled_get(Eo *obj EINA_UNUSED, Efl_Input_Key_Data *pd, const char * name)
{
+ Efl_Input_Device *seat;
if (!pd->locks) return EINA_FALSE;
- return evas_key_lock_is_set(pd->locks, name);
+ seat = efl_input_device_seat_get(pd->device);
+ if (!seat) return EINA_FALSE;
+ return evas_seat_key_lock_is_set(pd->locks, name, seat);
}
EOLIAN static Eina_Bool
diff --git a/src/lib/evas/canvas/efl_input_pointer.c b/src/lib/evas/canvas/efl_input_pointer.c
index 9b068d7730..4ec9af04e7 100644
--- a/src/lib/evas/canvas/efl_input_pointer.c
+++ b/src/lib/evas/canvas/efl_input_pointer.c
@@ -325,15 +325,23 @@ _efl_input_pointer_tool_set(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, int
EOLIAN static Eina_Bool
_efl_input_pointer_efl_input_state_modifier_enabled_get(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, const char *name)
{
+ Efl_Input_Device *seat;
+
if (!pd->modifiers) return EINA_FALSE;
- return evas_key_modifier_is_set(pd->modifiers, name);
+ seat = efl_input_device_seat_get(pd->device);
+ if (!seat) return EINA_FALSE;
+ return evas_seat_key_modifier_is_set(pd->modifiers, name, seat);
}
EOLIAN static Eina_Bool
_efl_input_pointer_efl_input_state_lock_enabled_get(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, const char *name)
{
+ Efl_Input_Device *seat;
+
if (!pd->locks) return EINA_FALSE;
- return evas_key_lock_is_set(pd->locks, name);
+ seat = efl_input_device_seat_get(pd->device);
+ if (!seat) return EINA_FALSE;
+ return evas_seat_key_lock_is_set(pd->locks, name, seat);
}
EOLIAN static void
diff --git a/src/lib/evas/canvas/evas_canvas.eo b/src/lib/evas/canvas/evas_canvas.eo
index aadeb336b1..9a2d62b934 100644
--- a/src/lib/evas/canvas/evas_canvas.eo
+++ b/src/lib/evas/canvas/evas_canvas.eo
@@ -207,7 +207,7 @@ class Evas.Canvas (Efl.Object, Efl.Canvas, Efl.Animator, Efl.Input.Interface)
]]
return: ptr(const(Evas.Lock)) @warn_unused; [[
An Evas_Lock handle to query Evas' keys subsystem with
- \@ref evas_key_lock_is_set, or $null on error.
+ \@ref evas_key_lock_is_set or \@ref evas_seat_key_lock_is_set, or $null on error.
]]
}
}
@@ -430,11 +430,12 @@ class Evas.Canvas (Efl.Object, Efl.Canvas, Efl.Animator, Efl.Input.Interface)
given time with the \@ref evas_key_modifier_is_set function.
See also @.key_modifier_add, @.key_modifier_del,
- @.key_modifier_on, @.key_modifier_off.
+ @.key_modifier_on, @.key_modifier_off, @.seat_key_modifier_on,
+ @.seat_key_modifier_off.
]]
return: ptr(const(Evas.Modifier)) @warn_unused; [[
An Evas_Modifier handle to query Evas' keys subsystem
- with \@ref evas_key_modifier_is_set, or $null on error.
+ with \@ref evas_key_modifier_is_set or \@ref evas_seat_key_modifier_is_set, or $null on error.
]]
}
}
@@ -507,18 +508,49 @@ class Evas.Canvas (Efl.Object, Efl.Canvas, Efl.Animator, Efl.Input.Interface)
}
key_lock_on {
[[Enables or turns on programmatically the lock key with name
- $keyname.
+ $keyname for the default seat.
The effect will be as if the key was put on its active state
after this call.
- See also @.key_lock_add, @.key_lock_del, @.key_lock_del,
- @.key_lock_off.
+ See also @.key_lock_add, @.key_lock_del, @.key_lock_del,
+ @.key_lock_off, @.seat_key_lock_on, @.seat_key_lock_off.
]]
params {
@in keyname: string @nonull; [[The name of the lock to enable.]]
}
}
+ seat_key_lock_on {
+ [[Enables or turns on programmatically the lock key with name
+ $keyname for a give seat.
+
+ The effect will be as if the key was put on its active state
+ after this call.
+
+ See also @.key_lock_add, @.key_lock_del, @.key_lock_del,
+ @.key_lock_off, @.key_lock_on, @.seat_key_lock_off.
+ @since 1.19
+ ]]
+ params {
+ @in keyname: string @nonull; [[The name of the lock to enable.]]
+ @in seat: Efl.Input.Device; [[The seat to enable the keylock. A $null seat repesents the default seat.]]
+ }
+ }
+ seat_key_lock_off {
+ [[Disables or turns off programmatically the lock key with name
+ $keyname for a given seat.
+
+ The effect will be as if the key was put on its inactive state
+ after this call.
+
+ See also @.key_lock_on, @.seat_key_lock_on, @.key_lock_off.
+ @since 1.19
+ ]]
+ params {
+ @in keyname: string @nonull; [[The name of the lock to enable.]]
+ @in seat: Efl.Input.Device; [[The seat to disable the keylock. A $null seat repesents the default seat.]]
+ }
+ }
key_modifier_mask_get @const {
[[Creates a bit mask from the $keyname modifier key. Values
returned from different calls to it may be ORed together,
@@ -529,8 +561,8 @@ class Evas.Canvas (Efl.Object, Efl.Canvas, Efl.Animator, Efl.Input.Interface)
Go check their documentation for more information.
See also @.key_modifier_add, \@ref evas_key_modifier_get,
- @.key_modifier_on, @.key_modifier_off,
- \@ref evas_key_modifier_is_set.
+ @.key_modifier_on, @.key_modifier_off, @.seat_key_modifier_on, @.seat_key_modifier_off,
+ \@ref evas_key_modifier_is_set, \@ref evas_seat_key_modifier_is_set..
]]
return: Evas.Modifier_Mask @warn_unused; [[
The bit mask or 0 if the $keyname key wasn't registered as a
@@ -568,11 +600,11 @@ class Evas.Canvas (Efl.Object, Efl.Canvas, Efl.Animator, Efl.Input.Interface)
}
key_modifier_off {
[[Disables or turns off programmatically the modifier key with
- name $keyname.
+ name $keyname for the default seat.
See also @.key_modifier_add, \@ref evas_key_modifier_get,
- @.key_modifier_on, @.key_modifier_mask_get,
- \@ref evas_key_modifier_is_set.
+ @.key_modifier_on, @.key_modifier_mask_get, @.seat_key_modifier_off,
+ @.seat_key_modifier_off, \@ref evas_key_modifier_is_set, \@ref evas_seat_key_modifier_is_set.
]]
params {
@in keyname: string @nonull; [[The name of the modifier to disable.]]
@@ -688,12 +720,12 @@ class Evas.Canvas (Efl.Object, Efl.Canvas, Efl.Animator, Efl.Input.Interface)
}
key_lock_off {
[[Disables or turns off programmatically the lock key with name
- $keyname.
+ $keyname for the default seat.
The effect will be as if the key was put on its inactive state
after this call.
- See also @.key_lock_on.
+ See also @.key_lock_on, @.seat_key_lock_on, @.seat_key_lock_off.
]]
params {
@in keyname: string @nonull; [[The name of the lock to disable.]]
@@ -753,17 +785,48 @@ class Evas.Canvas (Efl.Object, Efl.Canvas, Efl.Animator, Efl.Input.Interface)
}
key_modifier_on {
[[Enables or turns on programmatically the modifier key with name
- $keyname.
+ $keyname for the default seat.
The effect will be as if the key was pressed for the whole time
between this call and a matching evas_key_modifier_off().
- See also @.key_modifier_off.
+ See also @.key_modifier_off, @.seat_key_modifier_on,
+ @.seat_key_modifier_off.
]]
params {
@in keyname: string @nonull; [[The name of the modifier to enable.]]
}
}
+ seat_key_modifier_on {
+ [[Enables or turns on programmatically the modifier key with name
+ $keyname for a given seat.
+
+ The effect will be as if the key was pressed for the whole time
+ between this call and a matching @.seat_key_modifier_off.
+
+ See also @.key_modifier_off, @.seat_key_modifier_on,
+ @.seat_key_modifier_off.
+ @since 1.19
+ ]]
+ params {
+ @in keyname: string @nonull; [[The name of the lock to enable.]]
+ @in seat: Efl.Input.Device; [[The seat to enable the modifier. A $null seat repesents the default seat.]]
+ }
+ }
+ seat_key_modifier_off {
+ [[Disables or turns off programmatically the modifier key with
+ name $keyname for a given seat.
+
+ See also @.key_modifier_add, \@ref evas_key_modifier_get,
+ @.key_modifier_on, @.key_modifier_mask_get, @.seat_key_modifier_off,
+ @.seat_key_modifier_off, \@ref evas_key_modifier_is_set, \@ref evas_seat_key_modifier_is_set.
+ @since 1.19
+ ]]
+ params {
+ @in keyname: string @nonull; [[The name of the lock to enable.]]
+ @in seat: Efl.Input.Device; [[The seat to disable the modifier. A $null seat repesents the default seat.]]
+ }
+ }
font_available_list @const {
[[List of available font descriptions known or found by this evas.
diff --git a/src/lib/evas/canvas/evas_device.c b/src/lib/evas/canvas/evas_device.c
index 4398efa898..4ab6d1532a 100644
--- a/src/lib/evas/canvas/evas_device.c
+++ b/src/lib/evas/canvas/evas_device.c
@@ -88,6 +88,8 @@ _del_cb(void *data, const Efl_Event *ev)
e->default_keyboard = _new_default_device_find(e, ev->object);
_evas_pointer_data_remove(e, ev->object);
+ eina_hash_del_by_key(e->locks.masks, &ev->object);
+ eina_hash_del_by_key(e->modifiers.masks, &ev->object);
efl_event_callback_call(e->evas, EFL_CANVAS_EVENT_DEVICE_REMOVED,
ev->object);
}
diff --git a/src/lib/evas/canvas/evas_events.c b/src/lib/evas/canvas/evas_events.c
index 4172950ab5..9958f3b103 100644
--- a/src/lib/evas/canvas/evas_events.c
+++ b/src/lib/evas/canvas/evas_events.c
@@ -3070,8 +3070,11 @@ _canvas_event_feed_key_down_internal(Evas_Public_Data *e, Efl_Input_Key_Data *ev
{
Eina_List *l;
Evas_Key_Grab *g;
+ Evas_Modifier_Mask *seat_mask, modifier_mask;
e->walking_grabs++;
+ seat_mask = eina_hash_find(e->modifiers.masks, &ev->device);
+ modifier_mask = seat_mask ? *seat_mask : 0;
EINA_LIST_FOREACH(e->grabs, l, g)
{
if (g->just_added)
@@ -3082,11 +3085,11 @@ _canvas_event_feed_key_down_internal(Evas_Public_Data *e, Efl_Input_Key_Data *ev
if (g->delete_me) continue;
if (!g->object) continue;
if (!g->is_active) continue;
- if (((e->modifiers.mask & g->modifiers) ||
- (g->modifiers == e->modifiers.mask)) &&
+ if (((modifier_mask & g->modifiers) ||
+ (g->modifiers == modifier_mask)) &&
(!strcmp(ev->keyname, g->keyname)))
{
- if (!(e->modifiers.mask & g->not_modifiers))
+ if (!(modifier_mask & g->not_modifiers))
{
Evas_Object_Protected_Data *object_obj = efl_data_scope_get(g->object, EFL_CANVAS_OBJECT_CLASS);
if (!e->is_frozen &&
@@ -3153,8 +3156,11 @@ _canvas_event_feed_key_up_internal(Evas_Public_Data *e, Efl_Input_Key_Data *ev)
{
Eina_List *l;
Evas_Key_Grab *g;
+ Evas_Modifier_Mask *seat_mask, modifier_mask;
e->walking_grabs++;
+ seat_mask = eina_hash_find(e->modifiers.masks, &ev->device);
+ modifier_mask = seat_mask ? *seat_mask : 0;
EINA_LIST_FOREACH(e->grabs, l, g)
{
if (g->just_added)
@@ -3165,9 +3171,9 @@ _canvas_event_feed_key_up_internal(Evas_Public_Data *e, Efl_Input_Key_Data *ev)
if (g->delete_me) continue;
if (!g->object) continue;
if (!g->is_active) continue;
- if (((e->modifiers.mask & g->modifiers) ||
- (g->modifiers == e->modifiers.mask)) &&
- (!(e->modifiers.mask & g->not_modifiers)) &&
+ if (((modifier_mask & g->modifiers) ||
+ (g->modifiers == modifier_mask)) &&
+ (!(modifier_mask & g->not_modifiers)) &&
(!strcmp(ev->keyname, g->keyname)))
{
Evas_Object_Protected_Data *object_obj = efl_data_scope_get(g->object, EFL_CANVAS_OBJECT_CLASS);
diff --git a/src/lib/evas/canvas/evas_key.c b/src/lib/evas/canvas/evas_key.c
index 82041f2eb9..8f098e0a62 100644
--- a/src/lib/evas/canvas/evas_key.c
+++ b/src/lib/evas/canvas/evas_key.c
@@ -43,38 +43,55 @@ _evas_canvas_key_lock_get(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e)
return &(e->locks);
}
-EAPI Eina_Bool
-evas_key_modifier_is_set(const Evas_Modifier *m, const char *keyname)
+static Eina_Bool
+_key_is_set(int n, Eina_Hash *masks, const Evas_Device *seat)
{
- Evas_Modifier_Mask num;
- int n;
+ Evas_Modifier_Mask num, *seat_mask;
- if (!m) return 0;
- if (!keyname) return 0;
- n = evas_key_modifier_number(m, keyname);
if (n < 0) return 0;
else if (n >= 64) return 0;
num = (Evas_Modifier_Mask)n;
num = 1ULL << num;
- if (m->mask & num) return 1;
+ seat_mask = eina_hash_find(masks, &seat);
+ if (!seat_mask) return 0;
+ if (*seat_mask & num) return 1;
return 0;
}
EAPI Eina_Bool
+evas_seat_key_modifier_is_set(const Evas_Modifier *m, const char *keyname,
+ const Evas_Device *seat)
+{
+ if (!seat)
+ seat = m->e->default_seat;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(seat, 0);
+ if (!m) return 0;
+ if (!keyname) return 0;
+ return _key_is_set(evas_key_modifier_number(m, keyname), m->masks, seat);
+}
+
+EAPI Eina_Bool
+evas_key_modifier_is_set(const Evas_Modifier *m, const char *keyname)
+{
+ return evas_seat_key_modifier_is_set(m, keyname, NULL);
+}
+
+EAPI Eina_Bool
evas_key_lock_is_set(const Evas_Lock *l, const char *keyname)
{
- Evas_Modifier_Mask num;
- int n;
+ return evas_seat_key_lock_is_set(l, keyname, NULL);
+}
+EAPI Eina_Bool
+evas_seat_key_lock_is_set(const Evas_Lock *l, const char *keyname,
+ const Evas_Device *seat)
+{
+ if (!seat)
+ seat = l->e->default_seat;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(seat, 0);
if (!l) return 0;
if (!keyname) return 0;
- n = evas_key_lock_number(l, keyname);
- if (n < 0) return 0;
- else if (n >= 64) return 0;
- num = (Evas_Modifier_Mask)n;
- num = 1ULL << num;
- if (l->mask & num) return 1;
- return 0;
+ return _key_is_set(evas_key_lock_number(l, keyname), l->masks, seat);
}
EOLIAN void
@@ -86,7 +103,7 @@ _evas_canvas_key_modifier_add(Eo *eo_e, Evas_Public_Data *e, const char *keyname
e->modifiers.mod.count++;
e->modifiers.mod.list = realloc(e->modifiers.mod.list, e->modifiers.mod.count * sizeof(char *));
e->modifiers.mod.list[e->modifiers.mod.count - 1] = strdup(keyname);
- e->modifiers.mask = 0;
+ eina_hash_free_buckets(e->modifiers.masks);
}
EOLIAN void
@@ -105,7 +122,7 @@ _evas_canvas_key_modifier_del(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const c
e->modifiers.mod.count--;
for (j = i; j < e->modifiers.mod.count; j++)
e->modifiers.mod.list[j] = e->modifiers.mod.list[j + 1];
- e->modifiers.mask = 0;
+ eina_hash_free_buckets(e->modifiers.masks);
return;
}
}
@@ -120,7 +137,7 @@ _evas_canvas_key_lock_add(Eo *eo_e, Evas_Public_Data *e, const char *keyname)
e->locks.lock.count++;
e->locks.lock.list = realloc(e->locks.lock.list, e->locks.lock.count * sizeof(char *));
e->locks.lock.list[e->locks.lock.count - 1] = strdup(keyname);
- e->locks.mask = 0;
+ eina_hash_free_buckets(e->locks.masks);
}
EOLIAN void
@@ -128,7 +145,6 @@ _evas_canvas_key_lock_del(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char
{
int i;
if (!keyname) return;
- e->locks.mask = 0;
for (i = 0; i < e->locks.lock.count; i++)
{
if (!strcmp(e->locks.lock.list[i], keyname))
@@ -139,58 +155,110 @@ _evas_canvas_key_lock_del(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char
e->locks.lock.count--;
for (j = i; j < e->locks.lock.count; j++)
e->locks.lock.list[j] = e->locks.lock.list[j + 1];
- e->locks.mask = 0;
+ eina_hash_free_buckets(e->locks.masks);
return;
}
}
}
-EOLIAN void
-_evas_canvas_key_modifier_on(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *keyname)
+static void
+_mask_set(int n, Eina_Hash *masks, Efl_Input_Device *seat, Eina_Bool add)
{
+ Evas_Modifier_Mask *current_mask;
Evas_Modifier_Mask num;
- int n;
- n = (Evas_Modifier_Mask)evas_key_modifier_number(&(e->modifiers), keyname);
if (n < 0 || n > 63) return;
num = 1ULL << n;
- e->modifiers.mask |= num;
+
+ current_mask = eina_hash_find(masks, &seat);
+ if (add)
+ {
+ if (!current_mask)
+ {
+ current_mask = calloc(1, sizeof(Evas_Modifier_Mask));
+ EINA_SAFETY_ON_NULL_RETURN(current_mask);
+ eina_hash_add(masks, &seat, current_mask);
+ }
+ *current_mask |= num;
+ }
+ else
+ {
+ if (!current_mask) return;
+ *current_mask &= ~num;
+ if (!(*current_mask))
+ eina_hash_del_by_key(masks, &seat);
+ }
}
EOLIAN void
-_evas_canvas_key_modifier_off(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *keyname)
+_evas_canvas_seat_key_modifier_on(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e,
+ const char *keyname, Efl_Input_Device *seat)
{
- Evas_Modifier_Mask num;
- int n;
+ if (!seat)
+ seat = e->default_seat;
+ EINA_SAFETY_ON_NULL_RETURN(seat);
+ if (efl_input_device_type_get(seat) != EFL_INPUT_DEVICE_CLASS_SEAT) return;
+ _mask_set(evas_key_modifier_number(&(e->modifiers), keyname),
+ e->modifiers.masks, seat, EINA_TRUE);
+}
- n = evas_key_modifier_number(&(e->modifiers), keyname);
- if (n < 0 || n > 63) return;
- num = 1ULL << n;
- e->modifiers.mask &= ~num;
+EOLIAN void
+_evas_canvas_seat_key_modifier_off(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e,
+ const char *keyname, Efl_Input_Device *seat)
+{
+ if (!seat)
+ seat = e->default_seat;
+ EINA_SAFETY_ON_NULL_RETURN(seat);
+ _mask_set(evas_key_modifier_number(&(e->modifiers), keyname),
+ e->modifiers.masks, seat, EINA_FALSE);
}
EOLIAN void
-_evas_canvas_key_lock_on(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *keyname)
+_evas_canvas_key_modifier_on(Eo *eo_e, Evas_Public_Data *e, const char *keyname)
{
- Evas_Modifier_Mask num;
- int n;
+ _evas_canvas_seat_key_modifier_on(eo_e, e, keyname, NULL);
+}
- n = evas_key_lock_number(&(e->locks), keyname);
- if (n < 0 || n > 63) return;
- num = 1ULL << n;
- e->locks.mask |= num;
+EOLIAN void
+_evas_canvas_key_modifier_off(Eo *eo_e, Evas_Public_Data *e,
+ const char *keyname)
+{
+ _evas_canvas_seat_key_modifier_off(eo_e, e, keyname, NULL);
}
EOLIAN void
-_evas_canvas_key_lock_off(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *keyname)
+_evas_canvas_seat_key_lock_on(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e,
+ const char *keyname, Efl_Input_Device *seat)
{
- Evas_Modifier_Mask num;
- int n;
+ if (!seat)
+ seat = e->default_seat;
+ EINA_SAFETY_ON_NULL_RETURN(seat);
+ if (efl_input_device_type_get(seat) != EFL_INPUT_DEVICE_CLASS_SEAT) return;
+ _mask_set(evas_key_lock_number(&(e->locks), keyname), e->locks.masks,
+ seat, EINA_TRUE);
+}
- n = evas_key_lock_number(&(e->locks), keyname);
- if (n < 0 || n > 63) return;
- num = 1ULL << n;
- e->locks.mask &= ~num;
+EOLIAN void
+_evas_canvas_seat_key_lock_off(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e,
+ const char *keyname, Efl_Input_Device *seat)
+{
+ if (!seat)
+ seat = e->default_seat;
+ EINA_SAFETY_ON_NULL_RETURN(seat);
+ _mask_set(evas_key_lock_number(&(e->locks), keyname), e->locks.masks,
+ seat, EINA_FALSE);
+}
+
+EOLIAN void
+_evas_canvas_key_lock_on(Eo *eo_e, Evas_Public_Data *e, const char *keyname)
+{
+ _evas_canvas_seat_key_lock_on(eo_e, e, keyname, NULL);
+}
+
+EOLIAN void
+_evas_canvas_key_lock_off(Eo *eo_e, Evas_Public_Data *e, const char *keyname)
+{
+ _evas_canvas_seat_key_lock_off(eo_e, e, keyname, NULL);
}
/* errr need to add key grabbing/ungrabbing calls - missing modifier stuff. */
diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c
index 3860b4dc45..580101c2f6 100644
--- a/src/lib/evas/canvas/evas_main.c
+++ b/src/lib/evas/canvas/evas_main.c
@@ -191,6 +191,12 @@ evas_new(void)
return eo_obj;
}
+static void
+_evas_key_mask_free(void *data)
+{
+ free(data);
+}
+
EOLIAN static Eo *
_evas_canvas_efl_object_constructor(Eo *eo_obj, Evas_Public_Data *e)
{
@@ -239,6 +245,9 @@ _evas_canvas_efl_object_constructor(Eo *eo_obj, Evas_Public_Data *e)
_evas_canvas_event_init(eo_obj, e);
e->focused_objects = eina_hash_pointer_new(NULL);
+ e->locks.masks = eina_hash_pointer_new(_evas_key_mask_free);
+ e->modifiers.masks = eina_hash_pointer_new(_evas_key_mask_free);
+ e->locks.e = e->modifiers.e = e;
return eo_obj;
}
@@ -386,6 +395,8 @@ _evas_canvas_efl_object_destructor(Eo *eo_e, Evas_Public_Data *e)
eina_lock_free(&(e->lock_objects));
eina_spinlock_free(&(e->render.lock));
+ eina_hash_free(e->locks.masks);
+ eina_hash_free(e->modifiers.masks);
e->magic = 0;
efl_destructor(efl_super(eo_e, MY_CLASS));
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index 2af422f911..765765503c 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -769,7 +769,8 @@ struct _Evas_Modifier
int count;
char **list;
} mod;
- Evas_Modifier_Mask mask; /* ok we have a max of 64 modifiers */
+ Eina_Hash *masks; /* we have a max of 64 modifiers per seat */
+ Evas_Public_Data *e;
};
struct _Evas_Lock
@@ -778,7 +779,8 @@ struct _Evas_Lock
int count;
char **list;
} lock;
- Evas_Modifier_Mask mask; /* we have a max of 64 locks */
+ Eina_Hash *masks; /* we have a max of 64 locks per seat */
+ Evas_Public_Data *e;
};
struct _Evas_Post_Callback