diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_wince/ecore_wince_event.c | 1074 |
1 files changed, 1074 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_wince/ecore_wince_event.c b/libraries/ecore/src/lib/ecore_wince/ecore_wince_event.c new file mode 100644 index 0000000..41c355b --- /dev/null +++ b/libraries/ecore/src/lib/ecore_wince/ecore_wince_event.c | |||
@@ -0,0 +1,1074 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <stdlib.h> | ||
6 | |||
7 | #define WIN32_LEAN_AND_MEAN | ||
8 | #include <windows.h> | ||
9 | #undef WIN32_LEAN_AND_MEAN | ||
10 | |||
11 | #include <Eina.h> | ||
12 | #include <Ecore.h> | ||
13 | #include <Ecore_Input.h> | ||
14 | |||
15 | #include "Ecore_WinCE.h" | ||
16 | #include "ecore_wince_private.h" | ||
17 | |||
18 | /*============================================================================* | ||
19 | * Local * | ||
20 | *============================================================================*/ | ||
21 | |||
22 | /** | ||
23 | * @cond LOCAL | ||
24 | */ | ||
25 | |||
26 | typedef enum | ||
27 | { | ||
28 | ECORE_WINCE_KEY_MASK_LSHIFT = 1 << 0, | ||
29 | ECORE_WINCE_KEY_MASK_RSHIFT = 1 << 1, | ||
30 | ECORE_WINCE_KEY_MASK_LCONTROL = 1 << 2, | ||
31 | ECORE_WINCE_KEY_MASK_RCONTROL = 1 << 3, | ||
32 | ECORE_WINCE_KEY_MASK_LMENU = 1 << 4, | ||
33 | ECORE_WINCE_KEY_MASK_RMENU = 1 << 5 | ||
34 | } Ecore_Wince_Key_Mask; | ||
35 | |||
36 | static Ecore_WinCE_Window *_ecore_wince_mouse_down_last_window = NULL; | ||
37 | static Ecore_WinCE_Window *_ecore_wince_mouse_down_last_last_window = NULL; | ||
38 | static long _ecore_wince_mouse_down_last_time = 0; | ||
39 | static long _ecore_wince_mouse_down_last_last_time = 0; | ||
40 | static int _ecore_wince_mouse_down_did_triple = 0; | ||
41 | static int _ecore_wince_mouse_up_count = 0; | ||
42 | static Ecore_Wince_Key_Mask _ecore_wince_key_mask = 0; | ||
43 | |||
44 | static void | ||
45 | _ecore_wince_event_free_key_down(void *data __UNUSED__, | ||
46 | void *ev) | ||
47 | { | ||
48 | Ecore_Event_Key *e; | ||
49 | |||
50 | e = ev; | ||
51 | if (e->keyname) free((char *)e->keyname); | ||
52 | if (e->key) free((char *)e->key); | ||
53 | if (e->string) free((char *)e->string); | ||
54 | free(e); | ||
55 | } | ||
56 | |||
57 | static void | ||
58 | _ecore_wince_event_free_key_up(void *data __UNUSED__, | ||
59 | void *ev) | ||
60 | { | ||
61 | Ecore_Event_Key *e; | ||
62 | |||
63 | e = ev; | ||
64 | if (e->keyname) free((char *)e->keyname); | ||
65 | if (e->key) free((char *)e->key); | ||
66 | if (e->string) free((char *)e->string); | ||
67 | free(e); | ||
68 | } | ||
69 | |||
70 | static int | ||
71 | _ecore_wince_event_keystroke_get(int key, | ||
72 | Eina_Bool is_down, | ||
73 | char **keyname, | ||
74 | char **keysymbol, | ||
75 | char **keycompose) | ||
76 | { | ||
77 | char *kn; | ||
78 | char *ks; | ||
79 | char *kc; | ||
80 | |||
81 | *keyname = NULL; | ||
82 | *keysymbol = NULL; | ||
83 | *keycompose = NULL; | ||
84 | |||
85 | switch (key) | ||
86 | { | ||
87 | /* Keystroke */ | ||
88 | case VK_PRIOR: | ||
89 | kn = "Prior"; | ||
90 | ks = "Prior"; | ||
91 | kc = "Prior"; | ||
92 | break; | ||
93 | case VK_NEXT: | ||
94 | kn = "Next"; | ||
95 | ks = "Next"; | ||
96 | kc = "Next"; | ||
97 | break; | ||
98 | case VK_END: | ||
99 | kn = "End"; | ||
100 | ks = "End"; | ||
101 | kc = "End"; | ||
102 | break; | ||
103 | case VK_HOME: | ||
104 | kn = "Home"; | ||
105 | ks = "Home"; | ||
106 | kc = "Home"; | ||
107 | break; | ||
108 | case VK_LEFT: | ||
109 | kn = "Left"; | ||
110 | ks = "Left"; | ||
111 | kc = "Left"; | ||
112 | break; | ||
113 | case VK_UP: | ||
114 | kn = "Up"; | ||
115 | ks = "Up"; | ||
116 | kc = "Up"; | ||
117 | break; | ||
118 | case VK_RIGHT: | ||
119 | kn = "Right"; | ||
120 | ks = "Right"; | ||
121 | kc = "Right"; | ||
122 | break; | ||
123 | case VK_DOWN: | ||
124 | kn = "Down"; | ||
125 | ks = "Down"; | ||
126 | kc = "Down"; | ||
127 | break; | ||
128 | case VK_INSERT: | ||
129 | kn = "Insert"; | ||
130 | ks = "Insert"; | ||
131 | kc = "Insert"; | ||
132 | break; | ||
133 | case VK_DELETE: | ||
134 | kn = "Delete"; | ||
135 | ks = "Delete"; | ||
136 | kc = "Delete"; | ||
137 | break; | ||
138 | case VK_F1: | ||
139 | kn = "F1"; | ||
140 | ks = "F1"; | ||
141 | kc = ""; | ||
142 | break; | ||
143 | case VK_F2: | ||
144 | kn = "F2"; | ||
145 | ks = "F2"; | ||
146 | kc = ""; | ||
147 | break; | ||
148 | case VK_F3: | ||
149 | kn = "F3"; | ||
150 | ks = "F3"; | ||
151 | kc = ""; | ||
152 | break; | ||
153 | case VK_F4: | ||
154 | kn = "F4"; | ||
155 | ks = "F4"; | ||
156 | kc = ""; | ||
157 | break; | ||
158 | case VK_F5: | ||
159 | kn = "F5"; | ||
160 | ks = "F5"; | ||
161 | kc = ""; | ||
162 | break; | ||
163 | case VK_F6: | ||
164 | kn = "F6"; | ||
165 | ks = "F6"; | ||
166 | kc = ""; | ||
167 | break; | ||
168 | case VK_F7: | ||
169 | kn = "F7"; | ||
170 | ks = "F7"; | ||
171 | kc = ""; | ||
172 | break; | ||
173 | case VK_F8: | ||
174 | kn = "F8"; | ||
175 | ks = "F8"; | ||
176 | kc = ""; | ||
177 | break; | ||
178 | case VK_F9: | ||
179 | kn = "F9"; | ||
180 | ks = "F9"; | ||
181 | kc = ""; | ||
182 | break; | ||
183 | case VK_F10: | ||
184 | kn = "F10"; | ||
185 | ks = "F10"; | ||
186 | kc = ""; | ||
187 | break; | ||
188 | case VK_F11: | ||
189 | kn = "F11"; | ||
190 | ks = "F11"; | ||
191 | kc = ""; | ||
192 | break; | ||
193 | case VK_F12: | ||
194 | kn = "F12"; | ||
195 | ks = "F12"; | ||
196 | kc = ""; | ||
197 | break; | ||
198 | case VK_F13: | ||
199 | kn = "F13"; | ||
200 | ks = "F13"; | ||
201 | kc = ""; | ||
202 | break; | ||
203 | case VK_F14: | ||
204 | kn = "F14"; | ||
205 | ks = "F14"; | ||
206 | kc = ""; | ||
207 | break; | ||
208 | case VK_F15: | ||
209 | kn = "F15"; | ||
210 | ks = "F15"; | ||
211 | kc = ""; | ||
212 | break; | ||
213 | case VK_F16: | ||
214 | kn = "F16"; | ||
215 | ks = "F16"; | ||
216 | kc = ""; | ||
217 | break; | ||
218 | case VK_F17: | ||
219 | kn = "F17"; | ||
220 | ks = "F17"; | ||
221 | kc = ""; | ||
222 | break; | ||
223 | case VK_F18: | ||
224 | kn = "F18"; | ||
225 | ks = "F18"; | ||
226 | kc = ""; | ||
227 | break; | ||
228 | case VK_F19: | ||
229 | kn = "F19"; | ||
230 | ks = "F19"; | ||
231 | kc = ""; | ||
232 | break; | ||
233 | case VK_F20: | ||
234 | /* | ||
235 | * VK_F20 indicates that an arrow key came from a rocker. | ||
236 | * This can safely be ignored. | ||
237 | */ | ||
238 | return 0; | ||
239 | case VK_F21: | ||
240 | /* | ||
241 | * VK_F21 indicates that an arrow key came from a directional | ||
242 | * pad. This can safely be ignored. | ||
243 | */ | ||
244 | return 0; | ||
245 | case VK_F22: | ||
246 | kn = "F22"; | ||
247 | ks = "F22"; | ||
248 | kc = ""; | ||
249 | break; | ||
250 | case VK_F23: | ||
251 | /* | ||
252 | * Sent with VK_RETURN when doing an action (usually the middle | ||
253 | * button on a directional pad. This can safely be ignored. | ||
254 | */ | ||
255 | return 0; | ||
256 | case VK_F24: | ||
257 | kn = "F24"; | ||
258 | ks = "F24"; | ||
259 | kc = ""; | ||
260 | break; | ||
261 | case VK_APPS: | ||
262 | kn = "Application"; | ||
263 | ks = "Application"; | ||
264 | kc = ""; | ||
265 | break; | ||
266 | case VK_SHIFT: | ||
267 | { | ||
268 | SHORT res; | ||
269 | |||
270 | if (is_down) | ||
271 | { | ||
272 | res = GetKeyState(VK_LSHIFT); | ||
273 | if (res & 0x8000) | ||
274 | { | ||
275 | _ecore_wince_key_mask |= ECORE_WINCE_KEY_MASK_LSHIFT; | ||
276 | kn = "Shift_L"; | ||
277 | ks = "Shift_L"; | ||
278 | kc = ""; | ||
279 | } | ||
280 | res = GetKeyState(VK_RSHIFT); | ||
281 | if (res & 0x8000) | ||
282 | { | ||
283 | _ecore_wince_key_mask |= ECORE_WINCE_KEY_MASK_RSHIFT; | ||
284 | kn = "Shift_R"; | ||
285 | ks = "Shift_R"; | ||
286 | kc = ""; | ||
287 | } | ||
288 | } | ||
289 | else /* is_up */ | ||
290 | { | ||
291 | res = GetKeyState(VK_LSHIFT); | ||
292 | if (!(res & 0x8000) && | ||
293 | (_ecore_wince_key_mask & ECORE_WINCE_KEY_MASK_LSHIFT)) | ||
294 | { | ||
295 | kn = "Shift_L"; | ||
296 | ks = "Shift_L"; | ||
297 | kc = ""; | ||
298 | _ecore_wince_key_mask &= ~ECORE_WINCE_KEY_MASK_LSHIFT; | ||
299 | } | ||
300 | res = GetKeyState(VK_RSHIFT); | ||
301 | if (!(res & 0x8000) && | ||
302 | (_ecore_wince_key_mask & ECORE_WINCE_KEY_MASK_RSHIFT)) | ||
303 | { | ||
304 | kn = "Shift_R"; | ||
305 | ks = "Shift_R"; | ||
306 | kc = ""; | ||
307 | _ecore_wince_key_mask &= ~ECORE_WINCE_KEY_MASK_RSHIFT; | ||
308 | } | ||
309 | } | ||
310 | break; | ||
311 | } | ||
312 | case VK_CONTROL: | ||
313 | { | ||
314 | SHORT res; | ||
315 | |||
316 | if (is_down) | ||
317 | { | ||
318 | res = GetKeyState(VK_LCONTROL); | ||
319 | if (res & 0x8000) | ||
320 | { | ||
321 | _ecore_wince_key_mask |= ECORE_WINCE_KEY_MASK_LCONTROL; | ||
322 | kn = "Control_L"; | ||
323 | ks = "Control_L"; | ||
324 | kc = ""; | ||
325 | break; | ||
326 | } | ||
327 | res = GetKeyState(VK_RCONTROL); | ||
328 | if (res & 0x8000) | ||
329 | { | ||
330 | _ecore_wince_key_mask |= ECORE_WINCE_KEY_MASK_RCONTROL; | ||
331 | kn = "Control_R"; | ||
332 | ks = "Control_R"; | ||
333 | kc = ""; | ||
334 | break; | ||
335 | } | ||
336 | } | ||
337 | else /* is_up */ | ||
338 | { | ||
339 | res = GetKeyState(VK_LCONTROL); | ||
340 | if (!(res & 0x8000) && | ||
341 | (_ecore_wince_key_mask & ECORE_WINCE_KEY_MASK_LCONTROL)) | ||
342 | { | ||
343 | kn = "Control_L"; | ||
344 | ks = "Control_L"; | ||
345 | kc = ""; | ||
346 | _ecore_wince_key_mask &= ~ECORE_WINCE_KEY_MASK_LCONTROL; | ||
347 | break; | ||
348 | } | ||
349 | res = GetKeyState(VK_RCONTROL); | ||
350 | if (!(res & 0x8000) && | ||
351 | (_ecore_wince_key_mask & ECORE_WINCE_KEY_MASK_RCONTROL)) | ||
352 | { | ||
353 | kn = "Control_R"; | ||
354 | ks = "Control_R"; | ||
355 | kc = ""; | ||
356 | _ecore_wince_key_mask &= ~ECORE_WINCE_KEY_MASK_RCONTROL; | ||
357 | break; | ||
358 | } | ||
359 | } | ||
360 | break; | ||
361 | } | ||
362 | case VK_MENU: | ||
363 | { | ||
364 | SHORT res; | ||
365 | |||
366 | if (is_down) | ||
367 | { | ||
368 | res = GetKeyState(VK_LMENU); | ||
369 | if (res & 0x8000) | ||
370 | { | ||
371 | _ecore_wince_key_mask |= ECORE_WINCE_KEY_MASK_LMENU; | ||
372 | kn = "Alt_L"; | ||
373 | ks = "Alt_L"; | ||
374 | kc = ""; | ||
375 | } | ||
376 | res = GetKeyState(VK_RMENU); | ||
377 | if (res & 0x8000) | ||
378 | { | ||
379 | _ecore_wince_key_mask |= ECORE_WINCE_KEY_MASK_RMENU; | ||
380 | kn = "Alt_R"; | ||
381 | ks = "Alt_R"; | ||
382 | kc = ""; | ||
383 | } | ||
384 | } | ||
385 | else /* is_up */ | ||
386 | { | ||
387 | res = GetKeyState(VK_LMENU); | ||
388 | if (!(res & 0x8000) && | ||
389 | (_ecore_wince_key_mask & ECORE_WINCE_KEY_MASK_LMENU)) | ||
390 | { | ||
391 | kn = "Alt_L"; | ||
392 | ks = "Alt_L"; | ||
393 | kc = ""; | ||
394 | _ecore_wince_key_mask &= ~ECORE_WINCE_KEY_MASK_LMENU; | ||
395 | } | ||
396 | res = GetKeyState(VK_RMENU); | ||
397 | if (!(res & 0x8000) && | ||
398 | (_ecore_wince_key_mask & ECORE_WINCE_KEY_MASK_RMENU)) | ||
399 | { | ||
400 | kn = "Alt_R"; | ||
401 | ks = "Alt_R"; | ||
402 | kc = ""; | ||
403 | _ecore_wince_key_mask &= ~ECORE_WINCE_KEY_MASK_RMENU; | ||
404 | } | ||
405 | } | ||
406 | break; | ||
407 | } | ||
408 | default: | ||
409 | /* other non keystroke characters */ | ||
410 | return 0; | ||
411 | } | ||
412 | *keyname = strdup(kn); | ||
413 | if (!*keyname) return 0; | ||
414 | *keysymbol = strdup(ks); | ||
415 | if (!*keysymbol) | ||
416 | { | ||
417 | free(*keyname); | ||
418 | *keyname = NULL; | ||
419 | return 0; | ||
420 | } | ||
421 | *keycompose = strdup(kc); | ||
422 | if (!*keycompose) | ||
423 | { | ||
424 | free(*keyname); | ||
425 | free(*keysymbol); | ||
426 | *keyname = NULL; | ||
427 | *keysymbol = NULL; | ||
428 | return 0; | ||
429 | } | ||
430 | |||
431 | return 1; | ||
432 | } | ||
433 | |||
434 | static int | ||
435 | _ecore_wince_event_char_get(int key, | ||
436 | char **keyname, | ||
437 | char **keysymbol, | ||
438 | char **keycompose) | ||
439 | { | ||
440 | char kn[32]; | ||
441 | char ks[32]; | ||
442 | char kc[32]; | ||
443 | |||
444 | *keyname = NULL; | ||
445 | *keysymbol = NULL; | ||
446 | *keycompose = NULL; | ||
447 | |||
448 | switch (key) | ||
449 | { | ||
450 | case VK_APP3: | ||
451 | case VK_BACK: | ||
452 | strncpy(kn, "BackSpace", 32); | ||
453 | strncpy(ks, "BackSpace", 32); | ||
454 | strncpy(kc, "BackSpace", 32); | ||
455 | break; | ||
456 | case VK_APP4: | ||
457 | case VK_TAB: | ||
458 | strncpy(kn, "Tab", 32); | ||
459 | strncpy(ks, "Tab", 32); | ||
460 | strncpy(kc, "Tab", 32); | ||
461 | break; | ||
462 | case VK_APP5: | ||
463 | case 0x0a: | ||
464 | /* Line feed (Shift + Enter) */ | ||
465 | strncpy(kn, "LineFeed", 32); | ||
466 | strncpy(ks, "LineFeed", 32); | ||
467 | strncpy(kc, "LineFeed", 32); | ||
468 | break; | ||
469 | case VK_APP2: | ||
470 | case VK_RETURN: | ||
471 | strncpy(kn, "Return", 32); | ||
472 | strncpy(ks, "Return", 32); | ||
473 | strncpy(kc, "Return", 32); | ||
474 | break; | ||
475 | case VK_APP1: | ||
476 | case VK_ESCAPE: | ||
477 | strncpy(kn, "Escape", 32); | ||
478 | strncpy(ks, "Escape", 32); | ||
479 | strncpy(kc, "Escape", 32); | ||
480 | break; | ||
481 | case VK_SPACE: | ||
482 | strncpy(kn, "space", 32); | ||
483 | strncpy(ks, "space", 32); | ||
484 | strncpy(kc, " ", 32); | ||
485 | break; | ||
486 | default: | ||
487 | /* displayable characters */ | ||
488 | printf (" * key : %d\n", key); | ||
489 | kn[0] = (TCHAR)key; | ||
490 | kn[1] = '\0'; | ||
491 | ks[0] = (TCHAR)key; | ||
492 | ks[1] = '\0'; | ||
493 | kc[0] = (TCHAR)key; | ||
494 | kc[1] = '\0'; | ||
495 | break; | ||
496 | } | ||
497 | *keyname = strdup(kn); | ||
498 | if (!*keyname) return 0; | ||
499 | *keysymbol = strdup(ks); | ||
500 | if (!*keysymbol) | ||
501 | { | ||
502 | free(*keyname); | ||
503 | *keyname = NULL; | ||
504 | return 0; | ||
505 | } | ||
506 | *keycompose = strdup(kc); | ||
507 | if (!*keycompose) | ||
508 | { | ||
509 | free(*keyname); | ||
510 | free(*keysymbol); | ||
511 | *keyname = NULL; | ||
512 | *keysymbol = NULL; | ||
513 | return 0; | ||
514 | } | ||
515 | |||
516 | return 1; | ||
517 | } | ||
518 | |||
519 | /** | ||
520 | * @endcond | ||
521 | */ | ||
522 | |||
523 | |||
524 | /*============================================================================* | ||
525 | * Global * | ||
526 | *============================================================================*/ | ||
527 | |||
528 | void | ||
529 | _ecore_wince_event_handle_key_press(Ecore_WinCE_Callback_Data *msg, | ||
530 | int is_keystroke) | ||
531 | { | ||
532 | Ecore_Event_Key *e; | ||
533 | |||
534 | INF("key pressed"); | ||
535 | |||
536 | e = (Ecore_Event_Key *)malloc(sizeof(Ecore_Event_Key)); | ||
537 | if (!e) return; | ||
538 | |||
539 | if (is_keystroke) | ||
540 | { | ||
541 | if (!_ecore_wince_event_keystroke_get(LOWORD(msg->window_param), | ||
542 | EINA_TRUE, | ||
543 | (char **)&e->keyname, | ||
544 | (char **)&e->key, | ||
545 | (char **)&e->string)) | ||
546 | { | ||
547 | free(e); | ||
548 | return; | ||
549 | } | ||
550 | } | ||
551 | else | ||
552 | { | ||
553 | if (!_ecore_wince_event_char_get(LOWORD(msg->window_param), | ||
554 | (char **)&e->keyname, | ||
555 | (char **)&e->key, | ||
556 | (char **)&e->string)) | ||
557 | { | ||
558 | free(e); | ||
559 | return; | ||
560 | } | ||
561 | } | ||
562 | |||
563 | e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); | ||
564 | e->event_window = e->window; | ||
565 | if (!e->window) | ||
566 | { | ||
567 | free(e); | ||
568 | return; | ||
569 | } | ||
570 | e->timestamp = msg->time; | ||
571 | |||
572 | _ecore_wince_event_last_time = e->timestamp; | ||
573 | |||
574 | ecore_event_add(ECORE_EVENT_KEY_DOWN, e, _ecore_wince_event_free_key_down, NULL); | ||
575 | } | ||
576 | |||
577 | void | ||
578 | _ecore_wince_event_handle_key_release(Ecore_WinCE_Callback_Data *msg, | ||
579 | int is_keystroke) | ||
580 | { | ||
581 | Ecore_Event_Key *e; | ||
582 | |||
583 | INF("key released"); | ||
584 | |||
585 | e = (Ecore_Event_Key *)calloc(1, sizeof(Ecore_Event_Key)); | ||
586 | if (!e) return; | ||
587 | |||
588 | if (is_keystroke) | ||
589 | { | ||
590 | if (!_ecore_wince_event_keystroke_get(LOWORD(msg->window_param), | ||
591 | EINA_FALSE, | ||
592 | (char **)&e->keyname, | ||
593 | (char **)&e->key, | ||
594 | (char **)&e->string)) | ||
595 | { | ||
596 | free(e); | ||
597 | return; | ||
598 | } | ||
599 | } | ||
600 | else | ||
601 | { | ||
602 | if (!_ecore_wince_event_char_get(LOWORD(msg->window_param), | ||
603 | (char **)&e->keyname, | ||
604 | (char **)&e->key, | ||
605 | (char **)&e->string)) | ||
606 | { | ||
607 | free(e); | ||
608 | return; | ||
609 | } | ||
610 | } | ||
611 | |||
612 | e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); | ||
613 | e->event_window = e->window; | ||
614 | if (!e->window) | ||
615 | { | ||
616 | free(e); | ||
617 | return; | ||
618 | } | ||
619 | e->timestamp = msg->time; | ||
620 | |||
621 | _ecore_wince_event_last_time = e->timestamp; | ||
622 | |||
623 | ecore_event_add(ECORE_EVENT_KEY_UP, e, _ecore_wince_event_free_key_up, NULL); | ||
624 | } | ||
625 | |||
626 | void | ||
627 | _ecore_wince_event_handle_button_press(Ecore_WinCE_Callback_Data *msg, | ||
628 | int button) | ||
629 | { | ||
630 | Ecore_WinCE_Window *window; | ||
631 | |||
632 | INF("mouse button pressed"); | ||
633 | |||
634 | window = (Ecore_WinCE_Window *)GetWindowLong(msg->window, GWL_USERDATA); | ||
635 | |||
636 | { | ||
637 | Ecore_Event_Mouse_Move *e; | ||
638 | |||
639 | e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); | ||
640 | if (!e) return; | ||
641 | |||
642 | e->window = (Ecore_Window)window; | ||
643 | e->event_window = e->window; | ||
644 | e->x = LOWORD(msg->data_param); | ||
645 | e->y = HIWORD(msg->data_param); | ||
646 | e->timestamp = msg->time; | ||
647 | |||
648 | _ecore_wince_event_last_time = e->timestamp; | ||
649 | _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; | ||
650 | |||
651 | ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); | ||
652 | } | ||
653 | |||
654 | { | ||
655 | Ecore_Event_Mouse_Button *e; | ||
656 | |||
657 | if (_ecore_wince_mouse_down_did_triple) | ||
658 | { | ||
659 | _ecore_wince_mouse_down_last_window = NULL; | ||
660 | _ecore_wince_mouse_down_last_last_window = NULL; | ||
661 | _ecore_wince_mouse_down_last_time = 0; | ||
662 | _ecore_wince_mouse_down_last_last_time = 0; | ||
663 | } | ||
664 | |||
665 | e = (Ecore_Event_Mouse_Button *)calloc(1, sizeof(Ecore_Event_Mouse_Button)); | ||
666 | if (!e) return; | ||
667 | |||
668 | e->window = (Ecore_Window)window; | ||
669 | e->event_window = e->window; | ||
670 | e->buttons = button; | ||
671 | e->x = LOWORD(msg->data_param); | ||
672 | e->y = HIWORD(msg->data_param); | ||
673 | e->timestamp = msg->time; | ||
674 | |||
675 | if (((e->timestamp - _ecore_wince_mouse_down_last_time) <= (long)(1000 * _ecore_wince_double_click_time)) && | ||
676 | (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window)) | ||
677 | e->double_click = 1; | ||
678 | |||
679 | if (((e->timestamp - _ecore_wince_mouse_down_last_last_time) <= (long)(2 * 1000 * _ecore_wince_double_click_time)) && | ||
680 | (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window) && | ||
681 | (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_last_window)) | ||
682 | { | ||
683 | e->triple_click = 1; | ||
684 | _ecore_wince_mouse_down_did_triple = 1; | ||
685 | } | ||
686 | else | ||
687 | _ecore_wince_mouse_down_did_triple = 0; | ||
688 | |||
689 | if (!e->double_click && !e->triple_click) | ||
690 | _ecore_wince_mouse_up_count = 0; | ||
691 | |||
692 | _ecore_wince_event_last_time = e->timestamp; | ||
693 | _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; | ||
694 | |||
695 | if (!_ecore_wince_mouse_down_did_triple) | ||
696 | { | ||
697 | _ecore_wince_mouse_down_last_last_window = _ecore_wince_mouse_down_last_window; | ||
698 | _ecore_wince_mouse_down_last_window = (Ecore_WinCE_Window *)e->window; | ||
699 | _ecore_wince_mouse_down_last_last_time = _ecore_wince_mouse_down_last_time; | ||
700 | _ecore_wince_mouse_down_last_time = e->timestamp; | ||
701 | } | ||
702 | |||
703 | ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL); | ||
704 | } | ||
705 | } | ||
706 | |||
707 | void | ||
708 | _ecore_wince_event_handle_button_release(Ecore_WinCE_Callback_Data *msg, | ||
709 | int button) | ||
710 | { | ||
711 | Ecore_WinCE_Window *window; | ||
712 | |||
713 | INF("mouse button released"); | ||
714 | |||
715 | window = (void *)GetWindowLong(msg->window, GWL_USERDATA); | ||
716 | |||
717 | { | ||
718 | Ecore_Event_Mouse_Move *e; | ||
719 | |||
720 | e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); | ||
721 | if (!e) return; | ||
722 | |||
723 | e->window = (Ecore_Window)window; | ||
724 | e->event_window = e->window; | ||
725 | e->x = LOWORD(msg->data_param); | ||
726 | e->y = HIWORD(msg->data_param); | ||
727 | e->timestamp = msg->time; | ||
728 | |||
729 | _ecore_wince_event_last_time = e->timestamp; | ||
730 | _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; | ||
731 | |||
732 | ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); | ||
733 | } | ||
734 | |||
735 | { | ||
736 | Ecore_Event_Mouse_Button *e; | ||
737 | |||
738 | e = (Ecore_Event_Mouse_Button *)calloc(1, sizeof(Ecore_Event_Mouse_Button)); | ||
739 | if (!e) return; | ||
740 | |||
741 | e->window = (Ecore_Window)window; | ||
742 | e->event_window = e->window; | ||
743 | e->buttons = button; | ||
744 | e->x = LOWORD(msg->data_param); | ||
745 | e->y = HIWORD(msg->data_param); | ||
746 | e->timestamp = msg->time; | ||
747 | |||
748 | _ecore_wince_mouse_up_count++; | ||
749 | |||
750 | if ((_ecore_wince_mouse_up_count >= 2) && | ||
751 | ((e->timestamp - _ecore_wince_mouse_down_last_time) <= (long)(1000 * _ecore_wince_double_click_time)) && | ||
752 | (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window)) | ||
753 | e->double_click = 1; | ||
754 | |||
755 | if ((_ecore_wince_mouse_up_count >= 3) && | ||
756 | ((e->timestamp - _ecore_wince_mouse_down_last_last_time) <= (long)(2 * 1000 * _ecore_wince_double_click_time)) && | ||
757 | (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window) && | ||
758 | (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_last_window)) | ||
759 | e->triple_click = 1; | ||
760 | |||
761 | _ecore_wince_event_last_time = e->timestamp; | ||
762 | _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; | ||
763 | |||
764 | ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL); | ||
765 | } | ||
766 | } | ||
767 | |||
768 | void | ||
769 | _ecore_wince_event_handle_motion_notify(Ecore_WinCE_Callback_Data *msg) | ||
770 | { | ||
771 | Ecore_Event_Mouse_Move *e; | ||
772 | |||
773 | INF("mouse moved"); | ||
774 | |||
775 | e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); | ||
776 | if (!e) return; | ||
777 | |||
778 | e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); | ||
779 | e->event_window = e->window; | ||
780 | e->x = LOWORD(msg->data_param); | ||
781 | e->y = HIWORD(msg->data_param); | ||
782 | e->timestamp = msg->time; | ||
783 | |||
784 | ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); | ||
785 | } | ||
786 | |||
787 | void | ||
788 | _ecore_wince_event_handle_enter_notify(Ecore_WinCE_Callback_Data *msg) | ||
789 | { | ||
790 | Ecore_WinCE_Window *window; | ||
791 | |||
792 | INF("mouse in"); | ||
793 | |||
794 | window = (void *)GetWindowLong(msg->window, GWL_USERDATA); | ||
795 | |||
796 | { | ||
797 | Ecore_Event_Mouse_Move *e; | ||
798 | |||
799 | e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); | ||
800 | if (!e) return; | ||
801 | |||
802 | e->window = (Ecore_Window)window; | ||
803 | e->event_window = e->window; | ||
804 | e->x = msg->x; | ||
805 | e->y = msg->y; | ||
806 | e->timestamp = msg->time; | ||
807 | |||
808 | _ecore_wince_event_last_time = e->timestamp; | ||
809 | _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; | ||
810 | |||
811 | ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); | ||
812 | } | ||
813 | |||
814 | { | ||
815 | Ecore_WinCE_Event_Mouse_In *e; | ||
816 | |||
817 | e = (Ecore_WinCE_Event_Mouse_In *)calloc(1, sizeof(Ecore_WinCE_Event_Mouse_In)); | ||
818 | if (!e) return; | ||
819 | |||
820 | e->window = window; | ||
821 | e->x = msg->x; | ||
822 | e->y = msg->y; | ||
823 | e->time = msg->time; | ||
824 | |||
825 | _ecore_wince_event_last_time = e->time; | ||
826 | |||
827 | ecore_event_add(ECORE_WINCE_EVENT_MOUSE_IN, e, NULL, NULL); | ||
828 | } | ||
829 | } | ||
830 | |||
831 | void | ||
832 | _ecore_wince_event_handle_leave_notify(Ecore_WinCE_Callback_Data *msg) | ||
833 | { | ||
834 | Ecore_WinCE_Window *window; | ||
835 | |||
836 | INF("mouse out"); | ||
837 | |||
838 | window = (void *)GetWindowLong(msg->window, GWL_USERDATA); | ||
839 | |||
840 | { | ||
841 | Ecore_Event_Mouse_Move *e; | ||
842 | |||
843 | e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); | ||
844 | if (!e) return; | ||
845 | |||
846 | e->window = (Ecore_Window)window; | ||
847 | e->event_window = e->window; | ||
848 | e->x = msg->x; | ||
849 | e->y = msg->y; | ||
850 | e->timestamp = msg->time; | ||
851 | |||
852 | _ecore_wince_event_last_time = e->timestamp; | ||
853 | _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; | ||
854 | |||
855 | ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); | ||
856 | } | ||
857 | |||
858 | { | ||
859 | Ecore_WinCE_Event_Mouse_Out *e; | ||
860 | |||
861 | e = (Ecore_WinCE_Event_Mouse_Out *)calloc(1, sizeof(Ecore_WinCE_Event_Mouse_Out)); | ||
862 | if (!e) return; | ||
863 | |||
864 | e->window = window; | ||
865 | e->x = msg->x; | ||
866 | e->y = msg->y; | ||
867 | e->time = msg->time; | ||
868 | |||
869 | _ecore_wince_event_last_time = e->time; | ||
870 | |||
871 | ecore_event_add(ECORE_WINCE_EVENT_MOUSE_OUT, e, NULL, NULL); | ||
872 | } | ||
873 | } | ||
874 | |||
875 | void | ||
876 | _ecore_wince_event_handle_focus_in(Ecore_WinCE_Callback_Data *msg) | ||
877 | { | ||
878 | Ecore_WinCE_Event_Window_Focus_In *e; | ||
879 | Ecore_WinCE_Window *window; | ||
880 | |||
881 | INF("focus in"); | ||
882 | |||
883 | e = (Ecore_WinCE_Event_Window_Focus_In *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Focus_In)); | ||
884 | if (!e) return; | ||
885 | |||
886 | window = (void *)GetWindowLong(msg->window, GWL_USERDATA); | ||
887 | if (!e->window) | ||
888 | { | ||
889 | free(e); | ||
890 | return; | ||
891 | } | ||
892 | |||
893 | if (window->resume_cb) | ||
894 | window->resume_cb(window->backend); | ||
895 | |||
896 | e->window = window; | ||
897 | |||
898 | e->time = _ecore_wince_event_last_time; | ||
899 | _ecore_wince_event_last_time = e->time; | ||
900 | |||
901 | ecore_event_add(ECORE_WINCE_EVENT_WINDOW_FOCUS_IN, e, NULL, NULL); | ||
902 | } | ||
903 | |||
904 | void | ||
905 | _ecore_wince_event_handle_focus_out(Ecore_WinCE_Callback_Data *msg) | ||
906 | { | ||
907 | Ecore_WinCE_Event_Window_Focus_Out *e; | ||
908 | Ecore_WinCE_Window *window; | ||
909 | |||
910 | INF("focus out"); | ||
911 | |||
912 | e = (Ecore_WinCE_Event_Window_Focus_Out *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Focus_Out)); | ||
913 | if (!e) return; | ||
914 | |||
915 | window = (void *)GetWindowLong(msg->window, GWL_USERDATA); | ||
916 | if (!e->window) | ||
917 | { | ||
918 | free(e); | ||
919 | return; | ||
920 | } | ||
921 | if (window->suspend_cb) | ||
922 | window->suspend_cb(window->backend); | ||
923 | |||
924 | e->window = window; | ||
925 | |||
926 | e->time = _ecore_wince_event_last_time; | ||
927 | _ecore_wince_event_last_time = e->time; | ||
928 | |||
929 | ecore_event_add(ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT, e, NULL, NULL); | ||
930 | } | ||
931 | |||
932 | void | ||
933 | _ecore_wince_event_handle_expose(Ecore_WinCE_Callback_Data *msg) | ||
934 | { | ||
935 | Ecore_WinCE_Event_Window_Damage *e; | ||
936 | |||
937 | INF("window expose"); | ||
938 | |||
939 | e = (Ecore_WinCE_Event_Window_Damage *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Damage)); | ||
940 | if (!e) return; | ||
941 | |||
942 | e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); | ||
943 | if (!e->window) | ||
944 | { | ||
945 | free(e); | ||
946 | return; | ||
947 | } | ||
948 | |||
949 | e->x = msg->update.left; | ||
950 | e->y = msg->update.top; | ||
951 | e->width = msg->update.right - msg->update.left; | ||
952 | e->height = msg->update.bottom - msg->update.top; | ||
953 | INF("window expose size: %dx%d", e->width, e->height); | ||
954 | |||
955 | e->time = _ecore_wince_event_last_time; | ||
956 | |||
957 | ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DAMAGE, e, NULL, NULL); | ||
958 | } | ||
959 | |||
960 | void | ||
961 | _ecore_wince_event_handle_create_notify(Ecore_WinCE_Callback_Data *msg) | ||
962 | { | ||
963 | Ecore_WinCE_Event_Window_Create *e; | ||
964 | |||
965 | INF("window create notify"); | ||
966 | |||
967 | e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Create)); | ||
968 | if (!e) return; | ||
969 | |||
970 | e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); | ||
971 | if (!e->window) | ||
972 | { | ||
973 | free(e); | ||
974 | return; | ||
975 | } | ||
976 | |||
977 | e->time = _ecore_wince_event_last_time; | ||
978 | |||
979 | ecore_event_add(ECORE_WINCE_EVENT_WINDOW_CREATE, e, NULL, NULL); | ||
980 | } | ||
981 | |||
982 | void | ||
983 | _ecore_wince_event_handle_destroy_notify(Ecore_WinCE_Callback_Data *msg) | ||
984 | { | ||
985 | Ecore_WinCE_Event_Window_Destroy *e; | ||
986 | |||
987 | INF("window destroy notify"); | ||
988 | |||
989 | e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Destroy)); | ||
990 | if (!e) return; | ||
991 | |||
992 | e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); | ||
993 | if (!e->window) | ||
994 | { | ||
995 | free(e); | ||
996 | return; | ||
997 | } | ||
998 | |||
999 | e->time = _ecore_wince_event_last_time; | ||
1000 | /* if (e->window == _ecore_wince_event_last_window) _ecore_wince_event_last_window = NULL; */ | ||
1001 | |||
1002 | ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DESTROY, e, NULL, NULL); | ||
1003 | } | ||
1004 | |||
1005 | void | ||
1006 | _ecore_wince_event_handle_map_notify(Ecore_WinCE_Callback_Data *msg) | ||
1007 | { | ||
1008 | Ecore_WinCE_Event_Window_Show *e; | ||
1009 | |||
1010 | INF("window map notify"); | ||
1011 | |||
1012 | e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Show)); | ||
1013 | if (!e) return; | ||
1014 | |||
1015 | e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); | ||
1016 | if (!e->window) | ||
1017 | { | ||
1018 | free(e); | ||
1019 | return; | ||
1020 | } | ||
1021 | |||
1022 | e->time = _ecore_wince_event_last_time; | ||
1023 | |||
1024 | ecore_event_add(ECORE_WINCE_EVENT_WINDOW_SHOW, e, NULL, NULL); | ||
1025 | } | ||
1026 | |||
1027 | void | ||
1028 | _ecore_wince_event_handle_unmap_notify(Ecore_WinCE_Callback_Data *msg) | ||
1029 | { | ||
1030 | Ecore_WinCE_Event_Window_Hide *e; | ||
1031 | |||
1032 | INF("window unmap notify"); | ||
1033 | |||
1034 | e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Hide)); | ||
1035 | if (!e) return; | ||
1036 | |||
1037 | e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); | ||
1038 | if (!e->window) | ||
1039 | { | ||
1040 | free(e); | ||
1041 | return; | ||
1042 | } | ||
1043 | |||
1044 | e->time = _ecore_wince_event_last_time; | ||
1045 | |||
1046 | ecore_event_add(ECORE_WINCE_EVENT_WINDOW_HIDE, e, NULL, NULL); | ||
1047 | } | ||
1048 | |||
1049 | void | ||
1050 | _ecore_wince_event_handle_delete_request(Ecore_WinCE_Callback_Data *msg) | ||
1051 | { | ||
1052 | Ecore_WinCE_Event_Window_Delete_Request *e; | ||
1053 | |||
1054 | INF("window delete request"); | ||
1055 | |||
1056 | e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Delete_Request)); | ||
1057 | if (!e) return; | ||
1058 | |||
1059 | e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); | ||
1060 | if (!e->window) | ||
1061 | { | ||
1062 | free(e); | ||
1063 | return; | ||
1064 | } | ||
1065 | |||
1066 | e->time = _ecore_wince_event_last_time; | ||
1067 | |||
1068 | ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL); | ||
1069 | } | ||
1070 | |||
1071 | /*============================================================================* | ||
1072 | * API * | ||
1073 | *============================================================================*/ | ||
1074 | |||