1 #include "ecore_xcb_private.h"
2 #ifdef ECORE_XCB_RENDER
3 # include <xcb/render.h>
6 # include <xcb/shape.h>
8 #ifdef ECORE_XCB_XPRINT
9 #include <xcb/xprint.h>
12 /* local function prototypes */
13 static Ecore_X_Window _ecore_xcb_window_argb_internal_new(Ecore_X_Window parent,
18 uint8_t override_redirect,
20 static Ecore_X_Window _ecore_xcb_window_at_xy_get(Ecore_X_Window base,
27 static int _ecore_xcb_window_modifiers_get(unsigned int state);
28 static xcb_visualtype_t *_ecore_xcb_window_find_visual_by_id(xcb_visualid_t id);
29 #ifdef ECORE_XCB_XPRINT
30 static xcb_screen_t *_ecore_xcb_window_screen_of_display(int screen);
34 static int ignore_num = 0;
35 static Ecore_X_Window *ignore_list = NULL;
37 /* external variables */
38 int _ecore_xcb_button_grabs_num = 0;
39 int _ecore_xcb_key_grabs_num = 0;
40 Ecore_X_Window *_ecore_xcb_button_grabs = NULL;
41 Ecore_X_Window *_ecore_xcb_key_grabs = NULL;
42 Eina_Bool (*_ecore_xcb_window_grab_replay_func)(void *data,
45 void *_ecore_xcb_window_grab_replay_data;
48 * @defgroup Ecore_X_Window_Create_Group X Window Creation Functions
50 * Functions that can be used to create an X window.
54 * Creates a new window.
55 * @param parent The parent window to use. If @p parent is @c 0, the root
56 * window of the default display is used.
57 * @param x X position.
58 * @param y Y position.
61 * @return The new window handle.
62 * @ingroup Ecore_X_Window_Create_Group
65 ecore_x_window_new(Ecore_X_Window parent,
72 uint32_t mask, mask_list[9];
74 LOGFN(__FILE__, __LINE__, __FUNCTION__);
78 parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
80 /* NB: Order here is very important due to xcb_cw_t enum */
81 mask = (XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
82 XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE |
83 XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK |
84 XCB_CW_DONT_PROPAGATE);
86 mask_list[0] = XCB_BACK_PIXMAP_NONE;
88 mask_list[2] = XCB_GRAVITY_NORTH_WEST;
89 mask_list[3] = XCB_GRAVITY_NORTH_WEST;
90 mask_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
93 mask_list[7] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
94 XCB_EVENT_MASK_BUTTON_PRESS |
95 XCB_EVENT_MASK_BUTTON_RELEASE |
96 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
97 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
98 XCB_EVENT_MASK_VISIBILITY_CHANGE |
99 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
100 XCB_EVENT_MASK_FOCUS_CHANGE |
101 XCB_EVENT_MASK_PROPERTY_CHANGE |
102 XCB_EVENT_MASK_COLOR_MAP_CHANGE);
103 mask_list[8] = XCB_EVENT_MASK_NO_EVENT;
105 win = xcb_generate_id(_ecore_xcb_conn);
106 xcb_create_window(_ecore_xcb_conn, XCB_COPY_FROM_PARENT,
107 win, parent, x, y, w, h, 0,
108 XCB_WINDOW_CLASS_INPUT_OUTPUT,
109 XCB_COPY_FROM_PARENT, mask, mask_list);
111 if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root)
112 ecore_x_window_defaults_set(win);
118 * Creates a window with the override redirect attribute set to @c True.
119 * @param parent The parent window to use. If @p parent is @c 0, the root
120 * window of the default display is used.
121 * @param x X position.
122 * @param y Y position.
125 * @return The new window handle.
126 * @ingroup Ecore_X_Window_Create_Group
129 ecore_x_window_override_new(Ecore_X_Window parent,
136 uint32_t mask, mask_list[9];
138 LOGFN(__FILE__, __LINE__, __FUNCTION__);
142 parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
144 /* NB: Order here is very important due to xcb_cw_t enum */
145 mask = (XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
146 XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE |
147 XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK |
148 XCB_CW_DONT_PROPAGATE);
150 mask_list[0] = XCB_BACK_PIXMAP_NONE;
152 mask_list[2] = XCB_GRAVITY_NORTH_WEST;
153 mask_list[3] = XCB_GRAVITY_NORTH_WEST;
154 mask_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
157 mask_list[7] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
158 XCB_EVENT_MASK_BUTTON_PRESS |
159 XCB_EVENT_MASK_BUTTON_RELEASE |
160 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
161 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
162 XCB_EVENT_MASK_VISIBILITY_CHANGE |
163 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
164 XCB_EVENT_MASK_FOCUS_CHANGE |
165 XCB_EVENT_MASK_PROPERTY_CHANGE |
166 XCB_EVENT_MASK_COLOR_MAP_CHANGE);
167 mask_list[8] = XCB_EVENT_MASK_NO_EVENT;
169 win = xcb_generate_id(_ecore_xcb_conn);
170 xcb_create_window(_ecore_xcb_conn, XCB_COPY_FROM_PARENT,
171 win, parent, x, y, w, h, 0,
172 XCB_WINDOW_CLASS_INPUT_OUTPUT,
173 XCB_COPY_FROM_PARENT, mask, mask_list);
179 * Creates a new input window.
180 * @param parent The parent window to use. If @p parent is @c 0, the root
181 * window of the default display is used.
182 * @param x X position.
183 * @param y Y position.
186 * @return The new window.
187 * @ingroup Ecore_X_Window_Create_Group
190 ecore_x_window_input_new(Ecore_X_Window parent,
197 uint32_t mask, mask_list[3];
199 LOGFN(__FILE__, __LINE__, __FUNCTION__)
203 parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
205 /* NB: Order here is very important due to xcb_cw_t enum */
206 mask = (XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK |
207 XCB_CW_DONT_PROPAGATE);
210 mask_list[1] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
211 XCB_EVENT_MASK_BUTTON_PRESS |
212 XCB_EVENT_MASK_BUTTON_RELEASE |
213 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
214 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
215 XCB_EVENT_MASK_VISIBILITY_CHANGE |
216 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
217 XCB_EVENT_MASK_FOCUS_CHANGE |
218 XCB_EVENT_MASK_PROPERTY_CHANGE |
219 XCB_EVENT_MASK_COLOR_MAP_CHANGE);
220 mask_list[2] = XCB_EVENT_MASK_NO_EVENT;
222 win = xcb_generate_id(_ecore_xcb_conn);
223 xcb_create_window(_ecore_xcb_conn, XCB_COPY_FROM_PARENT,
224 win, parent, x, y, w, h, 0,
225 XCB_WINDOW_CLASS_INPUT_ONLY,
226 XCB_COPY_FROM_PARENT, mask, mask_list);
232 * Creates a new window.
233 * @param parent The parent window to use. If @p parent is @c 0, the root
234 * window of the default display is used.
235 * @param x X position.
236 * @param y Y position.
239 * @return The new window handle.
240 * @ingroup Ecore_X_Window_Create_Group
243 ecore_x_window_manager_argb_new(Ecore_X_Window parent,
249 Ecore_X_Window win = 0;
251 LOGFN(__FILE__, __LINE__, __FUNCTION__);
253 win = _ecore_xcb_window_argb_internal_new(parent, x, y, w, h, 1, 0);
259 * Creates a new window.
260 * @param parent The parent window to use. If @p parent is @c 0, the root
261 * window of the default display is used.
262 * @param x X position.
263 * @param y Y position.
266 * @return The new window handle.
267 * @ingroup Ecore_X_Window_Create_Group
270 ecore_x_window_argb_new(Ecore_X_Window parent,
276 Ecore_X_Window win = 0;
278 LOGFN(__FILE__, __LINE__, __FUNCTION__);
280 win = _ecore_xcb_window_argb_internal_new(parent, x, y, w, h, 0, 0);
286 * Creates a window with the override redirect attribute set to @c True.
287 * @param parent The parent window to use. If @p parent is @c 0, the root
288 * window of the default display is used.
289 * @param x X position.
290 * @param y Y position.
293 * @return The new window handle.
294 * @ingroup Ecore_X_Window_Create_Group
297 ecore_x_window_override_argb_new(Ecore_X_Window parent,
303 Ecore_X_Window win = 0;
305 LOGFN(__FILE__, __LINE__, __FUNCTION__);
307 win = _ecore_xcb_window_argb_internal_new(parent, x, y, w, h, 1, 0);
313 * @defgroup Ecore_X_Window_Destroy_Group X Window Destroy Functions
315 * Functions to destroy X windows.
319 * Deletes the given window.
320 * @param win The given window.
321 * @ingroup Ecore_X_Window_Destroy_Group
324 ecore_x_window_free(Ecore_X_Window win)
326 LOGFN(__FILE__, __LINE__, __FUNCTION__);
331 /* xcb_destroy_notify_event_t ev; */
332 /* Ecore_X_Window root; */
334 /* if (xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).rem == 1) */
335 /* root = ((xcb_screen_t *)_ecore_xcb_screen)->root; */
338 /* xcb_get_geometry_cookie_t cookie; */
339 /* xcb_get_geometry_reply_t *reply; */
341 /* cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win); */
342 /* reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL); */
343 /* if (!reply) return; */
344 /* root = reply->root; */
348 /* memset(&ev, 0, sizeof(xcb_destroy_notify_event_t)); */
350 /* ev.response_type = XCB_DESTROY_NOTIFY; */
351 /* ev.window = win; */
352 /* ev.event = root; */
354 /* xcb_send_event(_ecore_xcb_conn, 0, root, */
355 /* XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | */
356 /* XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, */
357 /* (const char *)&ev); */
359 xcb_destroy_window(_ecore_xcb_conn, win);
365 * Sends a delete request to the given window.
366 * @param win The given window.
367 * @ingroup Ecore_X_Window_Destroy_Group
370 ecore_x_window_delete_request_send(Ecore_X_Window win)
372 LOGFN(__FILE__, __LINE__, __FUNCTION__);
375 ecore_x_client_message32_send(win, ECORE_X_ATOM_WM_PROTOCOLS,
376 XCB_EVENT_MASK_NO_EVENT,
377 ECORE_X_ATOM_WM_DELETE_WINDOW,
378 XCB_CURRENT_TIME, 0, 0, 0);
382 ecore_x_window_configure(Ecore_X_Window win,
383 Ecore_X_Window_Configure_Mask mask,
389 Ecore_X_Window sibling,
396 LOGFN(__FILE__, __LINE__, __FUNCTION__);
401 if (mask & XCB_CONFIG_WINDOW_X)
403 vmask |= XCB_CONFIG_WINDOW_X;
406 if (mask & XCB_CONFIG_WINDOW_Y)
408 vmask |= XCB_CONFIG_WINDOW_Y;
411 if (mask & XCB_CONFIG_WINDOW_WIDTH)
413 vmask |= XCB_CONFIG_WINDOW_WIDTH;
416 if (mask & XCB_CONFIG_WINDOW_HEIGHT)
418 vmask |= XCB_CONFIG_WINDOW_HEIGHT;
421 if (mask & XCB_CONFIG_WINDOW_BORDER_WIDTH)
423 vmask |= XCB_CONFIG_WINDOW_BORDER_WIDTH;
424 vlist[i++] = border_width;
426 if (mask & XCB_CONFIG_WINDOW_SIBLING)
428 vmask |= XCB_CONFIG_WINDOW_SIBLING;
429 vlist[i++] = sibling;
431 if (mask & XCB_CONFIG_WINDOW_STACK_MODE)
433 vmask |= XCB_CONFIG_WINDOW_STACK_MODE;
434 vlist[i++] = stack_mode;
437 xcb_configure_window(_ecore_xcb_conn, win, vmask,
438 (const uint32_t *)&vlist);
443 * @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions
445 * Functions that change or retrieve the geometry of X windows.
449 * Moves a window to the position @p x, @p y.
451 * The position is relative to the upper left hand corner of the
454 * @param win The window to move.
455 * @param x X position.
456 * @param y Y position.
457 * @ingroup Ecore_X_Window_Geometry_Group
460 ecore_x_window_move(Ecore_X_Window win,
464 uint32_t list[2], mask;
466 LOGFN(__FILE__, __LINE__, __FUNCTION__);
471 mask = (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y);
475 xcb_configure_window(_ecore_xcb_conn, win, mask,
476 (const uint32_t *)&list);
482 * @param win The window to resize.
483 * @param w New width of the window.
484 * @param h New height of the window.
485 * @ingroup Ecore_X_Window_Geometry_Group
488 ecore_x_window_resize(Ecore_X_Window win,
492 uint32_t list[2], mask;
494 LOGFN(__FILE__, __LINE__, __FUNCTION__);
501 mask = (XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT);
505 xcb_configure_window(_ecore_xcb_conn, win, mask,
506 (const uint32_t *)&list);
511 * Moves and resizes a window.
512 * @param win The window to move and resize.
513 * @param x New X position of the window.
514 * @param y New Y position of the window.
515 * @param w New width of the window.
516 * @param h New height of the window.
517 * @ingroup Ecore_X_Window_Geometry_Group
520 ecore_x_window_move_resize(Ecore_X_Window win,
526 uint32_t list[4], mask;
528 LOGFN(__FILE__, __LINE__, __FUNCTION__);
535 mask = (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y |
536 XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT);
542 xcb_configure_window(_ecore_xcb_conn, win, mask,
543 (const uint32_t *)&list);
548 * Retrieves the width of the border of the given window.
549 * @param win The given window.
550 * @return Width of the border of @p win.
551 * @ingroup Ecore_X_Window_Geometry_Group
554 ecore_x_window_border_width_get(Ecore_X_Window win)
556 LOGFN(__FILE__, __LINE__, __FUNCTION__);
559 return ecore_x_drawable_border_width_get(win);
563 * Sets the width of the border of the given window.
564 * @param win The given window.
565 * @param width The new border width.
566 * @ingroup Ecore_X_Window_Geometry_Group
569 ecore_x_window_border_width_set(Ecore_X_Window win,
574 LOGFN(__FILE__, __LINE__, __FUNCTION__);
581 xcb_configure_window(_ecore_xcb_conn, win,
582 XCB_CONFIG_WINDOW_BORDER_WIDTH, &list);
587 * @defgroup Ecore_X_Window_Z_Order_Group X Window Z Order Functions
589 * Functions that change the Z order of X windows.
593 * Raises the given window.
594 * @param win The window to raise.
595 * @ingroup Ecore_X_Window_Z_Order_Group
598 ecore_x_window_raise(Ecore_X_Window win)
600 uint32_t list[] = { XCB_STACK_MODE_ABOVE };
602 LOGFN(__FILE__, __LINE__, __FUNCTION__);
605 xcb_configure_window(_ecore_xcb_conn, win,
606 XCB_CONFIG_WINDOW_STACK_MODE, list);
611 * Lowers the given window.
612 * @param win The window to lower.
613 * @ingroup Ecore_X_Window_Z_Order_Group
616 ecore_x_window_lower(Ecore_X_Window win)
618 uint32_t list[] = { XCB_STACK_MODE_BELOW };
620 LOGFN(__FILE__, __LINE__, __FUNCTION__);
623 xcb_configure_window(_ecore_xcb_conn, win,
624 XCB_CONFIG_WINDOW_STACK_MODE, list);
629 * Retrieves the depth of the given window.
630 * @param win The given window.
631 * @return Depth of the window.
634 ecore_x_window_depth_get(Ecore_X_Window win)
636 LOGFN(__FILE__, __LINE__, __FUNCTION__);
638 return ecore_x_drawable_depth_get(win);
642 * @defgroup Ecore_X_Window_Properties_Group X Window Property Functions
644 * Functions that set window properties.
648 * Sets the default properties for the given window.
650 * The default properties set for the window are @c WM_CLIENT_MACHINE and
653 * @param win The given window.
654 * @ingroup Ecore_X_Window_Properties_Group
657 ecore_x_window_defaults_set(Ecore_X_Window win)
659 char buff[MAXHOSTNAMELEN], **argv;
663 LOGFN(__FILE__, __LINE__, __FUNCTION__);
666 gethostname(buff, MAXHOSTNAMELEN);
667 buff[MAXHOSTNAMELEN - 1] = '\0';
669 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win,
670 ECORE_X_ATOM_WM_CLIENT_MACHINE, ECORE_X_ATOM_STRING,
671 8, strlen(buff), buff);
674 ecore_x_netwm_pid_set(win, pid);
675 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL);
676 ecore_app_args_get(&argc, &argv);
677 ecore_x_icccm_command_set(win, argc, argv);
681 * @defgroup Ecore_X_Window_Visibility_Group X Window Visibility Functions
683 * Functions to access and change the visibility of X windows.
689 * Synonymous to "mapping" a window in X Window System terminology.
691 * @param win The window to show.
692 * @ingroup Ecore_X_Window_Visibility
695 ecore_x_window_show(Ecore_X_Window win)
697 LOGFN(__FILE__, __LINE__, __FUNCTION__);
701 xcb_map_window(_ecore_xcb_conn, win);
707 * Synonymous to "unmapping" a window in X Window System terminology.
709 * @param win The window to hide.
710 * @ingroup Ecore_X_Window_Visibility
713 ecore_x_window_hide(Ecore_X_Window win)
715 LOGFN(__FILE__, __LINE__, __FUNCTION__);
720 xcb_unmap_notify_event_t ev;
723 if (xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).rem == 1)
724 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
727 xcb_get_geometry_cookie_t cookie;
728 xcb_get_geometry_reply_t *reply;
730 cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win);
731 reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
737 memset(&ev, 0, sizeof(xcb_unmap_notify_event_t));
739 ev.response_type = XCB_UNMAP_NOTIFY;
742 ev.from_configure = 0;
744 xcb_send_event(_ecore_xcb_conn, 0, root,
745 (XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
746 XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT),
749 xcb_unmap_window(_ecore_xcb_conn, win);
755 * @defgroup Ecore_X_Window_Focus_Functions X Window Focus Functions
757 * Functions that give the focus to an X Window.
761 * Sets the focus to the window @p win.
762 * @param win The window to focus.
763 * @ingroup Ecore_X_Window_Focus_Functions
766 ecore_x_window_focus(Ecore_X_Window win)
768 LOGFN(__FILE__, __LINE__, __FUNCTION__);
771 if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
773 xcb_set_input_focus(_ecore_xcb_conn,
774 XCB_INPUT_FOCUS_PARENT, win, XCB_CURRENT_TIME);
779 * Sets the focus to the given window at a specific time.
780 * @param win The window to focus.
781 * @param t When to set the focus to the window.
782 * @ingroup Ecore_X_Window_Focus_Functions
785 ecore_x_window_focus_at_time(Ecore_X_Window win,
786 Ecore_X_Time time __UNUSED__)
788 LOGFN(__FILE__, __LINE__, __FUNCTION__);
791 if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
792 xcb_set_input_focus(_ecore_xcb_conn,
793 XCB_INPUT_FOCUS_PARENT, win, XCB_CURRENT_TIME);
798 * @defgroup Ecore_X_Window_Parent_Group X Window Parent Functions
800 * Functions that retrieve or changes the parent window of a window.
804 * Moves a window to within another window at a given position.
805 * @param win The window to reparent.
806 * @param new_parent The new parent window.
807 * @param x X position within new parent window.
808 * @param y Y position within new parent window.
809 * @ingroup Ecore_X_Window_Parent_Group
812 ecore_x_window_reparent(Ecore_X_Window win,
813 Ecore_X_Window parent,
817 LOGFN(__FILE__, __LINE__, __FUNCTION__);
821 parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
823 xcb_reparent_window(_ecore_xcb_conn, win, parent, x, y);
828 ecore_x_window_pixmap_set(Ecore_X_Window win,
829 Ecore_X_Pixmap pixmap)
833 LOGFN(__FILE__, __LINE__, __FUNCTION__);
838 xcb_change_window_attributes(_ecore_xcb_conn, win,
839 XCB_CW_BACK_PIXMAP, &list);
844 * Sets the background color of the given window.
845 * @param win The given window
846 * @param r red value (0...65536, 16 bits)
847 * @param g green value (0...65536, 16 bits)
848 * @param b blue value (0...65536, 16 bits)
851 ecore_x_window_background_color_set(Ecore_X_Window win,
853 unsigned short green,
856 xcb_alloc_color_cookie_t cookie;
857 xcb_alloc_color_reply_t *reply;
860 LOGFN(__FILE__, __LINE__, __FUNCTION__);
864 xcb_alloc_color_unchecked(_ecore_xcb_conn,
865 ((xcb_screen_t *)_ecore_xcb_screen)->default_colormap,
867 reply = xcb_alloc_color_reply(_ecore_xcb_conn, cookie, NULL);
872 xcb_change_window_attributes(_ecore_xcb_conn, win,
873 XCB_CW_BACK_PIXEL, &list);
878 ecore_x_window_pixel_gravity_set(Ecore_X_Window win,
879 Ecore_X_Gravity gravity)
883 LOGFN(__FILE__, __LINE__, __FUNCTION__);
888 xcb_change_window_attributes(_ecore_xcb_conn, win,
889 XCB_CW_BIT_GRAVITY, &list);
894 ecore_x_window_gravity_set(Ecore_X_Window win,
895 Ecore_X_Gravity gravity)
899 LOGFN(__FILE__, __LINE__, __FUNCTION__);
904 xcb_change_window_attributes(_ecore_xcb_conn, win,
905 XCB_CW_WIN_GRAVITY, &list);
910 ecore_x_window_override_set(Ecore_X_Window win,
915 LOGFN(__FILE__, __LINE__, __FUNCTION__);
920 xcb_change_window_attributes(_ecore_xcb_conn, win,
921 XCB_CW_OVERRIDE_REDIRECT, &list);
926 * @brief Show the cursor on a window of type Ecore_X_Window.
927 * @param win The window for which the cursor will be showed.
928 * @param show Enables the show of the cursor on the window if equals EINA_TRUE, disables if equals EINA_FALSE.
931 ecore_x_window_cursor_show(Ecore_X_Window win,
936 LOGFN(__FILE__, __LINE__, __FUNCTION__);
939 if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
943 Ecore_X_Cursor cursor;
948 p = xcb_generate_id(_ecore_xcb_conn);
949 xcb_create_pixmap(_ecore_xcb_conn, 1, p, win, 1, 1);
950 m = xcb_generate_id(_ecore_xcb_conn);
951 xcb_create_pixmap(_ecore_xcb_conn, 1, m, win, 1, 1);
952 gc = xcb_generate_id(_ecore_xcb_conn);
953 xcb_create_gc(_ecore_xcb_conn, gc, win, 0, NULL);
954 xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_FOREGROUND, &list);
957 xcb_poly_point(_ecore_xcb_conn, XCB_COORD_MODE_ORIGIN,
959 xcb_free_gc(_ecore_xcb_conn, gc);
961 cursor = xcb_generate_id(_ecore_xcb_conn);
962 xcb_create_cursor(_ecore_xcb_conn, cursor,
963 p, m, 0, 0, 0, 0, 0, 0, 0, 0);
966 xcb_change_window_attributes(_ecore_xcb_conn, win,
967 XCB_CW_CURSOR, &list);
969 xcb_free_cursor(_ecore_xcb_conn, cursor);
970 xcb_free_pixmap(_ecore_xcb_conn, m);
971 xcb_free_pixmap(_ecore_xcb_conn, p);
975 xcb_change_window_attributes(_ecore_xcb_conn, win,
976 XCB_CW_CURSOR, &list);
982 ecore_x_window_cursor_set(Ecore_X_Window win,
983 Ecore_X_Cursor cursor)
987 LOGFN(__FILE__, __LINE__, __FUNCTION__);
992 xcb_change_window_attributes(_ecore_xcb_conn, win, XCB_CW_CURSOR, &list);
997 ecore_x_window_container_manage(Ecore_X_Window win)
1001 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1004 list = (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
1005 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY);
1007 xcb_change_window_attributes(_ecore_xcb_conn, win,
1008 XCB_CW_EVENT_MASK, &list);
1013 ecore_x_window_client_manage(Ecore_X_Window win)
1017 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1020 list = (XCB_EVENT_MASK_VISIBILITY_CHANGE |
1021 XCB_EVENT_MASK_FOCUS_CHANGE |
1022 XCB_EVENT_MASK_PROPERTY_CHANGE |
1023 XCB_EVENT_MASK_COLOR_MAP_CHANGE |
1024 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
1025 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY);
1027 xcb_change_window_attributes(_ecore_xcb_conn, win,
1028 XCB_CW_EVENT_MASK, &list);
1030 #ifdef ECORE_XCB_SHAPE
1031 xcb_shape_select_input(_ecore_xcb_conn, win, EINA_TRUE);
1037 ecore_x_window_sniff(Ecore_X_Window win)
1041 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1044 list = (XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
1045 XCB_EVENT_MASK_PROPERTY_CHANGE);
1047 xcb_change_window_attributes(_ecore_xcb_conn, win,
1048 XCB_CW_EVENT_MASK, &list);
1053 ecore_x_window_client_sniff(Ecore_X_Window win)
1057 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1060 list = (XCB_EVENT_MASK_VISIBILITY_CHANGE |
1061 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
1062 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
1063 XCB_EVENT_MASK_FOCUS_CHANGE |
1064 XCB_EVENT_MASK_PROPERTY_CHANGE |
1065 XCB_EVENT_MASK_COLOR_MAP_CHANGE);
1067 xcb_change_window_attributes(_ecore_xcb_conn, win,
1068 XCB_CW_EVENT_MASK, &list);
1069 #ifdef ECORE_XCB_SHAPE
1070 xcb_shape_select_input(_ecore_xcb_conn, win, EINA_TRUE);
1076 ecore_x_window_area_clear(Ecore_X_Window win,
1082 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1085 xcb_clear_area(_ecore_xcb_conn, 0, win, x, y, w, h);
1090 ecore_x_window_area_expose(Ecore_X_Window win,
1096 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1099 xcb_clear_area(_ecore_xcb_conn, 1, win, x, y, w, h);
1104 ecore_x_window_save_set_add(Ecore_X_Window win)
1106 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1109 xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_INSERT, win);
1113 ecore_x_window_save_set_del(Ecore_X_Window win)
1115 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1118 xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_DELETE, win);
1122 * gets the window that has focus.
1123 * @return The window that has focus.
1124 * @ingroup Ecore_X_Window_Focus_Functions
1127 ecore_x_window_focus_get(void)
1129 xcb_get_input_focus_cookie_t cookie;
1130 xcb_get_input_focus_reply_t *reply;
1131 Ecore_X_Window focus = 0;
1133 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1136 cookie = xcb_get_input_focus_unchecked(_ecore_xcb_conn);
1137 reply = xcb_get_input_focus_reply(_ecore_xcb_conn, cookie, NULL);
1138 if (!reply) return 0;
1139 focus = reply->focus;
1145 ecore_x_window_argb_get(Ecore_X_Window win)
1148 #ifdef ECORE_XCB_RENDER
1149 Ecore_X_Visual visual;
1152 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1155 // if (!win) return ret;
1157 #ifdef ECORE_XCB_RENDER
1158 /* grab the window's visual */
1159 visual = _ecore_xcb_window_visual_get(win);
1161 /* check if this visual supports alpha */
1162 ret = _ecore_xcb_render_visual_supports_alpha(visual);
1169 ecore_x_window_manage(Ecore_X_Window win)
1171 xcb_get_window_attributes_cookie_t cookie;
1172 xcb_get_window_attributes_reply_t *reply;
1173 xcb_void_cookie_t change_cookie;
1174 xcb_generic_error_t *err;
1177 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1180 cookie = xcb_get_window_attributes(_ecore_xcb_conn, win);
1181 reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL);
1182 if (!reply) return EINA_FALSE;
1184 ecore_x_sync(); // needed
1186 list = (XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
1187 XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_RESIZE_REDIRECT |
1188 XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
1189 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
1190 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
1191 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
1192 reply->your_event_mask);
1195 change_cookie = xcb_change_window_attributes(_ecore_xcb_conn, win,
1196 XCB_CW_EVENT_MASK, &list);
1198 ecore_x_sync(); // needed
1200 err = xcb_request_check(_ecore_xcb_conn, change_cookie);
1203 _ecore_xcb_error_handle(err);
1212 ecore_x_window_attributes_get(Ecore_X_Window win,
1213 Ecore_X_Window_Attributes *att_ret)
1215 xcb_get_window_attributes_cookie_t cookie;
1216 xcb_get_window_attributes_reply_t *reply;
1217 xcb_get_geometry_cookie_t gcookie;
1218 xcb_get_geometry_reply_t *greply;
1220 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1223 cookie = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, win);
1224 reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL);
1225 if (!reply) return EINA_FALSE;
1227 memset(att_ret, 0, sizeof(Ecore_X_Window_Attributes));
1229 if (reply->map_state != XCB_MAP_STATE_UNMAPPED)
1230 att_ret->visible = EINA_TRUE;
1232 if (reply->map_state == XCB_MAP_STATE_VIEWABLE)
1233 att_ret->viewable = EINA_TRUE;
1235 if (reply->override_redirect)
1236 att_ret->override = EINA_TRUE;
1238 if (reply->_class == XCB_WINDOW_CLASS_INPUT_ONLY)
1239 att_ret->input_only = EINA_TRUE;
1241 if (reply->save_under)
1242 att_ret->save_under = EINA_TRUE;
1244 att_ret->event_mask.mine = reply->your_event_mask;
1245 att_ret->event_mask.all = reply->all_event_masks;
1246 att_ret->event_mask.no_propagate = reply->do_not_propagate_mask;
1247 att_ret->window_gravity = reply->win_gravity;
1248 att_ret->pixel_gravity = reply->bit_gravity;
1249 att_ret->colormap = reply->colormap;
1250 att_ret->visual = _ecore_xcb_window_find_visual_by_id(reply->visual);
1254 gcookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win);
1255 greply = xcb_get_geometry_reply(_ecore_xcb_conn, gcookie, NULL);
1256 if (!greply) return EINA_TRUE;
1258 /* xcb_translate_coordinates_reply_t *trans; */
1259 /* xcb_query_tree_cookie_t tcookie; */
1260 /* xcb_query_tree_reply_t *treply; */
1262 /* tcookie = xcb_query_tree(_ecore_xcb_conn, win); */
1263 /* treply = xcb_query_tree_reply(_ecore_xcb_conn, tcookie, NULL); */
1266 /* xcb_translate_coordinates_reply(_ecore_xcb_conn, */
1267 /* xcb_translate_coordinates(_ecore_xcb_conn, */
1268 /* win, treply->parent, greply->x, greply->y), NULL); */
1271 att_ret->root = greply->root;
1272 att_ret->depth = greply->depth;
1273 // att_ret->x = trans->dst_x;
1274 // att_ret->y = trans->dst_y;
1275 att_ret->x = greply->x;
1276 att_ret->y = greply->y;
1277 att_ret->w = greply->width;
1278 att_ret->h = greply->height;
1279 att_ret->border = greply->border_width;
1288 * Retrieves the size of the given window.
1289 * @param win The given window.
1290 * @param w Pointer to an integer into which the width is to be stored.
1291 * @param h Pointer to an integer into which the height is to be stored.
1292 * @ingroup Ecore_X_Window_Geometry_Group
1295 ecore_x_window_size_get(Ecore_X_Window win,
1299 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1302 if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1303 ecore_x_drawable_geometry_get(win, NULL, NULL, width, height);
1307 * Set if a window should be ignored.
1308 * @param win The given window.
1309 * @param ignore if to ignore
1312 ecore_x_window_ignore_set(Ecore_X_Window win,
1315 int i = 0, j = 0, count = 0;
1317 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1324 for (i = 0; i < ignore_num; i++)
1325 if (win == ignore_list[i]) return;
1328 realloc(ignore_list, (ignore_num + 1) * sizeof(Ecore_X_Window));
1329 if (!ignore_list) return;
1331 ignore_list[ignore_num++] = win;
1336 ignore_list = malloc(sizeof(Ecore_X_Window));
1337 if (!ignore_list) return;
1338 ignore_list[ignore_num++] = win;
1343 if (!ignore_list) return;
1344 for (count = ignore_num, i = 0, j = 0; i < count; i++)
1346 if (win != ignore_list[i])
1347 ignore_list[j++] = ignore_list[i];
1351 if (ignore_num <= 0)
1359 realloc(ignore_list, ignore_num * sizeof(Ecore_X_Window));
1364 * Get the ignore list
1365 * @param num number of windows in the list
1366 * @return list of windows to ignore
1368 EAPI Ecore_X_Window *
1369 ecore_x_window_ignore_list(int *num)
1371 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1373 if (num) *num = ignore_num;
1378 * Get a list of all the root windows on the server.
1380 * @note The returned array will need to be freed after use.
1381 * @param num_ret Pointer to integer to put number of windows returned in.
1382 * @return An array of all the root windows. @c NULL is returned if memory
1383 * could not be allocated for the list, or if @p num_ret is @c NULL.
1385 EAPI Ecore_X_Window *
1386 ecore_x_window_root_list(int *num_ret)
1388 xcb_screen_iterator_t iter;
1390 Ecore_X_Window *roots = NULL;
1391 #ifdef ECORE_XCB_XPRINT
1392 const xcb_query_extension_reply_t *ext_reply;
1395 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1398 if (!num_ret) return NULL;
1399 if (num_ret) *num_ret = 0;
1401 /* if (xcb_connection_has_error(_ecore_xcb_conn)) */
1403 /* DBG("XCB Connection Has Error !!!"); */
1407 num = ecore_x_screen_count_get();
1409 #ifdef ECORE_XCB_XPRINT
1410 ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_x_print_id);
1411 if ((ext_reply) && (ext_reply->present))
1413 xcb_x_print_print_query_screens_cookie_t cookie;
1414 xcb_x_print_print_query_screens_reply_t *reply;
1416 cookie = xcb_x_print_print_query_screens_unchecked(_ecore_xcb_conn);
1418 xcb_x_print_print_query_screens_reply(_ecore_xcb_conn, cookie, NULL);
1421 xcb_window_t *screens;
1422 int psnum = 0, overlap = 0, j = 0, k = 0;
1424 psnum = xcb_x_print_print_query_screens_roots_length(reply);
1425 screens = xcb_x_print_print_query_screens_roots(reply);
1426 for (i = 0; i < num; i++)
1428 for (j = 0; j < psnum; j++)
1432 if ((s = _ecore_xcb_window_screen_of_display(i)))
1434 if (s->root == screens[j])
1439 if (!(roots = malloc((num - overlap)
1440 * sizeof(Ecore_X_Window)))) return NULL;
1441 for (i = 0; i < num; i++)
1443 Eina_Bool is_print = EINA_FALSE;
1445 for (j = 0; j < psnum; j++)
1449 if ((s = _ecore_xcb_window_screen_of_display(i)))
1451 if (s->root == screens[j])
1453 is_print = EINA_TRUE;
1462 if ((s = _ecore_xcb_window_screen_of_display(i)))
1469 if (num_ret) *num_ret = k;
1474 /* Fallback to default method */
1476 xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn));
1477 if (!(roots = malloc(num * sizeof(Ecore_X_Window)))) return NULL;
1478 if (num_ret) *num_ret = num;
1479 for (i = 0; iter.rem; xcb_screen_next(&iter), i++)
1480 roots[i] = iter.data->root;
1485 /* Fallback to default method */
1487 xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn));
1488 if (!(roots = malloc(num * sizeof(Ecore_X_Window)))) return NULL;
1489 if (num_ret) *num_ret = num;
1490 for (i = 0; iter.rem; xcb_screen_next(&iter), i++)
1491 roots[i] = iter.data->root;
1495 xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn));
1496 if (!(roots = malloc(num * sizeof(Ecore_X_Window)))) return NULL;
1497 if (num_ret) *num_ret = num;
1498 for (i = 0; iter.rem; xcb_screen_next(&iter), i++)
1499 roots[i] = iter.data->root;
1505 EAPI Ecore_X_Window *
1506 ecore_x_window_children_get(Ecore_X_Window win,
1509 xcb_query_tree_cookie_t cookie;
1510 xcb_query_tree_reply_t *reply;
1511 Ecore_X_Window *windows = NULL;
1513 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1517 cookie = xcb_query_tree_unchecked(_ecore_xcb_conn, win);
1518 reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL);
1519 if (!reply) return NULL;
1521 if (num) *num = reply->children_len;
1522 if (reply->children_len > 0)
1524 windows = malloc(sizeof(Ecore_X_Window) * reply->children_len);
1530 w = xcb_query_tree_children(reply);
1531 for (i = 0; i < reply->children_len; i++)
1541 * Retrieves the root window a given window is on.
1542 * @param win The window to get the root window of
1543 * @return The root window of @p win
1544 * @ingroup Ecore_X_Window_Geometry_Group
1547 ecore_x_window_root_get(Ecore_X_Window win)
1549 xcb_get_geometry_cookie_t gcookie;
1550 xcb_get_geometry_reply_t *greply;
1551 Ecore_X_Window window = 0;
1553 /* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
1556 gcookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win);
1557 greply = xcb_get_geometry_reply(_ecore_xcb_conn, gcookie, NULL);
1558 if (!greply) return 0;
1559 window = greply->root;
1566 ecore_x_window_root_first_get(void)
1568 return ((xcb_screen_t *)_ecore_xcb_screen)->root;
1572 * Retrieves the geometry of the given window.
1574 * Note that the x & y coordingates are relative to your parent. In
1575 * particular for reparenting window managers - relative to you window border.
1576 * If you want screen coordinates either walk the window tree to the root,
1577 * else for ecore_evas applications see ecore_evas_geometry_get(). Elementary
1578 * applications can use elm_win_screen_position_get().
1580 * @param win The given window.
1581 * @param x Pointer to an integer in which the X position is to be stored.
1582 * @param y Pointer to an integer in which the Y position is to be stored.
1583 * @param w Pointer to an integer in which the width is to be stored.
1584 * @param h Pointer to an integer in which the height is to be stored.
1585 * @ingroup Ecore_X_Window_Geometry_Group
1588 ecore_x_window_geometry_get(Ecore_X_Window win,
1594 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1597 if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1598 ecore_x_drawable_geometry_get(win, x, y, w, h);
1602 * Retrieves the top, visible window at the given location.
1603 * @param x The given X position.
1604 * @param y The given Y position.
1605 * @return The window at that position.
1606 * @ingroup Ecore_X_Window_Geometry_Group
1609 ecore_x_window_at_xy_get(int x,
1612 Ecore_X_Window root, win = 0;
1614 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1617 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1620 win = _ecore_xcb_window_at_xy_get(root, 0, 0, x, y, NULL, 0);
1623 return win ? win : root;
1627 * Retrieves the top, visible window at the given location,
1628 * but skips the windows in the list.
1629 * @param x The given X position.
1630 * @param y The given Y position.
1631 * @param skip The list of windows to be skipped.
1632 * @param skip_num The number of windows to be skipped.
1633 * @return The window at that position.
1634 * @ingroup Ecore_X_Window_Geometry_Group
1637 ecore_x_window_at_xy_with_skip_get(int x,
1639 Ecore_X_Window *skip,
1642 Ecore_X_Window root, win = 0;
1644 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1647 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1650 win = _ecore_xcb_window_at_xy_get(root, 0, 0, x, y, skip, skip_num);
1653 return win ? win : root;
1657 ecore_x_window_at_xy_begin_get(Ecore_X_Window begin,
1661 Ecore_X_Window win = 0;
1663 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1667 win = _ecore_xcb_window_at_xy_get(begin, 0, 0, x, y, NULL, 0);
1670 return win ? win : begin;
1674 * Retrieves the parent window of the given window.
1675 * @param win The given window.
1676 * @return The parent window of @p win.
1677 * @ingroup Ecore_X_Window_Parent_Group
1680 ecore_x_window_parent_get(Ecore_X_Window win)
1682 xcb_query_tree_cookie_t cookie;
1683 xcb_query_tree_reply_t *reply;
1684 Ecore_X_Window window = 0;
1686 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1689 // if (!win) return 0;
1690 cookie = xcb_query_tree(_ecore_xcb_conn, win);
1691 reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL);
1692 if (!reply) return 0;
1693 window = reply->parent;
1700 * Finds out whether the given window is currently visible.
1701 * @param win The given window.
1702 * @return 1 if the window is visible, otherwise 0.
1703 * @ingroup Ecore_X_Window_Visibility_Group
1706 ecore_x_window_visible_get(Ecore_X_Window win)
1708 xcb_get_window_attributes_cookie_t cookie;
1709 xcb_get_window_attributes_reply_t *reply;
1710 int ret = EINA_FALSE;
1712 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1715 cookie = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, win);
1716 reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL);
1717 if (!reply) return EINA_FALSE;
1719 if (reply->map_state == XCB_MAP_STATE_VIEWABLE)
1727 ecore_x_window_button_grab(Ecore_X_Window win,
1729 Ecore_X_Event_Mask mask,
1734 uint16_t m, locks[8], ev;
1738 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1743 b = XCB_BUTTON_INDEX_ANY;
1745 m = _ecore_xcb_window_modifiers_get(mod);
1746 if (any_mod) m = XCB_MOD_MASK_ANY;
1749 locks[1] = ECORE_X_LOCK_CAPS;
1750 locks[2] = ECORE_X_LOCK_NUM;
1751 locks[3] = ECORE_X_LOCK_SCROLL;
1752 locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
1753 locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
1754 locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1755 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1758 for (i = 0; i < 8; i++)
1759 xcb_grab_button(_ecore_xcb_conn, 0, win, ev,
1760 XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC,
1761 XCB_NONE, XCB_NONE, b, m | locks[i]);
1763 _ecore_xcb_button_grabs_num++;
1764 t = realloc(_ecore_xcb_button_grabs,
1765 _ecore_xcb_button_grabs_num * sizeof(Ecore_X_Window));
1768 _ecore_xcb_button_grabs = t;
1769 _ecore_xcb_button_grabs[_ecore_xcb_button_grabs_num - 1] = win;
1773 ecore_x_window_button_ungrab(Ecore_X_Window win,
1779 uint16_t m = 0, locks[8];
1782 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1786 if (b == 0) b = XCB_BUTTON_INDEX_ANY;
1788 m = _ecore_xcb_window_modifiers_get(mod);
1789 if (any_mod) m = XCB_MOD_MASK_ANY;
1792 locks[1] = ECORE_X_LOCK_CAPS;
1793 locks[2] = ECORE_X_LOCK_NUM;
1794 locks[3] = ECORE_X_LOCK_SCROLL;
1795 locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
1796 locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
1797 locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1798 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1800 for (i = 0; i < 8; i++)
1801 xcb_ungrab_button(_ecore_xcb_conn, b, win, m | locks[i]);
1803 _ecore_xcb_sync_magic_send(1, win);
1807 ecore_x_window_key_grab(Ecore_X_Window win,
1812 xcb_keycode_t keycode = XCB_NO_SYMBOL;
1813 uint16_t m = 0, locks[8];
1817 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1820 keycode = _ecore_xcb_keymap_string_to_keycode(key);
1821 if (keycode == XCB_NO_SYMBOL) return;
1823 m = _ecore_xcb_window_modifiers_get(mod);
1824 if (any_mod) m = XCB_MOD_MASK_ANY;
1827 locks[1] = ECORE_X_LOCK_CAPS;
1828 locks[2] = ECORE_X_LOCK_NUM;
1829 locks[3] = ECORE_X_LOCK_SCROLL;
1830 locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
1831 locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
1832 locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1833 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1835 for (i = 0; i < 8; i++)
1836 xcb_grab_key(_ecore_xcb_conn, 0, win, m | locks[i],
1837 keycode, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
1838 _ecore_xcb_key_grabs_num++;
1839 t = realloc(_ecore_xcb_key_grabs,
1840 _ecore_xcb_key_grabs_num * sizeof(Ecore_X_Window));
1842 _ecore_xcb_key_grabs = t;
1843 _ecore_xcb_key_grabs[_ecore_xcb_key_grabs_num - 1] = win;
1847 ecore_x_window_key_ungrab(Ecore_X_Window win,
1852 xcb_keycode_t keycode = XCB_NO_SYMBOL;
1853 uint16_t m = 0, locks[8];
1856 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1859 keycode = _ecore_xcb_keymap_string_to_keycode(key);
1860 if (keycode == XCB_NO_SYMBOL) return;
1862 m = _ecore_xcb_window_modifiers_get(mod);
1863 if (any_mod) m = XCB_MOD_MASK_ANY;
1866 locks[1] = ECORE_X_LOCK_CAPS;
1867 locks[2] = ECORE_X_LOCK_NUM;
1868 locks[3] = ECORE_X_LOCK_SCROLL;
1869 locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
1870 locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
1871 locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1872 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1874 for (i = 0; i < 8; i++)
1875 xcb_ungrab_key(_ecore_xcb_conn, keycode, win, m | locks[i]);
1877 _ecore_xcb_sync_magic_send(2, win);
1880 /* local functions */
1882 _ecore_xcb_window_root_of_screen_get(int screen)
1884 xcb_screen_iterator_t iter;
1887 iter = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn));
1888 for (; iter.rem; --screen, xcb_screen_next(&iter))
1893 if ((s = iter.data))
1899 static Ecore_X_Window
1900 _ecore_xcb_window_argb_internal_new(Ecore_X_Window parent,
1905 uint8_t override_redirect,
1908 Ecore_X_Window win = 0;
1909 #ifdef ECORE_XCB_RENDER
1910 uint32_t value_list[10];
1911 uint32_t value_mask;
1913 Ecore_X_Colormap colormap;
1916 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1919 #ifdef ECORE_XCB_RENDER
1921 parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1924 _ecore_xcb_render_find_visual_id(XCB_RENDER_PICT_TYPE_DIRECT, EINA_TRUE);
1926 colormap = xcb_generate_id(_ecore_xcb_conn);
1927 xcb_create_colormap(_ecore_xcb_conn, XCB_COLORMAP_ALLOC_NONE,
1928 colormap, parent, vis);
1930 value_mask = (XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
1931 XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE |
1932 XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER |
1933 XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE | XCB_CW_COLORMAP);
1935 value_list[0] = XCB_BACK_PIXMAP_NONE;
1937 value_list[2] = XCB_GRAVITY_NORTH_WEST;
1938 value_list[3] = XCB_GRAVITY_NORTH_WEST;
1939 value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
1940 value_list[5] = override_redirect;
1941 value_list[6] = save_under;
1942 value_list[7] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
1943 XCB_EVENT_MASK_BUTTON_PRESS |
1944 XCB_EVENT_MASK_BUTTON_RELEASE |
1945 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
1946 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
1947 XCB_EVENT_MASK_VISIBILITY_CHANGE |
1948 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
1949 XCB_EVENT_MASK_FOCUS_CHANGE |
1950 XCB_EVENT_MASK_PROPERTY_CHANGE |
1951 XCB_EVENT_MASK_COLOR_MAP_CHANGE);
1952 value_list[8] = XCB_EVENT_MASK_NO_EVENT;
1953 value_list[9] = colormap;
1955 win = xcb_generate_id(_ecore_xcb_conn);
1956 xcb_create_window(_ecore_xcb_conn, 32, win, parent, x, y, w, h, 0,
1957 XCB_WINDOW_CLASS_INPUT_OUTPUT, vis, value_mask,
1960 xcb_free_colormap(_ecore_xcb_conn, colormap);
1962 if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root)
1963 ecore_x_window_defaults_set(win);
1969 static Ecore_X_Window
1970 _ecore_xcb_window_at_xy_get(Ecore_X_Window base,
1975 Ecore_X_Window *skip,
1978 xcb_query_tree_cookie_t cookie;
1979 xcb_query_tree_reply_t *reply;
1980 Ecore_X_Window *windows = NULL;
1981 int wx, wy, ww, wh, num, i = 0;
1982 Eina_Bool skipit = EINA_FALSE;
1984 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1987 if (!ecore_x_window_visible_get(base)) return 0;
1989 ecore_x_window_geometry_get(base, &wx, &wy, &ww, &wh);
1993 if (!((x >= wx) && (y >= wy) && (x < (wx + ww)) && (y < (wy + wh))))
1996 cookie = xcb_query_tree_unchecked(_ecore_xcb_conn, base);
1997 reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL);
1998 if (!reply) return 0;
2000 num = reply->children_len;
2001 windows = xcb_query_tree_children(reply);
2003 for (i = (num - 1); i >= 0; --i)
2005 skipit = EINA_FALSE;
2011 for (j = 0; j < skip_num; j++)
2013 if (windows[i] == skip[j])
2023 Ecore_X_Window child = 0;
2026 _ecore_xcb_window_at_xy_get(windows[i],
2027 wx, wy, x, y, skip, skip_num);
2030 if (reply) free(reply);
2036 if (reply) free(reply);
2041 _ecore_xcb_window_visual_get(Ecore_X_Window win)
2043 xcb_get_window_attributes_cookie_t cookie;
2044 xcb_get_window_attributes_reply_t *reply;
2045 Ecore_X_Visual visual = 0;
2049 cookie = xcb_get_window_attributes(_ecore_xcb_conn, win);
2050 reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL);
2051 if (!reply) return 0;
2052 visual = _ecore_xcb_window_find_visual_by_id(reply->visual);
2059 _ecore_xcb_window_button_grab_remove(Ecore_X_Window win)
2061 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2064 if (_ecore_xcb_button_grabs_num > 0)
2066 int i = 0, shuffle = 0;
2068 for (i = 0; i < _ecore_xcb_button_grabs_num; i++)
2071 _ecore_xcb_button_grabs[i - 1] = _ecore_xcb_button_grabs[i];
2073 if ((!shuffle) && (_ecore_xcb_button_grabs[i] == win))
2081 _ecore_xcb_button_grabs_num--;
2082 if (_ecore_xcb_button_grabs_num <= 0)
2084 free(_ecore_xcb_button_grabs);
2085 _ecore_xcb_button_grabs = NULL;
2089 t = realloc(_ecore_xcb_button_grabs,
2090 _ecore_xcb_button_grabs_num * sizeof(Ecore_X_Window));
2092 _ecore_xcb_button_grabs = t;
2098 _ecore_xcb_window_key_grab_remove(Ecore_X_Window win)
2100 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2103 if (_ecore_xcb_key_grabs_num > 0)
2105 int i = 0, shuffle = 0;
2107 for (i = 0; i < _ecore_xcb_key_grabs_num; i++)
2110 _ecore_xcb_key_grabs[i - 1] = _ecore_xcb_key_grabs[i];
2112 if ((!shuffle) && (_ecore_xcb_key_grabs[i] == win))
2120 _ecore_xcb_key_grabs_num--;
2121 if (_ecore_xcb_key_grabs_num <= 0)
2123 free(_ecore_xcb_key_grabs);
2124 _ecore_xcb_key_grabs = NULL;
2128 t = realloc(_ecore_xcb_key_grabs,
2129 _ecore_xcb_key_grabs_num * sizeof(Ecore_X_Window));
2131 _ecore_xcb_key_grabs = t;
2137 _ecore_xcb_window_grab_allow_events(Ecore_X_Window event_win,
2138 Ecore_X_Window child_win,
2141 Ecore_X_Time timestamp)
2145 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2148 for (i = 0; i < _ecore_xcb_button_grabs_num; i++)
2150 if ((_ecore_xcb_button_grabs[i] == event_win) ||
2151 (_ecore_xcb_button_grabs[i] == child_win))
2153 Eina_Bool replay = EINA_FALSE;
2155 if (_ecore_xcb_window_grab_replay_func)
2158 _ecore_xcb_window_grab_replay_func(_ecore_xcb_window_grab_replay_data,
2163 xcb_allow_events(_ecore_xcb_conn,
2164 XCB_ALLOW_REPLAY_POINTER, timestamp);
2168 xcb_allow_events(_ecore_xcb_conn,
2169 XCB_ALLOW_ASYNC_POINTER, timestamp);
2177 _ecore_xcb_window_modifiers_get(unsigned int state)
2181 if (state & ECORE_EVENT_MODIFIER_SHIFT)
2182 xmodifiers |= ECORE_X_MODIFIER_SHIFT;
2183 if (state & ECORE_EVENT_MODIFIER_CTRL)
2184 xmodifiers |= ECORE_X_MODIFIER_CTRL;
2185 if (state & ECORE_EVENT_MODIFIER_ALT)
2186 xmodifiers |= ECORE_X_MODIFIER_ALT;
2187 if (state & ECORE_EVENT_MODIFIER_WIN)
2188 xmodifiers |= ECORE_X_MODIFIER_WIN;
2189 if (state & ECORE_EVENT_MODIFIER_ALTGR)
2190 xmodifiers |= ECORE_X_MODIFIER_ALTGR;
2191 if (state & ECORE_EVENT_LOCK_SCROLL)
2192 xmodifiers |= ECORE_X_LOCK_SCROLL;
2193 if (state & ECORE_EVENT_LOCK_NUM)
2194 xmodifiers |= ECORE_X_LOCK_NUM;
2195 if (state & ECORE_EVENT_LOCK_CAPS)
2196 xmodifiers |= ECORE_X_LOCK_CAPS;
2197 if (state & ECORE_EVENT_LOCK_SHIFT)
2198 xmodifiers |= ECORE_X_LOCK_SHIFT;
2203 static xcb_visualtype_t *
2204 _ecore_xcb_window_find_visual_by_id(xcb_visualid_t id)
2206 xcb_depth_iterator_t diter;
2207 xcb_visualtype_iterator_t viter;
2210 diter = xcb_screen_allowed_depths_iterator(_ecore_xcb_screen);
2211 for (; diter.rem; xcb_depth_next(&diter))
2213 viter = xcb_depth_visuals_iterator(diter.data);
2214 for (; viter.rem; xcb_visualtype_next(&viter))
2216 if (viter.data->visual_id == id)
2223 #ifdef ECORE_XCB_XPRINT
2224 static xcb_screen_t *
2225 _ecore_xcb_window_screen_of_display(int screen)
2227 xcb_screen_iterator_t iter;
2230 iter = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn));
2231 for (; iter.rem; --screen, xcb_screen_next(&iter))