summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/evas_key_grab.c
diff options
context:
space:
mode:
authorJEONGHYUN YUN <jh0506.yun@samsung.com>2016-06-01 17:14:12 +0830
committerJi-Youn Park <jy0703.park@samsung.com>2016-06-01 17:14:13 +0830
commit26b2e73d56efe2f73348253d24b03274c66d7bdf (patch)
tree85691695c10e2f18572b3eb0708657f100be661f /src/lib/evas/canvas/evas_key_grab.c
parent0e6139e4872550c12e26b4925236f12bee76cf71 (diff)
evas : evas_object_key_grab exclusive option logic is changed.
Summary: - added is_active property in Evas_Key_Grab. - Evas key down and key up events transferred to active grabs only. - If evas grabs has a exclusive grab, other grabs will be deactivated. - If a exclusive grab is ungrabbed, remained grabs will be activated. Reviewers: jypark Reviewed By: jypark Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D3996
Diffstat (limited to 'src/lib/evas/canvas/evas_key_grab.c')
-rw-r--r--src/lib/evas/canvas/evas_key_grab.c69
1 files changed, 56 insertions, 13 deletions
diff --git a/src/lib/evas/canvas/evas_key_grab.c b/src/lib/evas/canvas/evas_key_grab.c
index 7dfafeb..8a1575c 100644
--- a/src/lib/evas/canvas/evas_key_grab.c
+++ b/src/lib/evas/canvas/evas_key_grab.c
@@ -8,13 +8,29 @@
8/* modifiers/not_modifers they use */ 8/* modifiers/not_modifers they use */
9 9
10static Evas_Key_Grab *evas_key_grab_new (Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers, Eina_Bool exclusive); 10static Evas_Key_Grab *evas_key_grab_new (Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers, Eina_Bool exclusive);
11static Evas_Key_Grab *evas_key_grab_find (Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers, Eina_Bool exclusive); 11static Evas_Key_Grab *evas_key_grab_find (Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers);
12 12
13static Evas_Key_Grab * 13static Evas_Key_Grab *
14evas_key_grab_new(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers, Eina_Bool exclusive) 14evas_key_grab_new(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers, Eina_Bool exclusive)
15{ 15{
16 /* MEM OK */ 16 /* MEM OK */
17 Eina_List *l;
17 Evas_Key_Grab *g; 18 Evas_Key_Grab *g;
19 Eina_Bool have_exclusion = EINA_FALSE;
20
21 EINA_LIST_FOREACH(obj->layer->evas->grabs, l, g)
22 {
23 if ((g->modifiers == modifiers) &&
24 (g->not_modifiers == not_modifiers) &&
25 (!strcmp(g->keyname, keyname)) &&
26 (g->exclusive))
27 {
28 have_exclusion = EINA_TRUE;
29 break;
30 }
31 }
32
33 if (have_exclusion && exclusive) return NULL;
18 34
19 g = evas_mem_calloc(sizeof(Evas_Key_Grab)); 35 g = evas_mem_calloc(sizeof(Evas_Key_Grab));
20 if (!g) return NULL; 36 if (!g) return NULL;
@@ -25,6 +41,7 @@ evas_key_grab_new(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const ch
25 g->keyname = strdup(keyname); 41 g->keyname = strdup(keyname);
26 if (obj->layer->evas->walking_grabs) 42 if (obj->layer->evas->walking_grabs)
27 g->just_added = EINA_TRUE; 43 g->just_added = EINA_TRUE;
44 g->is_active = EINA_TRUE;
28 if (!g->keyname) 45 if (!g->keyname)
29 { 46 {
30 if (!evas_mem_free(strlen(keyname) + 1)) 47 if (!evas_mem_free(strlen(keyname) + 1))
@@ -39,13 +56,29 @@ evas_key_grab_new(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const ch
39 return NULL; 56 return NULL;
40 } 57 }
41 } 58 }
59
60 if (exclusive)
61 {
62 Evas_Key_Grab *ge;
63 EINA_LIST_FOREACH(obj->layer->evas->grabs, l, ge)
64 {
65 if ((ge->modifiers == modifiers) &&
66 (ge->not_modifiers == not_modifiers) &&
67 (!strcmp(ge->keyname, keyname)))
68 {
69 ge->is_active = EINA_FALSE;
70 }
71 }
72 }
73 if (have_exclusion) g->is_active = EINA_FALSE;
74
42 obj->grabs = eina_list_append(obj->grabs, g); 75 obj->grabs = eina_list_append(obj->grabs, g);
43 obj->layer->evas->grabs = eina_list_append(obj->layer->evas->grabs, g); 76 obj->layer->evas->grabs = eina_list_append(obj->layer->evas->grabs, g);
44 return g; 77 return g;
45} 78}
46 79
47static Evas_Key_Grab * 80static Evas_Key_Grab *
48evas_key_grab_find(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers, Eina_Bool exclusive) 81evas_key_grab_find(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers)
49{ 82{
50 /* MEM OK */ 83 /* MEM OK */
51 Eina_List *l; 84 Eina_List *l;
@@ -57,7 +90,7 @@ evas_key_grab_find(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const c
57 (g->not_modifiers == not_modifiers) && 90 (g->not_modifiers == not_modifiers) &&
58 (!strcmp(g->keyname, keyname))) 91 (!strcmp(g->keyname, keyname)))
59 { 92 {
60 if ((exclusive) || (eo_obj == g->object)) return g; 93 if (eo_obj == g->object) return g;
61 } 94 }
62 } 95 }
63 return NULL; 96 return NULL;
@@ -97,7 +130,7 @@ evas_key_grab_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, const c
97 /* MEM OK */ 130 /* MEM OK */
98 Evas_Key_Grab *g; 131 Evas_Key_Grab *g;
99 132
100 g = evas_key_grab_find(eo_obj, obj, keyname, modifiers, not_modifiers, 0); 133 g = evas_key_grab_find(eo_obj, obj, keyname, modifiers, not_modifiers);
101 if (!g) return; 134 if (!g) return;
102 Evas_Object_Protected_Data *g_object = eo_data_scope_get(g->object, EVAS_OBJECT_CLASS); 135 Evas_Object_Protected_Data *g_object = eo_data_scope_get(g->object, EVAS_OBJECT_CLASS);
103 g_object->grabs = eina_list_remove(g_object->grabs, g); 136 g_object->grabs = eina_list_remove(g_object->grabs, g);
@@ -115,12 +148,6 @@ _evas_object_key_grab(Eo *eo_obj, Evas_Object_Protected_Data *obj, const char *k
115 Evas_Key_Grab *g; 148 Evas_Key_Grab *g;
116 149
117 if (((modifiers == not_modifiers) && (modifiers != 0)) || (!keyname)) return EINA_FALSE; 150 if (((modifiers == not_modifiers) && (modifiers != 0)) || (!keyname)) return EINA_FALSE;
118 if (exclusive)
119 {
120 g = evas_key_grab_find(eo_obj, obj, keyname, modifiers, not_modifiers,
121 exclusive);
122 if (g) return EINA_FALSE;
123 }
124 g = evas_key_grab_new(eo_obj, obj, keyname, modifiers, not_modifiers, exclusive); 151 g = evas_key_grab_new(eo_obj, obj, keyname, modifiers, not_modifiers, exclusive);
125 return ((!g) ? EINA_FALSE : EINA_TRUE); 152 return ((!g) ? EINA_FALSE : EINA_TRUE);
126} 153}
@@ -130,9 +157,10 @@ _evas_object_key_ungrab(Eo *eo_obj, Evas_Object_Protected_Data *obj, const char
130{ 157{
131 /* MEM OK */ 158 /* MEM OK */
132 Evas_Key_Grab *g; 159 Evas_Key_Grab *g;
160 Eina_List *l;
133 161
134 if (!keyname) return; 162 if (!keyname) return;
135 g = evas_key_grab_find(eo_obj, obj, keyname, modifiers, not_modifiers, 0); 163 g = evas_key_grab_find(eo_obj, obj, keyname, modifiers, not_modifiers);
136 if (!g) return; 164 if (!g) return;
137 Evas_Object_Protected_Data *g_object = eo_data_scope_get(g->object, EVAS_OBJECT_CLASS); 165 Evas_Object_Protected_Data *g_object = eo_data_scope_get(g->object, EVAS_OBJECT_CLASS);
138 if (g_object->layer->evas->walking_grabs) 166 if (g_object->layer->evas->walking_grabs)
@@ -144,6 +172,21 @@ _evas_object_key_ungrab(Eo *eo_obj, Evas_Object_Protected_Data *obj, const char
144 } 172 }
145 } 173 }
146 else 174 else
147 evas_key_grab_free(g->object, g_object, keyname, modifiers, not_modifiers); 175 {
148} 176 if (g->exclusive)
177 {
178 Evas_Key_Grab *ge;
179 EINA_LIST_FOREACH(obj->layer->evas->grabs, l, ge)
180 {
181 if ((ge->modifiers == modifiers) &&
182 (ge->not_modifiers == not_modifiers) &&
183 (!strcmp(ge->keyname, keyname)))
184 {
185 if (!ge->is_active) ge->is_active = EINA_TRUE;
186 }
187 }
188 }
149 189
190 evas_key_grab_free(g->object, g_object, keyname, modifiers, not_modifiers);
191 }
192}