This removes Evas.Modifier_Mask from EO.
This introduces two new types instead:
- Efl.Input.Modifier
- Efl.Input.Lock
Those are enums, not strings, containing all the known and
currently supported lock and modifier keys. The enums are
bit masks.
This effectively removes the ability for an application to
create and handle specific modifier or lock keys - with EO
API (legacy compatibility is unchanged, of course). I wonder
who ever required this?
slider, [[Current position of the slider on the tool. Range: [-1, 1].
Default: 0.]]
}
+
+enum Efl.Input.Modifier {
+ [[Key modifiers such as Control, Alt, etc...
+
+ This enum may be used as a bitmask with OR operations, depending on the
+ API.
+
+ The available keys may vary depending on the physical keyboard layout, or
+ language and keyboard settings, or depending on the platform.
+
+ @since 1.20
+ ]]
+ none = 0, [[No key modifier]]
+ alt = 1 << 0, [[Alt key modifier]]
+ control = 1 << 1, [[Control key modifier ("Ctrl" key)]]
+ shift = 1 << 2, [[Shift key modifier]]
+ meta = 1 << 3, [[Meta key modifier (often the "Windows" key)]]
+ altgr = 1 << 4, [[AltGr key modifier (not present on all keyboards)]]
+ hyper = 1 << 5, [[Hyper key modifier (may be "Windows" key)]]
+ super = 1 << 6, [[Super key modifier (may be "Windows" key)]]
+}
+
+enum Efl.Input.Lock {
+ [[Key locks such as Num Lock, Scroll Lock and Caps Lock.
+
+ This enum may be used as a bitmask with OR operations, depending on the
+ API.
+
+ The available keys may vary depending on the physical keyboard layout, or
+ language and keyboard settings, or depending on the platform.
+
+ @since 1.20
+ ]]
+ none = 0, [[No key modifier]]
+ num = 1 << 0, [[Num Lock for numeric key pad use]]
+ caps = 1 << 1, [[Caps Lock for writing in all caps]]
+ scroll = 1 << 2, [[Scroll Lock]]
+ shift = 1 << 3, [[Shift Lock]]
+}
}
EOLIAN static Eina_Bool
-_efl_ui_win_keygrab_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *key, Evas_Modifier_Mask modifiers EINA_UNUSED, Evas_Modifier_Mask not_modifiers EINA_UNUSED, int priority EINA_UNUSED, Efl_Ui_Win_Keygrab_Mode grab_mode)
+_efl_ui_win_keygrab_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *key,
+ Efl_Input_Modifier modifiers EINA_UNUSED,
+ Efl_Input_Modifier not_modifiers EINA_UNUSED,
+ int priority EINA_UNUSED, Efl_Ui_Win_Keygrab_Mode grab_mode)
{
Eina_Bool ret = EINA_FALSE;
#ifdef HAVE_ELEMENTARY_X
}
EOLIAN static Eina_Bool
-_efl_ui_win_keygrab_unset(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *key, Evas_Modifier_Mask modifiers EINA_UNUSED, Evas_Modifier_Mask not_modifiers EINA_UNUSED)
+_efl_ui_win_keygrab_unset(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *key,
+ Efl_Input_Modifier modifiers EINA_UNUSED,
+ Efl_Input_Modifier not_modifiers EINA_UNUSED)
{
Eina_Bool ret = EINA_FALSE;
#ifdef HAVE_ELEMENTARY_X
return: bool; [[$true on success, $false otherwise]]
params {
@in key: string; [[This string is the keyname to grab.]]
- @in modifiers: Evas.Modifier_Mask; [[This is for the keymask feature. Currently this feature is not supported.]]
- @in not_modifiers: Evas.Modifier_Mask; [[This is for the keymask feature. Currently this feature is not supported.]]
- @in proirity: int; [[This is for the priority of keygrab. Currently this feature is not supported.]]
- @in grab_mode: Efl.Ui.Win.Keygrab_Mode; [[According to the grabmode, it can grab key differently.]]
+ @in modifiers: Efl.Input.Modifier; [[A combinaison of modifier keys
+ that must be present to trigger the event. Not supported yet.]]
+ @in not_modifiers: Efl.Input.Modifier; [[A combinaison of modifier
+ keys that must not be present to trigger the event. Not supported yet.]]
+ @in priority: int; [[Not supported yet.]]
+ @in grab_mode: Efl.Ui.Win.Keygrab_Mode; [[Describes how the key should
+ be grabbed, wrt. focus and stacking.]]
}
}
keygrab_unset {
return: bool; [[$true on success, $false otherwise]]
params {
@in key: string; [[This string is the keyname to grab.]]
- @in modifiers: Evas.Modifier_Mask; [[This is for the keymask feature. Currently this feature is not supported.]]
- @in not_modifiers: Evas.Modifier_Mask; [[This is for the keymask feature. Currently this feature is not supported.]]
+ @in modifiers: Efl.Input.Modifier; [[A combinaison of modifier keys
+ that must be present to trigger the event. Not supported yet.]]
+ @in not_modifiers: Efl.Input.Modifier; [[A combinaison of modifier keys
+ that must not be present to trigger the event. Not supported yet.]]
}
}
move_resize_start {
EAPI void *evas_object_event_callback_del_full(Evas_Object *obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data) EINA_ARG_NONNULL(1, 3);
/**
+ * @brief Requests @c keyname key events be directed to @c obj.
+ *
+ * Key grabs allow one or more objects to receive key events for specific key
+ * strokes even if other objects have focus. Whenever a key is grabbed, only
+ * the objects grabbing it will get the events for the given keys.
+ *
+ * @c keyname is a platform dependent symbolic name for the key pressed (see
+ * @ref Evas_Keys for more information).
+ *
+ * @c modifiers and @c not_modifiers are bit masks of all the modifiers that
+ * must and mustn't, respectively, be pressed along with @c keyname key in
+ * order to trigger this new key grab. Modifiers can be things such as Shift
+ * and Ctrl as well as user defined types via @ref evas_key_modifier_add.
+ * Retrieve them with @ref evas_key_modifier_mask_get or use 0 for empty masks.
+ *
+ * @c exclusive will make the given object the only one permitted to grab the
+ * given key. If given @c true, subsequent calls on this function with
+ * different @c obj arguments will fail, unless the key is ungrabbed again.
+ *
+ * @warning Providing impossible modifier sets creates undefined behavior.
+ *
+ * See also @ref evas_object_key_ungrab, @ref evas_object_focus_get,
+ * @ref evas_object_focus_set, @ref evas_focus_get, @ref evas_key_modifier_add.
+ *
+ * @param[in] keyname The key to request events for.
+ * @param[in] modifiers A mask of modifiers that must be present to trigger the
+ * event.
+ * @param[in] not_modifiers A mask of modifiers that must not be present to
+ * trigger the event.
+ * @param[in] exclusive Request that the @c obj is the only object receiving
+ * the @c keyname events.
+ *
+ * @return @c true if the call succeeded, @c false otherwise.
+ */
+EAPI Eina_Bool evas_object_key_grab(Evas_Object *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers, Eina_Bool exclusive) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(2);
+
+/**
+ * @brief Removes the grab on @c keyname key events by @c obj.
+ *
+ * Removes a key grab on @c obj if @c keyname, @c modifiers, and
+ * @c not_modifiers match.
+ *
+ * See also @ref evas_object_key_grab, @ref evas_object_focus_get,
+ * @ref evas_object_focus_set, @ref evas_focus_get.
+ *
+ * @param[in] keyname The key the grab is set for.
+ * @param[in] modifiers A mask of modifiers that must be present to trigger the
+ * event.
+ * @param[in] not_modifiers A mask of modifiers that mus not not be present to
+ * trigger the event.
+ */
+EAPI void evas_object_key_ungrab(Evas_Object *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers) EINA_ARG_NONNULL(2);
+
+/**
* @}
*/
See also @.key_ungrab, @.key_focus.get, @.key_focus.set,
\@ref evas_focus_get, \@ref evas_key_modifier_add.
]]
- /* FIXME-doc
- Example code follows.
- @dontinclude evas-events.c
- @skip if (d.focus)
- @until else
-
- See the full example @ref Example_Evas_Events "here".
- */
-
return: bool @warn_unused; [[$true if the call succeeded, $false otherwise.]]
params {
@in keyname: string @nonull; [[The key to request events for.]]
- @in modifiers: Evas.Modifier_Mask; [[A mask of modifiers that must be
- present to trigger the event.]]
- @in not_modifiers: Evas.Modifier_Mask; [[A mask of modifiers that must
- not be present to trigger the event.]]
+ @in modifiers: Efl.Input.Modifier; [[A combinaison of modifier
+ keys that must be present to trigger the event.]]
+ @in not_modifiers: Efl.Input.Modifier; [[A combinaison of modifier
+ keys that must not be present to trigger the event.]]
@in exclusive: bool; [[Request that the $obj is the only object
receiving the $keyname events.]]
}
+ legacy: null;
}
key_ungrab {
[[Removes the grab on $keyname key events by $obj.
$not_modifiers match.
See also @.key_grab, @.key_focus.get, @.key_focus.set,
- \@ref evas_focus_get.
+ and the legacy API evas_focus_get.
]]
- /* FIXME-doc
- Example code follows.
- @dontinclude evas-events.c
- @skip got here by key grabs
- @until }
-
- See the full example @ref Example_Evas_Events "here".
- */
params {
@in keyname: string @nonull; [[The key the grab is set for.]]
- @in modifiers: Evas.Modifier_Mask; [[A mask of modifiers that must be
+ @in modifiers: Efl.Input.Modifier; [[A mask of modifiers that must be
present to trigger the event.]]
- @in not_modifiers: Evas.Modifier_Mask; [[A mask of modifiers that mus
+ @in not_modifiers: Efl.Input.Modifier; [[A mask of modifiers that must
not not be present to trigger
- the event.
- ]]
+ the event.]]
}
+ legacy: null;
}
@property no_render {
get {
free(g);
}
-/* public calls */
+// Legacy implementation. TODO: remove use of Evas_Modifier_Mask
-EOLIAN Eina_Bool
-_efl_canvas_object_key_grab(Eo *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers, Eina_Bool exclusive)
+static Eina_Bool
+_object_key_grab(Eo *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname,
+ Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers,
+ Eina_Bool exclusive)
{
/* MEM OK */
Evas_Key_Grab *g;
return ((!g) ? EINA_FALSE : EINA_TRUE);
}
-EOLIAN void
-_efl_canvas_object_key_ungrab(Eo *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers)
+static void
+_object_key_ungrab(Eo *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname,
+ Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers)
{
/* MEM OK */
Evas_Key_Grab *g;
evas_key_grab_free(g->object, g_object, keyname, modifiers, not_modifiers);
}
}
+
+// Matching function between legacy (used throughout EFL) and EO enums
+
+static const struct {
+ const char *keyname;
+ Efl_Input_Modifier mod;
+} _modifier_match[] = {
+ { "Alt", EFL_INPUT_MODIFIER_ALT },
+ { "Control", EFL_INPUT_MODIFIER_CONTROL },
+ { "Shift", EFL_INPUT_MODIFIER_SHIFT },
+ { "Meta", EFL_INPUT_MODIFIER_META },
+ { "AltGr", EFL_INPUT_MODIFIER_ALTGR },
+ { "Hyper", EFL_INPUT_MODIFIER_HYPER },
+ { "Super", EFL_INPUT_MODIFIER_SUPER },
+ { NULL, EFL_INPUT_MODIFIER_NONE }
+};
+
+static inline Evas_Modifier_Mask
+_efl_input_modifier_to_evas_modifier_mask(Evas_Public_Data *e, Efl_Input_Modifier in)
+{
+ Evas_Modifier_Mask out = 0;
+ int i;
+
+ for (i = 0; _modifier_match[i].keyname; i++)
+ {
+ if (in & _modifier_match[i].mod)
+ out |= evas_key_modifier_mask_get(e->evas, _modifier_match[i].keyname);
+ }
+
+ return out;
+}
+
+// EO API
+
+EOLIAN Eina_Bool
+_efl_canvas_object_key_grab(Eo *eo_obj, Evas_Object_Protected_Data *obj,
+ const char *keyname, Efl_Input_Modifier mod,
+ Efl_Input_Modifier not_mod, Eina_Bool exclusive)
+{
+ Evas_Modifier_Mask modifiers, not_modifiers;
+
+ EVAS_OBJECT_DATA_VALID_CHECK(obj, EINA_FALSE);
+ modifiers = _efl_input_modifier_to_evas_modifier_mask(obj->layer->evas, mod);
+ not_modifiers = _efl_input_modifier_to_evas_modifier_mask(obj->layer->evas, not_mod);
+
+ return _object_key_grab(eo_obj, obj, keyname, modifiers, not_modifiers, exclusive);
+}
+
+EOLIAN void
+_efl_canvas_object_key_ungrab(Eo *eo_obj, Evas_Object_Protected_Data *obj,
+ const char *keyname, Efl_Input_Modifier mod,
+ Efl_Input_Modifier not_mod)
+{
+ Evas_Modifier_Mask modifiers, not_modifiers;
+
+ EVAS_OBJECT_DATA_VALID_CHECK(obj);
+ modifiers = _efl_input_modifier_to_evas_modifier_mask(obj->layer->evas, mod);
+ not_modifiers = _efl_input_modifier_to_evas_modifier_mask(obj->layer->evas, not_mod);
+
+ _object_key_ungrab(eo_obj, obj, keyname, modifiers, not_modifiers);
+}
+
+// Legacy API
+
+EAPI Eina_Bool
+evas_object_key_grab(Evas_Object *eo_obj, const char *keyname,
+ Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers,
+ Eina_Bool exclusive)
+{
+ Evas_Object_Protected_Data *obj;
+
+ obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj);
+ EVAS_OBJECT_DATA_VALID_CHECK(obj, EINA_FALSE);
+
+ return _object_key_grab(eo_obj, obj, keyname, modifiers, not_modifiers, exclusive);
+}
+
+EAPI void
+evas_object_key_ungrab(Efl_Canvas_Object *eo_obj, const char *keyname,
+ Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers)
+{
+ Evas_Object_Protected_Data *obj;
+
+ obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj);
+ EVAS_OBJECT_DATA_VALID_CHECK(obj);
+
+ _object_key_ungrab(eo_obj, obj, keyname, modifiers, not_modifiers);
+}
-type Evas.Modifier_Mask: ullong; [[An Evas modifier mask type]]
-
struct Evas.Modifier; [[An opaque type containing information on which modifier keys are registered in an Evas canvas]]
struct Evas.Lock; [[An opaque type containing information on which lock keys are registered in an Evas canvas]]