3 #endif /* ifdef HAVE_CONFIG_H */
12 #include "ecore_private.h"
13 #include "ecore_x_private.h"
15 #include "Ecore_X_Atoms.h"
17 /** OpenBSD does not define CODESET
22 #define CODESET "INVALID"
23 #endif /* ifndef CODESET */
25 typedef struct _Ecore_X_Mouse_Down_Info
31 Window last_event_win;
32 Window last_last_event_win;
35 Eina_Bool did_double : 1;
36 Eina_Bool did_triple : 1;
37 } Ecore_X_Mouse_Down_Info;
39 static int _ecore_x_last_event_mouse_move = 0;
40 static Ecore_Event *_ecore_x_last_event_mouse_move_event = NULL;
41 static Eina_Inlist *_ecore_x_mouse_down_info_list = NULL;
44 static Eina_Hash *emitted_events = NULL;
48 _ecore_x_mouse_down_info_clear(void)
50 Eina_Inlist *l = _ecore_x_mouse_down_info_list;
51 Ecore_X_Mouse_Down_Info *info = NULL;
54 info = EINA_INLIST_CONTAINER_GET(l, Ecore_X_Mouse_Down_Info);
55 l = eina_inlist_remove(l, l);
58 _ecore_x_mouse_down_info_list = NULL;
62 _ecore_x_events_init(void)
64 //Actually, Nothing to do.
66 emitted_events = eina_hash_int64_new(NULL);
71 _ecore_x_events_shutdown(void)
73 _ecore_x_mouse_down_info_clear();
75 eina_hash_free(emitted_events);
79 static Ecore_X_Mouse_Down_Info *
80 _ecore_x_mouse_down_info_get(int dev)
82 Eina_Inlist *l = _ecore_x_mouse_down_info_list;
83 Ecore_X_Mouse_Down_Info *info = NULL;
85 //Return the exist info
86 EINA_INLIST_FOREACH(l, info)
87 if (info->dev == dev) return info;
90 info = calloc(1, sizeof(Ecore_X_Mouse_Down_Info));
91 if (!info) return NULL;
94 l = eina_inlist_append(l, (Eina_Inlist *)info);
95 _ecore_x_mouse_down_info_list = l;
100 _ecore_x_event_free_mouse_move(void *data EINA_UNUSED,
103 Ecore_Event_Mouse_Move *e;
106 if (_ecore_x_last_event_mouse_move)
108 _ecore_x_last_event_mouse_move_event = NULL;
109 _ecore_x_last_event_mouse_move = 0;
116 ecore_x_event_mask_set(Ecore_X_Window w,
117 Ecore_X_Event_Mask mask)
119 XWindowAttributes attr;
120 XSetWindowAttributes s_attr;
122 LOGFN(__FILE__, __LINE__, __FUNCTION__);
124 EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
127 w = DefaultRootWindow(_ecore_x_disp);
129 memset(&attr, 0, sizeof(XWindowAttributes));
130 XGetWindowAttributes(_ecore_x_disp, w, &attr);
131 if (_ecore_xlib_sync) ecore_x_sync();
132 s_attr.event_mask = mask | attr.your_event_mask;
133 XChangeWindowAttributes(_ecore_x_disp, w, CWEventMask, &s_attr);
134 if (_ecore_xlib_sync) ecore_x_sync();
138 ecore_x_event_mask_unset(Ecore_X_Window w,
139 Ecore_X_Event_Mask mask)
141 XWindowAttributes attr;
142 XSetWindowAttributes s_attr;
144 LOGFN(__FILE__, __LINE__, __FUNCTION__);
146 EINA_SAFETY_ON_NULL_RETURN(_ecore_x_disp);
149 w = DefaultRootWindow(_ecore_x_disp);
151 memset(&attr, 0, sizeof(XWindowAttributes));
152 XGetWindowAttributes(_ecore_x_disp, w, &attr);
153 if (_ecore_xlib_sync) ecore_x_sync();
154 s_attr.event_mask = attr.your_event_mask & ~mask;
155 XChangeWindowAttributes(_ecore_x_disp, w, CWEventMask, &s_attr);
156 if (_ecore_xlib_sync) ecore_x_sync();
160 _ecore_x_event_free_xdnd_enter(void *data EINA_UNUSED,
163 Ecore_X_Event_Xdnd_Enter *e;
167 for (i = 0; i < e->num_types; i++)
174 _ecore_x_event_free_selection_notify(void *data EINA_UNUSED,
177 Ecore_X_Event_Selection_Notify *e;
178 Ecore_X_Selection_Data *sel;
190 _ecore_x_event_modifiers(unsigned int state)
192 unsigned int modifiers = 0;
194 if (state & ECORE_X_MODIFIER_SHIFT)
195 modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
197 if (state & ECORE_X_MODIFIER_CTRL)
198 modifiers |= ECORE_EVENT_MODIFIER_CTRL;
200 if (state & ECORE_X_MODIFIER_ALT)
201 modifiers |= ECORE_EVENT_MODIFIER_ALT;
203 if (state & ECORE_X_MODIFIER_WIN)
204 modifiers |= ECORE_EVENT_MODIFIER_WIN;
206 if (state & ECORE_X_MODIFIER_ALTGR)
207 modifiers |= ECORE_EVENT_MODIFIER_ALTGR;
209 if (state & ECORE_X_LOCK_SCROLL)
210 modifiers |= ECORE_EVENT_LOCK_SCROLL;
212 if (state & ECORE_X_LOCK_NUM)
213 modifiers |= ECORE_EVENT_LOCK_NUM;
215 if (state & ECORE_X_LOCK_CAPS)
216 modifiers |= ECORE_EVENT_LOCK_CAPS;
218 if (state & ECORE_X_LOCK_SHIFT)
219 modifiers |= ECORE_EVENT_LOCK_SHIFT;
225 _ecore_mouse_move(unsigned int timestamp,
226 unsigned int xmodifiers,
231 unsigned int event_window,
233 unsigned int root_win,
245 Ecore_Event_Mouse_Move *e;
248 e = calloc(1, sizeof(Ecore_Event_Mouse_Move));
253 e->root_window = root_win;
254 e->timestamp = timestamp;
255 e->same_screen = same_screen;
256 e->event_window = event_window;
258 e->modifiers = _ecore_x_event_modifiers(xmodifiers);
264 e->multi.device = dev;
265 e->multi.radius = (radx + rady) / 2;
266 e->multi.radius_x = radx;
267 e->multi.radius_y = rady;
268 e->multi.pressure = pressure;
269 e->multi.angle = angle;
272 e->multi.root.x = mrx;
273 e->multi.root.y = mry;
275 event = ecore_event_add(ECORE_EVENT_MOUSE_MOVE,
277 _ecore_x_event_free_mouse_move,
280 _ecore_x_event_last_time = timestamp;
281 _ecore_x_event_last_win = window;
282 _ecore_x_event_last_root_x = x_root;
283 _ecore_x_event_last_root_y = y_root;
285 _ecore_x_last_event_mouse_move_event = event;
289 _ecore_x_event_free_axis_update_event(void *data EINA_UNUSED, void *ev)
291 Ecore_Event_Axis_Update *e = ev;
292 if (e) free(e->axis);
297 _ecore_x_axis_update(Ecore_Window window,
298 Ecore_Window event_window,
299 Ecore_Window root_window,
300 unsigned int timestamp,
306 Ecore_Event_Axis_Update *e;
309 e = calloc(1, sizeof(Ecore_Event_Axis_Update));
312 if (axis) free(axis);
317 e->event_window = event_window;
318 e->root_window = root_window;
320 e->timestamp = timestamp;
328 INF("Axis update [%d] (%d) with %d events:", ECORE_EVENT_AXIS_UPDATE, e->device, e->naxis);
329 for (i = 0; i < naxis; i++)
331 INF("AXIS %d = %f", e->axis[i].label, e->axis[i].value);
334 ecore_event_add(ECORE_EVENT_AXIS_UPDATE, e, _ecore_x_event_free_axis_update_event, NULL);
336 _ecore_x_event_last_time = timestamp;
340 _ecore_key_press(int event,
344 char *compose = NULL;
348 char keyname_buffer[256];
349 char compose_buffer[256];
350 KeySym sym, sym2 = 0;
351 XComposeStatus status;
353 int key_len, keyname_len, compose_len;
355 _ecore_x_last_event_mouse_move = 0;
356 sym = _ecore_x_XKeycodeToKeysym(xevent->display, xevent->keycode, 0);
357 keyname = XKeysymToString(sym);
361 snprintf(keyname_buffer,
362 sizeof(keyname_buffer),
365 keyname = keyname_buffer;
370 val = XLookupString(xevent,
372 sizeof(compose_buffer),
377 compose_buffer[val] = 0;
378 compose = eina_str_convert(nl_langinfo(CODESET), "UTF-8",
381 ERR("Ecore_X cannot convert input key string '%s' to UTF-8. "
382 "Is Eina built with iconv support?", compose_buffer);
387 key = XKeysymToString(sym);
391 key_len = strlen(key);
392 keyname_len = strlen(keyname);
393 compose_len = (compose) ? strlen(compose) : 0;
395 e = calloc(1, sizeof(Ecore_Event_Key) + key_len + keyname_len +
400 e->keyname = (char *)(e + 1);
401 e->key = e->keyname + keyname_len + 1;
402 e->compose = (compose) ? e->key + key_len + 1 : NULL;
403 e->string = e->compose;
405 strcpy((char *)e->keyname, keyname);
406 strcpy((char *)e->key, key);
408 strcpy((char *)e->compose, compose);
410 e->modifiers = _ecore_x_event_modifiers(xevent->state);
412 e->timestamp = xevent->time;
413 e->window = xevent->subwindow ? xevent->subwindow : xevent->window;
414 e->event_window = xevent->window;
415 e->same_screen = xevent->same_screen;
416 e->root_window = xevent->root;
417 e->keycode = xevent->keycode;
419 ecore_event_add(event, e, NULL, NULL);
421 _ecore_x_event_last_time = e->timestamp;
428 Ecore_Event_Mouse_Button *
429 _ecore_mouse_button(int event,
430 unsigned int timestamp,
431 unsigned int xmodifiers,
432 unsigned int buttons,
437 unsigned int event_window,
439 unsigned int root_win,
451 Ecore_Event_Mouse_Button *e;
453 e = calloc(1, sizeof(Ecore_Event_Mouse_Button));
458 e->root_window = root_win;
459 e->timestamp = timestamp;
460 e->same_screen = same_screen;
461 e->event_window = event_window;
463 e->buttons = buttons;
464 e->modifiers = _ecore_x_event_modifiers(xmodifiers);
472 Ecore_X_Mouse_Down_Info *down_info = _ecore_x_mouse_down_info_get(dev);
476 //If mouse cancel event occred, should reset down info related with double & triple click
477 if (event == ECORE_EVENT_MOUSE_BUTTON_CANCEL)
479 down_info->last_win = 0;
480 down_info->last_last_win = 0;
481 down_info->last_event_win = 0;
482 down_info->last_last_event_win = 0;
483 down_info->last_time = 0;
484 down_info->last_last_time = 0;
485 down_info->did_double = EINA_FALSE;
486 down_info->did_triple = EINA_FALSE;
488 if ((event == ECORE_EVENT_MOUSE_BUTTON_DOWN) &&
489 down_info->did_triple)
491 down_info->last_win = 0;
492 down_info->last_last_win = 0;
493 down_info->last_event_win = 0;
494 down_info->last_last_event_win = 0;
495 down_info->last_time = 0;
496 down_info->last_last_time = 0;
498 if (event_window == window)
500 if (event == ECORE_EVENT_MOUSE_BUTTON_DOWN)
502 //Check Double Clicked
503 if (((int)(timestamp - down_info->last_time) <=
504 (int)(1000 * _ecore_x_double_click_time)) &&
505 (window == down_info->last_win) &&
506 (event_window == down_info->last_event_win))
509 down_info->did_double = EINA_TRUE;
513 down_info->did_double = EINA_FALSE;
514 down_info->did_triple = EINA_FALSE;
517 //Check Triple Clicked
518 if (((int)(timestamp - down_info->last_last_time) <=
519 (int)(2 * 1000 * _ecore_x_double_click_time)) &&
520 (window == down_info->last_win) &&
521 (window == down_info->last_last_win) &&
522 (event_window == down_info->last_event_win) &&
523 (event_window == down_info->last_last_event_win)
527 down_info->did_triple = EINA_TRUE;
531 down_info->did_triple = EINA_FALSE;
534 else if (event == ECORE_EVENT_MOUSE_BUTTON_UP)
536 if (down_info->did_double)
538 if (down_info->did_triple)
544 /* NB: Block commented out as _ecore_x_mouse_up_count appears to have
545 * no use. The variable is also commented out above. This code block is
546 * the only place that this variable is used, and appears to serve no
548 if (event == ECORE_EVENT_MOUSE_BUTTON_DOWN
551 _ecore_x_mouse_up_count = 0;
554 e->multi.device = dev;
555 e->multi.radius = (radx + rady) / 2;
556 e->multi.radius_x = radx;
557 e->multi.radius_y = rady;
558 e->multi.pressure = pressure;
559 e->multi.angle = angle;
562 e->multi.root.x = mrx;
563 e->multi.root.y = mry;
565 _ecore_x_event_last_time = e->timestamp;
566 _ecore_x_event_last_win = e->window;
567 _ecore_x_event_last_root_x = x_root;
568 _ecore_x_event_last_root_y = y_root;
570 ecore_event_add(event, e, NULL, NULL);
573 (event == ECORE_EVENT_MOUSE_BUTTON_DOWN) &&
574 (window == event_window) &&
575 (!down_info->did_triple))
577 down_info->last_last_win = down_info->last_win;
578 down_info->last_win = window;
579 down_info->last_last_event_win = down_info->last_event_win;
580 down_info->last_event_win = event_window;
581 down_info->last_last_time = down_info->last_time;
582 down_info->last_time = timestamp;
589 _ecore_x_event_handle_any_event(XEvent *xevent)
591 XEvent *ev = malloc(sizeof(XEvent));
593 memcpy(ev, xevent, sizeof(XEvent));
594 ecore_event_add(ECORE_X_EVENT_ANY, ev, NULL, NULL);
598 _ecore_x_event_handle_key_press(XEvent *xevent)
600 _ecore_key_press(ECORE_EVENT_KEY_DOWN, (XKeyEvent *)xevent);
604 _ecore_x_event_handle_key_release(XEvent *xevent)
606 _ecore_key_press(ECORE_EVENT_KEY_UP, (XKeyEvent *)xevent);
610 _ecore_x_event_handle_button_press(XEvent *xevent)
614 INF("ButtonEvent:press time=%u x=%d y=%d button=%d", (unsigned int)xevent->xbutton.time, (int)xevent->xbutton.x, (int)xevent->xbutton.y, xevent->xbutton.button);
616 _ecore_x_last_event_mouse_move = 0;
617 if ((xevent->xbutton.button > 3) && (xevent->xbutton.button < 8))
619 Ecore_Event_Mouse_Wheel *e;
621 e = calloc(1, sizeof(Ecore_Event_Mouse_Wheel));
625 e->timestamp = xevent->xbutton.time;
626 e->modifiers = _ecore_x_event_modifiers(xevent->xbutton.state);
627 switch (xevent->xbutton.button)
629 case 4: e->direction = 0; e->z = -1; break;
631 case 5: e->direction = 0; e->z = 1; break;
633 case 6: e->direction = 1; e->z = -1; break;
635 case 7: e->direction = 1; e->z = 1; break;
637 default: e->direction = 0; e->z = 0; break;
640 e->x = xevent->xbutton.x;
641 e->y = xevent->xbutton.y;
642 e->root.x = xevent->xbutton.x_root;
643 e->root.y = xevent->xbutton.y_root;
645 if (xevent->xbutton.subwindow)
646 e->window = xevent->xbutton.subwindow;
648 e->window = xevent->xbutton.window;
650 e->event_window = xevent->xbutton.window;
651 e->same_screen = xevent->xbutton.same_screen;
652 e->root_window = xevent->xbutton.root;
654 _ecore_x_event_last_time = e->timestamp;
655 _ecore_x_event_last_win = e->window;
656 _ecore_x_event_last_root_x = xevent->xbutton.x_root;
657 _ecore_x_event_last_root_y = xevent->xbutton.y_root;
658 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, e, NULL, NULL);
660 for (i = 0; i < _ecore_window_grabs_num; i++)
662 if ((_ecore_window_grabs[i].win == xevent->xbutton.window) ||
663 (_ecore_window_grabs[i].win == xevent->xbutton.subwindow))
665 Eina_Bool replay = EINA_FALSE;
667 if (_ecore_window_grab_replay_func)
668 replay = _ecore_window_grab_replay_func(
669 _ecore_window_grab_replay_data,
670 ECORE_EVENT_MOUSE_WHEEL,
674 XAllowEvents(xevent->xbutton.display,
675 ReplayPointer, xevent->xbutton.time);
677 XAllowEvents(xevent->xbutton.display,
678 AsyncPointer, xevent->xbutton.time);
687 _ecore_mouse_move(xevent->xbutton.time, xevent->xbutton.state,
688 xevent->xbutton.x, xevent->xbutton.y,
689 xevent->xbutton.x_root, xevent->xbutton.y_root,
690 xevent->xbutton.window,
691 (xevent->xbutton.subwindow ? xevent->xbutton.
692 subwindow : xevent->xbutton.window),
693 xevent->xbutton.root,
694 xevent->xbutton.same_screen,
698 xevent->xbutton.x, xevent->xbutton.y,
699 xevent->xbutton.x_root, xevent->xbutton.y_root);
702 Ecore_Event_Mouse_Button *e;
707 (xevent->xbutton.subwindow ? xevent->xbutton.subwindow : xevent->
709 event_window = xevent->xbutton.window;
711 e = _ecore_mouse_button(ECORE_EVENT_MOUSE_BUTTON_DOWN,
712 xevent->xbutton.time,
713 xevent->xbutton.state,
714 xevent->xbutton.button,
717 xevent->xbutton.x_root,
718 xevent->xbutton.y_root,
721 xevent->xbutton.root,
722 xevent->xbutton.same_screen,
732 xevent->xbutton.x_root,
733 xevent->xbutton.y_root);
735 for (i = 0; i < _ecore_window_grabs_num; i++)
737 if ((_ecore_window_grabs[i].win == xevent->xbutton.window) ||
738 (_ecore_window_grabs[i].win == xevent->xbutton.subwindow))
740 Eina_Bool replay = EINA_FALSE;
742 if (_ecore_window_grab_replay_func)
743 replay = _ecore_window_grab_replay_func(
744 _ecore_window_grab_replay_data,
745 ECORE_EVENT_MOUSE_BUTTON_DOWN,
749 XAllowEvents(xevent->xbutton.display,
750 ReplayPointer, xevent->xbutton.time);
752 XAllowEvents(xevent->xbutton.display,
753 AsyncPointer, xevent->xbutton.time);
763 _ecore_x_event_handle_button_release(XEvent *xevent)
765 _ecore_x_last_event_mouse_move = 0;
766 INF("ButtonEvent:release time=%u x=%d y=%d button=%d", (unsigned int)xevent->xbutton.time, (int)xevent->xbutton.x, (int)xevent->xbutton.y, xevent->xbutton.button);
767 /* filter out wheel buttons */
768 if ((xevent->xbutton.button <= 3) || (xevent->xbutton.button > 7))
770 _ecore_mouse_move(xevent->xbutton.time, xevent->xbutton.state,
771 xevent->xbutton.x, xevent->xbutton.y,
772 xevent->xbutton.x_root, xevent->xbutton.y_root,
773 xevent->xbutton.window,
774 (xevent->xbutton.subwindow ? xevent->xbutton.
775 subwindow : xevent->xbutton.window),
776 xevent->xbutton.root,
777 xevent->xbutton.same_screen,
781 xevent->xbutton.x, xevent->xbutton.y,
782 xevent->xbutton.x_root, xevent->xbutton.y_root);
784 _ecore_mouse_button(ECORE_EVENT_MOUSE_BUTTON_UP,
785 xevent->xbutton.time, xevent->xbutton.state,
786 xevent->xbutton.button,
787 xevent->xbutton.x, xevent->xbutton.y,
788 xevent->xbutton.x_root, xevent->xbutton.y_root,
789 xevent->xbutton.window,
790 (xevent->xbutton.subwindow ? xevent->xbutton.
791 subwindow : xevent->xbutton.window),
792 xevent->xbutton.root,
793 xevent->xbutton.same_screen,
797 xevent->xbutton.x, xevent->xbutton.y,
798 xevent->xbutton.x_root, xevent->xbutton.y_root);
803 _ecore_x_event_handle_motion_notify(XEvent *xevent)
806 if (_ecore_x_last_event_mouse_move)
808 ecore_event_del(_ecore_x_last_event_mouse_move_event);
809 _ecore_x_last_event_mouse_move = 0;
810 _ecore_x_last_event_mouse_move_event = NULL;
813 _ecore_mouse_move(xevent->xmotion.time, xevent->xmotion.state,
814 xevent->xmotion.x, xevent->xmotion.y,
815 xevent->xmotion.x_root, xevent->xmotion.y_root,
816 xevent->xmotion.window,
817 (xevent->xmotion.subwindow ? xevent->xmotion.subwindow :
818 xevent->xmotion.window),
819 xevent->xmotion.root,
820 xevent->xmotion.same_screen,
824 xevent->xmotion.x, xevent->xmotion.y,
825 xevent->xmotion.x_root, xevent->xmotion.y_root);
827 _ecore_x_last_event_mouse_move = 1;
830 _ecore_x_dnd_drag(xevent->xmotion.root,
831 xevent->xmotion.x_root,
832 xevent->xmotion.y_root);
836 _ecore_x_event_handle_enter_notify(XEvent *xevent)
838 _ecore_x_last_event_mouse_move = 0;
840 _ecore_mouse_move(xevent->xcrossing.time, xevent->xcrossing.state,
841 xevent->xcrossing.x, xevent->xcrossing.y,
842 xevent->xcrossing.x_root, xevent->xcrossing.y_root,
843 xevent->xcrossing.window,
844 (xevent->xcrossing.subwindow ? xevent->xcrossing.
845 subwindow : xevent->xcrossing.window),
846 xevent->xcrossing.root,
847 xevent->xcrossing.same_screen,
851 xevent->xcrossing.x, xevent->xcrossing.y,
852 xevent->xcrossing.x_root, xevent->xcrossing.y_root);
855 Ecore_X_Event_Mouse_In *e;
857 e = calloc(1, sizeof(Ecore_X_Event_Mouse_In));
861 e->modifiers = _ecore_x_event_modifiers(xevent->xcrossing.state);
862 e->x = xevent->xcrossing.x;
863 e->y = xevent->xcrossing.y;
864 e->root.x = xevent->xcrossing.x_root;
865 e->root.y = xevent->xcrossing.y_root;
866 if (xevent->xcrossing.subwindow)
867 e->win = xevent->xcrossing.subwindow;
869 e->win = xevent->xcrossing.window;
871 e->same_screen = xevent->xcrossing.same_screen;
872 e->root_win = xevent->xcrossing.root;
873 e->event_win = xevent->xcrossing.window;
875 if (xevent->xcrossing.mode == NotifyNormal)
876 e->mode = ECORE_X_EVENT_MODE_NORMAL;
877 else if (xevent->xcrossing.mode == NotifyGrab)
878 e->mode = ECORE_X_EVENT_MODE_GRAB;
879 else if (xevent->xcrossing.mode == NotifyUngrab)
880 e->mode = ECORE_X_EVENT_MODE_UNGRAB;
882 if (xevent->xcrossing.detail == NotifyAncestor)
883 e->detail = ECORE_X_EVENT_DETAIL_ANCESTOR;
884 else if (xevent->xcrossing.detail == NotifyVirtual)
885 e->detail = ECORE_X_EVENT_DETAIL_VIRTUAL;
886 else if (xevent->xcrossing.detail == NotifyInferior)
887 e->detail = ECORE_X_EVENT_DETAIL_INFERIOR;
888 else if (xevent->xcrossing.detail == NotifyNonlinear)
889 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR;
890 else if (xevent->xcrossing.detail == NotifyNonlinearVirtual)
891 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
893 e->time = xevent->xcrossing.time;
894 _ecore_x_event_last_time = e->time;
895 ecore_event_add(ECORE_X_EVENT_MOUSE_IN, e, NULL, NULL);
900 _ecore_x_event_handle_leave_notify(XEvent *xevent)
902 _ecore_x_last_event_mouse_move = 0;
904 _ecore_mouse_move(xevent->xcrossing.time, xevent->xcrossing.state,
905 xevent->xcrossing.x, xevent->xcrossing.y,
906 xevent->xcrossing.x_root, xevent->xcrossing.y_root,
907 xevent->xcrossing.window,
908 (xevent->xcrossing.subwindow ? xevent->xcrossing.
909 subwindow : xevent->xcrossing.window),
910 xevent->xcrossing.root,
911 xevent->xcrossing.same_screen,
915 xevent->xcrossing.x, xevent->xcrossing.y,
916 xevent->xcrossing.x_root, xevent->xcrossing.y_root);
919 Ecore_X_Event_Mouse_Out *e;
921 e = calloc(1, sizeof(Ecore_X_Event_Mouse_Out));
925 e->modifiers = _ecore_x_event_modifiers(xevent->xcrossing.state);
926 e->x = xevent->xcrossing.x;
927 e->y = xevent->xcrossing.y;
928 e->root.x = xevent->xcrossing.x_root;
929 e->root.y = xevent->xcrossing.y_root;
930 if (xevent->xcrossing.subwindow)
931 e->win = xevent->xcrossing.subwindow;
933 e->win = xevent->xcrossing.window;
935 e->same_screen = xevent->xcrossing.same_screen;
936 e->root_win = xevent->xcrossing.root;
937 e->event_win = xevent->xcrossing.window;
939 if (xevent->xcrossing.mode == NotifyNormal)
940 e->mode = ECORE_X_EVENT_MODE_NORMAL;
941 else if (xevent->xcrossing.mode == NotifyGrab)
942 e->mode = ECORE_X_EVENT_MODE_GRAB;
943 else if (xevent->xcrossing.mode == NotifyUngrab)
944 e->mode = ECORE_X_EVENT_MODE_UNGRAB;
946 if (xevent->xcrossing.detail == NotifyAncestor)
947 e->detail = ECORE_X_EVENT_DETAIL_ANCESTOR;
948 else if (xevent->xcrossing.detail == NotifyVirtual)
949 e->detail = ECORE_X_EVENT_DETAIL_VIRTUAL;
950 else if (xevent->xcrossing.detail == NotifyInferior)
951 e->detail = ECORE_X_EVENT_DETAIL_INFERIOR;
952 else if (xevent->xcrossing.detail == NotifyNonlinear)
953 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR;
954 else if (xevent->xcrossing.detail == NotifyNonlinearVirtual)
955 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
957 e->time = xevent->xcrossing.time;
958 _ecore_x_event_last_time = e->time;
959 _ecore_x_event_last_win = e->win;
960 _ecore_x_event_last_root_x = e->root.x;
961 _ecore_x_event_last_root_y = e->root.y;
962 ecore_event_add(ECORE_X_EVENT_MOUSE_OUT, e, NULL, NULL);
967 _ecore_x_event_handle_focus_in(XEvent *xevent)
969 Ecore_X_Event_Window_Focus_In *e;
971 _ecore_x_last_event_mouse_move = 0;
973 e = calloc(1, sizeof(Ecore_X_Event_Window_Focus_In));
977 e->win = xevent->xfocus.window;
979 if (xevent->xfocus.mode == NotifyNormal)
980 e->mode = ECORE_X_EVENT_MODE_NORMAL;
981 else if (xevent->xfocus.mode == NotifyWhileGrabbed)
982 e->mode = ECORE_X_EVENT_MODE_WHILE_GRABBED;
983 else if (xevent->xfocus.mode == NotifyGrab)
984 e->mode = ECORE_X_EVENT_MODE_GRAB;
985 else if (xevent->xfocus.mode == NotifyUngrab)
986 e->mode = ECORE_X_EVENT_MODE_UNGRAB;
988 if (xevent->xfocus.detail == NotifyAncestor)
989 e->detail = ECORE_X_EVENT_DETAIL_ANCESTOR;
990 else if (xevent->xfocus.detail == NotifyVirtual)
991 e->detail = ECORE_X_EVENT_DETAIL_VIRTUAL;
992 else if (xevent->xfocus.detail == NotifyInferior)
993 e->detail = ECORE_X_EVENT_DETAIL_INFERIOR;
994 else if (xevent->xfocus.detail == NotifyNonlinear)
995 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR;
996 else if (xevent->xfocus.detail == NotifyNonlinearVirtual)
997 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
998 else if (xevent->xfocus.detail == NotifyPointer)
999 e->detail = ECORE_X_EVENT_DETAIL_POINTER;
1000 else if (xevent->xfocus.detail == NotifyPointerRoot)
1001 e->detail = ECORE_X_EVENT_DETAIL_POINTER_ROOT;
1002 else if (xevent->xfocus.detail == NotifyDetailNone)
1003 e->detail = ECORE_X_EVENT_DETAIL_DETAIL_NONE;
1005 e->time = _ecore_x_event_last_time;
1006 _ecore_x_event_last_time = e->time;
1007 ecore_event_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, e, NULL, NULL);
1011 _ecore_x_event_handle_focus_out(XEvent *xevent)
1013 Ecore_X_Event_Window_Focus_Out *e;
1015 _ecore_x_last_event_mouse_move = 0;
1017 e = calloc(1, sizeof(Ecore_X_Event_Window_Focus_Out));
1021 e->win = xevent->xfocus.window;
1023 if (xevent->xfocus.mode == NotifyNormal)
1024 e->mode = ECORE_X_EVENT_MODE_NORMAL;
1025 else if (xevent->xfocus.mode == NotifyWhileGrabbed)
1026 e->mode = ECORE_X_EVENT_MODE_WHILE_GRABBED;
1027 else if (xevent->xfocus.mode == NotifyGrab)
1028 e->mode = ECORE_X_EVENT_MODE_GRAB;
1029 else if (xevent->xfocus.mode == NotifyUngrab)
1030 e->mode = ECORE_X_EVENT_MODE_UNGRAB;
1032 if (xevent->xfocus.detail == NotifyAncestor)
1033 e->detail = ECORE_X_EVENT_DETAIL_ANCESTOR;
1034 else if (xevent->xfocus.detail == NotifyVirtual)
1035 e->detail = ECORE_X_EVENT_DETAIL_VIRTUAL;
1036 else if (xevent->xfocus.detail == NotifyInferior)
1037 e->detail = ECORE_X_EVENT_DETAIL_INFERIOR;
1038 else if (xevent->xfocus.detail == NotifyNonlinear)
1039 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR;
1040 else if (xevent->xfocus.detail == NotifyNonlinearVirtual)
1041 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
1042 else if (xevent->xfocus.detail == NotifyPointer)
1043 e->detail = ECORE_X_EVENT_DETAIL_POINTER;
1044 else if (xevent->xfocus.detail == NotifyPointerRoot)
1045 e->detail = ECORE_X_EVENT_DETAIL_POINTER_ROOT;
1046 else if (xevent->xfocus.detail == NotifyDetailNone)
1047 e->detail = ECORE_X_EVENT_DETAIL_DETAIL_NONE;
1049 e->time = _ecore_x_event_last_time;
1050 _ecore_x_event_last_time = e->time;
1051 ecore_event_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, e, NULL, NULL);
1055 _ecore_x_event_handle_keymap_notify(XEvent *xevent EINA_UNUSED)
1057 _ecore_x_last_event_mouse_move = 0;
1058 /* FIXME: handle this event type */
1062 _ecore_x_event_handle_expose(XEvent *xevent)
1064 Ecore_X_Event_Window_Damage *e;
1066 _ecore_x_last_event_mouse_move = 0;
1067 e = calloc(1, sizeof(Ecore_X_Event_Window_Damage));
1071 e->win = xevent->xexpose.window;
1072 e->time = _ecore_x_event_last_time;
1073 e->x = xevent->xexpose.x;
1074 e->y = xevent->xexpose.y;
1075 e->w = xevent->xexpose.width;
1076 e->h = xevent->xexpose.height;
1077 e->count = xevent->xexpose.count;
1078 ecore_event_add(ECORE_X_EVENT_WINDOW_DAMAGE, e, NULL, NULL);
1082 _ecore_x_event_handle_graphics_expose(XEvent *xevent)
1084 Ecore_X_Event_Window_Damage *e;
1086 _ecore_x_last_event_mouse_move = 0;
1087 e = calloc(1, sizeof(Ecore_X_Event_Window_Damage));
1091 e->win = xevent->xgraphicsexpose.drawable;
1092 e->time = _ecore_x_event_last_time;
1093 e->x = xevent->xgraphicsexpose.x;
1094 e->y = xevent->xgraphicsexpose.y;
1095 e->w = xevent->xgraphicsexpose.width;
1096 e->h = xevent->xgraphicsexpose.height;
1097 e->count = xevent->xgraphicsexpose.count;
1098 ecore_event_add(ECORE_X_EVENT_WINDOW_DAMAGE, e, NULL, NULL);
1102 _ecore_x_event_handle_visibility_notify(XEvent *xevent)
1104 _ecore_x_last_event_mouse_move = 0;
1105 // if (xevent->xvisibility.state != VisibilityPartiallyObscured)
1107 Ecore_X_Event_Window_Visibility_Change *e;
1109 e = calloc(1, sizeof(Ecore_X_Event_Window_Visibility_Change));
1113 e->win = xevent->xvisibility.window;
1114 e->time = _ecore_x_event_last_time;
1115 if (xevent->xvisibility.state == VisibilityFullyObscured)
1116 e->fully_obscured = 1;
1118 e->fully_obscured = 0;
1120 ecore_event_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, e, NULL, NULL);
1125 _ecore_x_event_handle_create_notify(XEvent *xevent)
1127 Ecore_X_Event_Window_Create *e;
1129 _ecore_x_last_event_mouse_move = 0;
1130 e = calloc(1, sizeof(Ecore_X_Event_Window_Create));
1134 e->win = xevent->xcreatewindow.window;
1135 e->parent = xevent->xcreatewindow.parent;
1136 if (xevent->xcreatewindow.override_redirect)
1141 e->x = xevent->xcreatewindow.x;
1142 e->y = xevent->xcreatewindow.y;
1143 e->w = xevent->xcreatewindow.width;
1144 e->h = xevent->xcreatewindow.height;
1145 e->border = xevent->xcreatewindow.border_width;
1146 e->time = _ecore_x_event_last_time;
1147 ecore_event_add(ECORE_X_EVENT_WINDOW_CREATE, e, NULL, NULL);
1151 _ecore_x_event_handle_destroy_notify(XEvent *xevent)
1153 Ecore_X_Event_Window_Destroy *e;
1155 _ecore_x_last_event_mouse_move = 0;
1156 e = calloc(1, sizeof(Ecore_X_Event_Window_Destroy));
1160 e->win = xevent->xdestroywindow.window;
1161 e->event_win = xevent->xdestroywindow.event;
1162 e->time = _ecore_x_event_last_time;
1163 if (e->win == _ecore_x_event_last_win)
1164 _ecore_x_event_last_win = 0;
1166 ecore_event_add(ECORE_X_EVENT_WINDOW_DESTROY, e, NULL, NULL);
1167 while (_ecore_x_window_grab_remove(e->win, -1, 0, 0));
1168 while (_ecore_x_key_grab_remove(e->win, NULL, 0, 0));
1172 _ecore_x_event_handle_unmap_notify(XEvent *xevent)
1174 Ecore_X_Event_Window_Hide *e;
1176 _ecore_x_last_event_mouse_move = 0;
1177 e = calloc(1, sizeof(Ecore_X_Event_Window_Hide));
1181 e->win = xevent->xunmap.window;
1182 e->event_win = xevent->xunmap.event;
1183 e->time = _ecore_x_event_last_time;
1184 e->send_event = xevent->xunmap.send_event;
1185 ecore_event_add(ECORE_X_EVENT_WINDOW_HIDE, e, NULL, NULL);
1189 _ecore_x_event_handle_map_notify(XEvent *xevent)
1191 Ecore_X_Event_Window_Show *e;
1193 _ecore_x_last_event_mouse_move = 0;
1194 e = calloc(1, sizeof(Ecore_X_Event_Window_Show));
1198 e->win = xevent->xmap.window;
1199 e->event_win = xevent->xmap.event;
1200 e->time = _ecore_x_event_last_time;
1201 ecore_event_add(ECORE_X_EVENT_WINDOW_SHOW, e, NULL, NULL);
1205 _ecore_x_event_handle_map_request(XEvent *xevent)
1207 Ecore_X_Event_Window_Show_Request *e;
1209 _ecore_x_last_event_mouse_move = 0;
1210 e = calloc(1, sizeof(Ecore_X_Event_Window_Show_Request));
1214 e->win = xevent->xmaprequest.window;
1215 e->time = _ecore_x_event_last_time;
1216 e->parent = xevent->xmaprequest.parent;
1217 ecore_event_add(ECORE_X_EVENT_WINDOW_SHOW_REQUEST, e, NULL, NULL);
1221 _ecore_x_event_handle_reparent_notify(XEvent *xevent)
1223 Ecore_X_Event_Window_Reparent *e;
1225 _ecore_x_last_event_mouse_move = 0;
1226 e = calloc(1, sizeof(Ecore_X_Event_Window_Reparent));
1230 e->win = xevent->xreparent.window;
1231 e->event_win = xevent->xreparent.event;
1232 e->parent = xevent->xreparent.parent;
1233 e->time = _ecore_x_event_last_time;
1234 ecore_event_add(ECORE_X_EVENT_WINDOW_REPARENT, e, NULL, NULL);
1238 _ecore_x_event_handle_configure_notify(XEvent *xevent)
1240 Ecore_X_Event_Window_Configure *e;
1242 _ecore_x_last_event_mouse_move = 0;
1243 e = calloc(1, sizeof(Ecore_X_Event_Window_Configure));
1247 e->win = xevent->xconfigure.window;
1248 e->event_win = xevent->xconfigure.event;
1249 e->abovewin = xevent->xconfigure.above;
1250 e->x = xevent->xconfigure.x;
1251 e->y = xevent->xconfigure.y;
1252 e->w = xevent->xconfigure.width;
1253 e->h = xevent->xconfigure.height;
1254 e->border = xevent->xconfigure.border_width;
1255 e->override = xevent->xconfigure.override_redirect;
1256 e->from_wm = xevent->xconfigure.send_event;
1257 e->time = _ecore_x_event_last_time;
1258 ecore_event_add(ECORE_X_EVENT_WINDOW_CONFIGURE, e, NULL, NULL);
1262 _ecore_x_event_handle_configure_request(XEvent *xevent)
1264 Ecore_X_Event_Window_Configure_Request *e;
1266 _ecore_x_last_event_mouse_move = 0;
1267 e = calloc(1, sizeof(Ecore_X_Event_Window_Configure_Request));
1271 e->win = xevent->xconfigurerequest.window;
1272 e->parent_win = xevent->xconfigurerequest.parent;
1273 e->abovewin = xevent->xconfigurerequest.above;
1274 e->x = xevent->xconfigurerequest.x;
1275 e->y = xevent->xconfigurerequest.y;
1276 e->w = xevent->xconfigurerequest.width;
1277 e->h = xevent->xconfigurerequest.height;
1278 e->border = xevent->xconfigurerequest.border_width;
1279 e->value_mask = xevent->xconfigurerequest.value_mask;
1280 e->time = _ecore_x_event_last_time;
1282 if (xevent->xconfigurerequest.detail == Above)
1283 e->detail = ECORE_X_WINDOW_STACK_ABOVE;
1284 else if (xevent->xconfigurerequest.detail == Below)
1285 e->detail = ECORE_X_WINDOW_STACK_BELOW;
1286 else if (xevent->xconfigurerequest.detail == TopIf)
1287 e->detail = ECORE_X_WINDOW_STACK_TOP_IF;
1288 else if (xevent->xconfigurerequest.detail == BottomIf)
1289 e->detail = ECORE_X_WINDOW_STACK_BOTTOM_IF;
1290 else if (xevent->xconfigurerequest.detail == Opposite)
1291 e->detail = ECORE_X_WINDOW_STACK_OPPOSITE;
1293 ecore_event_add(ECORE_X_EVENT_WINDOW_CONFIGURE_REQUEST, e, NULL, NULL);
1297 _ecore_x_event_handle_gravity_notify(XEvent *xevent EINA_UNUSED)
1299 _ecore_x_last_event_mouse_move = 0;
1300 /* FIXME: handle this event type */
1304 _ecore_x_event_handle_resize_request(XEvent *xevent)
1306 Ecore_X_Event_Window_Resize_Request *e;
1308 _ecore_x_last_event_mouse_move = 0;
1309 e = calloc(1, sizeof(Ecore_X_Event_Window_Resize_Request));
1313 e->win = xevent->xresizerequest.window;
1314 e->w = xevent->xresizerequest.width;
1315 e->h = xevent->xresizerequest.height;
1316 e->time = _ecore_x_event_last_time;
1317 ecore_event_add(ECORE_X_EVENT_WINDOW_RESIZE_REQUEST, e, NULL, NULL);
1321 _ecore_x_event_handle_circulate_notify(XEvent *xevent)
1323 Ecore_X_Event_Window_Stack *e;
1325 _ecore_x_last_event_mouse_move = 0;
1326 e = calloc(1, sizeof(Ecore_X_Event_Window_Stack));
1330 e->win = xevent->xcirculate.window;
1331 e->event_win = xevent->xcirculate.event;
1332 if (xevent->xcirculate.place == PlaceOnTop)
1333 e->detail = ECORE_X_WINDOW_STACK_ABOVE;
1335 e->detail = ECORE_X_WINDOW_STACK_BELOW;
1337 e->time = _ecore_x_event_last_time;
1338 ecore_event_add(ECORE_X_EVENT_WINDOW_STACK, e, NULL, NULL);
1342 _ecore_x_event_handle_circulate_request(XEvent *xevent)
1344 Ecore_X_Event_Window_Stack_Request *e;
1346 _ecore_x_last_event_mouse_move = 0;
1347 e = calloc(1, sizeof(Ecore_X_Event_Window_Stack_Request));
1351 e->win = xevent->xcirculaterequest.window;
1352 e->parent = xevent->xcirculaterequest.parent;
1353 if (xevent->xcirculaterequest.place == PlaceOnTop)
1354 e->detail = ECORE_X_WINDOW_STACK_ABOVE;
1356 e->detail = ECORE_X_WINDOW_STACK_BELOW;
1358 e->time = _ecore_x_event_last_time;
1359 ecore_event_add(ECORE_X_EVENT_WINDOW_STACK_REQUEST, e, NULL, NULL);
1363 _ecore_x_event_handle_property_notify(XEvent *xevent)
1365 _ecore_x_last_event_mouse_move = 0;
1367 Ecore_X_Event_Window_Property *e;
1369 e = calloc(1, sizeof(Ecore_X_Event_Window_Property));
1373 e->win = xevent->xproperty.window;
1374 e->atom = xevent->xproperty.atom;
1375 e->time = xevent->xproperty.time;
1376 e->state = !!xevent->xproperty.state;
1377 _ecore_x_event_last_time = e->time;
1378 ecore_event_add(ECORE_X_EVENT_WINDOW_PROPERTY, e, NULL, NULL);
1383 _ecore_x_event_handle_selection_clear(XEvent *xevent)
1385 Ecore_X_Selection_Intern *d;
1386 Ecore_X_Event_Selection_Clear *e;
1389 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1390 _ecore_x_last_event_mouse_move = 0;
1391 d = _ecore_x_selection_get(xevent->xselectionclear.selection);
1392 if (d && (xevent->xselectionclear.time <= d->time)) return;
1393 /* errr..... why? paranoia.
1394 if (d && (xevent->xselectionclear.time > d->time))
1396 _ecore_x_selection_set(None, NULL, 0,
1397 xevent->xselectionclear.selection);
1400 /* Generate event for app cleanup */
1401 e = malloc(sizeof(Ecore_X_Event_Selection_Clear));
1402 e->win = xevent->xselectionclear.window;
1403 e->time = xevent->xselectionclear.time;
1404 e->atom = sel = xevent->xselectionclear.selection;
1405 if (sel == ECORE_X_ATOM_SELECTION_PRIMARY)
1406 e->selection = ECORE_X_SELECTION_PRIMARY;
1407 else if (sel == ECORE_X_ATOM_SELECTION_SECONDARY)
1408 e->selection = ECORE_X_SELECTION_SECONDARY;
1409 else if (sel == ECORE_X_ATOM_SELECTION_XDND)
1410 e->selection = ECORE_X_SELECTION_XDND;
1411 else if (sel == ECORE_X_ATOM_SELECTION_CLIPBOARD)
1412 e->selection = ECORE_X_SELECTION_CLIPBOARD;
1414 e->selection = ECORE_X_SELECTION_OTHER;
1416 ecore_event_add(ECORE_X_EVENT_SELECTION_CLEAR, e, NULL, NULL);
1420 _ecore_x_event_handle_selection_request(XEvent *xevent)
1422 Ecore_X_Event_Selection_Request *e;
1423 Ecore_X_Selection_Intern *sd;
1428 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1429 _ecore_x_last_event_mouse_move = 0;
1431 * Generate a selection request event.
1433 e = malloc(sizeof(Ecore_X_Event_Selection_Request));
1434 e->owner = xevent->xselectionrequest.owner;
1435 e->requestor = xevent->xselectionrequest.requestor;
1436 e->time = xevent->xselectionrequest.time;
1437 e->selection = xevent->xselectionrequest.selection;
1438 e->target = xevent->xselectionrequest.target;
1439 e->property = xevent->xselectionrequest.property;
1440 ecore_event_add(ECORE_X_EVENT_SELECTION_REQUEST, e, NULL, NULL);
1442 if ((sd = _ecore_x_selection_get(xevent->xselectionrequest.selection)) &&
1443 (sd->win == xevent->xselectionrequest.owner))
1445 Ecore_X_Selection_Intern *si;
1447 si = _ecore_x_selection_get(xevent->xselectionrequest.selection);
1450 Ecore_X_Atom property = None;
1453 /* Set up defaults for strings first */
1454 type = xevent->xselectionrequest.target;
1458 if (!ecore_x_selection_convert(xevent->xselectionrequest.selection,
1459 xevent->xselectionrequest.target,
1460 &data, &len, &type, &typesize))
1461 /* Refuse selection, conversion to requested target failed */
1465 /* FIXME: This does not properly handle large data transfers */
1466 ecore_x_window_prop_property_set(
1467 xevent->xselectionrequest.requestor,
1468 xevent->xselectionrequest.
1474 property = xevent->xselectionrequest.property;
1478 ecore_x_selection_notify_send(xevent->xselectionrequest.requestor,
1479 xevent->xselectionrequest.selection,
1480 xevent->xselectionrequest.target,
1482 xevent->xselectionrequest.time);
1488 _ecore_x_event_handle_selection_notify(XEvent *xevent)
1490 Ecore_X_Event_Selection_Notify *e;
1491 unsigned char *data = NULL;
1492 Ecore_X_Atom selection;
1493 int num_ret, format;
1495 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1496 _ecore_x_last_event_mouse_move = 0;
1497 selection = xevent->xselection.selection;
1499 if (xevent->xselection.target == ECORE_X_ATOM_SELECTION_TARGETS)
1501 format = ecore_x_window_prop_property_get(xevent->xselection.requestor,
1502 xevent->xselection.property,
1503 XA_ATOM, 32, &data, &num_ret);
1506 /* fallback if targets handling is not working and try get the
1507 * selection directly */
1508 XConvertSelection(_ecore_x_disp, selection,
1509 ECORE_X_ATOM_UTF8_STRING,
1511 xevent->xselection.requestor,
1513 if (data) free(data);
1519 format = ecore_x_window_prop_property_get(xevent->xselection.requestor,
1520 xevent->xselection.property,
1521 AnyPropertyType, 8, &data,
1523 if (!format) return;
1526 e = calloc(1, sizeof(Ecore_X_Event_Selection_Notify));
1529 if (data) free(data);
1533 e->win = xevent->xselection.requestor;
1534 e->time = xevent->xselection.time;
1535 e->atom = selection;
1536 e->property = xevent->xselection.property;
1537 e->target = _ecore_x_selection_target_get(xevent->xselection.target);
1539 if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
1540 e->selection = ECORE_X_SELECTION_PRIMARY;
1541 else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
1542 e->selection = ECORE_X_SELECTION_SECONDARY;
1543 else if (selection == ECORE_X_ATOM_SELECTION_XDND)
1544 e->selection = ECORE_X_SELECTION_XDND;
1545 else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
1546 e->selection = ECORE_X_SELECTION_CLIPBOARD;
1548 e->selection = ECORE_X_SELECTION_OTHER;
1550 e->data = _ecore_x_selection_parse(e->target, data, num_ret, format);
1552 ecore_event_add(ECORE_X_EVENT_SELECTION_NOTIFY, e,
1553 _ecore_x_event_free_selection_notify, NULL);
1557 _ecore_x_event_handle_colormap_notify(XEvent *xevent)
1559 Ecore_X_Event_Window_Colormap *e;
1561 _ecore_x_last_event_mouse_move = 0;
1562 e = calloc(1, sizeof(Ecore_X_Event_Window_Colormap));
1566 e->win = xevent->xcolormap.window;
1567 e->cmap = xevent->xcolormap.colormap;
1568 e->time = _ecore_x_event_last_time;
1569 if (xevent->xcolormap.state == ColormapInstalled)
1570 e->installed = EINA_TRUE;
1572 e->installed = EINA_FALSE;
1574 ecore_event_add(ECORE_X_EVENT_WINDOW_COLORMAP, e, NULL, NULL);
1578 _ecore_x_event_handle_client_message(XEvent *xevent)
1580 _ecore_x_last_event_mouse_move = 0;
1581 /* Special client message event handling here. need to put LOTS of if */
1582 /* checks here and generate synthetic events per special message known */
1583 /* otherwise generate generic client message event. this would handle*/
1584 /* netwm, ICCCM, gnomewm, old kde and mwm hint client message protocols */
1585 if ((xevent->xclient.message_type == ECORE_X_ATOM_WM_PROTOCOLS) &&
1586 (xevent->xclient.format == 32) &&
1587 (xevent->xclient.data.l[0] == (long)ECORE_X_ATOM_WM_DELETE_WINDOW))
1589 Ecore_X_Event_Window_Delete_Request *e;
1591 e = calloc(1, sizeof(Ecore_X_Event_Window_Delete_Request));
1595 e->win = xevent->xclient.window;
1596 e->time = _ecore_x_event_last_time;
1597 ecore_event_add(ECORE_X_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL);
1599 else if ((xevent->xclient.message_type == ECORE_X_ATOM_NET_WM_MOVERESIZE) &&
1600 (xevent->xclient.format == 32) &&
1601 /* Ignore move and resize with keyboard */
1602 (xevent->xclient.data.l[2] < 9))
1604 Ecore_X_Event_Window_Move_Resize_Request *e;
1606 e = calloc(1, sizeof(Ecore_X_Event_Window_Move_Resize_Request));
1610 e->win = xevent->xclient.window;
1611 e->x = xevent->xclient.data.l[0];
1612 e->y = xevent->xclient.data.l[1];
1613 e->direction = xevent->xclient.data.l[2];
1614 e->button = xevent->xclient.data.l[3];
1615 e->source = xevent->xclient.data.l[4];
1616 ecore_event_add(ECORE_X_EVENT_WINDOW_MOVE_RESIZE_REQUEST, e, NULL, NULL);
1618 /* Xdnd Client Message Handling Begin */
1619 /* Message Type: XdndEnter target */
1620 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_ENTER)
1622 Ecore_X_Event_Xdnd_Enter *e;
1623 Ecore_X_DND_Target *target;
1625 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Enter));
1628 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1630 target = _ecore_x_dnd_target_get();
1631 target->state = ECORE_X_DND_TARGET_ENTERED;
1632 target->source = xevent->xclient.data.l[0];
1633 target->win = xevent->xclient.window;
1634 target->version = (int)(xevent->xclient.data.l[1] >> 24);
1635 if (target->version > ECORE_X_DND_VERSION)
1637 WRN("DND: Requested version %d, we only support up to %d",
1638 target->version, ECORE_X_DND_VERSION);
1643 if (xevent->xclient.data.l[1] & 0x1UL)
1645 /* source supports more than 3 types, fetch property */
1646 unsigned char *data;
1647 Ecore_X_Atom *types;
1650 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1651 if (!(ecore_x_window_prop_property_get(target->source,
1652 ECORE_X_ATOM_XDND_TYPE_LIST,
1654 32, &data, &num_ret)))
1657 "DND: Could not fetch data type list from source window, aborting.");
1658 if (data) free(data);
1663 types = (Ecore_X_Atom *)data;
1664 e->types = calloc(num_ret, sizeof(char *));
1667 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1668 for (i = 0; i < num_ret; i++)
1669 e->types[i] = XGetAtomName(_ecore_x_disp, types[i]);
1672 e->num_types = num_ret;
1673 if (data) free(data);
1679 e->types = calloc(3, sizeof(char *));
1682 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1683 while ((i < 3) && (xevent->xclient.data.l[i + 2]))
1685 e->types[i] = XGetAtomName(_ecore_x_disp,
1686 xevent->xclient.data.l[i + 2]);
1694 e->win = target->win;
1695 e->source = target->source;
1696 ecore_event_add(ECORE_X_EVENT_XDND_ENTER, e,
1697 _ecore_x_event_free_xdnd_enter, NULL);
1699 /* Message Type: XdndPosition target */
1700 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_POSITION)
1702 Ecore_X_Event_Xdnd_Position *e;
1703 Ecore_X_DND_Target *target;
1705 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1707 target = _ecore_x_dnd_target_get();
1708 if ((target->source != (Ecore_X_Window)xevent->xclient.data.l[0]) ||
1709 (target->win != xevent->xclient.window))
1712 target->pos.x = xevent->xclient.data.l[2] >> 16;
1713 target->pos.y = xevent->xclient.data.l[2] & 0xFFFFUL;
1714 target->action = xevent->xclient.data.l[4]; /* Version 2 */
1716 target->time = (target->version >= 1) ?
1717 (Time)xevent->xclient.data.l[3] : CurrentTime;
1719 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Position));
1722 e->win = target->win;
1723 e->source = target->source;
1724 e->position.x = target->pos.x;
1725 e->position.y = target->pos.y;
1726 e->action = target->action;
1727 ecore_event_add(ECORE_X_EVENT_XDND_POSITION, e, NULL, NULL);
1729 /* Message Type: XdndStatus source */
1730 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_STATUS)
1732 Ecore_X_Event_Xdnd_Status *e;
1733 Ecore_X_DND_Source *source;
1735 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1737 source = _ecore_x_dnd_source_get();
1738 /* Make sure source/target match */
1739 if ((source->win != xevent->xclient.window) ||
1740 (source->dest != (Window)xevent->xclient.data.l[0]))
1743 source->await_status = 0;
1745 source->will_accept = xevent->xclient.data.l[1] & 0x1UL;
1746 source->suppress = (xevent->xclient.data.l[1] & 0x2UL) ? 0 : 1;
1748 source->rectangle.x = xevent->xclient.data.l[2] >> 16;
1749 source->rectangle.y = xevent->xclient.data.l[2] & 0xFFFFUL;
1750 source->rectangle.width = xevent->xclient.data.l[3] >> 16;
1751 source->rectangle.height = xevent->xclient.data.l[3] & 0xFFFFUL;
1753 source->accepted_action = xevent->xclient.data.l[4];
1755 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Status));
1758 e->win = source->win;
1759 e->target = source->dest;
1760 e->will_accept = source->will_accept;
1761 e->rectangle.x = source->rectangle.x;
1762 e->rectangle.y = source->rectangle.y;
1763 e->rectangle.width = source->rectangle.width;
1764 e->rectangle.height = source->rectangle.height;
1765 e->action = source->accepted_action;
1767 ecore_event_add(ECORE_X_EVENT_XDND_STATUS, e, NULL, NULL);
1769 /* Message Type: XdndLeave target */
1770 /* Pretend the whole thing never happened, sort of */
1771 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_LEAVE)
1773 Ecore_X_Event_Xdnd_Leave *e;
1774 Ecore_X_DND_Target *target;
1776 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1778 target = _ecore_x_dnd_target_get();
1779 if ((target->source != (Ecore_X_Window)xevent->xclient.data.l[0]) ||
1780 (target->win != xevent->xclient.window))
1783 target->state = ECORE_X_DND_TARGET_IDLE;
1785 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Leave));
1788 e->win = xevent->xclient.window;
1789 e->source = (Window)xevent->xclient.data.l[0];
1790 ecore_event_add(ECORE_X_EVENT_XDND_LEAVE, e, NULL, NULL);
1792 /* Message Type: XdndDrop target */
1793 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_DROP)
1795 Ecore_X_Event_Xdnd_Drop *e;
1796 Ecore_X_DND_Target *target;
1798 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1800 target = _ecore_x_dnd_target_get();
1801 /* Match source/target */
1802 if ((target->source != (Window)xevent->xclient.data.l[0]) ||
1803 (target->win != xevent->xclient.window))
1806 target->time = (target->version >= 1) ?
1807 (Time)xevent->xclient.data.l[2] : _ecore_x_event_last_time;
1809 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Drop));
1812 e->win = target->win;
1813 e->source = target->source;
1814 e->action = target->action;
1815 e->position.x = target->pos.x;
1816 e->position.y = target->pos.y;
1817 ecore_event_add(ECORE_X_EVENT_XDND_DROP, e, NULL, NULL);
1819 /* Message Type: XdndFinished source */
1820 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_FINISHED)
1822 Ecore_X_Event_Xdnd_Finished *e;
1823 Ecore_X_DND_Source *source;
1824 Eina_Bool completed = EINA_TRUE;
1826 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1828 source = _ecore_x_dnd_source_get();
1829 /* Match source/target */
1830 if ((source->win != xevent->xclient.window) ||
1831 (source->dest != (Window)xevent->xclient.data.l[0]))
1834 if ((source->version < 5) || (xevent->xclient.data.l[1] & 0x1UL))
1836 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1837 /* Target successfully performed drop action */
1838 ecore_x_selection_xdnd_clear();
1839 source->state = ECORE_X_DND_SOURCE_IDLE;
1841 else if (source->version >= 5)
1843 completed = EINA_FALSE;
1844 source->state = ECORE_X_DND_SOURCE_CONVERTING;
1846 /* FIXME: Probably need to add a timer to switch back to idle
1847 * and discard the selection data */
1850 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Finished));
1853 e->win = source->win;
1854 e->target = source->dest;
1855 e->completed = completed;
1856 if (source->version >= 5)
1858 source->accepted_action = xevent->xclient.data.l[2];
1859 e->action = source->accepted_action;
1863 source->accepted_action = 0;
1864 e->action = source->action;
1867 ecore_event_add(ECORE_X_EVENT_XDND_FINISHED, e, NULL, NULL);
1869 else if (xevent->xclient.message_type == ECORE_X_ATOM_NET_WM_STATE)
1871 Ecore_X_Event_Window_State_Request *e;
1873 e = calloc(1, sizeof(Ecore_X_Event_Window_State_Request));
1876 e->win = xevent->xclient.window;
1877 if (xevent->xclient.data.l[0] == 0)
1878 e->action = ECORE_X_WINDOW_STATE_ACTION_REMOVE;
1879 else if (xevent->xclient.data.l[0] == 1)
1880 e->action = ECORE_X_WINDOW_STATE_ACTION_ADD;
1881 else if (xevent->xclient.data.l[0] == 2)
1882 e->action = ECORE_X_WINDOW_STATE_ACTION_TOGGLE;
1889 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1890 e->state[0] = _ecore_x_netwm_state_get(xevent->xclient.data.l[1]);
1891 if (e->state[0] == ECORE_X_WINDOW_STATE_UNKNOWN)
1894 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1896 // name = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[1]);
1897 // if (name) ERR("Unknown state: %s", name);
1900 e->state[1] = _ecore_x_netwm_state_get(xevent->xclient.data.l[2]);
1901 if (e->state[1] == ECORE_X_WINDOW_STATE_UNKNOWN)
1904 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1906 // name = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[2]);
1907 // if (name) ERR("Unknown state: %s", name);
1911 e->source = xevent->xclient.data.l[3];
1913 ecore_event_add(ECORE_X_EVENT_WINDOW_STATE_REQUEST, e, NULL, NULL);
1915 else if ((xevent->xclient.message_type == ECORE_X_ATOM_WM_CHANGE_STATE)
1916 && (xevent->xclient.format == 32)
1917 && (xevent->xclient.data.l[0] == IconicState))
1919 Ecore_X_Event_Window_State_Request *e;
1921 e = calloc(1, sizeof(Ecore_X_Event_Window_State_Request));
1925 e->win = xevent->xclient.window;
1926 e->action = ECORE_X_WINDOW_STATE_ACTION_ADD;
1927 e->state[0] = ECORE_X_WINDOW_STATE_ICONIFIED;
1929 ecore_event_add(ECORE_X_EVENT_WINDOW_STATE_REQUEST, e, NULL, NULL);
1931 else if ((xevent->xclient.message_type == ECORE_X_ATOM_NET_WM_DESKTOP)
1932 && (xevent->xclient.format == 32))
1934 Ecore_X_Event_Desktop_Change *e;
1936 e = calloc(1, sizeof(Ecore_X_Event_Desktop_Change));
1940 e->win = xevent->xclient.window;
1941 e->desk = xevent->xclient.data.l[0];
1942 e->source = xevent->xclient.data.l[1];
1944 ecore_event_add(ECORE_X_EVENT_DESKTOP_CHANGE, e, NULL, NULL);
1946 else if (xevent->xclient.message_type ==
1947 ECORE_X_ATOM_NET_REQUEST_FRAME_EXTENTS)
1949 Ecore_X_Event_Frame_Extents_Request *e;
1951 e = calloc(1, sizeof(Ecore_X_Event_Frame_Extents_Request));
1955 e->win = xevent->xclient.window;
1957 ecore_event_add(ECORE_X_EVENT_FRAME_EXTENTS_REQUEST, e, NULL, NULL);
1959 else if ((xevent->xclient.message_type == ECORE_X_ATOM_WM_PROTOCOLS)
1960 && ((Ecore_X_Atom)xevent->xclient.data.l[0] ==
1961 ECORE_X_ATOM_NET_WM_PING)
1962 && (xevent->xclient.format == 32))
1964 Ecore_X_Event_Ping *e;
1965 Ecore_X_Window root = 0;
1967 e = calloc(1, sizeof(Ecore_X_Event_Ping));
1971 e->win = xevent->xclient.window;
1972 e->time = xevent->xclient.data.l[1];
1973 e->event_win = xevent->xclient.data.l[2];
1975 /* send a reply anyway - we are alive... eventloop at least */
1976 ecore_event_add(ECORE_X_EVENT_PING, e, NULL, NULL);
1977 if (ScreenCount(_ecore_x_disp) > 1)
1979 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1980 root = ecore_x_window_root_get(e->win);
1983 root = DefaultRootWindow(_ecore_x_disp);
1985 if (xevent->xclient.window != root)
1987 xevent->xclient.window = root;
1988 XSendEvent(_ecore_x_disp, root, False,
1989 SubstructureRedirectMask | SubstructureNotifyMask,
1991 if (_ecore_xlib_sync) ecore_x_sync();
1994 else if ((xevent->xclient.message_type ==
1995 ECORE_X_ATOM_NET_STARTUP_INFO_BEGIN) &&
1996 (xevent->xclient.format == 8))
1997 _ecore_x_netwm_startup_info_begin(xevent->xclient.window,
1998 xevent->xclient.data.b);
1999 else if ((xevent->xclient.message_type == ECORE_X_ATOM_NET_STARTUP_INFO) &&
2000 (xevent->xclient.format == 8))
2001 _ecore_x_netwm_startup_info(xevent->xclient.window,
2002 xevent->xclient.data.b);
2003 else if ((xevent->xclient.message_type == 27777)
2004 && (xevent->xclient.data.l[0] == 0x7162534)
2005 && (xevent->xclient.format == 32)
2006 && (xevent->xclient.window == _ecore_x_private_win))
2008 int val = xevent->xclient.data.l[1] & 0xff;
2009 int anymod = (xevent->xclient.data.l[1] >> 8) & 0xff;
2010 int mod = xevent->xclient.data.l[4];
2011 int b = xevent->xclient.data.l[3];
2012 Ecore_X_Window swin = xevent->xclient.data.l[2];
2014 /* a grab sync marker */
2017 _ecore_x_window_grab_remove(swin, b, mod, anymod);
2023 str = ecore_x_keysym_string_get(b);
2024 if (str) _ecore_x_key_grab_remove(swin, str, mod, anymod);
2029 Ecore_X_Event_Client_Message *e;
2032 e = calloc(1, sizeof(Ecore_X_Event_Client_Message));
2036 e->win = xevent->xclient.window;
2037 e->message_type = xevent->xclient.message_type;
2038 e->format = xevent->xclient.format;
2039 e->time = _ecore_x_event_last_time;
2040 for (i = 0; i < 5; i++)
2041 e->data.l[i] = xevent->xclient.data.l[i];
2043 ecore_event_add(ECORE_X_EVENT_CLIENT_MESSAGE, e, NULL, NULL);
2048 _ecore_x_event_handle_mapping_notify(XEvent *xevent)
2050 Ecore_X_Event_Mapping_Change *e;
2052 _ecore_x_last_event_mouse_move = 0;
2054 _ecore_x_window_grab_suspend();
2055 _ecore_x_key_grab_suspend();
2057 XRefreshKeyboardMapping((XMappingEvent *)xevent);
2058 _ecore_x_modifiers_get();
2060 _ecore_x_window_grab_resume();
2061 _ecore_x_key_grab_resume();
2062 e = calloc(1, sizeof(Ecore_X_Event_Mapping_Change));
2064 switch (xevent->xmapping.request)
2066 case MappingModifier:
2067 e->type = ECORE_X_MAPPING_MODIFIER;
2070 case MappingKeyboard:
2071 e->type = ECORE_X_MAPPING_KEYBOARD;
2074 case MappingPointer:
2076 e->type = ECORE_X_MAPPING_MOUSE;
2079 e->keycode = xevent->xmapping.first_keycode;
2080 e->num = xevent->xmapping.count;
2081 ecore_event_add(ECORE_X_EVENT_MAPPING_CHANGE, e, NULL, NULL);
2085 _ecore_x_event_handle_shape_change(XEvent *xevent)
2087 XShapeEvent *shape_event;
2088 Ecore_X_Event_Window_Shape *e;
2090 _ecore_x_last_event_mouse_move = 0;
2091 shape_event = (XShapeEvent *)xevent;
2092 e = calloc(1, sizeof(Ecore_X_Event_Window_Shape));
2096 e->win = shape_event->window;
2097 e->time = shape_event->time;
2098 switch (shape_event->kind)
2101 e->type = ECORE_X_SHAPE_BOUNDING;
2105 e->type = ECORE_X_SHAPE_CLIP;
2109 e->type = ECORE_X_SHAPE_INPUT;
2115 e->x = shape_event->x;
2116 e->y = shape_event->y;
2117 e->w = shape_event->width;
2118 e->h = shape_event->height;
2119 e->shaped = shape_event->shaped;
2120 ecore_event_add(ECORE_X_EVENT_WINDOW_SHAPE, e, NULL, NULL);
2124 _ecore_x_event_handle_screensaver_notify(XEvent *xevent)
2127 XScreenSaverNotifyEvent *screensaver_event;
2128 Ecore_X_Event_Screensaver_Notify *e;
2130 _ecore_x_last_event_mouse_move = 0;
2131 screensaver_event = (XScreenSaverNotifyEvent *)xevent;
2132 e = calloc(1, sizeof(Ecore_X_Event_Screensaver_Notify));
2136 e->win = screensaver_event->window;
2137 if ((screensaver_event->state == ScreenSaverOn) ||
2138 (screensaver_event->state == ScreenSaverCycle))
2143 e->time = screensaver_event->time;
2144 ecore_event_add(ECORE_X_EVENT_SCREENSAVER_NOTIFY, e, NULL, NULL);
2145 #else /* ifdef ECORE_XSS */
2147 #endif /* ifdef ECORE_XSS */
2151 _ecore_x_event_handle_sync_counter(XEvent *xevent)
2153 XSyncCounterNotifyEvent *sync_counter_event;
2154 Ecore_X_Event_Sync_Counter *e;
2156 _ecore_x_last_event_mouse_move = 0;
2157 sync_counter_event = (XSyncCounterNotifyEvent *)xevent;
2158 e = calloc(1, sizeof(Ecore_X_Event_Sync_Counter));
2162 e->time = sync_counter_event->time;
2163 ecore_event_add(ECORE_X_EVENT_SYNC_COUNTER, e, NULL, NULL);
2167 _ecore_x_event_handle_sync_alarm(XEvent *xevent)
2169 XSyncAlarmNotifyEvent *sync_alarm_event;
2170 Ecore_X_Event_Sync_Alarm *e;
2172 _ecore_x_last_event_mouse_move = 0;
2173 sync_alarm_event = (XSyncAlarmNotifyEvent *)xevent;
2175 e = calloc(1, sizeof(Ecore_X_Event_Sync_Alarm));
2179 e->time = sync_alarm_event->time;
2180 e->alarm = sync_alarm_event->alarm;
2181 ecore_event_add(ECORE_X_EVENT_SYNC_ALARM, e, NULL, NULL);
2186 _ecore_x_event_handle_randr_change(XEvent *xevent)
2188 XRRScreenChangeNotifyEvent *randr_event;
2189 Ecore_X_Event_Screen_Change *e;
2191 _ecore_x_last_event_mouse_move = 0;
2192 randr_event = (XRRScreenChangeNotifyEvent *)xevent;
2193 if (!XRRUpdateConfiguration(xevent))
2194 ERR("Can't update RR config!");
2196 e = calloc(1, sizeof(Ecore_X_Event_Screen_Change));
2200 e->win = randr_event->window;
2201 e->root = randr_event->root;
2202 e->size.width = randr_event->width;
2203 e->size.height = randr_event->height;
2204 e->time = randr_event->timestamp;
2205 e->config_time = randr_event->config_timestamp;
2206 e->size.width_mm = randr_event->mwidth;
2207 e->size.height_mm = randr_event->mheight;
2208 e->orientation = randr_event->rotation;
2209 e->subpixel_order = randr_event->subpixel_order;
2210 ecore_event_add(ECORE_X_EVENT_SCREEN_CHANGE, e, NULL, NULL);
2214 _ecore_x_event_handle_randr_notify_crtc_change(const XRRNotifyEvent *xevent)
2216 const XRRCrtcChangeNotifyEvent *randr_event;
2217 Ecore_X_Event_Randr_Crtc_Change *e;
2219 randr_event = (const XRRCrtcChangeNotifyEvent *)xevent;
2221 e = calloc(1, sizeof(Ecore_X_Event_Randr_Crtc_Change));
2225 e->win = randr_event->window;
2226 e->crtc = randr_event->crtc;
2227 e->mode = randr_event->mode;
2228 e->orientation = randr_event->rotation;
2229 e->geo.x = randr_event->x;
2230 e->geo.y = randr_event->y;
2231 e->geo.w = randr_event->width;
2232 e->geo.h = randr_event->height;
2233 ecore_event_add(ECORE_X_EVENT_RANDR_CRTC_CHANGE, e, NULL, NULL);
2237 _ecore_x_event_handle_randr_notify_output_change(const XRRNotifyEvent *xevent)
2239 const XRROutputChangeNotifyEvent *randr_event;
2240 Ecore_X_Event_Randr_Output_Change *e;
2242 randr_event = (const XRROutputChangeNotifyEvent *)xevent;
2244 e = calloc(1, sizeof(Ecore_X_Event_Randr_Output_Change));
2248 e->win = randr_event->window;
2249 e->output = randr_event->output;
2250 e->crtc = randr_event->crtc;
2251 e->mode = randr_event->mode;
2252 e->orientation = randr_event->rotation;
2253 e->connection = randr_event->connection;
2254 e->subpixel_order = randr_event->subpixel_order;
2255 ecore_event_add(ECORE_X_EVENT_RANDR_OUTPUT_CHANGE, e, NULL, NULL);
2259 _ecore_x_event_handle_randr_notify_output_property(const XRRNotifyEvent *xevent)
2261 const XRROutputPropertyNotifyEvent *randr_event;
2262 Ecore_X_Event_Randr_Output_Property_Notify *e;
2264 randr_event = (const XRROutputPropertyNotifyEvent *)xevent;
2266 e = calloc(1, sizeof(Ecore_X_Event_Randr_Output_Property_Notify));
2270 e->win = randr_event->window;
2271 e->output = randr_event->output;
2272 e->property = randr_event->property;
2273 e->time = randr_event->timestamp;
2274 if (randr_event->state == PropertyNewValue)
2275 e->state = ECORE_X_RANDR_PROPERTY_CHANGE_ADD;
2277 e->state = ECORE_X_RANDR_PROPERTY_CHANGE_DEL;
2278 ecore_event_add(ECORE_X_EVENT_RANDR_OUTPUT_PROPERTY_NOTIFY, e, NULL, NULL);
2282 _ecore_x_event_handle_randr_notify(XEvent *xevent)
2284 const XRRNotifyEvent *randr_event;
2286 _ecore_x_last_event_mouse_move = 0;
2287 randr_event = (const XRRNotifyEvent *)xevent;
2288 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2289 switch (randr_event->subtype)
2291 case RRNotify_CrtcChange:
2292 _ecore_x_event_handle_randr_notify_crtc_change(randr_event);
2295 case RRNotify_OutputChange:
2296 _ecore_x_event_handle_randr_notify_output_change(randr_event);
2299 case RRNotify_OutputProperty:
2300 _ecore_x_event_handle_randr_notify_output_property(randr_event);
2304 ERR("Unknown XRandR RRNotify subtype: %d.",
2305 randr_event->subtype);
2310 #endif /* ifdef ECORE_XRANDR */
2314 _ecore_x_event_handle_fixes_selection_notify(XEvent *event)
2316 XFixesSelectionNotifyEvent *notify_event =
2317 (XFixesSelectionNotifyEvent *)event;
2318 Ecore_X_Event_Fixes_Selection_Notify *e;
2321 _ecore_x_last_event_mouse_move = 0;
2322 /* Nothing here yet */
2324 e = calloc(1, sizeof(*e));
2328 e->win = notify_event->window;
2329 e->owner = notify_event->owner;
2330 e->time = notify_event->timestamp;
2331 e->selection_time = notify_event->selection_timestamp;
2332 e->atom = sel = notify_event->selection;
2333 if (sel == ECORE_X_ATOM_SELECTION_PRIMARY)
2334 e->selection = ECORE_X_SELECTION_PRIMARY;
2335 else if (sel == ECORE_X_ATOM_SELECTION_SECONDARY)
2336 e->selection = ECORE_X_SELECTION_SECONDARY;
2337 else if (sel == ECORE_X_ATOM_SELECTION_XDND)
2338 e->selection = ECORE_X_SELECTION_XDND;
2339 else if (sel == ECORE_X_ATOM_SELECTION_CLIPBOARD)
2340 e->selection = ECORE_X_SELECTION_CLIPBOARD;
2342 e->selection = ECORE_X_SELECTION_OTHER;
2343 e->reason = notify_event->subtype;
2345 ecore_event_add(ECORE_X_EVENT_FIXES_SELECTION_NOTIFY, e, NULL, NULL);
2348 #endif /* ifdef ECORE_XFIXES */
2350 #ifdef ECORE_XDAMAGE
2352 _ecore_x_event_handle_damage_notify(XEvent *event)
2354 XDamageNotifyEvent *damage_event;
2355 Ecore_X_Event_Damage *e;
2357 _ecore_x_last_event_mouse_move = 0;
2358 damage_event = (XDamageNotifyEvent *)event;
2360 e = calloc(1, sizeof(Ecore_X_Event_Damage));
2364 e->level = damage_event->level;
2365 e->drawable = damage_event->drawable;
2366 e->damage = damage_event->damage;
2367 e->more = damage_event->more;
2368 e->time = damage_event->timestamp;
2369 e->area.x = damage_event->area.x;
2370 e->area.y = damage_event->area.y;
2371 e->area.width = damage_event->area.width;
2372 e->area.height = damage_event->area.height;
2373 e->geometry.x = damage_event->geometry.x;
2374 e->geometry.y = damage_event->geometry.y;
2375 e->geometry.width = damage_event->geometry.width;
2376 e->geometry.height = damage_event->geometry.height;
2378 ecore_event_add(ECORE_X_EVENT_DAMAGE_NOTIFY, e, NULL, NULL);
2381 #endif /* ifdef ECORE_XDAMAGE */
2384 _ecore_x_event_free_generic_event(void *data,
2387 Ecore_X_Event_Generic *e = (Ecore_X_Event_Generic *)ev;
2392 XFreeEventData(_ecore_x_disp, (XGenericEventCookie *)data);
2399 _ecore_x_event_handle_generic_event(XEvent *event)
2401 XGenericEvent *generic_event;
2402 Ecore_X_Event_Generic *e;
2403 XGenericEventCookie *data;
2405 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2406 generic_event = (XGenericEvent *)event;
2408 #ifdef ECORE_XPRESENT
2409 if (generic_event->extension == _ecore_x_present_major)
2411 _ecore_x_present_handler(generic_event);
2416 e = calloc(1, sizeof(Ecore_X_Event_Generic));
2420 if (XGetEventData(_ecore_x_disp, &(event->xcookie)))
2422 e->cookie = event->xcookie.cookie;
2423 e->data = event->xcookie.data;
2431 e->extension = generic_event->extension;
2432 e->evtype = generic_event->evtype;
2434 if (e->extension == _ecore_x_xi2_opcode)
2435 _ecore_x_input_handler(event);
2436 #endif /* ifdef ECORE_XI2 */
2437 data = malloc(sizeof(XGenericEventCookie));
2438 if (data) memcpy(data, &(event->xcookie), sizeof(XGenericEventCookie));
2439 ecore_event_add(ECORE_X_EVENT_GENERIC,
2441 _ecore_x_event_free_generic_event,
2445 #ifdef ECORE_XGESTURE
2447 _ecore_x_event_handle_gesture_notify_flick(XEvent *xevent)
2449 XGestureNotifyFlickEvent *xfe;
2450 Ecore_X_Event_Gesture_Notify_Flick *e;
2452 _ecore_x_last_event_mouse_move = 0;
2453 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2455 xfe = (XGestureNotifyFlickEvent *)xevent;
2456 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Flick));
2460 e->win = xfe->window;
2461 e->time = xfe->time;
2462 e->subtype = xfe->kind;
2463 e->num_fingers = xfe->num_finger;
2464 e->distance = xfe->distance;
2465 e->duration = xfe->duration;
2466 e->direction = xfe->direction;
2467 e->angle = XFixedToDouble(xfe->angle);
2469 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_FLICK, e, NULL, NULL);
2473 _ecore_x_event_handle_gesture_notify_pan(XEvent *xevent)
2475 XGestureNotifyPanEvent *xpe;
2476 Ecore_X_Event_Gesture_Notify_Pan *e;
2478 _ecore_x_last_event_mouse_move = 0;
2479 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2481 xpe = (XGestureNotifyPanEvent *)xevent;
2482 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Pan));
2486 e->win = xpe->window;
2487 e->time = xpe->time;
2488 e->subtype = xpe->kind;
2489 e->num_fingers = xpe->num_finger;
2492 e->distance = xpe->distance;
2493 e->duration = xpe->duration;
2494 e->direction = xpe->direction;
2496 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_PAN, e, NULL, NULL);
2500 _ecore_x_event_handle_gesture_notify_pinchrotation(XEvent *xevent)
2502 XGestureNotifyPinchRotationEvent *xpre;
2503 Ecore_X_Event_Gesture_Notify_PinchRotation *e;
2505 _ecore_x_last_event_mouse_move = 0;
2506 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2508 xpre = (XGestureNotifyPinchRotationEvent *)xevent;
2509 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_PinchRotation));
2513 e->win = xpre->window;
2514 e->time = xpre->time;
2515 e->subtype = xpre->kind;
2516 e->num_fingers = xpre->num_finger;
2517 e->distance = xpre->distance;
2520 e->zoom = XFixedToDouble(xpre->zoom);
2521 e->angle = XFixedToDouble(xpre->angle);
2523 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION, e, NULL, NULL);
2527 _ecore_x_event_handle_gesture_notify_tap(XEvent *xevent)
2529 XGestureNotifyTapEvent *xte;
2530 Ecore_X_Event_Gesture_Notify_Tap *e;
2532 _ecore_x_last_event_mouse_move = 0;
2533 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2535 xte = (XGestureNotifyTapEvent *)xevent;
2536 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Tap));
2540 e->win = xte->window;
2541 e->time = xte->time;
2542 e->subtype = xte->kind;
2543 e->num_fingers = xte->num_finger;
2546 e->tap_repeat = xte->tap_repeat;
2547 e->interval = xte->interval;
2549 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAP, e, NULL, NULL);
2553 _ecore_x_event_handle_gesture_notify_tapnhold(XEvent *xevent)
2555 XGestureNotifyTapNHoldEvent *xthe;
2556 Ecore_X_Event_Gesture_Notify_TapNHold *e;
2558 _ecore_x_last_event_mouse_move = 0;
2559 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2561 xthe = (XGestureNotifyTapNHoldEvent *)xevent;
2562 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_TapNHold));
2566 e->win = xthe->window;
2567 e->time = xthe->time;
2568 e->subtype = xthe->kind;
2569 e->num_fingers = xthe->num_finger;
2572 e->interval = xthe->interval;
2573 e->hold_time = xthe->holdtime;
2575 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD, e, NULL, NULL);
2579 _ecore_x_event_handle_gesture_notify_hold(XEvent *xevent)
2581 XGestureNotifyHoldEvent *xhe;
2582 Ecore_X_Event_Gesture_Notify_Hold *e;
2584 _ecore_x_last_event_mouse_move = 0;
2585 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2587 xhe = (XGestureNotifyHoldEvent *)xevent;
2588 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Hold));
2592 e->win = xhe->window;
2593 e->time = xhe->time;
2594 e->subtype = xhe->kind;
2595 e->num_fingers = xhe->num_finger;
2598 e->hold_time = xhe->holdtime;
2600 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_HOLD, e, NULL, NULL);
2604 _ecore_x_event_handle_gesture_notify_group(XEvent *xevent)
2606 XGestureNotifyGroupEvent *xge;
2607 Ecore_X_Event_Gesture_Notify_Group *e;
2609 _ecore_x_last_event_mouse_move = 0;
2610 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2612 xge = (XGestureNotifyGroupEvent *)xevent;
2613 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Group));
2617 e->win = xge->window;
2618 e->time = xge->time;
2619 e->subtype = xge->kind;
2620 e->num_groups = xge->num_group;
2621 e->group_id = xge->groupid;
2623 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_GROUP, e, NULL, NULL);
2626 #endif /* ifdef ECORE_XGESTURE */
2630 free_hash(void *userdata EINA_UNUSED, void *funcdata EINA_UNUSED)
2632 eina_hash_del_by_data(emitted_events, (void*) 1);
2636 _ecore_x_event_handle_xkb(XEvent *xevent)
2640 xkbev = (XkbEvent *) xevent;
2643 if (xkbev->any.xkb_type == XkbStateNotify)
2645 Ecore_X_Event_Xkb *e;
2647 if (eina_hash_find(emitted_events, &xkbev->state.serial)) return;
2649 e = calloc(1, sizeof(Ecore_X_Event_Xkb));
2653 e->group = xkbev->state.group;
2654 ecore_event_add(ECORE_X_EVENT_XKB_STATE_NOTIFY, e, free_hash, NULL);
2655 eina_hash_add(emitted_events, &xkbev->state.serial, (void*) 1);
2657 else if ((xkbev->any.xkb_type == XkbNewKeyboardNotify) ||
2658 (xkbev->any.xkb_type == XkbMapNotify))
2660 if (eina_hash_find(emitted_events, &xkbev->state.serial)) return;
2662 if (xkbev->any.xkb_type == XkbMapNotify)
2664 XkbMapNotifyEvent *xkbmapping;
2666 xkbmapping = (XkbMapNotifyEvent *)xkbev;
2667 XkbRefreshKeyboardMapping(xkbmapping);
2669 ecore_event_add(ECORE_X_EVENT_XKB_NEWKBD_NOTIFY, NULL, free_hash, NULL);
2670 eina_hash_add(emitted_events, &xkbev->new_kbd.serial, (void*) 1);
2673 #endif /* ifdef ECORE_XKB */