summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/evas/canvas')
-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
3 files changed, 106 insertions, 33 deletions
diff --git a/src/lib/evas/canvas/efl_canvas_object.eo b/src/lib/evas/canvas/efl_canvas_object.eo
index 61ef44e542..62b8e5672d 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 9cc2284090..9e5f10f4c7 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 be8ab779a4..1993adc8fd 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