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 _ecore_x_mouse_down_info_clear(void)
46 Eina_Inlist *l = _ecore_x_mouse_down_info_list;
47 Ecore_X_Mouse_Down_Info *info = NULL;
50 info = EINA_INLIST_CONTAINER_GET(l, Ecore_X_Mouse_Down_Info);
51 l = eina_inlist_remove(l, l);
54 _ecore_x_mouse_down_info_list = NULL;
58 _ecore_x_events_init(void)
60 //Actually, Nothing to do.
64 _ecore_x_events_shutdown(void)
66 _ecore_x_mouse_down_info_clear();
69 static Ecore_X_Mouse_Down_Info *
70 _ecore_x_mouse_down_info_get(int dev)
72 Eina_Inlist *l = _ecore_x_mouse_down_info_list;
73 Ecore_X_Mouse_Down_Info *info = NULL;
75 //Return the exist info
76 EINA_INLIST_FOREACH(l, info)
77 if (info->dev == dev) return info;
80 info = calloc(1, sizeof(Ecore_X_Mouse_Down_Info));
81 if (!info) return NULL;
84 l = eina_inlist_append(l, (Eina_Inlist *)info);
85 _ecore_x_mouse_down_info_list = l;
90 _ecore_x_event_free_mouse_move(void *data __UNUSED__,
93 Ecore_Event_Mouse_Move *e;
96 if (_ecore_x_last_event_mouse_move)
98 _ecore_x_last_event_mouse_move_event = NULL;
99 _ecore_x_last_event_mouse_move = 0;
106 ecore_x_event_mask_set(Ecore_X_Window w,
107 Ecore_X_Event_Mask mask)
109 XWindowAttributes attr;
110 XSetWindowAttributes s_attr;
112 LOGFN(__FILE__, __LINE__, __FUNCTION__);
114 w = DefaultRootWindow(_ecore_x_disp);
116 memset(&attr, 0, sizeof(XWindowAttributes));
117 XGetWindowAttributes(_ecore_x_disp, w, &attr);
118 s_attr.event_mask = mask | attr.your_event_mask;
119 XChangeWindowAttributes(_ecore_x_disp, w, CWEventMask, &s_attr);
123 ecore_x_event_mask_unset(Ecore_X_Window w,
124 Ecore_X_Event_Mask mask)
126 XWindowAttributes attr;
127 XSetWindowAttributes s_attr;
129 LOGFN(__FILE__, __LINE__, __FUNCTION__);
131 w = DefaultRootWindow(_ecore_x_disp);
133 memset(&attr, 0, sizeof(XWindowAttributes));
134 XGetWindowAttributes(_ecore_x_disp, w, &attr);
135 s_attr.event_mask = attr.your_event_mask & ~mask;
136 XChangeWindowAttributes(_ecore_x_disp, w, CWEventMask, &s_attr);
140 _ecore_x_event_free_xdnd_enter(void *data __UNUSED__,
143 Ecore_X_Event_Xdnd_Enter *e;
147 for (i = 0; i < e->num_types; i++)
154 _ecore_x_event_free_selection_notify(void *data __UNUSED__,
157 Ecore_X_Event_Selection_Notify *e;
158 Ecore_X_Selection_Data *sel;
170 _ecore_x_event_modifiers(unsigned int state)
172 unsigned int modifiers = 0;
174 if (state & ECORE_X_MODIFIER_SHIFT)
175 modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
177 if (state & ECORE_X_MODIFIER_CTRL)
178 modifiers |= ECORE_EVENT_MODIFIER_CTRL;
180 if (state & ECORE_X_MODIFIER_ALT)
181 modifiers |= ECORE_EVENT_MODIFIER_ALT;
183 if (state & ECORE_X_MODIFIER_WIN)
184 modifiers |= ECORE_EVENT_MODIFIER_WIN;
186 if (state & ECORE_X_MODIFIER_MODE)
187 modifiers |= ECORE_EVENT_MODIFIER_MODE;
189 if (state & ECORE_X_LOCK_SCROLL)
190 modifiers |= ECORE_EVENT_LOCK_SCROLL;
192 if (state & ECORE_X_LOCK_NUM)
193 modifiers |= ECORE_EVENT_LOCK_NUM;
195 if (state & ECORE_X_LOCK_CAPS)
196 modifiers |= ECORE_EVENT_LOCK_CAPS;
198 if (state & ECORE_X_LOCK_SHIFT)
199 modifiers |= ECORE_EVENT_LOCK_SHIFT;
205 _ecore_mouse_move(unsigned int timestamp,
206 unsigned int xmodifiers,
211 unsigned int event_window,
213 unsigned int root_win,
225 Ecore_Event_Mouse_Move *e;
228 e = malloc(sizeof(Ecore_Event_Mouse_Move));
233 e->root_window = root_win;
234 e->timestamp = timestamp;
235 e->same_screen = same_screen;
236 e->event_window = event_window;
238 e->modifiers = _ecore_x_event_modifiers(xmodifiers);
244 e->multi.device = dev;
245 e->multi.radius = (radx + rady) / 2;
246 e->multi.radius_x = radx;
247 e->multi.radius_y = rady;
248 e->multi.pressure = pressure;
249 e->multi.angle = angle;
252 e->multi.root.x = mrx;
253 e->multi.root.y = mry;
255 event = ecore_event_add(ECORE_EVENT_MOUSE_MOVE,
257 _ecore_x_event_free_mouse_move,
260 _ecore_x_event_last_time = timestamp;
261 _ecore_x_event_last_win = window;
262 _ecore_x_event_last_root_x = x_root;
263 _ecore_x_event_last_root_y = y_root;
265 _ecore_x_last_event_mouse_move_event = event;
269 _ecore_key_press(int event,
273 char *compose = NULL;
277 char keyname_buffer[256];
278 char compose_buffer[256];
280 XComposeStatus status;
283 _ecore_x_last_event_mouse_move = 0;
284 keyname = XKeysymToString(_ecore_x_XKeycodeToKeysym(xevent->display,
285 xevent->keycode, 0));
288 snprintf(keyname_buffer,
289 sizeof(keyname_buffer),
292 keyname = keyname_buffer;
298 val = XLookupString(xevent,
300 sizeof(compose_buffer),
305 compose_buffer[val] = 0;
306 compose = eina_str_convert(nl_langinfo(CODESET), "UTF-8",
309 ERR("Ecore_X cannot convert input key string '%s' to UTF-8. "
310 "Is Eina built with iconv support?", compose_buffer);
314 key = XKeysymToString(sym);
319 malloc(sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
320 (compose ? strlen(compose) : 0) + 3);
324 e->keyname = (char *)(e + 1);
325 e->key = e->keyname + strlen(keyname) + 1;
326 e->compose = (compose) ? e->key + strlen(key) + 1 : NULL;
327 e->string = e->compose;
329 strcpy((char *)e->keyname, keyname);
330 strcpy((char *)e->key, key);
332 strcpy((char *)e->compose, compose);
334 e->modifiers = _ecore_x_event_modifiers(xevent->state);
336 e->timestamp = xevent->time;
337 e->window = xevent->subwindow ? xevent->subwindow : xevent->window;
338 e->event_window = xevent->window;
339 e->same_screen = xevent->same_screen;
340 e->root_window = xevent->root;
342 ecore_event_add(event, e, NULL, NULL);
344 _ecore_x_event_last_time = e->timestamp;
351 Ecore_Event_Mouse_Button *
352 _ecore_mouse_button(int event,
353 unsigned int timestamp,
354 unsigned int xmodifiers,
355 unsigned int buttons,
360 unsigned int event_window,
362 unsigned int root_win,
374 Ecore_Event_Mouse_Button *e;
376 e = malloc(sizeof(Ecore_Event_Mouse_Button));
381 e->root_window = root_win;
382 e->timestamp = timestamp;
383 e->same_screen = same_screen;
384 e->event_window = event_window;
386 e->buttons = buttons;
387 e->modifiers = _ecore_x_event_modifiers(xmodifiers);
395 Ecore_X_Mouse_Down_Info *down_info = _ecore_x_mouse_down_info_get(dev);
399 if ((event == ECORE_EVENT_MOUSE_BUTTON_DOWN) &&
400 down_info->did_triple)
402 down_info->last_win = 0;
403 down_info->last_last_win = 0;
404 down_info->last_event_win = 0;
405 down_info->last_last_event_win = 0;
406 down_info->last_time = 0;
407 down_info->last_last_time = 0;
409 if (event_window == window)
411 if (event == ECORE_EVENT_MOUSE_BUTTON_DOWN)
413 //Check Double Clicked
414 if (((int)(timestamp - down_info->last_time) <=
415 (int)(1000 * _ecore_x_double_click_time)) &&
416 (window == down_info->last_win) &&
417 (event_window == down_info->last_event_win))
420 down_info->did_double = EINA_TRUE;
424 down_info->did_double = EINA_FALSE;
425 down_info->did_triple = EINA_FALSE;
428 //Check Triple Clicked
429 if (((int)(timestamp - down_info->last_last_time) <=
430 (int)(2 * 1000 * _ecore_x_double_click_time)) &&
431 (window == down_info->last_win) &&
432 (window == down_info->last_last_win) &&
433 (event_window == down_info->last_event_win) &&
434 (event_window == down_info->last_last_event_win)
438 down_info->did_triple = EINA_TRUE;
442 down_info->did_triple = EINA_FALSE;
447 if (down_info->did_double)
449 if (down_info->did_triple)
455 /* NB: Block commented out as _ecore_x_mouse_up_count appears to have
456 * no use. The variable is also commented out above. This code block is
457 * the only place that this variable is used, and appears to serve no
459 if (event == ECORE_EVENT_MOUSE_BUTTON_DOWN
462 _ecore_x_mouse_up_count = 0;
465 e->multi.device = dev;
466 e->multi.radius = (radx + rady) / 2;
467 e->multi.radius_x = radx;
468 e->multi.radius_y = rady;
469 e->multi.pressure = pressure;
470 e->multi.angle = angle;
473 e->multi.root.x = mrx;
474 e->multi.root.y = mry;
476 _ecore_x_event_last_time = e->timestamp;
477 _ecore_x_event_last_win = e->window;
478 _ecore_x_event_last_root_x = x_root;
479 _ecore_x_event_last_root_y = y_root;
481 ecore_event_add(event, e, NULL, NULL);
484 (event == ECORE_EVENT_MOUSE_BUTTON_DOWN) &&
485 (window == event_window) &&
486 (!down_info->did_triple))
488 down_info->last_last_win = down_info->last_win;
489 down_info->last_win = window;
490 down_info->last_last_event_win = down_info->last_event_win;
491 down_info->last_event_win = event_window;
492 down_info->last_last_time = down_info->last_time;
493 down_info->last_time = timestamp;
500 _ecore_x_event_handle_any_event(XEvent *xevent)
502 XEvent *ev = malloc(sizeof(XEvent));
504 memcpy(ev, xevent, sizeof(XEvent));
505 ecore_event_add(ECORE_X_EVENT_ANY, ev, NULL, NULL);
509 _ecore_x_event_handle_key_press(XEvent *xevent)
511 _ecore_key_press(ECORE_EVENT_KEY_DOWN, (XKeyEvent *)xevent);
515 _ecore_x_event_handle_key_release(XEvent *xevent)
517 _ecore_key_press(ECORE_EVENT_KEY_UP, (XKeyEvent *)xevent);
521 _ecore_x_event_handle_button_press(XEvent *xevent)
525 _ecore_x_last_event_mouse_move = 0;
526 if ((xevent->xbutton.button > 3) && (xevent->xbutton.button < 8))
528 Ecore_Event_Mouse_Wheel *e;
530 e = malloc(sizeof(Ecore_Event_Mouse_Wheel));
534 e->timestamp = xevent->xbutton.time;
535 e->modifiers = _ecore_x_event_modifiers(xevent->xbutton.state);
536 switch (xevent->xbutton.button)
538 case 4: e->direction = 0; e->z = -1; break;
540 case 5: e->direction = 0; e->z = 1; break;
542 case 6: e->direction = 1; e->z = -1; break;
544 case 7: e->direction = 1; e->z = 1; break;
546 default: e->direction = 0; e->z = 0; break;
549 e->x = xevent->xbutton.x;
550 e->y = xevent->xbutton.y;
551 e->root.x = xevent->xbutton.x_root;
552 e->root.y = xevent->xbutton.y_root;
554 if (xevent->xbutton.subwindow)
555 e->window = xevent->xbutton.subwindow;
557 e->window = xevent->xbutton.window;
559 e->event_window = xevent->xbutton.window;
560 e->same_screen = xevent->xbutton.same_screen;
561 e->root_window = xevent->xbutton.root;
563 _ecore_x_event_last_time = e->timestamp;
564 _ecore_x_event_last_win = e->window;
565 _ecore_x_event_last_root_x = xevent->xbutton.x_root;
566 _ecore_x_event_last_root_y = xevent->xbutton.y_root;
567 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, e, NULL, NULL);
569 for (i = 0; i < _ecore_window_grabs_num; i++)
571 if ((_ecore_window_grabs[i] == xevent->xbutton.window) ||
572 (_ecore_window_grabs[i] == xevent->xbutton.subwindow))
574 Eina_Bool replay = EINA_FALSE;
576 if (_ecore_window_grab_replay_func)
577 replay = _ecore_window_grab_replay_func(
578 _ecore_window_grab_replay_data,
579 ECORE_EVENT_MOUSE_WHEEL,
583 XAllowEvents(xevent->xbutton.display,
584 ReplayPointer, xevent->xbutton.time);
586 XAllowEvents(xevent->xbutton.display,
587 AsyncPointer, xevent->xbutton.time);
596 _ecore_mouse_move(xevent->xbutton.time, xevent->xbutton.state,
597 xevent->xbutton.x, xevent->xbutton.y,
598 xevent->xbutton.x_root, xevent->xbutton.y_root,
599 xevent->xbutton.window,
600 (xevent->xbutton.subwindow ? xevent->xbutton.
601 subwindow : xevent->xbutton.window),
602 xevent->xbutton.root,
603 xevent->xbutton.same_screen,
607 xevent->xbutton.x, xevent->xbutton.y,
608 xevent->xbutton.x_root, xevent->xbutton.y_root);
611 Ecore_Event_Mouse_Button *e;
616 (xevent->xbutton.subwindow ? xevent->xbutton.subwindow : xevent->
618 event_window = xevent->xbutton.window;
620 e = _ecore_mouse_button(ECORE_EVENT_MOUSE_BUTTON_DOWN,
621 xevent->xbutton.time,
622 xevent->xbutton.state,
623 xevent->xbutton.button,
626 xevent->xbutton.x_root,
627 xevent->xbutton.y_root,
630 xevent->xbutton.root,
631 xevent->xbutton.same_screen,
641 xevent->xbutton.x_root,
642 xevent->xbutton.y_root);
644 for (i = 0; i < _ecore_window_grabs_num; i++)
646 if ((_ecore_window_grabs[i] == xevent->xbutton.window) ||
647 (_ecore_window_grabs[i] == xevent->xbutton.subwindow))
649 Eina_Bool replay = EINA_FALSE;
651 if (_ecore_window_grab_replay_func)
652 replay = _ecore_window_grab_replay_func(
653 _ecore_window_grab_replay_data,
654 ECORE_EVENT_MOUSE_BUTTON_DOWN,
658 XAllowEvents(xevent->xbutton.display,
659 ReplayPointer, xevent->xbutton.time);
661 XAllowEvents(xevent->xbutton.display,
662 AsyncPointer, xevent->xbutton.time);
672 _ecore_x_event_handle_button_release(XEvent *xevent)
674 _ecore_x_last_event_mouse_move = 0;
675 /* filter out wheel buttons */
676 if ((xevent->xbutton.button <= 3) || (xevent->xbutton.button > 7))
678 _ecore_mouse_move(xevent->xbutton.time, xevent->xbutton.state,
679 xevent->xbutton.x, xevent->xbutton.y,
680 xevent->xbutton.x_root, xevent->xbutton.y_root,
681 xevent->xbutton.window,
682 (xevent->xbutton.subwindow ? xevent->xbutton.
683 subwindow : xevent->xbutton.window),
684 xevent->xbutton.root,
685 xevent->xbutton.same_screen,
689 xevent->xbutton.x, xevent->xbutton.y,
690 xevent->xbutton.x_root, xevent->xbutton.y_root);
692 _ecore_mouse_button(ECORE_EVENT_MOUSE_BUTTON_UP,
693 xevent->xbutton.time, xevent->xbutton.state,
694 xevent->xbutton.button,
695 xevent->xbutton.x, xevent->xbutton.y,
696 xevent->xbutton.x_root, xevent->xbutton.y_root,
697 xevent->xbutton.window,
698 (xevent->xbutton.subwindow ? xevent->xbutton.
699 subwindow : xevent->xbutton.window),
700 xevent->xbutton.root,
701 xevent->xbutton.same_screen,
705 xevent->xbutton.x, xevent->xbutton.y,
706 xevent->xbutton.x_root, xevent->xbutton.y_root);
711 _ecore_x_event_handle_motion_notify(XEvent *xevent)
714 if (_ecore_x_last_event_mouse_move)
716 ecore_event_del(_ecore_x_last_event_mouse_move_event);
717 _ecore_x_last_event_mouse_move = 0;
718 _ecore_x_last_event_mouse_move_event = NULL;
721 _ecore_mouse_move(xevent->xmotion.time, xevent->xmotion.state,
722 xevent->xmotion.x, xevent->xmotion.y,
723 xevent->xmotion.x_root, xevent->xmotion.y_root,
724 xevent->xmotion.window,
725 (xevent->xmotion.subwindow ? xevent->xmotion.subwindow :
726 xevent->xmotion.window),
727 xevent->xmotion.root,
728 xevent->xmotion.same_screen,
732 xevent->xmotion.x, xevent->xmotion.y,
733 xevent->xmotion.x_root, xevent->xmotion.y_root);
735 _ecore_x_last_event_mouse_move = 1;
738 _ecore_x_dnd_drag(xevent->xmotion.root,
739 xevent->xmotion.x_root,
740 xevent->xmotion.y_root);
744 _ecore_x_event_handle_enter_notify(XEvent *xevent)
746 _ecore_x_last_event_mouse_move = 0;
748 _ecore_mouse_move(xevent->xcrossing.time, xevent->xcrossing.state,
749 xevent->xcrossing.x, xevent->xcrossing.y,
750 xevent->xcrossing.x_root, xevent->xcrossing.y_root,
751 xevent->xcrossing.window,
752 (xevent->xcrossing.subwindow ? xevent->xcrossing.
753 subwindow : xevent->xcrossing.window),
754 xevent->xcrossing.root,
755 xevent->xcrossing.same_screen,
759 xevent->xcrossing.x, xevent->xcrossing.y,
760 xevent->xcrossing.x_root, xevent->xcrossing.y_root);
763 Ecore_X_Event_Mouse_In *e;
765 e = calloc(1, sizeof(Ecore_X_Event_Mouse_In));
769 e->modifiers = _ecore_x_event_modifiers(xevent->xcrossing.state);
770 e->x = xevent->xcrossing.x;
771 e->y = xevent->xcrossing.y;
772 e->root.x = xevent->xcrossing.x_root;
773 e->root.y = xevent->xcrossing.y_root;
774 if (xevent->xcrossing.subwindow)
775 e->win = xevent->xcrossing.subwindow;
777 e->win = xevent->xcrossing.window;
779 e->same_screen = xevent->xcrossing.same_screen;
780 e->root_win = xevent->xcrossing.root;
781 e->event_win = xevent->xcrossing.window;
783 if (xevent->xcrossing.mode == NotifyNormal)
784 e->mode = ECORE_X_EVENT_MODE_NORMAL;
785 else if (xevent->xcrossing.mode == NotifyGrab)
786 e->mode = ECORE_X_EVENT_MODE_GRAB;
787 else if (xevent->xcrossing.mode == NotifyUngrab)
788 e->mode = ECORE_X_EVENT_MODE_UNGRAB;
790 if (xevent->xcrossing.detail == NotifyAncestor)
791 e->detail = ECORE_X_EVENT_DETAIL_ANCESTOR;
792 else if (xevent->xcrossing.detail == NotifyVirtual)
793 e->detail = ECORE_X_EVENT_DETAIL_VIRTUAL;
794 else if (xevent->xcrossing.detail == NotifyInferior)
795 e->detail = ECORE_X_EVENT_DETAIL_INFERIOR;
796 else if (xevent->xcrossing.detail == NotifyNonlinear)
797 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR;
798 else if (xevent->xcrossing.detail == NotifyNonlinearVirtual)
799 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
801 e->time = xevent->xcrossing.time;
802 _ecore_x_event_last_time = e->time;
803 ecore_event_add(ECORE_X_EVENT_MOUSE_IN, e, NULL, NULL);
808 _ecore_x_event_handle_leave_notify(XEvent *xevent)
810 _ecore_x_last_event_mouse_move = 0;
812 _ecore_mouse_move(xevent->xcrossing.time, xevent->xcrossing.state,
813 xevent->xcrossing.x, xevent->xcrossing.y,
814 xevent->xcrossing.x_root, xevent->xcrossing.y_root,
815 xevent->xcrossing.window,
816 (xevent->xcrossing.subwindow ? xevent->xcrossing.
817 subwindow : xevent->xcrossing.window),
818 xevent->xcrossing.root,
819 xevent->xcrossing.same_screen,
823 xevent->xcrossing.x, xevent->xcrossing.y,
824 xevent->xcrossing.x_root, xevent->xcrossing.y_root);
827 Ecore_X_Event_Mouse_Out *e;
829 e = calloc(1, sizeof(Ecore_X_Event_Mouse_Out));
833 e->modifiers = _ecore_x_event_modifiers(xevent->xcrossing.state);
834 e->x = xevent->xcrossing.x;
835 e->y = xevent->xcrossing.y;
836 e->root.x = xevent->xcrossing.x_root;
837 e->root.y = xevent->xcrossing.y_root;
838 if (xevent->xcrossing.subwindow)
839 e->win = xevent->xcrossing.subwindow;
841 e->win = xevent->xcrossing.window;
843 e->same_screen = xevent->xcrossing.same_screen;
844 e->root_win = xevent->xcrossing.root;
845 e->event_win = xevent->xcrossing.window;
847 if (xevent->xcrossing.mode == NotifyNormal)
848 e->mode = ECORE_X_EVENT_MODE_NORMAL;
849 else if (xevent->xcrossing.mode == NotifyGrab)
850 e->mode = ECORE_X_EVENT_MODE_GRAB;
851 else if (xevent->xcrossing.mode == NotifyUngrab)
852 e->mode = ECORE_X_EVENT_MODE_UNGRAB;
854 if (xevent->xcrossing.detail == NotifyAncestor)
855 e->detail = ECORE_X_EVENT_DETAIL_ANCESTOR;
856 else if (xevent->xcrossing.detail == NotifyVirtual)
857 e->detail = ECORE_X_EVENT_DETAIL_VIRTUAL;
858 else if (xevent->xcrossing.detail == NotifyInferior)
859 e->detail = ECORE_X_EVENT_DETAIL_INFERIOR;
860 else if (xevent->xcrossing.detail == NotifyNonlinear)
861 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR;
862 else if (xevent->xcrossing.detail == NotifyNonlinearVirtual)
863 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
865 e->time = xevent->xcrossing.time;
866 _ecore_x_event_last_time = e->time;
867 _ecore_x_event_last_win = e->win;
868 _ecore_x_event_last_root_x = e->root.x;
869 _ecore_x_event_last_root_y = e->root.y;
870 ecore_event_add(ECORE_X_EVENT_MOUSE_OUT, e, NULL, NULL);
875 _ecore_x_event_handle_focus_in(XEvent *xevent)
877 Ecore_X_Event_Window_Focus_In *e;
879 _ecore_x_last_event_mouse_move = 0;
881 e = calloc(1, sizeof(Ecore_X_Event_Window_Focus_In));
885 e->win = xevent->xfocus.window;
887 if (xevent->xfocus.mode == NotifyNormal)
888 e->mode = ECORE_X_EVENT_MODE_NORMAL;
889 else if (xevent->xfocus.mode == NotifyWhileGrabbed)
890 e->mode = ECORE_X_EVENT_MODE_WHILE_GRABBED;
891 else if (xevent->xfocus.mode == NotifyGrab)
892 e->mode = ECORE_X_EVENT_MODE_GRAB;
893 else if (xevent->xfocus.mode == NotifyUngrab)
894 e->mode = ECORE_X_EVENT_MODE_UNGRAB;
896 if (xevent->xfocus.detail == NotifyAncestor)
897 e->detail = ECORE_X_EVENT_DETAIL_ANCESTOR;
898 else if (xevent->xfocus.detail == NotifyVirtual)
899 e->detail = ECORE_X_EVENT_DETAIL_VIRTUAL;
900 else if (xevent->xfocus.detail == NotifyInferior)
901 e->detail = ECORE_X_EVENT_DETAIL_INFERIOR;
902 else if (xevent->xfocus.detail == NotifyNonlinear)
903 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR;
904 else if (xevent->xfocus.detail == NotifyNonlinearVirtual)
905 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
906 else if (xevent->xfocus.detail == NotifyPointer)
907 e->detail = ECORE_X_EVENT_DETAIL_POINTER;
908 else if (xevent->xfocus.detail == NotifyPointerRoot)
909 e->detail = ECORE_X_EVENT_DETAIL_POINTER_ROOT;
910 else if (xevent->xfocus.detail == NotifyDetailNone)
911 e->detail = ECORE_X_EVENT_DETAIL_DETAIL_NONE;
913 e->time = _ecore_x_event_last_time;
914 _ecore_x_event_last_time = e->time;
915 ecore_event_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, e, NULL, NULL);
919 _ecore_x_event_handle_focus_out(XEvent *xevent)
921 Ecore_X_Event_Window_Focus_Out *e;
923 _ecore_x_last_event_mouse_move = 0;
925 e = calloc(1, sizeof(Ecore_X_Event_Window_Focus_Out));
929 e->win = xevent->xfocus.window;
931 if (xevent->xfocus.mode == NotifyNormal)
932 e->mode = ECORE_X_EVENT_MODE_NORMAL;
933 else if (xevent->xfocus.mode == NotifyWhileGrabbed)
934 e->mode = ECORE_X_EVENT_MODE_WHILE_GRABBED;
935 else if (xevent->xfocus.mode == NotifyGrab)
936 e->mode = ECORE_X_EVENT_MODE_GRAB;
937 else if (xevent->xfocus.mode == NotifyUngrab)
938 e->mode = ECORE_X_EVENT_MODE_UNGRAB;
940 if (xevent->xfocus.detail == NotifyAncestor)
941 e->detail = ECORE_X_EVENT_DETAIL_ANCESTOR;
942 else if (xevent->xfocus.detail == NotifyVirtual)
943 e->detail = ECORE_X_EVENT_DETAIL_VIRTUAL;
944 else if (xevent->xfocus.detail == NotifyInferior)
945 e->detail = ECORE_X_EVENT_DETAIL_INFERIOR;
946 else if (xevent->xfocus.detail == NotifyNonlinear)
947 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR;
948 else if (xevent->xfocus.detail == NotifyNonlinearVirtual)
949 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
950 else if (xevent->xfocus.detail == NotifyPointer)
951 e->detail = ECORE_X_EVENT_DETAIL_POINTER;
952 else if (xevent->xfocus.detail == NotifyPointerRoot)
953 e->detail = ECORE_X_EVENT_DETAIL_POINTER_ROOT;
954 else if (xevent->xfocus.detail == NotifyDetailNone)
955 e->detail = ECORE_X_EVENT_DETAIL_DETAIL_NONE;
957 e->time = _ecore_x_event_last_time;
958 _ecore_x_event_last_time = e->time;
959 ecore_event_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, e, NULL, NULL);
963 _ecore_x_event_handle_keymap_notify(XEvent *xevent __UNUSED__)
965 _ecore_x_last_event_mouse_move = 0;
966 /* FIXME: handle this event type */
970 _ecore_x_event_handle_expose(XEvent *xevent)
972 Ecore_X_Event_Window_Damage *e;
974 _ecore_x_last_event_mouse_move = 0;
975 e = calloc(1, sizeof(Ecore_X_Event_Window_Damage));
979 e->win = xevent->xexpose.window;
980 e->time = _ecore_x_event_last_time;
981 e->x = xevent->xexpose.x;
982 e->y = xevent->xexpose.y;
983 e->w = xevent->xexpose.width;
984 e->h = xevent->xexpose.height;
985 e->count = xevent->xexpose.count;
986 ecore_event_add(ECORE_X_EVENT_WINDOW_DAMAGE, e, NULL, NULL);
990 _ecore_x_event_handle_graphics_expose(XEvent *xevent)
992 Ecore_X_Event_Window_Damage *e;
994 _ecore_x_last_event_mouse_move = 0;
995 e = calloc(1, sizeof(Ecore_X_Event_Window_Damage));
999 e->win = xevent->xgraphicsexpose.drawable;
1000 e->time = _ecore_x_event_last_time;
1001 e->x = xevent->xgraphicsexpose.x;
1002 e->y = xevent->xgraphicsexpose.y;
1003 e->w = xevent->xgraphicsexpose.width;
1004 e->h = xevent->xgraphicsexpose.height;
1005 e->count = xevent->xgraphicsexpose.count;
1006 ecore_event_add(ECORE_X_EVENT_WINDOW_DAMAGE, e, NULL, NULL);
1010 _ecore_x_event_handle_visibility_notify(XEvent *xevent)
1012 _ecore_x_last_event_mouse_move = 0;
1013 // if (xevent->xvisibility.state != VisibilityPartiallyObscured)
1015 Ecore_X_Event_Window_Visibility_Change *e;
1017 e = calloc(1, sizeof(Ecore_X_Event_Window_Visibility_Change));
1021 e->win = xevent->xvisibility.window;
1022 e->time = _ecore_x_event_last_time;
1023 if (xevent->xvisibility.state == VisibilityFullyObscured)
1024 e->fully_obscured = 1;
1026 e->fully_obscured = 0;
1028 ecore_event_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, e, NULL, NULL);
1033 _ecore_x_event_handle_create_notify(XEvent *xevent)
1035 Ecore_X_Event_Window_Create *e;
1037 _ecore_x_last_event_mouse_move = 0;
1038 e = calloc(1, sizeof(Ecore_X_Event_Window_Create));
1042 e->win = xevent->xcreatewindow.window;
1043 e->parent = xevent->xcreatewindow.parent;
1044 if (xevent->xcreatewindow.override_redirect)
1049 e->x = xevent->xcreatewindow.x;
1050 e->y = xevent->xcreatewindow.y;
1051 e->w = xevent->xcreatewindow.width;
1052 e->h = xevent->xcreatewindow.height;
1053 e->border = xevent->xcreatewindow.border_width;
1054 e->time = _ecore_x_event_last_time;
1055 ecore_event_add(ECORE_X_EVENT_WINDOW_CREATE, e, NULL, NULL);
1059 _ecore_x_event_handle_destroy_notify(XEvent *xevent)
1061 Ecore_X_Event_Window_Destroy *e;
1063 _ecore_x_last_event_mouse_move = 0;
1064 e = calloc(1, sizeof(Ecore_X_Event_Window_Destroy));
1068 e->win = xevent->xdestroywindow.window;
1069 e->event_win = xevent->xdestroywindow.event;
1070 e->time = _ecore_x_event_last_time;
1071 if (e->win == _ecore_x_event_last_win)
1072 _ecore_x_event_last_win = 0;
1074 ecore_event_add(ECORE_X_EVENT_WINDOW_DESTROY, e, NULL, NULL);
1078 _ecore_x_event_handle_unmap_notify(XEvent *xevent)
1080 Ecore_X_Event_Window_Hide *e;
1082 _ecore_x_last_event_mouse_move = 0;
1083 e = calloc(1, sizeof(Ecore_X_Event_Window_Hide));
1087 e->win = xevent->xunmap.window;
1088 e->event_win = xevent->xunmap.event;
1089 e->time = _ecore_x_event_last_time;
1090 ecore_event_add(ECORE_X_EVENT_WINDOW_HIDE, e, NULL, NULL);
1094 _ecore_x_event_handle_map_notify(XEvent *xevent)
1096 Ecore_X_Event_Window_Show *e;
1098 _ecore_x_last_event_mouse_move = 0;
1099 e = calloc(1, sizeof(Ecore_X_Event_Window_Show));
1103 e->win = xevent->xmap.window;
1104 e->event_win = xevent->xmap.event;
1105 e->time = _ecore_x_event_last_time;
1106 ecore_event_add(ECORE_X_EVENT_WINDOW_SHOW, e, NULL, NULL);
1110 _ecore_x_event_handle_map_request(XEvent *xevent)
1112 Ecore_X_Event_Window_Show_Request *e;
1114 _ecore_x_last_event_mouse_move = 0;
1115 e = calloc(1, sizeof(Ecore_X_Event_Window_Show_Request));
1119 e->win = xevent->xmaprequest.window;
1120 e->time = _ecore_x_event_last_time;
1121 e->parent = xevent->xmaprequest.parent;
1122 ecore_event_add(ECORE_X_EVENT_WINDOW_SHOW_REQUEST, e, NULL, NULL);
1126 _ecore_x_event_handle_reparent_notify(XEvent *xevent)
1128 Ecore_X_Event_Window_Reparent *e;
1130 _ecore_x_last_event_mouse_move = 0;
1131 e = calloc(1, sizeof(Ecore_X_Event_Window_Reparent));
1135 e->win = xevent->xreparent.window;
1136 e->event_win = xevent->xreparent.event;
1137 e->parent = xevent->xreparent.parent;
1138 e->time = _ecore_x_event_last_time;
1139 ecore_event_add(ECORE_X_EVENT_WINDOW_REPARENT, e, NULL, NULL);
1143 _ecore_x_event_handle_configure_notify(XEvent *xevent)
1145 Ecore_X_Event_Window_Configure *e;
1147 _ecore_x_last_event_mouse_move = 0;
1148 e = calloc(1, sizeof(Ecore_X_Event_Window_Configure));
1152 e->win = xevent->xconfigure.window;
1153 e->event_win = xevent->xconfigure.event;
1154 e->abovewin = xevent->xconfigure.above;
1155 e->x = xevent->xconfigure.x;
1156 e->y = xevent->xconfigure.y;
1157 e->w = xevent->xconfigure.width;
1158 e->h = xevent->xconfigure.height;
1159 e->border = xevent->xconfigure.border_width;
1160 e->override = xevent->xconfigure.override_redirect;
1161 e->from_wm = xevent->xconfigure.send_event;
1162 e->time = _ecore_x_event_last_time;
1163 ecore_event_add(ECORE_X_EVENT_WINDOW_CONFIGURE, e, NULL, NULL);
1167 _ecore_x_event_handle_configure_request(XEvent *xevent)
1169 Ecore_X_Event_Window_Configure_Request *e;
1171 _ecore_x_last_event_mouse_move = 0;
1172 e = calloc(1, sizeof(Ecore_X_Event_Window_Configure_Request));
1176 e->win = xevent->xconfigurerequest.window;
1177 e->parent_win = xevent->xconfigurerequest.parent;
1178 e->abovewin = xevent->xconfigurerequest.above;
1179 e->x = xevent->xconfigurerequest.x;
1180 e->y = xevent->xconfigurerequest.y;
1181 e->w = xevent->xconfigurerequest.width;
1182 e->h = xevent->xconfigurerequest.height;
1183 e->border = xevent->xconfigurerequest.border_width;
1184 e->value_mask = xevent->xconfigurerequest.value_mask;
1185 e->time = _ecore_x_event_last_time;
1187 if (xevent->xconfigurerequest.detail == Above)
1188 e->detail = ECORE_X_WINDOW_STACK_ABOVE;
1189 else if (xevent->xconfigurerequest.detail == Below)
1190 e->detail = ECORE_X_WINDOW_STACK_BELOW;
1191 else if (xevent->xconfigurerequest.detail == TopIf)
1192 e->detail = ECORE_X_WINDOW_STACK_TOP_IF;
1193 else if (xevent->xconfigurerequest.detail == BottomIf)
1194 e->detail = ECORE_X_WINDOW_STACK_BOTTOM_IF;
1195 else if (xevent->xconfigurerequest.detail == Opposite)
1196 e->detail = ECORE_X_WINDOW_STACK_OPPOSITE;
1198 ecore_event_add(ECORE_X_EVENT_WINDOW_CONFIGURE_REQUEST, e, NULL, NULL);
1202 _ecore_x_event_handle_gravity_notify(XEvent *xevent __UNUSED__)
1204 _ecore_x_last_event_mouse_move = 0;
1205 /* FIXME: handle this event type */
1209 _ecore_x_event_handle_resize_request(XEvent *xevent)
1211 Ecore_X_Event_Window_Resize_Request *e;
1213 _ecore_x_last_event_mouse_move = 0;
1214 e = calloc(1, sizeof(Ecore_X_Event_Window_Resize_Request));
1218 e->win = xevent->xresizerequest.window;
1219 e->w = xevent->xresizerequest.width;
1220 e->h = xevent->xresizerequest.height;
1221 e->time = _ecore_x_event_last_time;
1222 ecore_event_add(ECORE_X_EVENT_WINDOW_RESIZE_REQUEST, e, NULL, NULL);
1226 _ecore_x_event_handle_circulate_notify(XEvent *xevent)
1228 Ecore_X_Event_Window_Stack *e;
1230 _ecore_x_last_event_mouse_move = 0;
1231 e = calloc(1, sizeof(Ecore_X_Event_Window_Stack));
1235 e->win = xevent->xcirculate.window;
1236 e->event_win = xevent->xcirculate.event;
1237 if (xevent->xcirculate.place == PlaceOnTop)
1238 e->detail = ECORE_X_WINDOW_STACK_ABOVE;
1240 e->detail = ECORE_X_WINDOW_STACK_BELOW;
1242 e->time = _ecore_x_event_last_time;
1243 ecore_event_add(ECORE_X_EVENT_WINDOW_STACK, e, NULL, NULL);
1247 _ecore_x_event_handle_circulate_request(XEvent *xevent)
1249 Ecore_X_Event_Window_Stack_Request *e;
1251 _ecore_x_last_event_mouse_move = 0;
1252 e = calloc(1, sizeof(Ecore_X_Event_Window_Stack_Request));
1256 e->win = xevent->xcirculaterequest.window;
1257 e->parent = xevent->xcirculaterequest.parent;
1258 if (xevent->xcirculaterequest.place == PlaceOnTop)
1259 e->detail = ECORE_X_WINDOW_STACK_ABOVE;
1261 e->detail = ECORE_X_WINDOW_STACK_BELOW;
1263 e->time = _ecore_x_event_last_time;
1264 ecore_event_add(ECORE_X_EVENT_WINDOW_STACK_REQUEST, e, NULL, NULL);
1268 _ecore_x_event_handle_property_notify(XEvent *xevent)
1270 _ecore_x_last_event_mouse_move = 0;
1272 Ecore_X_Event_Window_Property *e;
1274 e = calloc(1, sizeof(Ecore_X_Event_Window_Property));
1278 e->win = xevent->xproperty.window;
1279 e->atom = xevent->xproperty.atom;
1280 e->time = xevent->xproperty.time;
1281 _ecore_x_event_last_time = e->time;
1282 ecore_event_add(ECORE_X_EVENT_WINDOW_PROPERTY, e, NULL, NULL);
1287 _ecore_x_event_handle_selection_clear(XEvent *xevent)
1289 // Ecore_X_Selection_Intern *d;
1290 Ecore_X_Event_Selection_Clear *e;
1293 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1294 _ecore_x_last_event_mouse_move = 0;
1295 /* errr..... why? paranoia.
1296 d = _ecore_x_selection_get(xevent->xselectionclear.selection);
1297 if (d && (xevent->xselectionclear.time > d->time))
1299 _ecore_x_selection_set(None, NULL, 0,
1300 xevent->xselectionclear.selection);
1303 /* Generate event for app cleanup */
1304 e = malloc(sizeof(Ecore_X_Event_Selection_Clear));
1305 e->win = xevent->xselectionclear.window;
1306 e->time = xevent->xselectionclear.time;
1307 e->atom = sel = xevent->xselectionclear.selection;
1308 if (sel == ECORE_X_ATOM_SELECTION_PRIMARY)
1309 e->selection = ECORE_X_SELECTION_PRIMARY;
1310 else if (sel == ECORE_X_ATOM_SELECTION_SECONDARY)
1311 e->selection = ECORE_X_SELECTION_SECONDARY;
1312 else if (sel == ECORE_X_ATOM_SELECTION_CLIPBOARD)
1313 e->selection = ECORE_X_SELECTION_CLIPBOARD;
1315 e->selection = ECORE_X_SELECTION_OTHER;
1317 ecore_event_add(ECORE_X_EVENT_SELECTION_CLEAR, e, NULL, NULL);
1321 _ecore_x_event_handle_selection_request(XEvent *xevent)
1323 Ecore_X_Event_Selection_Request *e;
1324 Ecore_X_Selection_Intern *sd;
1329 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1330 _ecore_x_last_event_mouse_move = 0;
1332 * Generate a selection request event.
1334 e = malloc(sizeof(Ecore_X_Event_Selection_Request));
1335 e->owner = xevent->xselectionrequest.owner;
1336 e->requestor = xevent->xselectionrequest.requestor;
1337 e->time = xevent->xselectionrequest.time;
1338 e->selection = xevent->xselectionrequest.selection;
1339 e->target = xevent->xselectionrequest.target;
1340 e->property = xevent->xselectionrequest.property;
1341 ecore_event_add(ECORE_X_EVENT_SELECTION_REQUEST, e, NULL, NULL);
1343 if ((sd = _ecore_x_selection_get(xevent->xselectionrequest.selection)) &&
1344 (sd->win == xevent->xselectionrequest.owner))
1346 Ecore_X_Selection_Intern *si;
1348 si = _ecore_x_selection_get(xevent->xselectionrequest.selection);
1351 Ecore_X_Atom property = None;
1354 /* Set up defaults for strings first */
1355 type = xevent->xselectionrequest.target;
1359 if (!ecore_x_selection_convert(xevent->xselectionrequest.selection,
1360 xevent->xselectionrequest.target,
1361 &data, &len, &type, &typesize))
1362 /* Refuse selection, conversion to requested target failed */
1366 /* FIXME: This does not properly handle large data transfers */
1367 ecore_x_window_prop_property_set(
1368 xevent->xselectionrequest.requestor,
1369 xevent->xselectionrequest.
1375 property = xevent->xselectionrequest.property;
1379 ecore_x_selection_notify_send(xevent->xselectionrequest.requestor,
1380 xevent->xselectionrequest.selection,
1381 xevent->xselectionrequest.target,
1383 xevent->xselectionrequest.time);
1389 _ecore_x_event_handle_selection_notify(XEvent *xevent)
1391 Ecore_X_Event_Selection_Notify *e;
1392 unsigned char *data = NULL;
1393 Ecore_X_Atom selection;
1394 int num_ret, format;
1396 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1397 _ecore_x_last_event_mouse_move = 0;
1398 selection = xevent->xselection.selection;
1400 if (xevent->xselection.target == ECORE_X_ATOM_SELECTION_TARGETS)
1402 format = ecore_x_window_prop_property_get(xevent->xselection.requestor,
1403 xevent->xselection.property,
1404 XA_ATOM, 32, &data, &num_ret);
1410 format = ecore_x_window_prop_property_get(xevent->xselection.requestor,
1411 xevent->xselection.property,
1412 AnyPropertyType, 8, &data,
1418 e = calloc(1, sizeof(Ecore_X_Event_Selection_Notify));
1422 e->win = xevent->xselection.requestor;
1423 e->time = xevent->xselection.time;
1424 e->atom = selection;
1425 e->target = _ecore_x_selection_target_get(xevent->xselection.target);
1427 if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
1428 e->selection = ECORE_X_SELECTION_PRIMARY;
1429 else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
1430 e->selection = ECORE_X_SELECTION_SECONDARY;
1431 else if (selection == ECORE_X_ATOM_SELECTION_XDND)
1432 e->selection = ECORE_X_SELECTION_XDND;
1433 else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
1434 e->selection = ECORE_X_SELECTION_CLIPBOARD;
1436 e->selection = ECORE_X_SELECTION_OTHER;
1438 e->data = _ecore_x_selection_parse(e->target, data, num_ret, format);
1440 ecore_event_add(ECORE_X_EVENT_SELECTION_NOTIFY, e,
1441 _ecore_x_event_free_selection_notify, NULL);
1445 _ecore_x_event_handle_colormap_notify(XEvent *xevent)
1447 Ecore_X_Event_Window_Colormap *e;
1449 _ecore_x_last_event_mouse_move = 0;
1450 e = calloc(1, sizeof(Ecore_X_Event_Window_Colormap));
1454 e->win = xevent->xcolormap.window;
1455 e->cmap = xevent->xcolormap.colormap;
1456 e->time = _ecore_x_event_last_time;
1457 if (xevent->xcolormap.state == ColormapInstalled)
1458 e->installed = EINA_TRUE;
1460 e->installed = EINA_FALSE;
1462 ecore_event_add(ECORE_X_EVENT_WINDOW_COLORMAP, e, NULL, NULL);
1466 _ecore_x_event_handle_client_message(XEvent *xevent)
1468 _ecore_x_last_event_mouse_move = 0;
1469 /* Special client message event handling here. need to put LOTS of if */
1470 /* checks here and generate synthetic events per special message known */
1471 /* otherwise generate generic client message event. this would handle*/
1472 /* netwm, ICCCM, gnomewm, old kde and mwm hint client message protocols */
1473 if ((xevent->xclient.message_type == ECORE_X_ATOM_WM_PROTOCOLS) &&
1474 (xevent->xclient.format == 32) &&
1475 (xevent->xclient.data.l[0] == (long)ECORE_X_ATOM_WM_DELETE_WINDOW))
1477 Ecore_X_Event_Window_Delete_Request *e;
1479 e = calloc(1, sizeof(Ecore_X_Event_Window_Delete_Request));
1483 e->win = xevent->xclient.window;
1484 e->time = _ecore_x_event_last_time;
1485 ecore_event_add(ECORE_X_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL);
1487 else if ((xevent->xclient.message_type == ECORE_X_ATOM_NET_WM_MOVERESIZE) &&
1488 (xevent->xclient.format == 32) &&
1489 /* Ignore move and resize with keyboard */
1490 (xevent->xclient.data.l[2] < 9))
1492 Ecore_X_Event_Window_Move_Resize_Request *e;
1494 e = calloc(1, sizeof(Ecore_X_Event_Window_Move_Resize_Request));
1498 e->win = xevent->xclient.window;
1499 e->x = xevent->xclient.data.l[0];
1500 e->y = xevent->xclient.data.l[1];
1501 e->direction = xevent->xclient.data.l[2];
1502 e->button = xevent->xclient.data.l[3];
1503 e->source = xevent->xclient.data.l[4];
1504 ecore_event_add(ECORE_X_EVENT_WINDOW_MOVE_RESIZE_REQUEST, e, NULL, NULL);
1506 /* Xdnd Client Message Handling Begin */
1507 /* Message Type: XdndEnter target */
1508 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_ENTER)
1510 Ecore_X_Event_Xdnd_Enter *e;
1511 Ecore_X_DND_Target *target;
1513 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Enter));
1516 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1518 target = _ecore_x_dnd_target_get();
1519 target->state = ECORE_X_DND_TARGET_ENTERED;
1520 target->source = xevent->xclient.data.l[0];
1521 target->win = xevent->xclient.window;
1522 target->version = (int)(xevent->xclient.data.l[1] >> 24);
1523 if (target->version > ECORE_X_DND_VERSION)
1525 WRN("DND: Requested version %d, we only support up to %d",
1526 target->version, ECORE_X_DND_VERSION);
1531 if (xevent->xclient.data.l[1] & 0x1UL)
1533 /* source supports more than 3 types, fetch property */
1534 unsigned char *data;
1535 Ecore_X_Atom *types;
1538 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1539 if (!(ecore_x_window_prop_property_get(target->source,
1540 ECORE_X_ATOM_XDND_TYPE_LIST,
1542 32, &data, &num_ret)))
1545 "DND: Could not fetch data type list from source window, aborting.");
1550 types = (Ecore_X_Atom *)data;
1551 e->types = calloc(num_ret, sizeof(char *));
1554 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1555 for (i = 0; i < num_ret; i++)
1556 e->types[i] = XGetAtomName(_ecore_x_disp, types[i]);
1559 e->num_types = num_ret;
1565 e->types = calloc(3, sizeof(char *));
1568 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1569 while ((i < 3) && (xevent->xclient.data.l[i + 2]))
1571 e->types[i] = XGetAtomName(_ecore_x_disp,
1572 xevent->xclient.data.l[i + 2]);
1580 e->win = target->win;
1581 e->source = target->source;
1582 ecore_event_add(ECORE_X_EVENT_XDND_ENTER, e,
1583 _ecore_x_event_free_xdnd_enter, NULL);
1585 /* Message Type: XdndPosition target */
1586 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_POSITION)
1588 Ecore_X_Event_Xdnd_Position *e;
1589 Ecore_X_DND_Target *target;
1591 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1593 target = _ecore_x_dnd_target_get();
1594 if ((target->source != (Ecore_X_Window)xevent->xclient.data.l[0]) ||
1595 (target->win != xevent->xclient.window))
1598 target->pos.x = xevent->xclient.data.l[2] >> 16;
1599 target->pos.y = xevent->xclient.data.l[2] & 0xFFFFUL;
1600 target->action = xevent->xclient.data.l[4]; /* Version 2 */
1602 target->time = (target->version >= 1) ?
1603 (Time)xevent->xclient.data.l[3] : CurrentTime;
1605 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Position));
1608 e->win = target->win;
1609 e->source = target->source;
1610 e->position.x = target->pos.x;
1611 e->position.y = target->pos.y;
1612 e->action = target->action;
1613 ecore_event_add(ECORE_X_EVENT_XDND_POSITION, e, NULL, NULL);
1615 /* Message Type: XdndStatus source */
1616 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_STATUS)
1618 Ecore_X_Event_Xdnd_Status *e;
1619 Ecore_X_DND_Source *source;
1621 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1623 source = _ecore_x_dnd_source_get();
1624 /* Make sure source/target match */
1625 if ((source->win != xevent->xclient.window) ||
1626 (source->dest != (Window)xevent->xclient.data.l[0]))
1629 source->await_status = 0;
1631 source->will_accept = xevent->xclient.data.l[1] & 0x1UL;
1632 source->suppress = (xevent->xclient.data.l[1] & 0x2UL) ? 0 : 1;
1634 source->rectangle.x = xevent->xclient.data.l[2] >> 16;
1635 source->rectangle.y = xevent->xclient.data.l[2] & 0xFFFFUL;
1636 source->rectangle.width = xevent->xclient.data.l[3] >> 16;
1637 source->rectangle.height = xevent->xclient.data.l[3] & 0xFFFFUL;
1639 source->accepted_action = xevent->xclient.data.l[4];
1641 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Status));
1644 e->win = source->win;
1645 e->target = source->dest;
1646 e->will_accept = source->will_accept;
1647 e->rectangle.x = source->rectangle.x;
1648 e->rectangle.y = source->rectangle.y;
1649 e->rectangle.width = source->rectangle.width;
1650 e->rectangle.height = source->rectangle.height;
1651 e->action = source->accepted_action;
1653 ecore_event_add(ECORE_X_EVENT_XDND_STATUS, e, NULL, NULL);
1655 /* Message Type: XdndLeave target */
1656 /* Pretend the whole thing never happened, sort of */
1657 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_LEAVE)
1659 Ecore_X_Event_Xdnd_Leave *e;
1660 Ecore_X_DND_Target *target;
1662 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1664 target = _ecore_x_dnd_target_get();
1665 if ((target->source != (Ecore_X_Window)xevent->xclient.data.l[0]) ||
1666 (target->win != xevent->xclient.window))
1669 target->state = ECORE_X_DND_TARGET_IDLE;
1671 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Leave));
1674 e->win = xevent->xclient.window;
1675 e->source = (Window)xevent->xclient.data.l[0];
1676 ecore_event_add(ECORE_X_EVENT_XDND_LEAVE, e, NULL, NULL);
1678 /* Message Type: XdndDrop target */
1679 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_DROP)
1681 Ecore_X_Event_Xdnd_Drop *e;
1682 Ecore_X_DND_Target *target;
1684 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1686 target = _ecore_x_dnd_target_get();
1687 /* Match source/target */
1688 if ((target->source != (Window)xevent->xclient.data.l[0]) ||
1689 (target->win != xevent->xclient.window))
1692 target->time = (target->version >= 1) ?
1693 (Time)xevent->xclient.data.l[2] : _ecore_x_event_last_time;
1695 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Drop));
1698 e->win = target->win;
1699 e->source = target->source;
1700 e->action = target->action;
1701 e->position.x = target->pos.x;
1702 e->position.y = target->pos.y;
1703 ecore_event_add(ECORE_X_EVENT_XDND_DROP, e, NULL, NULL);
1705 /* Message Type: XdndFinished source */
1706 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_FINISHED)
1708 Ecore_X_Event_Xdnd_Finished *e;
1709 Ecore_X_DND_Source *source;
1710 Eina_Bool completed = EINA_TRUE;
1712 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1714 source = _ecore_x_dnd_source_get();
1715 /* Match source/target */
1716 if ((source->win != xevent->xclient.window) ||
1717 (source->dest != (Window)xevent->xclient.data.l[0]))
1720 if ((source->version < 5) || (xevent->xclient.data.l[1] & 0x1UL))
1722 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1723 /* Target successfully performed drop action */
1724 ecore_x_selection_xdnd_clear();
1725 source->state = ECORE_X_DND_SOURCE_IDLE;
1727 else if (source->version >= 5)
1729 completed = EINA_FALSE;
1730 source->state = ECORE_X_DND_SOURCE_CONVERTING;
1732 /* FIXME: Probably need to add a timer to switch back to idle
1733 * and discard the selection data */
1736 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Finished));
1739 e->win = source->win;
1740 e->target = source->dest;
1741 e->completed = completed;
1742 if (source->version >= 5)
1744 source->accepted_action = xevent->xclient.data.l[2];
1745 e->action = source->accepted_action;
1749 source->accepted_action = 0;
1750 e->action = source->action;
1753 ecore_event_add(ECORE_X_EVENT_XDND_FINISHED, e, NULL, NULL);
1755 else if (xevent->xclient.message_type == ECORE_X_ATOM_NET_WM_STATE)
1757 Ecore_X_Event_Window_State_Request *e;
1759 e = calloc(1, sizeof(Ecore_X_Event_Window_State_Request));
1762 e->win = xevent->xclient.window;
1763 if (xevent->xclient.data.l[0] == 0)
1764 e->action = ECORE_X_WINDOW_STATE_ACTION_REMOVE;
1765 else if (xevent->xclient.data.l[0] == 1)
1766 e->action = ECORE_X_WINDOW_STATE_ACTION_ADD;
1767 else if (xevent->xclient.data.l[0] == 2)
1768 e->action = ECORE_X_WINDOW_STATE_ACTION_TOGGLE;
1775 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1776 e->state[0] = _ecore_x_netwm_state_get(xevent->xclient.data.l[1]);
1777 if (e->state[0] == ECORE_X_WINDOW_STATE_UNKNOWN)
1780 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1782 // name = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[1]);
1783 // if (name) ERR("Unknown state: %s", name);
1786 e->state[1] = _ecore_x_netwm_state_get(xevent->xclient.data.l[2]);
1787 if (e->state[1] == ECORE_X_WINDOW_STATE_UNKNOWN)
1790 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1792 // name = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[2]);
1793 // if (name) ERR("Unknown state: %s", name);
1797 e->source = xevent->xclient.data.l[3];
1799 ecore_event_add(ECORE_X_EVENT_WINDOW_STATE_REQUEST, e, NULL, NULL);
1801 else if ((xevent->xclient.message_type == ECORE_X_ATOM_WM_CHANGE_STATE)
1802 && (xevent->xclient.format == 32)
1803 && (xevent->xclient.data.l[0] == IconicState))
1805 Ecore_X_Event_Window_State_Request *e;
1807 e = calloc(1, sizeof(Ecore_X_Event_Window_State_Request));
1811 e->win = xevent->xclient.window;
1812 e->action = ECORE_X_WINDOW_STATE_ACTION_ADD;
1813 e->state[0] = ECORE_X_WINDOW_STATE_ICONIFIED;
1815 ecore_event_add(ECORE_X_EVENT_WINDOW_STATE_REQUEST, e, NULL, NULL);
1817 else if ((xevent->xclient.message_type == ECORE_X_ATOM_NET_WM_DESKTOP)
1818 && (xevent->xclient.format == 32))
1820 Ecore_X_Event_Desktop_Change *e;
1822 e = calloc(1, sizeof(Ecore_X_Event_Desktop_Change));
1826 e->win = xevent->xclient.window;
1827 e->desk = xevent->xclient.data.l[0];
1828 e->source = xevent->xclient.data.l[1];
1830 ecore_event_add(ECORE_X_EVENT_DESKTOP_CHANGE, e, NULL, NULL);
1832 else if ((xevent->xclient.message_type ==
1833 ECORE_X_ATOM_NET_REQUEST_FRAME_EXTENTS))
1835 Ecore_X_Event_Frame_Extents_Request *e;
1837 e = calloc(1, sizeof(Ecore_X_Event_Frame_Extents_Request));
1841 e->win = xevent->xclient.window;
1843 ecore_event_add(ECORE_X_EVENT_FRAME_EXTENTS_REQUEST, e, NULL, NULL);
1845 else if ((xevent->xclient.message_type == ECORE_X_ATOM_WM_PROTOCOLS)
1846 && ((Ecore_X_Atom)xevent->xclient.data.l[0] ==
1847 ECORE_X_ATOM_NET_WM_PING)
1848 && (xevent->xclient.format == 32))
1850 Ecore_X_Event_Ping *e;
1851 Ecore_X_Window root = 0;
1853 e = calloc(1, sizeof(Ecore_X_Event_Ping));
1857 e->win = xevent->xclient.window;
1858 e->time = xevent->xclient.data.l[1];
1859 e->event_win = xevent->xclient.data.l[2];
1861 /* send a reply anyway - we are alive... eventloop at least */
1862 ecore_event_add(ECORE_X_EVENT_PING, e, NULL, NULL);
1863 if (ScreenCount(_ecore_x_disp) > 1)
1865 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1866 root = ecore_x_window_root_get(e->win);
1869 root = DefaultRootWindow(_ecore_x_disp);
1871 if (xevent->xclient.window != root)
1873 xevent->xclient.window = root;
1874 XSendEvent(_ecore_x_disp, root, False,
1875 SubstructureRedirectMask | SubstructureNotifyMask,
1879 else if ((xevent->xclient.message_type ==
1880 ECORE_X_ATOM_NET_STARTUP_INFO_BEGIN) &&
1881 (xevent->xclient.format == 8))
1882 _ecore_x_netwm_startup_info_begin(xevent->xclient.window,
1883 xevent->xclient.data.b);
1884 else if ((xevent->xclient.message_type == ECORE_X_ATOM_NET_STARTUP_INFO) &&
1885 (xevent->xclient.format == 8))
1886 _ecore_x_netwm_startup_info(xevent->xclient.window,
1887 xevent->xclient.data.b);
1888 else if ((xevent->xclient.message_type == 27777)
1889 && (xevent->xclient.data.l[0] == 0x7162534)
1890 && (xevent->xclient.format == 32)
1891 && (xevent->xclient.window == _ecore_x_private_win))
1893 /* a grab sync marker */
1894 if (xevent->xclient.data.l[1] == 0x10000001)
1895 _ecore_x_window_grab_remove(xevent->xclient.data.l[2]);
1896 else if (xevent->xclient.data.l[1] == 0x10000002)
1897 _ecore_x_key_grab_remove(xevent->xclient.data.l[2]);
1901 Ecore_X_Event_Client_Message *e;
1904 e = calloc(1, sizeof(Ecore_X_Event_Client_Message));
1908 e->win = xevent->xclient.window;
1909 e->message_type = xevent->xclient.message_type;
1910 e->format = xevent->xclient.format;
1911 for (i = 0; i < 5; i++)
1912 e->data.l[i] = xevent->xclient.data.l[i];
1914 ecore_event_add(ECORE_X_EVENT_CLIENT_MESSAGE, e, NULL, NULL);
1919 _ecore_x_event_handle_mapping_notify(XEvent *xevent)
1921 Ecore_X_Event_Mapping_Change *e;
1923 _ecore_x_last_event_mouse_move = 0;
1924 XRefreshKeyboardMapping((XMappingEvent *)xevent);
1925 _ecore_x_modifiers_get();
1926 e = calloc(1, sizeof(Ecore_X_Event_Mapping_Change));
1928 switch (xevent->xmapping.request)
1930 case MappingModifier:
1931 e->type = ECORE_X_MAPPING_MODIFIER;
1934 case MappingKeyboard:
1935 e->type = ECORE_X_MAPPING_KEYBOARD;
1938 case MappingPointer:
1940 e->type = ECORE_X_MAPPING_MOUSE;
1943 e->keycode = xevent->xmapping.first_keycode;
1944 e->num = xevent->xmapping.count;
1945 ecore_event_add(ECORE_X_EVENT_MAPPING_CHANGE, e, NULL, NULL);
1949 _ecore_x_event_handle_shape_change(XEvent *xevent)
1951 XShapeEvent *shape_event;
1952 Ecore_X_Event_Window_Shape *e;
1954 _ecore_x_last_event_mouse_move = 0;
1955 shape_event = (XShapeEvent *)xevent;
1956 e = calloc(1, sizeof(Ecore_X_Event_Window_Shape));
1960 e->win = shape_event->window;
1961 e->time = shape_event->time;
1962 switch (shape_event->kind)
1965 e->type = ECORE_X_SHAPE_BOUNDING;
1969 e->type = ECORE_X_SHAPE_CLIP;
1973 e->type = ECORE_X_SHAPE_INPUT;
1979 e->x = shape_event->x;
1980 e->y = shape_event->y;
1981 e->w = shape_event->width;
1982 e->h = shape_event->height;
1983 e->shaped = shape_event->shaped;
1984 ecore_event_add(ECORE_X_EVENT_WINDOW_SHAPE, e, NULL, NULL);
1988 _ecore_x_event_handle_screensaver_notify(XEvent *xevent)
1991 XScreenSaverNotifyEvent *screensaver_event;
1992 Ecore_X_Event_Screensaver_Notify *e;
1994 _ecore_x_last_event_mouse_move = 0;
1995 screensaver_event = (XScreenSaverNotifyEvent *)xevent;
1996 e = calloc(1, sizeof(Ecore_X_Event_Screensaver_Notify));
2000 e->win = screensaver_event->window;
2001 if (screensaver_event->state == ScreenSaverOn)
2006 e->time = screensaver_event->time;
2007 ecore_event_add(ECORE_X_EVENT_SCREENSAVER_NOTIFY, e, NULL, NULL);
2008 #else /* ifdef ECORE_XSS */
2010 #endif /* ifdef ECORE_XSS */
2014 _ecore_x_event_handle_sync_counter(XEvent *xevent)
2016 XSyncCounterNotifyEvent *sync_counter_event;
2017 Ecore_X_Event_Sync_Counter *e;
2019 _ecore_x_last_event_mouse_move = 0;
2020 sync_counter_event = (XSyncCounterNotifyEvent *)xevent;
2021 e = calloc(1, sizeof(Ecore_X_Event_Sync_Counter));
2025 e->time = sync_counter_event->time;
2026 ecore_event_add(ECORE_X_EVENT_SYNC_COUNTER, e, NULL, NULL);
2030 _ecore_x_event_handle_sync_alarm(XEvent *xevent)
2032 XSyncAlarmNotifyEvent *sync_alarm_event;
2033 Ecore_X_Event_Sync_Alarm *e;
2035 _ecore_x_last_event_mouse_move = 0;
2036 sync_alarm_event = (XSyncAlarmNotifyEvent *)xevent;
2038 e = calloc(1, sizeof(Ecore_X_Event_Sync_Alarm));
2042 e->time = sync_alarm_event->time;
2043 e->alarm = sync_alarm_event->alarm;
2044 ecore_event_add(ECORE_X_EVENT_SYNC_ALARM, e, NULL, NULL);
2049 _ecore_x_event_handle_randr_change(XEvent *xevent)
2051 XRRScreenChangeNotifyEvent *randr_event;
2052 Ecore_X_Event_Screen_Change *e;
2054 _ecore_x_last_event_mouse_move = 0;
2055 randr_event = (XRRScreenChangeNotifyEvent *)xevent;
2056 if (!XRRUpdateConfiguration(xevent))
2057 ERR("Can't update RR config!");
2059 e = calloc(1, sizeof(Ecore_X_Event_Screen_Change));
2063 e->win = randr_event->window;
2064 e->root = randr_event->root;
2065 e->size.width = randr_event->width;
2066 e->size.height = randr_event->height;
2067 e->time = randr_event->timestamp;
2068 e->config_time = randr_event->config_timestamp;
2069 e->size.width_mm = randr_event->mwidth;
2070 e->size.height_mm = randr_event->mheight;
2071 e->orientation = randr_event->rotation;
2072 e->subpixel_order = randr_event->subpixel_order;
2073 ecore_event_add(ECORE_X_EVENT_SCREEN_CHANGE, e, NULL, NULL);
2077 _ecore_x_event_handle_randr_notify_crtc_change(const XRRNotifyEvent *xevent)
2079 const XRRCrtcChangeNotifyEvent *randr_event;
2080 Ecore_X_Event_Randr_Crtc_Change *e;
2082 randr_event = (const XRRCrtcChangeNotifyEvent *)xevent;
2084 e = calloc(1, sizeof(Ecore_X_Event_Randr_Crtc_Change));
2088 e->win = randr_event->window;
2089 e->crtc = randr_event->crtc;
2090 e->mode = randr_event->mode;
2091 e->orientation = randr_event->rotation;
2092 e->geo.x = randr_event->x;
2093 e->geo.y = randr_event->y;
2094 e->geo.w = randr_event->width;
2095 e->geo.h = randr_event->height;
2096 ecore_event_add(ECORE_X_EVENT_RANDR_CRTC_CHANGE, e, NULL, NULL);
2100 _ecore_x_event_handle_randr_notify_output_change(const XRRNotifyEvent *xevent)
2102 const XRROutputChangeNotifyEvent *randr_event;
2103 Ecore_X_Event_Randr_Output_Change *e;
2105 randr_event = (const XRROutputChangeNotifyEvent *)xevent;
2107 e = calloc(1, sizeof(Ecore_X_Event_Randr_Output_Change));
2111 e->win = randr_event->window;
2112 e->output = randr_event->output;
2113 e->crtc = randr_event->crtc;
2114 e->mode = randr_event->mode;
2115 e->orientation = randr_event->rotation;
2116 e->connection = randr_event->connection;
2117 e->subpixel_order = randr_event->subpixel_order;
2118 ecore_event_add(ECORE_X_EVENT_RANDR_OUTPUT_CHANGE, e, NULL, NULL);
2122 _ecore_x_event_handle_randr_notify_output_property(const XRRNotifyEvent *xevent)
2124 const XRROutputPropertyNotifyEvent *randr_event;
2125 Ecore_X_Event_Randr_Output_Property_Notify *e;
2127 randr_event = (const XRROutputPropertyNotifyEvent *)xevent;
2129 e = calloc(1, sizeof(Ecore_X_Event_Randr_Output_Property_Notify));
2133 e->win = randr_event->window;
2134 e->output = randr_event->output;
2135 e->property = randr_event->property;
2136 e->time = randr_event->timestamp;
2137 if (randr_event->state == PropertyNewValue)
2138 e->state = ECORE_X_RANDR_PROPERTY_CHANGE_ADD;
2140 e->state = ECORE_X_RANDR_PROPERTY_CHANGE_DEL;
2141 ecore_event_add(ECORE_X_EVENT_RANDR_OUTPUT_PROPERTY_NOTIFY, e, NULL, NULL);
2145 _ecore_x_event_handle_randr_notify(XEvent *xevent)
2147 const XRRNotifyEvent *randr_event;
2149 _ecore_x_last_event_mouse_move = 0;
2150 randr_event = (const XRRNotifyEvent *)xevent;
2151 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2152 switch (randr_event->subtype)
2154 case RRNotify_CrtcChange:
2155 _ecore_x_event_handle_randr_notify_crtc_change(randr_event);
2158 case RRNotify_OutputChange:
2159 _ecore_x_event_handle_randr_notify_output_change(randr_event);
2162 case RRNotify_OutputProperty:
2163 _ecore_x_event_handle_randr_notify_output_property(randr_event);
2167 ERR("Unknown XRandR RRNotify subtype: %d.",
2168 randr_event->subtype);
2173 #endif /* ifdef ECORE_XRANDR */
2177 _ecore_x_event_handle_fixes_selection_notify(XEvent *event)
2179 XFixesSelectionNotifyEvent *notify_event =
2180 (XFixesSelectionNotifyEvent *)event;
2181 Ecore_X_Event_Fixes_Selection_Notify *e;
2184 _ecore_x_last_event_mouse_move = 0;
2185 /* Nothing here yet */
2187 e = calloc(1, sizeof(*e));
2191 e->win = notify_event->window;
2192 e->owner = notify_event->owner;
2193 e->time = notify_event->timestamp;
2194 e->selection_time = notify_event->selection_timestamp;
2195 e->atom = sel = notify_event->selection;
2196 if (sel == ECORE_X_ATOM_SELECTION_PRIMARY)
2197 e->selection = ECORE_X_SELECTION_PRIMARY;
2198 else if (sel == ECORE_X_ATOM_SELECTION_SECONDARY)
2199 e->selection = ECORE_X_SELECTION_SECONDARY;
2200 else if (sel == ECORE_X_ATOM_SELECTION_CLIPBOARD)
2201 e->selection = ECORE_X_SELECTION_CLIPBOARD;
2203 e->selection = ECORE_X_SELECTION_OTHER;
2204 e->reason = notify_event->subtype;
2206 ecore_event_add(ECORE_X_EVENT_FIXES_SELECTION_NOTIFY, e, NULL, NULL);
2209 #endif /* ifdef ECORE_XFIXES */
2211 #ifdef ECORE_XDAMAGE
2213 _ecore_x_event_handle_damage_notify(XEvent *event)
2215 XDamageNotifyEvent *damage_event;
2216 Ecore_X_Event_Damage *e;
2218 _ecore_x_last_event_mouse_move = 0;
2219 damage_event = (XDamageNotifyEvent *)event;
2221 e = calloc(1, sizeof(Ecore_X_Event_Damage));
2225 e->level = damage_event->level;
2226 e->drawable = damage_event->drawable;
2227 e->damage = damage_event->damage;
2228 e->more = damage_event->more;
2229 e->time = damage_event->timestamp;
2230 e->area.x = damage_event->area.x;
2231 e->area.y = damage_event->area.y;
2232 e->area.width = damage_event->area.width;
2233 e->area.height = damage_event->area.height;
2234 e->geometry.x = damage_event->geometry.x;
2235 e->geometry.y = damage_event->geometry.y;
2236 e->geometry.width = damage_event->geometry.width;
2237 e->geometry.height = damage_event->geometry.height;
2239 ecore_event_add(ECORE_X_EVENT_DAMAGE_NOTIFY, e, NULL, NULL);
2242 #endif /* ifdef ECORE_XDAMAGE */
2245 _ecore_x_event_free_generic_event(void *data,
2249 Ecore_X_Event_Generic *e = (Ecore_X_Event_Generic *)ev;
2254 XFreeEventData(_ecore_x_disp, (XGenericEventCookie *)data);
2260 data = NULL; ev = NULL;
2261 #endif /* ifdef ECORE_XI2 */
2265 _ecore_x_event_handle_generic_event(XEvent *event)
2268 XGenericEvent *generic_event;
2269 Ecore_X_Event_Generic *e;
2270 XGenericEventCookie *data;
2272 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2273 generic_event = (XGenericEvent *)event;
2275 e = calloc(1, sizeof(Ecore_X_Event_Generic));
2279 if (XGetEventData(_ecore_x_disp, &(event->xcookie)))
2281 e->cookie = event->xcookie.cookie;
2282 e->data = event->xcookie.data;
2290 e->extension = generic_event->extension;
2291 e->evtype = generic_event->evtype;
2293 if (e->extension == _ecore_x_xi2_opcode)
2294 _ecore_x_input_handler(event);
2296 data = malloc(sizeof(XGenericEventCookie));
2297 if (data) memcpy(data, &(event->xcookie), sizeof(XGenericEventCookie));
2298 ecore_event_add(ECORE_X_EVENT_GENERIC,
2300 _ecore_x_event_free_generic_event,
2305 #endif /* ifdef ECORE_XI2 */
2308 #ifdef ECORE_XGESTURE
2310 _ecore_x_event_handle_gesture_notify_flick(XEvent *xevent)
2312 XGestureNotifyFlickEvent *xfe;
2313 Ecore_X_Event_Gesture_Notify_Flick *e;
2315 _ecore_x_last_event_mouse_move = 0;
2316 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2318 xfe = (XGestureNotifyFlickEvent *)xevent;
2319 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Flick));
2323 e->win = xfe->window;
2324 e->time = xfe->time;
2325 e->subtype = xfe->kind;
2326 e->num_fingers = xfe->num_finger;
2327 e->distance = xfe->distance;
2328 e->duration = xfe->duration;
2329 e->direction = xfe->direction;
2330 e->angle = XFixedToDouble(xfe->angle);
2332 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_FLICK, e, NULL, NULL);
2336 _ecore_x_event_handle_gesture_notify_pan(XEvent *xevent)
2338 XGestureNotifyPanEvent *xpe;
2339 Ecore_X_Event_Gesture_Notify_Pan *e;
2341 _ecore_x_last_event_mouse_move = 0;
2342 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2344 xpe = (XGestureNotifyPanEvent *)xevent;
2345 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Pan));
2349 e->win = xpe->window;
2350 e->time = xpe->time;
2351 e->subtype = xpe->kind;
2352 e->num_fingers = xpe->num_finger;
2355 e->distance = xpe->distance;
2356 e->duration = xpe->duration;
2357 e->direction = xpe->direction;
2359 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_PAN, e, NULL, NULL);
2363 _ecore_x_event_handle_gesture_notify_pinchrotation(XEvent *xevent)
2365 XGestureNotifyPinchRotationEvent *xpre;
2366 Ecore_X_Event_Gesture_Notify_PinchRotation *e;
2368 _ecore_x_last_event_mouse_move = 0;
2369 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2371 xpre = (XGestureNotifyPinchRotationEvent *)xevent;
2372 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_PinchRotation));
2376 e->win = xpre->window;
2377 e->time = xpre->time;
2378 e->subtype = xpre->kind;
2379 e->num_fingers = xpre->num_finger;
2380 e->distance = xpre->distance;
2383 e->zoom = XFixedToDouble(xpre->zoom);
2384 e->angle = XFixedToDouble(xpre->angle);
2386 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION, e, NULL, NULL);
2390 _ecore_x_event_handle_gesture_notify_tap(XEvent *xevent)
2392 XGestureNotifyTapEvent *xte;
2393 Ecore_X_Event_Gesture_Notify_Tap *e;
2395 _ecore_x_last_event_mouse_move = 0;
2396 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2398 xte = (XGestureNotifyTapEvent *)xevent;
2399 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Tap));
2403 e->win = xte->window;
2404 e->time = xte->time;
2405 e->subtype = xte->kind;
2406 e->num_fingers = xte->num_finger;
2409 e->tap_repeat = xte->tap_repeat;
2410 e->interval = xte->interval;
2412 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAP, e, NULL, NULL);
2416 _ecore_x_event_handle_gesture_notify_tapnhold(XEvent *xevent)
2418 XGestureNotifyTapNHoldEvent *xthe;
2419 Ecore_X_Event_Gesture_Notify_TapNHold *e;
2421 _ecore_x_last_event_mouse_move = 0;
2422 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2424 xthe = (XGestureNotifyTapNHoldEvent *)xevent;
2425 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_TapNHold));
2429 e->win = xthe->window;
2430 e->time = xthe->time;
2431 e->subtype = xthe->kind;
2432 e->num_fingers = xthe->num_finger;
2435 e->interval = xthe->interval;
2436 e->hold_time = xthe->holdtime;
2438 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD, e, NULL, NULL);
2442 _ecore_x_event_handle_gesture_notify_hold(XEvent *xevent)
2444 XGestureNotifyHoldEvent *xhe;
2445 Ecore_X_Event_Gesture_Notify_Hold *e;
2447 _ecore_x_last_event_mouse_move = 0;
2448 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2450 xhe = (XGestureNotifyHoldEvent *)xevent;
2451 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Hold));
2455 e->win = xhe->window;
2456 e->time = xhe->time;
2457 e->subtype = xhe->kind;
2458 e->num_fingers = xhe->num_finger;
2461 e->hold_time = xhe->holdtime;
2463 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_HOLD, e, NULL, NULL);
2467 _ecore_x_event_handle_gesture_notify_group(XEvent *xevent)
2469 XGestureNotifyGroupEvent *xge;
2470 Ecore_X_Event_Gesture_Notify_Group *e;
2472 _ecore_x_last_event_mouse_move = 0;
2473 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2475 xge = (XGestureNotifyGroupEvent *)xevent;
2476 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Group));
2480 e->win = xge->window;
2481 e->time = xge->time;
2482 e->subtype = xge->kind;
2483 e->num_groups = xge->num_group;
2484 e->group_id = xge->groupid;
2486 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_GROUP, e, NULL, NULL);
2489 #endif /* ifdef ECORE_XGESTURE */