summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/lib/ecore_imf_evas/ecore_imf_evas.c
diff options
context:
space:
mode:
authorandrunko <andrunko>2007-11-21 22:20:16 +0000
committerandrunko <andrunko@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2007-11-21 22:20:16 +0000
commit2204cc19276ac79a493a107e45908f582e634588 (patch)
tree876ae068988013174ae7442376c554cfd92dae7f /legacy/ecore/src/lib/ecore_imf_evas/ecore_imf_evas.c
parent2e3bda35c93acbfe0b1142f2b6385b96b4857cbe (diff)
Added Ecore_IMF_Evas.
Removed Evas dependency from Ecore_IMF, that was requested by Ewl developers in order to be able to integrate Ecore_IMF on it. Added Ecore_IMF_Evas, a library with helper functions to use Ecore_IMF together with Evas. Now everybody should be happy. SVN revision: 32812
Diffstat (limited to 'legacy/ecore/src/lib/ecore_imf_evas/ecore_imf_evas.c')
-rw-r--r--legacy/ecore/src/lib/ecore_imf_evas/ecore_imf_evas.c261
1 files changed, 261 insertions, 0 deletions
diff --git a/legacy/ecore/src/lib/ecore_imf_evas/ecore_imf_evas.c b/legacy/ecore/src/lib/ecore_imf_evas/ecore_imf_evas.c
new file mode 100644
index 0000000000..2cf1d18ed2
--- /dev/null
+++ b/legacy/ecore/src/lib/ecore_imf_evas/ecore_imf_evas.c
@@ -0,0 +1,261 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4
5#include "config.h"
6
7#include "Ecore_IMF_Evas.h"
8
9/**
10 * @defgroup Ecore_IMF_Evas_Group Ecore Input Method Context Evas Helper Functions
11 *
12 * Helper functions to make it easy to use Evas with Ecore_IMF.
13 */
14
15static char *_ecore_imf_evas_event_empty = "";
16
17/* Converts the Evas modifiers to Ecore_IMF keyboard modifiers */
18static void
19_ecore_imf_evas_event_modifiers_wrap(Evas_Modifier *evas_modifiers,
20 Ecore_IMF_Keyboard_Modifiers *imf_keyboard_modifiers)
21{
22 if (!evas_modifiers || !imf_keyboard_modifiers)
23 return;
24
25 *imf_keyboard_modifiers = ECORE_IMF_KEYBOARD_MODIFIER_NONE;
26 if (evas_key_modifier_is_set(evas_modifiers, "Control"))
27 *imf_keyboard_modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL;
28 if (evas_key_modifier_is_set(evas_modifiers, "Alt"))
29 *imf_keyboard_modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_ALT;
30 if (evas_key_modifier_is_set(evas_modifiers, "Shift"))
31 *imf_keyboard_modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT;
32 if (evas_key_modifier_is_set(evas_modifiers, "Super") || evas_key_modifier_is_set(evas_modifiers, "Hyper"))
33 *imf_keyboard_modifiers |= ECORE_IMF_KEYBOARD_MODIFIER_WIN;
34}
35
36/* Converts the Evas locks to Ecore_IMF keyboard locks */
37static void
38_ecore_imf_evas_event_locks_wrap(Evas_Lock *evas_locks,
39 Ecore_IMF_Keyboard_Locks *imf_keyboard_locks)
40{
41 if (!evas_locks || !imf_keyboard_locks)
42 return;
43
44 *imf_keyboard_locks = ECORE_IMF_KEYBOARD_LOCK_NONE;
45 if (evas_key_lock_is_set(evas_locks, "Num_Lock"))
46 *imf_keyboard_locks |= ECORE_IMF_KEYBOARD_LOCK_NUM;
47 if (evas_key_lock_is_set(evas_locks, "Caps_Lock"))
48 *imf_keyboard_locks |= ECORE_IMF_KEYBOARD_LOCK_CAPS;
49 if (evas_key_lock_is_set(evas_locks, "Scroll_Lock"))
50 *imf_keyboard_locks |= ECORE_IMF_KEYBOARD_LOCK_SCROLL;
51}
52
53/* Converts the Evas mouse flags to Ecore_IMF mouse flags */
54static void
55_ecore_imf_evas_event_mouse_flags_wrap(Evas_Button_Flags evas_flags,
56 Ecore_IMF_Mouse_Flags *imf_flags)
57{
58 if (!imf_flags)
59 return;
60
61 *imf_flags = ECORE_IMF_MOUSE_NONE;
62 if (evas_flags & EVAS_BUTTON_DOUBLE_CLICK)
63 *imf_flags |= ECORE_IMF_MOUSE_DOUBLE_CLICK;
64 if (evas_flags & EVAS_BUTTON_TRIPLE_CLICK)
65 *imf_flags |= ECORE_IMF_MOUSE_TRIPLE_CLICK;
66}
67
68/**
69 * Converts a "mouse_in" event from Evas to the corresponding event of Ecore_IMF.
70 *
71 * @param evas_event The received Evas event.
72 * @param imf_event The location to store the converted Ecore_IMF event.
73 * @ingroup Ecore_IMF_Evas_Group
74 */
75EAPI void
76ecore_imf_evas_event_mouse_in_wrap(Evas_Event_Mouse_In *evas_event,
77 Ecore_IMF_Event_Mouse_In *imf_event)
78{
79 if (!evas_event || !imf_event)
80 return;
81
82 imf_event->buttons = evas_event->buttons;
83 imf_event->output.x = evas_event->output.x;
84 imf_event->output.y = evas_event->output.y;
85 imf_event->canvas.x = evas_event->canvas.x;
86 imf_event->canvas.y = evas_event->canvas.y;
87 imf_event->timestamp = evas_event->timestamp;
88 _ecore_imf_evas_event_modifiers_wrap(evas_event->modifiers, &imf_event->modifiers);
89 _ecore_imf_evas_event_locks_wrap(evas_event->locks, &imf_event->locks);
90}
91
92/**
93 * Converts a "mouse_out" event from Evas to the corresponding event of Ecore_IMF.
94 *
95 * @param evas_event The received Evas event.
96 * @param imf_event The location to store the converted Ecore_IMF event.
97 * @ingroup Ecore_IMF_Evas_Group
98 */
99EAPI void
100ecore_imf_evas_event_mouse_out_wrap(Evas_Event_Mouse_Out *evas_event,
101 Ecore_IMF_Event_Mouse_Out *imf_event)
102{
103 if (!evas_event || !imf_event)
104 return;
105
106 imf_event->buttons = evas_event->buttons;
107 imf_event->output.x = evas_event->output.x;
108 imf_event->output.y = evas_event->output.y;
109 imf_event->canvas.x = evas_event->canvas.x;
110 imf_event->canvas.y = evas_event->canvas.y;
111 imf_event->timestamp = evas_event->timestamp;
112 _ecore_imf_evas_event_modifiers_wrap(evas_event->modifiers, &imf_event->modifiers);
113 _ecore_imf_evas_event_locks_wrap(evas_event->locks, &imf_event->locks);
114}
115
116/**
117 * Converts a "mouse_move" event from Evas to the corresponding event of Ecore_IMF.
118 *
119 * @param evas_event The received Evas event.
120 * @param imf_event The location to store the converted Ecore_IMF event.
121 * @ingroup Ecore_IMF_Evas_Group
122 */
123EAPI void
124ecore_imf_evas_event_mouse_move_wrap(Evas_Event_Mouse_Move *evas_event,
125 Ecore_IMF_Event_Mouse_Move *imf_event)
126{
127 if (!evas_event || !imf_event)
128 return;
129
130 imf_event->buttons = evas_event->buttons;
131 imf_event->cur.output.x = evas_event->cur.output.x;
132 imf_event->cur.output.y = evas_event->cur.output.y;
133 imf_event->prev.output.x = evas_event->prev.output.x;
134 imf_event->prev.output.y = evas_event->prev.output.y;
135 imf_event->cur.canvas.x = evas_event->cur.canvas.x;
136 imf_event->cur.canvas.y = evas_event->cur.canvas.y;
137 imf_event->prev.canvas.x = evas_event->prev.canvas.x;
138 imf_event->prev.canvas.y = evas_event->prev.canvas.y;
139 imf_event->timestamp = evas_event->timestamp;
140 _ecore_imf_evas_event_modifiers_wrap(evas_event->modifiers, &imf_event->modifiers);
141 _ecore_imf_evas_event_locks_wrap(evas_event->locks, &imf_event->locks);
142}
143
144/**
145 * Converts a "mouse_down" event from Evas to the corresponding event of Ecore_IMF.
146 *
147 * @param evas_event The received Evas event.
148 * @param imf_event The location to store the converted Ecore_IMF event.
149 * @ingroup Ecore_IMF_Evas_Group
150 */
151EAPI void
152ecore_imf_evas_event_mouse_down_wrap(Evas_Event_Mouse_Down *evas_event,
153 Ecore_IMF_Event_Mouse_Down *imf_event)
154{
155 if (!evas_event || !imf_event)
156 return;
157
158 imf_event->button = evas_event->button;
159 imf_event->output.x = evas_event->output.x;
160 imf_event->output.y = evas_event->output.y;
161 imf_event->canvas.x = evas_event->canvas.x;
162 imf_event->canvas.y = evas_event->canvas.y;
163 imf_event->timestamp = evas_event->timestamp;
164 _ecore_imf_evas_event_modifiers_wrap(evas_event->modifiers, &imf_event->modifiers);
165 _ecore_imf_evas_event_locks_wrap(evas_event->locks, &imf_event->locks);
166 _ecore_imf_evas_event_mouse_flags_wrap(evas_event->flags, &imf_event->flags);
167}
168
169/**
170 * Converts a "mouse_up" event from Evas to the corresponding event of Ecore_IMF.
171 *
172 * @param evas_event The received Evas event.
173 * @param imf_event The location to store the converted Ecore_IMF event.
174 * @ingroup Ecore_IMF_Evas_Group
175 */
176EAPI void
177ecore_imf_evas_event_mouse_up_wrap(Evas_Event_Mouse_Up *evas_event,
178 Ecore_IMF_Event_Mouse_Up *imf_event)
179{
180 if (!evas_event || !imf_event)
181 return;
182
183 imf_event->button = evas_event->button;
184 imf_event->output.x = evas_event->output.x;
185 imf_event->output.y = evas_event->output.y;
186 imf_event->canvas.x = evas_event->canvas.x;
187 imf_event->canvas.y = evas_event->canvas.y;
188 imf_event->timestamp = evas_event->timestamp;
189 _ecore_imf_evas_event_modifiers_wrap(evas_event->modifiers, &imf_event->modifiers);
190 _ecore_imf_evas_event_locks_wrap(evas_event->locks, &imf_event->locks);
191 _ecore_imf_evas_event_mouse_flags_wrap(evas_event->flags, &imf_event->flags);
192}
193
194/**
195 * Converts a "mouse_wheel" event from Evas to the corresponding event of Ecore_IMF.
196 *
197 * @param evas_event The received Evas event.
198 * @param imf_event The location to store the converted Ecore_IMF event.
199 * @ingroup Ecore_IMF_Evas_Group
200 */
201EAPI void
202ecore_imf_evas_event_mouse_wheel_wrap(Evas_Event_Mouse_Wheel *evas_event,
203 Ecore_IMF_Event_Mouse_Wheel *imf_event)
204{
205 if (!evas_event || !imf_event)
206 return;
207
208 imf_event->direction = evas_event->direction;
209 imf_event->z = evas_event->z;
210 imf_event->output.x = evas_event->output.x;
211 imf_event->output.y = evas_event->output.y;
212 imf_event->canvas.x = evas_event->canvas.x;
213 imf_event->canvas.y = evas_event->canvas.y;
214 imf_event->timestamp = evas_event->timestamp;
215 _ecore_imf_evas_event_modifiers_wrap(evas_event->modifiers, &imf_event->modifiers);
216 _ecore_imf_evas_event_locks_wrap(evas_event->locks, &imf_event->locks);
217 imf_event->timestamp = evas_event->timestamp;
218}
219
220/**
221 * Converts a "key_down" event from Evas to the corresponding event of Ecore_IMF.
222 *
223 * @param evas_event The received Evas event.
224 * @param imf_event The location to store the converted Ecore_IMF event.
225 * @ingroup Ecore_IMF_Evas_Group
226 */
227EAPI void
228ecore_imf_evas_event_key_down_wrap(Evas_Event_Key_Down *evas_event,
229 Ecore_IMF_Event_Key_Down *imf_event)
230{
231 if (!evas_event || !imf_event)
232 return;
233
234 imf_event->keyname = evas_event->keyname ? evas_event->keyname : _ecore_imf_evas_event_empty;
235 imf_event->key = evas_event->key ? evas_event->key : _ecore_imf_evas_event_empty;
236 imf_event->string = evas_event->string ? evas_event->string : _ecore_imf_evas_event_empty;
237 imf_event->compose = evas_event->compose ? evas_event->compose : _ecore_imf_evas_event_empty;
238 imf_event->timestamp = evas_event->timestamp;
239 _ecore_imf_evas_event_modifiers_wrap(evas_event->modifiers, &imf_event->modifiers);
240 _ecore_imf_evas_event_locks_wrap(evas_event->locks, &imf_event->locks);
241}
242
243/**
244 * Converts a "key_up" event from Evas to the corresponding event of Ecore_IMF.
245 *
246 * @param evas_event The received Evas event.
247 * @param imf_event The location to store the converted Ecore_IMF event.
248 * @ingroup Ecore_IMF_Evas_Group
249 */
250EAPI void
251ecore_imf_evas_event_key_up_wrap(Evas_Event_Key_Up *evas_event,
252 Ecore_IMF_Event_Key_Up *imf_event)
253{
254 imf_event->keyname = evas_event->keyname ? evas_event->keyname : _ecore_imf_evas_event_empty;
255 imf_event->key = evas_event->key ? evas_event->key : _ecore_imf_evas_event_empty;
256 imf_event->string = evas_event->string ? evas_event->string : _ecore_imf_evas_event_empty;
257 imf_event->compose = evas_event->compose ? evas_event->compose : _ecore_imf_evas_event_empty;
258 imf_event->timestamp = evas_event->timestamp;
259 _ecore_imf_evas_event_modifiers_wrap(evas_event->modifiers, &imf_event->modifiers);
260 _ecore_imf_evas_event_locks_wrap(evas_event->locks, &imf_event->locks);
261}