summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/evas_key_grab.c
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/lib/evas/canvas/evas_key_grab.c
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/lib/evas/canvas/evas_key_grab.c')
-rw-r--r--src/lib/evas/canvas/evas_key_grab.c101
1 files changed, 96 insertions, 5 deletions
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}