summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-05-16 11:16:28 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-05-16 20:47:48 +0900
commit2d6f53f2b938432bed9989fcc9d49f81ac5474cc (patch)
tree79a3373906aaf97ee77a0909d10d9a25ac8d8bef /src
parentfd35532d9e05ffe56d975a1aae7188a6a9340e77 (diff)
evas: Replace Evas.Modifier_Mask with Efl.Input enums
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?
Diffstat (limited to 'src')
-rw-r--r--src/lib/efl/interfaces/efl_input_types.eot39
-rw-r--r--src/lib/elementary/efl_ui_win.c9
-rw-r--r--src/lib/elementary/efl_ui_win.eo17
-rw-r--r--src/lib/evas/Evas_Legacy.h54
-rw-r--r--src/lib/evas/canvas/efl_canvas_object.eo36
-rw-r--r--src/lib/evas/canvas/evas_key_grab.c101
-rw-r--r--src/lib/evas/canvas/evas_types.eot2
7 files changed, 217 insertions, 41 deletions
diff --git a/src/lib/efl/interfaces/efl_input_types.eot b/src/lib/efl/interfaces/efl_input_types.eot
index 60f0833..fa1ae07 100644
--- a/src/lib/efl/interfaces/efl_input_types.eot
+++ b/src/lib/efl/interfaces/efl_input_types.eot
@@ -137,3 +137,42 @@ enum Efl.Input.Value {
137 slider, [[Current position of the slider on the tool. Range: [-1, 1]. 137 slider, [[Current position of the slider on the tool. Range: [-1, 1].
138 Default: 0.]] 138 Default: 0.]]
139} 139}
140
141enum Efl.Input.Modifier {
142 [[Key modifiers such as Control, Alt, etc...
143
144 This enum may be used as a bitmask with OR operations, depending on the
145 API.
146
147 The available keys may vary depending on the physical keyboard layout, or
148 language and keyboard settings, or depending on the platform.
149
150 @since 1.20
151 ]]
152 none = 0, [[No key modifier]]
153 alt = 1 << 0, [[Alt key modifier]]
154 control = 1 << 1, [[Control key modifier ("Ctrl" key)]]
155 shift = 1 << 2, [[Shift key modifier]]
156 meta = 1 << 3, [[Meta key modifier (often the "Windows" key)]]
157 altgr = 1 << 4, [[AltGr key modifier (not present on all keyboards)]]
158 hyper = 1 << 5, [[Hyper key modifier (may be "Windows" key)]]
159 super = 1 << 6, [[Super key modifier (may be "Windows" key)]]
160}
161
162enum Efl.Input.Lock {
163 [[Key locks such as Num Lock, Scroll Lock and Caps Lock.
164
165 This enum may be used as a bitmask with OR operations, depending on the
166 API.
167
168 The available keys may vary depending on the physical keyboard layout, or
169 language and keyboard settings, or depending on the platform.
170
171 @since 1.20
172 ]]
173 none = 0, [[No key modifier]]
174 num = 1 << 0, [[Num Lock for numeric key pad use]]
175 caps = 1 << 1, [[Caps Lock for writing in all caps]]
176 scroll = 1 << 2, [[Scroll Lock]]
177 shift = 1 << 3, [[Shift Lock]]
178}
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index 30d4240..16c4000 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -6088,7 +6088,10 @@ _efl_ui_win_prop_focus_skip_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_B
6088} 6088}
6089 6089
6090EOLIAN static Eina_Bool 6090EOLIAN static Eina_Bool
6091_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) 6091_efl_ui_win_keygrab_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *key,
6092 Efl_Input_Modifier modifiers EINA_UNUSED,
6093 Efl_Input_Modifier not_modifiers EINA_UNUSED,
6094 int priority EINA_UNUSED, Efl_Ui_Win_Keygrab_Mode grab_mode)
6092{ 6095{
6093 Eina_Bool ret = EINA_FALSE; 6096 Eina_Bool ret = EINA_FALSE;
6094#ifdef HAVE_ELEMENTARY_X 6097#ifdef HAVE_ELEMENTARY_X
@@ -6124,7 +6127,9 @@ _efl_ui_win_keygrab_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *ke
6124} 6127}
6125 6128
6126EOLIAN static Eina_Bool 6129EOLIAN static Eina_Bool
6127_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) 6130_efl_ui_win_keygrab_unset(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *key,
6131 Efl_Input_Modifier modifiers EINA_UNUSED,
6132 Efl_Input_Modifier not_modifiers EINA_UNUSED)
6128{ 6133{
6129 Eina_Bool ret = EINA_FALSE; 6134 Eina_Bool ret = EINA_FALSE;
6130#ifdef HAVE_ELEMENTARY_X 6135#ifdef HAVE_ELEMENTARY_X
diff --git a/src/lib/elementary/efl_ui_win.eo b/src/lib/elementary/efl_ui_win.eo
index 2e743af..b99aa75 100644
--- a/src/lib/elementary/efl_ui_win.eo
+++ b/src/lib/elementary/efl_ui_win.eo
@@ -851,10 +851,13 @@ class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Elm.Interface.Atspi.Window,
851 return: bool; [[$true on success, $false otherwise]] 851 return: bool; [[$true on success, $false otherwise]]
852 params { 852 params {
853 @in key: string; [[This string is the keyname to grab.]] 853 @in key: string; [[This string is the keyname to grab.]]
854 @in modifiers: Evas.Modifier_Mask; [[This is for the keymask feature. Currently this feature is not supported.]] 854 @in modifiers: Efl.Input.Modifier; [[A combinaison of modifier keys
855 @in not_modifiers: Evas.Modifier_Mask; [[This is for the keymask feature. Currently this feature is not supported.]] 855 that must be present to trigger the event. Not supported yet.]]
856 @in proirity: int; [[This is for the priority of keygrab. Currently this feature is not supported.]] 856 @in not_modifiers: Efl.Input.Modifier; [[A combinaison of modifier
857 @in grab_mode: Efl.Ui.Win.Keygrab_Mode; [[According to the grabmode, it can grab key differently.]] 857 keys that must not be present to trigger the event. Not supported yet.]]
858 @in priority: int; [[Not supported yet.]]
859 @in grab_mode: Efl.Ui.Win.Keygrab_Mode; [[Describes how the key should
860 be grabbed, wrt. focus and stacking.]]
858 } 861 }
859 } 862 }
860 keygrab_unset { 863 keygrab_unset {
@@ -865,8 +868,10 @@ class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Elm.Interface.Atspi.Window,
865 return: bool; [[$true on success, $false otherwise]] 868 return: bool; [[$true on success, $false otherwise]]
866 params { 869 params {
867 @in key: string; [[This string is the keyname to grab.]] 870 @in key: string; [[This string is the keyname to grab.]]
868 @in modifiers: Evas.Modifier_Mask; [[This is for the keymask feature. Currently this feature is not supported.]] 871 @in modifiers: Efl.Input.Modifier; [[A combinaison of modifier keys
869 @in not_modifiers: Evas.Modifier_Mask; [[This is for the keymask feature. Currently this feature is not supported.]] 872 that must be present to trigger the event. Not supported yet.]]
873 @in not_modifiers: Efl.Input.Modifier; [[A combinaison of modifier keys
874 that must not be present to trigger the event. Not supported yet.]]
870 } 875 }
871 } 876 }
872 move_resize_start { 877 move_resize_start {
diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h
index 7cbb074..7fcfe6f 100644
--- a/src/lib/evas/Evas_Legacy.h
+++ b/src/lib/evas/Evas_Legacy.h
@@ -2004,6 +2004,60 @@ EAPI void *evas_object_event_callback_del(Evas_Object *obj, Evas_Callback_Ty
2004EAPI 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); 2004EAPI 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);
2005 2005
2006/** 2006/**
2007 * @brief Requests @c keyname key events be directed to @c obj.
2008 *
2009 * Key grabs allow one or more objects to receive key events for specific key
2010 * strokes even if other objects have focus. Whenever a key is grabbed, only
2011 * the objects grabbing it will get the events for the given keys.
2012 *
2013 * @c keyname is a platform dependent symbolic name for the key pressed (see
2014 * @ref Evas_Keys for more information).
2015 *
2016 * @c modifiers and @c not_modifiers are bit masks of all the modifiers that
2017 * must and mustn't, respectively, be pressed along with @c keyname key in
2018 * order to trigger this new key grab. Modifiers can be things such as Shift
2019 * and Ctrl as well as user defined types via @ref evas_key_modifier_add.
2020 * Retrieve them with @ref evas_key_modifier_mask_get or use 0 for empty masks.
2021 *
2022 * @c exclusive will make the given object the only one permitted to grab the
2023 * given key. If given @c true, subsequent calls on this function with
2024 * different @c obj arguments will fail, unless the key is ungrabbed again.
2025 *
2026 * @warning Providing impossible modifier sets creates undefined behavior.
2027 *
2028 * See also @ref evas_object_key_ungrab, @ref evas_object_focus_get,
2029 * @ref evas_object_focus_set, @ref evas_focus_get, @ref evas_key_modifier_add.
2030 *
2031 * @param[in] keyname The key to request events for.
2032 * @param[in] modifiers A mask of modifiers that must be present to trigger the
2033 * event.
2034 * @param[in] not_modifiers A mask of modifiers that must not be present to
2035 * trigger the event.
2036 * @param[in] exclusive Request that the @c obj is the only object receiving
2037 * the @c keyname events.
2038 *
2039 * @return @c true if the call succeeded, @c false otherwise.
2040 */
2041EAPI 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);
2042
2043/**
2044 * @brief Removes the grab on @c keyname key events by @c obj.
2045 *
2046 * Removes a key grab on @c obj if @c keyname, @c modifiers, and
2047 * @c not_modifiers match.
2048 *
2049 * See also @ref evas_object_key_grab, @ref evas_object_focus_get,
2050 * @ref evas_object_focus_set, @ref evas_focus_get.
2051 *
2052 * @param[in] keyname The key the grab is set for.
2053 * @param[in] modifiers A mask of modifiers that must be present to trigger the
2054 * event.
2055 * @param[in] not_modifiers A mask of modifiers that mus not not be present to
2056 * trigger the event.
2057 */
2058EAPI void evas_object_key_ungrab(Evas_Object *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers) EINA_ARG_NONNULL(2);
2059
2060/**
2007 * @} 2061 * @}
2008 */ 2062 */
2009 2063
diff --git a/src/lib/evas/canvas/efl_canvas_object.eo b/src/lib/evas/canvas/efl_canvas_object.eo
index 61ef44e..62b8e56 100644
--- a/src/lib/evas/canvas/efl_canvas_object.eo
+++ b/src/lib/evas/canvas/efl_canvas_object.eo
@@ -551,25 +551,17 @@ abstract Efl.Canvas.Object (Efl.Object, Efl.Gfx, Efl.Gfx.Stack, Efl.Animator,
551 See also @.key_ungrab, @.key_focus.get, @.key_focus.set, 551 See also @.key_ungrab, @.key_focus.get, @.key_focus.set,
552 \@ref evas_focus_get, \@ref evas_key_modifier_add. 552 \@ref evas_focus_get, \@ref evas_key_modifier_add.
553 ]] 553 ]]
554 /* FIXME-doc
555 Example code follows.
556 @dontinclude evas-events.c
557 @skip if (d.focus)
558 @until else
559
560 See the full example @ref Example_Evas_Events "here".
561 */
562
563 return: bool @warn_unused; [[$true if the call succeeded, $false otherwise.]] 554 return: bool @warn_unused; [[$true if the call succeeded, $false otherwise.]]
564 params { 555 params {
565 @in keyname: string @nonull; [[The key to request events for.]] 556 @in keyname: string @nonull; [[The key to request events for.]]
566 @in modifiers: Evas.Modifier_Mask; [[A mask of modifiers that must be 557 @in modifiers: Efl.Input.Modifier; [[A combinaison of modifier
567 present to trigger the event.]] 558 keys that must be present to trigger the event.]]
568 @in not_modifiers: Evas.Modifier_Mask; [[A mask of modifiers that must 559 @in not_modifiers: Efl.Input.Modifier; [[A combinaison of modifier
569 not be present to trigger the event.]] 560 keys that must not be present to trigger the event.]]
570 @in exclusive: bool; [[Request that the $obj is the only object 561 @in exclusive: bool; [[Request that the $obj is the only object
571 receiving the $keyname events.]] 562 receiving the $keyname events.]]
572 } 563 }
564 legacy: null;
573 } 565 }
574 key_ungrab { 566 key_ungrab {
575 [[Removes the grab on $keyname key events by $obj. 567 [[Removes the grab on $keyname key events by $obj.
@@ -578,25 +570,17 @@ abstract Efl.Canvas.Object (Efl.Object, Efl.Gfx, Efl.Gfx.Stack, Efl.Animator,
578 $not_modifiers match. 570 $not_modifiers match.
579 571
580 See also @.key_grab, @.key_focus.get, @.key_focus.set, 572 See also @.key_grab, @.key_focus.get, @.key_focus.set,
581 \@ref evas_focus_get. 573 and the legacy API evas_focus_get.
582 ]] 574 ]]
583 /* FIXME-doc
584 Example code follows.
585 @dontinclude evas-events.c
586 @skip got here by key grabs
587 @until }
588
589 See the full example @ref Example_Evas_Events "here".
590 */
591 params { 575 params {
592 @in keyname: string @nonull; [[The key the grab is set for.]] 576 @in keyname: string @nonull; [[The key the grab is set for.]]
593 @in modifiers: Evas.Modifier_Mask; [[A mask of modifiers that must be 577 @in modifiers: Efl.Input.Modifier; [[A mask of modifiers that must be
594 present to trigger the event.]] 578 present to trigger the event.]]
595 @in not_modifiers: Evas.Modifier_Mask; [[A mask of modifiers that mus 579 @in not_modifiers: Efl.Input.Modifier; [[A mask of modifiers that must
596 not not be present to trigger 580 not not be present to trigger
597 the event. 581 the event.]]
598 ]]
599 } 582 }
583 legacy: null;
600 } 584 }
601 @property no_render { 585 @property no_render {
602 get { 586 get {
diff --git a/src/lib/evas/canvas/evas_key_grab.c b/src/lib/evas/canvas/evas_key_grab.c
index 9cc2284..9e5f10f 100644
--- a/src/lib/evas/canvas/evas_key_grab.c
+++ b/src/lib/evas/canvas/evas_key_grab.c
@@ -139,10 +139,12 @@ evas_key_grab_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const c
139 free(g); 139 free(g);
140} 140}
141 141
142/* public calls */ 142// Legacy implementation. TODO: remove use of Evas_Modifier_Mask
143 143
144EOLIAN Eina_Bool 144static Eina_Bool
145_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) 145_object_key_grab(Eo *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname,
146 Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers,
147 Eina_Bool exclusive)
146{ 148{
147 /* MEM OK */ 149 /* MEM OK */
148 Evas_Key_Grab *g; 150 Evas_Key_Grab *g;
@@ -152,8 +154,9 @@ _efl_canvas_object_key_grab(Eo *eo_obj, Evas_Object_Protected_Data *obj, const c
152 return ((!g) ? EINA_FALSE : EINA_TRUE); 154 return ((!g) ? EINA_FALSE : EINA_TRUE);
153} 155}
154 156
155EOLIAN void 157static void
156_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) 158_object_key_ungrab(Eo *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname,
159 Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers)
157{ 160{
158 /* MEM OK */ 161 /* MEM OK */
159 Evas_Key_Grab *g; 162 Evas_Key_Grab *g;
@@ -190,3 +193,91 @@ _efl_canvas_object_key_ungrab(Eo *eo_obj, Evas_Object_Protected_Data *obj, const
190 evas_key_grab_free(g->object, g_object, keyname, modifiers, not_modifiers); 193 evas_key_grab_free(g->object, g_object, keyname, modifiers, not_modifiers);
191 } 194 }
192} 195}
196
197// Matching function between legacy (used throughout EFL) and EO enums
198
199static const struct {
200 const char *keyname;
201 Efl_Input_Modifier mod;
202} _modifier_match[] = {
203 { "Alt", EFL_INPUT_MODIFIER_ALT },
204 { "Control", EFL_INPUT_MODIFIER_CONTROL },
205 { "Shift", EFL_INPUT_MODIFIER_SHIFT },
206 { "Meta", EFL_INPUT_MODIFIER_META },
207 { "AltGr", EFL_INPUT_MODIFIER_ALTGR },
208 { "Hyper", EFL_INPUT_MODIFIER_HYPER },
209 { "Super", EFL_INPUT_MODIFIER_SUPER },
210 { NULL, EFL_INPUT_MODIFIER_NONE }
211};
212
213static inline Evas_Modifier_Mask
214_efl_input_modifier_to_evas_modifier_mask(Evas_Public_Data *e, Efl_Input_Modifier in)
215{
216 Evas_Modifier_Mask out = 0;
217 int i;
218
219 for (i = 0; _modifier_match[i].keyname; i++)
220 {
221 if (in & _modifier_match[i].mod)
222 out |= evas_key_modifier_mask_get(e->evas, _modifier_match[i].keyname);
223 }
224
225 return out;
226}
227
228// EO API
229
230EOLIAN Eina_Bool
231_efl_canvas_object_key_grab(Eo *eo_obj, Evas_Object_Protected_Data *obj,
232 const char *keyname, Efl_Input_Modifier mod,
233 Efl_Input_Modifier not_mod, Eina_Bool exclusive)
234{
235 Evas_Modifier_Mask modifiers, not_modifiers;
236
237 EVAS_OBJECT_DATA_VALID_CHECK(obj, EINA_FALSE);
238 modifiers = _efl_input_modifier_to_evas_modifier_mask(obj->layer->evas, mod);
239 not_modifiers = _efl_input_modifier_to_evas_modifier_mask(obj->layer->evas, not_mod);
240
241 return _object_key_grab(eo_obj, obj, keyname, modifiers, not_modifiers, exclusive);
242}
243
244EOLIAN void
245_efl_canvas_object_key_ungrab(Eo *eo_obj, Evas_Object_Protected_Data *obj,
246 const char *keyname, Efl_Input_Modifier mod,
247 Efl_Input_Modifier not_mod)
248{
249 Evas_Modifier_Mask modifiers, not_modifiers;
250
251 EVAS_OBJECT_DATA_VALID_CHECK(obj);
252 modifiers = _efl_input_modifier_to_evas_modifier_mask(obj->layer->evas, mod);
253 not_modifiers = _efl_input_modifier_to_evas_modifier_mask(obj->layer->evas, not_mod);
254
255 _object_key_ungrab(eo_obj, obj, keyname, modifiers, not_modifiers);
256}
257
258// Legacy API
259
260EAPI Eina_Bool
261evas_object_key_grab(Evas_Object *eo_obj, const char *keyname,
262 Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers,
263 Eina_Bool exclusive)
264{
265 Evas_Object_Protected_Data *obj;
266
267 obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj);
268 EVAS_OBJECT_DATA_VALID_CHECK(obj, EINA_FALSE);
269
270 return _object_key_grab(eo_obj, obj, keyname, modifiers, not_modifiers, exclusive);
271}
272
273EAPI void
274evas_object_key_ungrab(Efl_Canvas_Object *eo_obj, const char *keyname,
275 Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers)
276{
277 Evas_Object_Protected_Data *obj;
278
279 obj = EVAS_OBJECT_DATA_SAFE_GET(eo_obj);
280 EVAS_OBJECT_DATA_VALID_CHECK(obj);
281
282 _object_key_ungrab(eo_obj, obj, keyname, modifiers, not_modifiers);
283}
diff --git a/src/lib/evas/canvas/evas_types.eot b/src/lib/evas/canvas/evas_types.eot
index be8ab77..1993adc 100644
--- a/src/lib/evas/canvas/evas_types.eot
+++ b/src/lib/evas/canvas/evas_types.eot
@@ -1,5 +1,3 @@
1type Evas.Modifier_Mask: ullong; [[An Evas modifier mask type]]
2
3struct Evas.Modifier; [[An opaque type containing information on which modifier keys are registered in an Evas canvas]] 1struct Evas.Modifier; [[An opaque type containing information on which modifier keys are registered in an Evas canvas]]
4struct Evas.Lock; [[An opaque type containing information on which lock keys are registered in an Evas canvas]] 2struct Evas.Lock; [[An opaque type containing information on which lock keys are registered in an Evas canvas]]
5 3