2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
6 #include "ecore_xcb_private.h"
7 #include "Ecore_X_Atoms.h"
10 static int ignore_num = 0;
11 static Ecore_X_Window *ignore_list = NULL;
13 static Ecore_X_Window _ecore_x_window_at_xy_get(Ecore_X_Window base,
21 #ifdef ECORE_XCB_RENDER
22 static Ecore_X_Window _ecore_x_window_argb_internal_new(Ecore_X_Window parent,
27 uint8_t override_redirect,
29 #endif /* ECORE_XCB_RENDER */
33 * @defgroup Ecore_X_Window_Create_Group X Window Creation Functions
35 * Functions that can be used to create an X window.
39 * Creates a new window.
40 * @param parent The parent window to use. If @p parent is @c 0, the root
41 * window of the default display is used.
42 * @param x X position.
43 * @param y Y position.
46 * @return The new window handle.
47 * @ingroup Ecore_X_Window_Create_Group
50 ecore_x_window_new(Ecore_X_Window parent,
56 uint32_t value_list[9];
57 Ecore_X_Window window;
58 xcb_visualid_t vis = { XCB_WINDOW_CLASS_COPY_FROM_PARENT };
61 if (parent == 0) parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
64 XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
65 XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_OVERRIDE_REDIRECT |
66 XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE;
68 value_list[0] = XCB_NONE;
70 value_list[2] = XCB_GRAVITY_NORTH_WEST;
71 value_list[3] = XCB_GRAVITY_NORTH_WEST;
72 value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
76 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
77 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
78 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
79 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
80 XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
81 XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
82 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
83 value_list[8] = XCB_EVENT_MASK_NO_EVENT;
85 window = xcb_generate_id(_ecore_xcb_conn);
86 xcb_create_window(_ecore_xcb_conn,
87 XCB_WINDOW_CLASS_COPY_FROM_PARENT,
88 window, parent, x, y, width, height, 0,
89 XCB_WINDOW_CLASS_INPUT_OUTPUT,
94 if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root) ecore_x_window_defaults_set(window);
99 * Creates a window with the override redirect attribute set to @c True.
100 * @param parent The parent window to use. If @p parent is @c 0, the root
101 * window of the default display is used.
102 * @param x X position.
103 * @param y Y position.
106 * @return The new window handle.
107 * @ingroup Ecore_X_Window_Create_Group
110 ecore_x_window_override_new(Ecore_X_Window parent,
116 uint32_t value_list[9];
117 Ecore_X_Window window;
118 xcb_visualid_t vis = { XCB_WINDOW_CLASS_COPY_FROM_PARENT };
121 if (parent == 0) parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
124 XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
125 XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_OVERRIDE_REDIRECT |
126 XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE;
128 value_list[0] = XCB_NONE;
130 value_list[2] = XCB_GRAVITY_NORTH_WEST;
131 value_list[3] = XCB_GRAVITY_NORTH_WEST;
132 value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
136 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
137 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
138 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
139 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
140 XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
141 XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
142 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
143 value_list[8] = XCB_EVENT_MASK_NO_EVENT;
145 window = xcb_generate_id(_ecore_xcb_conn);
146 xcb_create_window(_ecore_xcb_conn,
147 XCB_WINDOW_CLASS_COPY_FROM_PARENT,
148 window, parent, x, y, width, height, 0,
149 XCB_WINDOW_CLASS_INPUT_OUTPUT,
157 * Creates a new input window.
158 * @param parent The parent window to use. If @p parent is @c 0, the root
159 * window of the default display is used.
160 * @param x X position.
161 * @param y Y position.
164 * @return The new window.
165 * @ingroup Ecore_X_Window_Create_Group
168 ecore_x_window_input_new(Ecore_X_Window parent,
174 uint32_t value_list[3];
175 Ecore_X_Window window;
176 xcb_visualid_t vis = { XCB_WINDOW_CLASS_COPY_FROM_PARENT };
179 if (parent == 0) parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
181 value_mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE;
185 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
186 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
187 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
188 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
189 XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
190 XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
191 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
192 value_list[2] = XCB_EVENT_MASK_NO_EVENT;
194 window = xcb_generate_id(_ecore_xcb_conn);
195 xcb_create_window(_ecore_xcb_conn,
196 XCB_WINDOW_CLASS_COPY_FROM_PARENT,
197 window, parent, x, y, width, height, 0,
198 XCB_WINDOW_CLASS_INPUT_OUTPUT,
203 if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root)
211 * Creates a new window.
212 * @param parent The parent window to use. If @p parent is @c 0, the root
213 * window of the default display is used.
214 * @param x X position.
215 * @param y Y position.
216 * @param width Width.
217 * @param height Height.
218 * @return The new window handle.
219 * @ingroup Ecore_X_Window_Create_Group
222 ecore_x_window_manager_argb_new(Ecore_X_Window parent,
228 Ecore_X_Window window = 0;
230 #ifdef ECORE_XCB_RENDER
231 window = _ecore_x_window_argb_internal_new(parent,
234 #endif /* ECORE_XCB_RENDER */
240 * Creates a new window.
241 * @param parent The parent window to use. If @p parent is @c 0, the root
242 * window of the default display is used.
243 * @param x X position.
244 * @param y Y position.
245 * @param width Width.
246 * @param height Height.
247 * @return The new window handle.
248 * @ingroup Ecore_X_Window_Create_Group
251 ecore_x_window_argb_new(Ecore_X_Window parent,
257 Ecore_X_Window window = 0;
259 #ifdef ECORE_XCB_RENDER
260 window = _ecore_x_window_argb_internal_new(parent,
263 #endif /* ECORE_XCB_RENDER */
269 * Creates a window with the override redirect attribute set to @c True.
270 * @param parent The parent window to use. If @p parent is @c 0, the root
271 * window of the default display is used.
272 * @param x X position.
273 * @param y Y position.
274 * @param width Width.
275 * @param height Height.
276 * @return The new window handle.
277 * @ingroup Ecore_X_Window_Create_Group
280 ecore_x_window_override_argb_new(Ecore_X_Window parent,
286 Ecore_X_Window window = 0;
288 #ifdef ECORE_XCB_RENDER
289 window = _ecore_x_window_argb_internal_new(parent,
292 #endif /* ECORE_XCB_RENDER */
298 * @defgroup Ecore_X_Window_Destroy_Group X Window Destroy Functions
300 * Functions to destroy X windows.
304 * Deletes the given window.
305 * @param window The given window.
306 * @ingroup Ecore_X_Window_Destroy_Group
309 ecore_x_window_del(Ecore_X_Window window)
311 /* sorry sir, deleting the root window doesn't sound like
315 xcb_destroy_window(_ecore_xcb_conn, window);
319 * Sends a delete request to the given window.
320 * @param window The given window.
321 * @ingroup Ecore_X_Window_Destroy_Group
324 ecore_x_window_delete_request_send(Ecore_X_Window window)
326 xcb_client_message_event_t ev;
328 /* sorry sir, deleting the root window doesn't sound like
334 ev.response_type = XCB_CLIENT_MESSAGE;
338 ev.type = ECORE_X_ATOM_WM_PROTOCOLS;
339 ev.data.data32[0] = ECORE_X_ATOM_WM_DELETE_WINDOW;
340 ev.data.data32[1] = XCB_CURRENT_TIME;
342 xcb_send_event(_ecore_xcb_conn, 0, window,
343 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
347 * @defgroup Ecore_X_Window_Configure_Group X Window Configure Functions
349 * Functions to configure X windows.
354 * Configures the given window with the given mask.
355 * @param window The given window.
356 * @param mask The given mask.
357 * @param x The X coordinate of the window.
358 * @param y The Y coordinate of the window.
359 * @param width The width of the window.
360 * @param height The height of the window.
361 * @param border_width The border width of the window.
362 * @param sibling The sibling window of the window.
363 * @param stack_mode The stack mode of the window.
364 * @ingroup Ecore_X_Window_Configure_Group
367 ecore_x_window_configure(Ecore_X_Window window,
368 Ecore_X_Window_Configure_Mask mask,
374 Ecore_X_Window sibling,
377 uint32_t *value_list;
385 for ( ; value_mask; value_mask >>= 1)
388 value_list = (uint32_t *)malloc(sizeof(uint32_t) * length);
393 for ( ; value_mask; value_mask >>= 1, value_list++)
396 switch (value_mask) {
397 case XCB_CONFIG_WINDOW_X:
400 case XCB_CONFIG_WINDOW_Y:
403 case XCB_CONFIG_WINDOW_WIDTH:
406 case XCB_CONFIG_WINDOW_HEIGHT:
407 *value_list = height;
409 case XCB_CONFIG_WINDOW_BORDER_WIDTH:
410 *value_list = border_width;
412 case XCB_CONFIG_WINDOW_SIBLING:
413 *value_list = sibling;
415 case XCB_CONFIG_WINDOW_STACK_MODE:
416 *value_list = stack_mode;
421 xcb_configure_window(_ecore_xcb_conn, window, mask, value_list);
426 * Moves a window to the position @p x, @p y.
428 * The position is relative to the upper left hand corner of the
431 * @param window The window to move.
432 * @param x X position.
433 * @param y Y position.
434 * @ingroup Ecore_X_Window_Configure_Group
437 ecore_x_window_move(Ecore_X_Window window,
441 uint32_t value_list[2];
447 value_mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
452 xcb_configure_window(_ecore_xcb_conn, window, value_mask, value_list);
457 * @param window The window to resize.
458 * @param width New width of the window.
459 * @param height New height of the window.
460 * @ingroup Ecore_X_Window_Configure_Group
463 ecore_x_window_resize(Ecore_X_Window window,
467 uint32_t value_list[2];
473 if (width < 1) width = 1;
474 if (height < 1) height = 1;
476 value_mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
478 value_list[0] = width;
479 value_list[1] = height;
481 xcb_configure_window(_ecore_xcb_conn, window, value_mask, value_list);
485 * Moves and resizes a window.
486 * @param window The window to move and resize.
487 * @param x New X position of the window.
488 * @param y New Y position of the window.
489 * @param width New width of the window.
490 * @param height New height of the window.
491 * @ingroup Ecore_X_Window_Configure_Group
494 ecore_x_window_move_resize(Ecore_X_Window window,
500 uint32_t value_list[4];
506 if (width < 1) width = 1;
507 if (height < 1) height = 1;
510 XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y |
511 XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
515 value_list[2] = width;
516 value_list[3] = height;
518 xcb_configure_window(_ecore_xcb_conn, window, value_mask, value_list);
522 * Sets the width of the border of the given window.
523 * @param window The given window.
524 * @param border_width The new border width.
525 * @ingroup Ecore_X_Window_Configure_Group
528 ecore_x_window_border_width_set(Ecore_X_Window window,
533 /* doesn't make sense to call this on a root window */
537 value_list = border_width;
539 xcb_configure_window(_ecore_xcb_conn, window, XCB_CONFIG_WINDOW_BORDER_WIDTH, &value_list);
543 * Raises the given window.
544 * @param window The window to raise.
545 * @ingroup Ecore_X_Window_Configure_Group
548 ecore_x_window_raise(Ecore_X_Window window)
555 value_list = XCB_STACK_MODE_ABOVE;
557 xcb_configure_window(_ecore_xcb_conn, window, XCB_CONFIG_WINDOW_STACK_MODE, &value_list);
561 * Lowers the given window.
562 * @param window The window to lower.
563 * @ingroup Ecore_X_Window_Configure_Group
566 ecore_x_window_lower(Ecore_X_Window window)
573 value_list = XCB_STACK_MODE_BELOW;
575 xcb_configure_window(_ecore_xcb_conn, window, XCB_CONFIG_WINDOW_STACK_MODE, &value_list);
579 * @defgroup Evas_X_Window_Change_Properties_Group X Window Change Property Functions
581 * Functions that change window properties.
585 * Sets the default properties for the given window.
587 * The default properties set for the window are @c WM_CLIENT_MACHINE and
590 * @param window The given window.
591 * @ingroup Ecore_X_Window_Change_Property_Group
594 ecore_x_window_defaults_set(Ecore_X_Window window)
596 char buf[MAXHOSTNAMELEN];
602 * Set WM_CLIENT_MACHINE.
604 gethostname(buf, MAXHOSTNAMELEN);
605 buf[MAXHOSTNAMELEN - 1] = '\0';
606 /* The ecore function uses UTF8 which Xlib may not like (especially
607 * with older clients) */
608 /* ecore_xcb_window_prop_string_set(win, ECORE_X_ATOM_WM_CLIENT_MACHINE,
610 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
611 ECORE_X_ATOM_WM_CLIENT_MACHINE,
613 8, strlen(buf), buf);
619 ecore_x_netwm_pid_set(window, pid);
621 ecore_x_netwm_window_type_set(window, ECORE_X_WINDOW_TYPE_NORMAL);
623 ecore_app_args_get(&argc, &argv);
624 ecore_x_icccm_command_set(window, argc, argv);
628 * @defgroup Ecore_X_Window_Visibility_Group X Window Visibility Functions
630 * Functions to change the visibility of X windows.
636 * Synonymous to "mapping" a window in X Window System terminology.
638 * @param window The window to show.
639 * @ingroup Ecore_X_Window_Visibility_Group
642 ecore_x_window_show(Ecore_X_Window window)
644 xcb_map_window(_ecore_xcb_conn, window);
650 * Synonymous to "unmapping" a window in X Window System terminology.
652 * @param window The window to hide.
653 * @ingroup Ecore_X_Window_Visibility_Group
656 ecore_x_window_hide(Ecore_X_Window window)
658 xcb_unmap_notify_event_t ev;
661 /* ICCCM: SEND unmap event... */
663 /* FIXME: is it correct ? */
664 if (xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).rem == 1)
665 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
668 xcb_get_geometry_cookie_t cookie;
669 xcb_get_geometry_reply_t *rep;
670 Ecore_X_Drawable draw;
672 /* FIXME: can we avoid round trips, here ? */
674 cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, draw);
675 rep = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
681 ev.response_type = XCB_UNMAP_NOTIFY;
686 ev.from_configure = 0;
688 xcb_send_event(_ecore_xcb_conn, 0, root,
689 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
691 xcb_unmap_window(_ecore_xcb_conn, window);
695 * @defgroup Ecore_X_Window_Input_Focus_Group X Window Input Focus Functions
697 * Functions that manage the focus of an X Window.
701 * Sets the focus to the window @p window.
702 * @param window The window to focus.
703 * @ingroup Ecore_X_Window_Input_Focus_Group
706 ecore_x_window_focus(Ecore_X_Window window)
708 Ecore_X_Time time = XCB_CURRENT_TIME;
710 if (window == 0) window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
712 /* xcb_set_input_focus(_ecore_xcb_conn, XCB_INPUT_FOCUS_NONE, win, time); */
713 xcb_set_input_focus(_ecore_xcb_conn,
714 XCB_INPUT_FOCUS_POINTER_ROOT, window, time);
718 * Sets the focus to the given window at a specific time.
719 * @param window The window to focus.
720 * @param time When to set the focus to the window.
721 * @ingroup Ecore_X_Window_Input_Focus_Group
724 ecore_x_window_focus_at_time(Ecore_X_Window window,
727 if (window == 0) window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
729 /* xcb_set_input_focus(_ecore_xcb_conn, XCB_INPUT_FOCUS_NONE, win, time); */
730 xcb_set_input_focus(_ecore_xcb_conn,
731 XCB_INPUT_FOCUS_POINTER_ROOT, window, time);
735 * @defgroup Ecore_X_Window_Reparent_Group X Window Reparent Functions
737 * Functions that retrieve or changes the parent window of a window.
741 * Moves a window to within another window at a given position.
742 * @param window The window to reparent.
743 * @param new_parent The new parent window.
744 * @param x X position within new parent window.
745 * @param y Y position within new parent window.
746 * @ingroup Ecore_X_Window_Reparent_Group
749 ecore_x_window_reparent(Ecore_X_Window window,
750 Ecore_X_Window new_parent,
754 if (new_parent == 0) new_parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
756 xcb_reparent_window(_ecore_xcb_conn, window, new_parent, x, y);
761 * @defgroup Ecore_X_Window_Change_Attributes_Group X Window Change Attributes Functions
763 * Functions that change the attributes of a window.
767 * Sets the background pixmap of the given window.
768 * @param window The given window.
769 * @param pixmap The pixmap to set to.
770 * @ingroup Ecore_X_Window_Change_Attributes_Group
773 ecore_x_window_pixmap_set(Ecore_X_Window window,
774 Ecore_X_Pixmap pixmap)
779 xcb_change_window_attributes(_ecore_xcb_conn, window,
780 XCB_CW_BACK_PIXMAP, &value_list);
784 * Sets the background color of the given window.
785 * @param window The given window.
786 * @param red The red component of the color to set to.
787 * @param green The green component of the color to set to.
788 * @param blue The blue component of the color to set to.
789 * @ingroup Ecore_X_Window_Change_Attributes_Group
792 ecore_x_window_background_color_set(Ecore_X_Window window,
794 unsigned short green,
797 xcb_alloc_color_cookie_t cookie;
798 xcb_alloc_color_reply_t *rep;
801 /* FIXME: should I provide a reply, and not the color components, here ? */
802 /* (because of roundtrips) */
803 cookie = xcb_alloc_color_unchecked(_ecore_xcb_conn,
804 ((xcb_screen_t *)_ecore_xcb_screen)->default_colormap,
806 rep = xcb_alloc_color_reply(_ecore_xcb_conn, cookie, NULL);
810 value_list = rep->pixel;
811 xcb_change_window_attributes(_ecore_xcb_conn, window,
812 XCB_CW_BACK_PIXEL, &value_list);
817 * Sets the bit gravity of the given window.
818 * @param window The given window.
819 * @param gravity The gravity.
820 * @ingroup Ecore_X_Window_Change_Attributes_Group
823 ecore_x_window_pixel_gravity_set(Ecore_X_Window window,
824 Ecore_X_Gravity gravity)
828 value_list = gravity;
829 xcb_change_window_attributes(_ecore_xcb_conn, window,
830 XCB_CW_BIT_GRAVITY, &value_list);
834 * Sets the gravity of the given window.
835 * @param window The given window.
836 * @param gravity The gravity.
837 * @ingroup Ecore_X_Window_Change_Attributes_Group
840 ecore_x_window_gravity_set(Ecore_X_Window window,
841 Ecore_X_Gravity gravity)
845 value_list = gravity;
846 xcb_change_window_attributes(_ecore_xcb_conn, window,
847 XCB_CW_WIN_GRAVITY, &value_list);
851 * Sets the override attribute of the given window.
852 * @param window The given window.
853 * @param override_redirect The override_redirect boolean.
854 * @ingroup Ecore_X_Window_Change_Attributes_Group
857 ecore_x_window_override_set(Ecore_X_Window window,
858 int override_redirect)
862 value_list = override_redirect;
863 xcb_change_window_attributes(_ecore_xcb_conn, window,
864 XCB_CW_OVERRIDE_REDIRECT, &value_list);
868 * Shows the cursor of the given window.
869 * @param window The given window.
870 * @param show If set to @c 0, hide the cursor. Show it otherwise.
871 * @ingroup Ecore_X_Window_Change_Attributes_Group
874 ecore_x_window_cursor_show(Ecore_X_Window window,
877 if (window == 0) window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
881 Ecore_X_Cursor cursor;
882 Ecore_X_Drawable draw;
883 Ecore_X_Pixmap pixmap;
890 pixmap = xcb_generate_id(_ecore_xcb_conn);
891 xcb_create_pixmap(_ecore_xcb_conn,
894 mask = xcb_generate_id(_ecore_xcb_conn);
895 xcb_create_pixmap(_ecore_xcb_conn,
899 gc = xcb_generate_id(_ecore_xcb_conn);
900 xcb_create_gc (_ecore_xcb_conn, gc, draw, 0, NULL);
902 xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_FOREGROUND, &value_list);
907 xcb_poly_point(_ecore_xcb_conn, XCB_COORD_MODE_ORIGIN, draw,
910 xcb_free_gc(_ecore_xcb_conn, gc);
912 cursor = xcb_generate_id(_ecore_xcb_conn);
913 xcb_create_cursor(_ecore_xcb_conn, cursor,
919 xcb_change_window_attributes(_ecore_xcb_conn, window,
920 XCB_CW_CURSOR, &value_list);
922 xcb_free_cursor(_ecore_xcb_conn, cursor);
923 xcb_free_pixmap(_ecore_xcb_conn, mask);
924 xcb_free_pixmap(_ecore_xcb_conn, pixmap);
931 xcb_change_window_attributes(_ecore_xcb_conn, window,
932 XCB_CW_CURSOR, &value_list);
937 * Sets the cursor of the given window.
938 * @param window The given window.
939 * @param cursor The given cursor.
940 * @ingroup Ecore_X_Window_Change_Attributes_Group
943 ecore_x_window_cursor_set(Ecore_X_Window window,
944 Ecore_X_Cursor cursor)
949 xcb_change_window_attributes(_ecore_xcb_conn, window,
950 XCB_CW_CURSOR, &value_list);
955 * @param window The given window.
956 * @ingroup Ecore_X_Window_Change_Attributes_Group
959 ecore_x_window_container_manage(Ecore_X_Window window)
964 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
965 XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
966 xcb_change_window_attributes(_ecore_xcb_conn, window,
967 XCB_CW_EVENT_MASK, &value_list);
973 * @param window The given window.
974 * @ingroup Ecore_X_Window_Change_Attributes_Group
977 ecore_x_window_client_manage(Ecore_X_Window window)
982 XCB_EVENT_MASK_VISIBILITY_CHANGE |
983 /* XCB_EVENT_MASK_RESIZE_REDIRECT | */
984 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
985 XCB_EVENT_MASK_FOCUS_CHANGE |
986 XCB_EVENT_MASK_PROPERTY_CHANGE |
987 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
988 xcb_change_window_attributes(_ecore_xcb_conn, window,
989 XCB_CW_EVENT_MASK, &value_list);
990 #ifdef ECORE_XCB_SHAPE
991 xcb_shape_select_input(_ecore_xcb_conn, window, 1);
992 #endif /* ECORE_XCB_SHAPE */
997 * @param window The given window.
998 * @ingroup Ecore_X_Window_Change_Attributes_Group
1001 ecore_x_window_sniff(Ecore_X_Window window)
1003 uint32_t value_list;
1006 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
1007 XCB_EVENT_MASK_PROPERTY_CHANGE;
1008 xcb_change_window_attributes(_ecore_xcb_conn, window,
1009 XCB_CW_EVENT_MASK, &value_list);
1014 * @param window The given window.
1015 * @ingroup Ecore_X_Window_Change_Attributes_Group
1018 ecore_x_window_client_sniff(Ecore_X_Window window)
1020 uint32_t value_list;
1023 XCB_EVENT_MASK_VISIBILITY_CHANGE |
1024 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
1025 XCB_EVENT_MASK_FOCUS_CHANGE |
1026 XCB_EVENT_MASK_PROPERTY_CHANGE |
1027 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
1028 xcb_change_window_attributes(_ecore_xcb_conn, window,
1029 XCB_CW_EVENT_MASK, &value_list);
1030 #ifdef ECORE_XCB_SHAPE
1031 xcb_shape_select_input(_ecore_xcb_conn, window, 1);
1032 #endif /* ECORE_XCB_SHAPE */
1036 * Clears an area of the given window.
1037 * @param window The given window.
1038 * @param x The X coordinate of the area.
1039 * @param y The Y coordinate of the area.
1040 * @param width The width of the area.
1041 * @param height The height of the area.
1042 * @ingroup Ecore_X_Window_Clear_Area_Group
1045 ecore_x_window_area_clear(Ecore_X_Window window,
1051 xcb_clear_area(_ecore_xcb_conn, 0, window, x, y, width, height);
1055 * Exposes an area of the given window.
1056 * @param window The given window.
1057 * @param x The X coordinate of the area.
1058 * @param y The Y coordinate of the area.
1059 * @param width The width of the area.
1060 * @param height The height of the area.
1061 * @ingroup Ecore_X_Window_Clear_Area_Group
1064 ecore_x_window_area_expose(Ecore_X_Window window,
1070 xcb_clear_area(_ecore_xcb_conn, 1, window, x, y, width, height);
1075 * @defgroup Ecore_X_Window_Save_Set_Group X Window Change Save Set Functions
1077 * Functions that either inserts or deletes the specified window from
1078 * the client's save-set.
1082 * Inserts the window in the client's save-set.
1083 * @param window The window to insert in the client's save-set.
1084 * @ingroup Ecore_X_Window_Save_Set_Group
1087 ecore_x_window_save_set_add(Ecore_X_Window window)
1089 xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_INSERT, window);
1093 * Deletes the window from the client's save-set.
1094 * @param window The window to delete from the client's save-set.
1095 * @ingroup Ecore_X_Window_Save_Set_Group
1098 ecore_x_window_save_set_del(Ecore_X_Window window)
1100 xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_DELETE, window);
1103 /******************************
1105 * Request that have a reply
1107 ******************************/
1111 * Sends the GetInputFocus request.
1112 * @ingroup Ecore_X_Window_Input_Focus_Group
1115 ecore_x_get_input_focus_prefetch(void)
1117 xcb_get_input_focus_cookie_t cookie;
1119 cookie = xcb_get_input_focus_unchecked(_ecore_xcb_conn);
1120 _ecore_xcb_cookie_cache(cookie.sequence);
1124 * Gets the reply of the GetInputFocus request sent by ecore_x_get_input_focus_prefetch().
1125 * @ingroup Ecore_X_Window_Input_Focus_Group
1128 ecore_x_get_input_focus_fetch(void)
1130 xcb_get_input_focus_cookie_t cookie;
1131 xcb_get_input_focus_reply_t *reply;
1133 cookie.sequence = _ecore_xcb_cookie_get();
1134 reply = xcb_get_input_focus_reply(_ecore_xcb_conn, cookie, NULL);
1135 _ecore_xcb_reply_cache(reply);
1139 * Gets the window that has focus.
1140 * @return The window that has focus.
1142 * Returns the window that has the focus. If an error aoocured, @c 0
1143 * is returned, otherwise the function returns the window that has focus.
1145 * To use this function, you must call before, and in order,
1146 * ecore_x_get_input_focus_prefetch(), which sends the GetInputFocus request,
1147 * then ecore_x_get_input_focus_fetch(), which gets the reply.
1148 * @ingroup Ecore_X_Window_Input_Focus_Group
1151 ecore_x_window_focus_get(void)
1153 xcb_get_input_focus_reply_t *reply;
1154 Ecore_X_Window window = 0;
1156 reply = _ecore_xcb_reply_get();
1157 if (!reply) return window;
1159 return reply->focus;
1164 * @defgroup Ecore_X_Window_Get_Attributes_Group X Window Get Attributes Functions
1166 * Functions that get the attributes of a window.
1171 * Sends the GetWindowAttributes request.
1172 * @ingroup Ecore_X_Window_Get_Attributes_Group
1175 ecore_x_get_window_attributes_prefetch(Ecore_X_Window window)
1177 xcb_get_window_attributes_cookie_t cookie;
1179 cookie = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, window);
1180 _ecore_xcb_cookie_cache(cookie.sequence);
1184 * Gets the reply of the GetWindowAttributes request sent by ecore_x_get_window_attributes_prefetch().
1185 * @ingroup Ecore_X_Window_Get_Attributes_Group
1188 ecore_x_get_window_attributes_fetch(void)
1190 xcb_get_window_attributes_cookie_t cookie;
1191 xcb_get_window_attributes_reply_t *reply;
1193 cookie.sequence = _ecore_xcb_cookie_get();
1194 reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL);
1195 _ecore_xcb_reply_cache(reply);
1199 * Retrieves the attributes of a window.
1200 * @param windows Unused.
1201 * @param att_ret Pointer to an Ecore_X_Window_Attributes
1202 * structure in which the attributes of a window
1205 * Retrieves the attributes of a window. If
1206 * @p att_ret is @c NULL, the function does nothing. If an error
1207 * occurred, @p att_ret is set to 0. Otherwise, the @p att_ret structure
1208 * is filled with the attributes os the requested window.
1210 * To use this function, you must call before, and in order,
1211 * ecore_x_get_window_attributes_prefetch(), which sends the GetWindowAttributes request,
1212 * then ecore_x_get_window_attributes_fetch(), which gets the reply.
1213 * @ingroup Ecore_X_Window_Get_Attributes_Group
1216 ecore_x_window_attributes_get(Ecore_X_Window window __UNUSED__,
1217 Ecore_X_Window_Attributes *att_ret)
1219 xcb_get_window_attributes_reply_t *reply;
1221 if (!att_ret) return 0;
1223 reply = _ecore_xcb_reply_get();
1224 if (!reply) return 0;
1226 memset(att_ret, 0, sizeof(Ecore_X_Window_Attributes));
1228 if (reply->map_state != XCB_MAP_STATE_UNMAPPED) att_ret->visible = 1;
1229 if (reply->map_state == XCB_MAP_STATE_VIEWABLE) att_ret->viewable = 1;
1230 if (reply->override_redirect) att_ret->override = 1;
1231 if (reply->_class == XCB_WINDOW_CLASS_INPUT_ONLY) att_ret->input_only = 1;
1232 if (reply->save_under) att_ret->save_under = 1;
1234 att_ret->event_mask.mine = reply->your_event_mask;
1235 att_ret->event_mask.all = reply->all_event_masks;
1236 att_ret->event_mask.no_propagate = reply->do_not_propagate_mask;
1237 att_ret->window_gravity = reply->win_gravity;
1238 att_ret->pixel_gravity = reply->bit_gravity;
1239 att_ret->colormap = reply->colormap;
1240 att_ret->visual = reply->visual;
1246 * Finds out whether the given window is currently visible.
1247 * @param window Unused.
1248 * @return 1 if the window is visible, otherwise 0.
1250 * Finds out whether the given window is currently visible.
1251 * If an error occurred, or if the window is not visible, 0 is
1252 * returned. Otherwise 1 is returned.
1254 * To use this function, you must call before, and in order,
1255 * ecore_x_get_window_attributes_prefetch(), which sends the GetWindowAttributes request,
1256 * then ecore_x_get_window_attributes_fetch(), which gets the reply.
1257 * @ingroup Ecore_X_Window_Get_Attributes_Group
1260 ecore_x_window_visible_get(Ecore_X_Window window __UNUSED__)
1262 xcb_get_window_attributes_reply_t *reply;
1264 reply = _ecore_xcb_reply_get();
1265 if (!reply) return 0;
1267 return (reply->map_state == XCB_MAP_STATE_VIEWABLE) ? 1 : 0;
1272 * Sends the QueryPointer request.
1273 * @ingroup Ecore_X_Window_Parent_Group
1276 ecore_x_pointer_xy_get_prefetch(Ecore_X_Window window)
1278 xcb_query_pointer_cookie_t cookie;
1280 cookie = xcb_query_pointer_unchecked(_ecore_xcb_conn, window);
1281 _ecore_xcb_cookie_cache(cookie.sequence);
1285 * Gets the reply of the QueryPointer request sent by ecore_x_query_pointer_prefetch().
1286 * @ingroup Ecore_X_Window_Parent_Group
1289 ecore_x_pointer_xy_get_fetch(void)
1291 xcb_query_pointer_cookie_t cookie;
1292 xcb_query_pointer_reply_t *reply;
1294 cookie.sequence = _ecore_xcb_cookie_get();
1295 reply = xcb_query_pointer_reply(_ecore_xcb_conn, cookie, NULL);
1296 _ecore_xcb_reply_cache(reply);
1300 * Retrieves the coordinates of the pointer.
1301 * @param window Unused.
1302 * @param x The X coordinate of the pointer.
1303 * @param y The Y coordinate of the pointer.
1305 * Retrieves the coordinates of the pointer.
1306 * If the window used in
1307 * ecore_x_query_pointer_prefetch() is not on the same screen than
1308 * the root window or if an error occured, @p x and @p y are set
1309 * to 0. Otherwise, they are respectively set to the X and Y
1310 * coordinates of the pointer.
1312 * To use this function, you must call before, and in order,
1313 * ecore_x_query_pointer_prefetch(), which sends the QueryPointer request,
1314 * then ecore_x_query_pointer_fetch(), which gets the reply.
1315 * @ingroup Ecore_X_Window_Parent_Group
1318 ecore_x_pointer_xy_get(Ecore_X_Window window __UNUSED__,
1322 xcb_query_pointer_reply_t *reply;
1324 reply = _ecore_xcb_reply_get();
1333 if (x) *x = reply->win_x;
1334 if (y) *y = reply->win_y;
1339 * Sends the QueryTree request.
1340 * @ingroup Ecore_X_Window_Parent_Group
1343 ecore_x_query_tree_prefetch(Ecore_X_Window window)
1345 xcb_query_tree_cookie_t cookie;
1347 cookie = xcb_query_tree_unchecked(_ecore_xcb_conn, window);
1348 _ecore_xcb_cookie_cache(cookie.sequence);
1352 * Gets the reply of the QueryTree request sent by ecore_x_query_tree_prefetch().
1353 * @ingroup Ecore_X_Window_Parent_Group
1356 ecore_x_query_tree_fetch(void)
1358 xcb_query_tree_cookie_t cookie;
1359 xcb_query_tree_reply_t *reply;
1361 cookie.sequence = _ecore_xcb_cookie_get();
1362 reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL);
1363 _ecore_xcb_reply_cache(reply);
1367 * Retrieves the parent window of the given window.
1368 * @param window Unused.
1369 * @return The parent window of @p window.
1371 * Retrieves the parent window of the given window. If
1372 * an error occured, @c 0 is returned.
1374 * To use this function, you must call before, and in order,
1375 * ecore_x_query_tree_prefetch(), which sends the QueryTree request,
1376 * then ecore_x_query_tree_fetch(), which gets the reply.
1377 * @ingroup Ecore_X_Window_Parent_Group
1380 ecore_x_window_parent_get(Ecore_X_Window window __UNUSED__)
1382 xcb_query_tree_reply_t *reply;
1384 reply = _ecore_xcb_reply_get();
1385 if (!reply) return 0;
1387 return reply->parent;
1392 * Retrieves the children windows of the given window.
1393 * @param window Unused.
1394 * @param num children windows count.
1395 * @return The children windows.
1397 * Retrieves the children windows of the given window. If
1398 * an error occured, @c 0 is returned.
1400 * To use this function, you must call before, and in order,
1401 * ecore_x_query_tree_prefetch(), which sends the QueryTree request,
1402 * then ecore_x_query_tree_fetch(), which gets the reply.
1403 * @ingroup Ecore_X_Window_Parent_Group
1405 EAPI Ecore_X_Window *
1406 ecore_x_window_children_get(Ecore_X_Window window __UNUSED__,
1409 xcb_query_tree_reply_t *reply;
1410 Ecore_X_Window *windows = NULL;
1413 reply = _ecore_xcb_reply_get();
1414 if (!reply) return NULL;
1416 windows = malloc(reply->children_len);
1420 if (num) *num = reply->children_len;
1422 xcb_query_tree_children(reply),
1423 sizeof(Ecore_X_Window) * reply->children_len);
1428 /* FIXME: I've tried to remove the round trips. 3 cookies are */
1429 /* created at the beginning of the function. Because of */
1430 /* the recursivity of the algo, I can't find better trick */
1431 static Ecore_X_Window
1432 _ecore_x_window_at_xy_get(Ecore_X_Window base,
1437 Ecore_X_Window *skip,
1440 xcb_window_iterator_t iter_children;
1441 xcb_get_window_attributes_cookie_t cookie_get_window_attributes;
1442 xcb_get_geometry_cookie_t cookie_get_geometry;
1443 xcb_query_tree_cookie_t cookie_query_tree;
1444 xcb_get_window_attributes_reply_t *reply_get_window_attributes;
1445 xcb_get_geometry_reply_t *reply_get_geometry;
1446 xcb_query_tree_reply_t *reply_query_tree;
1447 Ecore_X_Window window = 0;
1448 Ecore_X_Window child = 0;
1452 uint16_t win_height;
1454 cookie_get_window_attributes = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, base);
1455 cookie_get_geometry = xcb_get_geometry_unchecked(_ecore_xcb_conn, base);
1456 cookie_query_tree = xcb_query_tree_unchecked(_ecore_xcb_conn, base);
1458 reply_get_window_attributes = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie_get_window_attributes, NULL);
1459 if (!reply_get_window_attributes)
1461 reply_get_geometry = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_get_geometry, NULL);
1462 if (reply_get_geometry) free(reply_get_geometry);
1463 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1464 if (reply_query_tree) free(reply_query_tree);
1468 if (reply_get_window_attributes->map_state != XCB_MAP_STATE_VIEWABLE)
1470 free(reply_get_window_attributes);
1471 reply_get_geometry = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_get_geometry, NULL);
1472 if (reply_get_geometry) free(reply_get_geometry);
1473 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1474 if (reply_query_tree) free(reply_query_tree);
1478 free(reply_get_window_attributes);
1480 reply_get_geometry = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_get_geometry, NULL);
1481 if (!reply_get_geometry)
1483 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1484 if (reply_query_tree) free(reply_query_tree);
1488 win_x = reply_get_geometry->x;
1489 win_y = reply_get_geometry->y;
1490 win_width = reply_get_geometry->width;
1491 win_height = reply_get_geometry->height;
1493 free(reply_get_geometry);
1498 if (!((x >= win_x) &&
1500 (x < (int16_t)(win_x + win_width)) &&
1501 (y < (int16_t)(win_y + win_height))))
1503 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1504 if (reply_query_tree) free(reply_query_tree);
1508 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1509 if (!reply_query_tree)
1515 for (i = 0; i < skip_num; i++)
1516 if (base == skip[i])
1522 iter_children = xcb_query_tree_children_iterator(reply_query_tree);
1523 for (; iter_children.rem; xcb_window_next(&iter_children))
1529 for (j = 0; j < skip_num; j++)
1530 if (*iter_children.data == skip[j])
1533 child = _ecore_x_window_at_xy_get(*iter_children.data, win_x, win_y, x, y, skip, skip_num);
1536 free(reply_query_tree);
1546 for (i = 0; i < skip_num; i++)
1547 if (base == skip[i])
1549 /* We return 0. child has an xid equal to 0 */
1550 free(reply_query_tree);
1555 free(reply_query_tree);
1561 * @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions
1563 * Functions that change or retrieve the geometry of X windows.
1567 * Retrieves the top, visible window at the given location.
1568 * @param x The given X position.
1569 * @param y The given Y position.
1570 * @return The window at that position.
1571 * @ingroup Ecore_X_Window_Geometry_Group
1574 ecore_x_window_at_xy_get(int x,
1577 Ecore_X_Window window;
1578 Ecore_X_Window root;
1580 /* FIXME: Proper function to determine current root/virtual root
1581 * window missing here */
1582 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1585 window = _ecore_x_window_at_xy_get(root, 0, 0, x, y, NULL, 0);
1588 return window ? window : root;
1592 * Retrieves the top, visible window at the given location,
1593 * but skips the windows in the list.
1594 * @param x The given X position.
1595 * @param y The given Y position.
1596 * @return The window at that position.
1597 * @ingroup Ecore_X_Window_Geometry_Group
1600 ecore_x_window_at_xy_with_skip_get(int x,
1602 Ecore_X_Window *skip,
1605 Ecore_X_Window window;
1606 Ecore_X_Window root;
1608 /* FIXME: Proper function to determine current root/virtual root
1609 * window missing here */
1610 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1613 window = _ecore_x_window_at_xy_get(root, 0, 0, x, y, skip, skip_num);
1616 return window ? window : root;
1620 * Retrieves the top, visible window at the given location,
1621 * but begins at the @p begin window instead of the root one.
1622 * @param begin The window from which we begin.
1623 * @param x The given X position.
1624 * @param y The given Y position.
1625 * @return The window at that position.
1626 * @ingroup Ecore_X_Window_Geometry_Group
1629 ecore_x_window_at_xy_begin_get(Ecore_X_Window begin,
1633 Ecore_X_Window window;
1636 window = _ecore_x_window_at_xy_get(begin, 0, 0, x, y, NULL, 0);
1639 return window ? window : begin;
1644 /* FIXME: Should I provide the replies (or the cookies), instead of
1645 creating them in the function ? */
1646 #ifdef ECORE_XCB_RENDER
1647 static Ecore_X_Window
1648 _ecore_x_window_argb_internal_new(Ecore_X_Window parent,
1653 uint8_t override_redirect,
1656 uint32_t value_list[10];
1657 xcb_depth_iterator_t iter_depth;
1658 xcb_visualtype_iterator_t iter_visualtype;
1659 xcb_render_query_pict_formats_cookie_t cookie_pict_format;
1660 xcb_render_query_pict_formats_reply_t *rep_pict_format;
1661 Ecore_X_Screen *screen = NULL;
1662 Ecore_X_Window win = { 0 };
1663 xcb_visualid_t vis = { 0 };
1664 Ecore_X_Colormap colormap;
1665 uint32_t value_mask;
1667 cookie_pict_format = xcb_render_query_pict_formats_unchecked(_ecore_xcb_conn);
1671 parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1672 screen = ((xcb_screen_t *)_ecore_xcb_screen);
1676 xcb_screen_iterator_t iter_screen;
1677 xcb_get_geometry_reply_t *rep;
1678 Ecore_X_Drawable draw;
1679 Ecore_X_Window root;
1682 rep = xcb_get_geometry_reply(_ecore_xcb_conn,
1683 xcb_get_geometry_unchecked(_ecore_xcb_conn,
1693 for (; iter_screen.rem; xcb_screen_next(&iter_screen))
1695 if (iter_screen.data->root == root)
1697 screen = iter_screen.data;
1704 /* we get the X visual types */
1705 iter_depth = xcb_screen_allowed_depths_iterator(screen);
1706 for (; iter_depth.rem; xcb_depth_next(&iter_depth)) {
1707 if (iter_depth.data->depth == 32) {
1708 iter_visualtype = xcb_depth_visuals_iterator(iter_depth.data);
1713 /* we get the X render visual id */
1714 rep_pict_format = xcb_render_query_pict_formats_reply(_ecore_xcb_conn,
1717 if (!rep_pict_format)
1720 for (; iter_visualtype.rem; xcb_visualtype_next(&iter_visualtype)) {
1721 if (iter_visualtype.data->_class == XCB_VISUAL_CLASS_TRUE_COLOR) {
1722 xcb_render_pictforminfo_iterator_t iter_forminfo;
1723 xcb_render_pictscreen_iterator_t iter_pictscreen;
1724 xcb_render_pictformat_t pict_format = { 0 };
1726 iter_forminfo = xcb_render_query_pict_formats_formats_iterator(rep_pict_format);
1727 for (; iter_forminfo.rem; xcb_render_pictforminfo_next(&iter_forminfo)) {
1728 if (iter_forminfo.data->type == XCB_RENDER_PICT_TYPE_DIRECT &&
1729 iter_forminfo.data->direct.alpha_mask && iter_forminfo.data->depth == 32) {
1730 pict_format = iter_forminfo.data->id;
1734 if (pict_format == 0) {
1735 free(rep_pict_format);
1738 iter_pictscreen = xcb_render_query_pict_formats_screens_iterator(rep_pict_format);
1739 for (; iter_pictscreen.rem; xcb_render_pictscreen_next(&iter_pictscreen)) {
1740 xcb_render_pictdepth_iterator_t iter_depth;
1742 iter_depth = xcb_render_pictscreen_depths_iterator(iter_pictscreen.data);
1743 for (; iter_depth.rem; xcb_render_pictdepth_next(&iter_depth)) {
1744 xcb_render_pictvisual_iterator_t iter_visual;
1746 iter_visual = xcb_render_pictdepth_visuals_iterator(iter_depth.data);
1747 for (; iter_visual.rem; xcb_render_pictvisual_next(&iter_visual)) {
1748 if ((iter_visual.data->visual == iter_visualtype.data->visual_id) &&
1749 (pict_format == iter_visual.data->format)) {
1750 vis = iter_visual.data->visual;
1759 free(rep_pict_format);
1764 colormap = xcb_generate_id(_ecore_xcb_conn);
1765 xcb_create_colormap(_ecore_xcb_conn, XCB_COLORMAP_ALLOC_NONE, colormap, parent, vis);
1768 XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
1769 XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_OVERRIDE_REDIRECT |
1770 XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE |
1773 value_list[0] = XCB_NONE;
1775 value_list[2] = XCB_GRAVITY_NORTH_WEST;
1776 value_list[3] = XCB_GRAVITY_NORTH_WEST;
1777 value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
1778 value_list[5] = override_redirect;
1779 value_list[6] = save_under;
1781 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
1782 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
1783 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
1784 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
1785 XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
1786 XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
1787 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
1788 value_list[8] = XCB_EVENT_MASK_NO_EVENT;
1789 value_list[9] = colormap;
1791 win = xcb_generate_id(_ecore_xcb_conn);
1792 xcb_create_window(_ecore_xcb_conn,
1796 XCB_WINDOW_CLASS_INPUT_OUTPUT,
1801 xcb_free_colormap(_ecore_xcb_conn, colormap);
1803 if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root)
1804 ecore_x_window_defaults_set(win);
1808 #endif /* ECORE_XCB_RENDER */
1812 /* FIXME: round trip */
1814 ecore_x_window_argb_get(Ecore_X_Window win)
1817 #ifdef ECORE_XCB_RENDER
1818 xcb_render_pictforminfo_iterator_t iter_forminfo;
1819 xcb_render_pictscreen_iterator_t iter_pictscreen;
1820 xcb_render_pictformat_t pict_format = { 0 };
1821 xcb_render_query_pict_formats_reply_t *rep_pictformat;
1822 xcb_get_window_attributes_reply_t *rep;
1823 xcb_visualid_t visual;
1825 rep = xcb_get_window_attributes_reply(_ecore_xcb_conn,
1826 xcb_get_window_attributes_unchecked(_ecore_xcb_conn,
1832 visual = rep->visual;
1836 rep_pictformat = xcb_render_query_pict_formats_reply(_ecore_xcb_conn,
1837 xcb_render_query_pict_formats_unchecked(_ecore_xcb_conn),
1839 if (!rep_pictformat)
1842 iter_forminfo = xcb_render_query_pict_formats_formats_iterator(rep_pictformat);
1843 for (; iter_forminfo.rem; xcb_render_pictforminfo_next(&iter_forminfo))
1845 if ((iter_forminfo.data->type == XCB_RENDER_PICT_TYPE_DIRECT) &&
1846 (iter_forminfo.data->direct.alpha_mask))
1848 pict_format = iter_forminfo.data->id;
1852 if (pict_format == 0)
1854 free(rep_pictformat);
1859 iter_pictscreen = xcb_render_query_pict_formats_screens_iterator(rep_pictformat);
1860 for (; iter_pictscreen.rem; xcb_render_pictscreen_next(&iter_pictscreen))
1862 xcb_render_pictdepth_iterator_t iter_depth;
1864 iter_depth = xcb_render_pictscreen_depths_iterator(iter_pictscreen.data);
1865 for (; iter_depth.rem; xcb_render_pictdepth_next(&iter_depth))
1867 xcb_render_pictvisual_iterator_t iter_visual;
1869 iter_visual = xcb_render_pictdepth_visuals_iterator(iter_depth.data);
1870 for (; iter_visual.rem; xcb_render_pictvisual_next(&iter_visual))
1872 if ((iter_visual.data->visual == visual) &&
1873 (pict_format == iter_visual.data->format))
1882 free(rep_pictformat);
1883 #endif /* ECORE_XCB_RENDER */
1892 * Set if a window should be ignored.
1893 * @param window The given window.
1894 * @param ignore if to ignore
1897 ecore_x_window_ignore_set(Ecore_X_Window window,
1906 for (i = 0; i < ignore_num; i++)
1908 if (window == ignore_list[i])
1911 ignore_list = realloc(ignore_list, (ignore_num + 1) * sizeof(Ecore_X_Window));
1912 if (!ignore_list) return;
1913 ignore_list[ignore_num++] = window;
1918 ignore_list = malloc(sizeof(Ecore_X_Window));
1919 ignore_list[ignore_num++] = window;
1924 if (!ignore_list) return;
1925 for (i = 0, j = 0; i < ignore_num; i++)
1927 if (window != ignore_list[i])
1928 ignore_list[i] = ignore_list[j++];
1932 ignore_list = realloc(ignore_list, ignore_num * sizeof(Ecore_X_Window));
1937 * Get the ignore list
1938 * @param num number of windows in the list
1939 * @return list of windows to ignore
1941 EAPI Ecore_X_Window *
1942 ecore_x_window_ignore_list(int *num)
1944 if (num) *num = ignore_num;
1949 * Retrieves the size of the given window.
1950 * @param win The given window.
1951 * @param w Pointer to an integer into which the width is to be stored.
1952 * @param h Pointer to an integer into which the height is to be stored.
1954 * To use this function, you must call before, and in order,
1955 * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
1956 * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
1957 * @ingroup Ecore_X_Window_Geometry_Group
1960 ecore_x_window_size_get(Ecore_X_Window window,
1965 window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1967 ecore_x_drawable_geometry_get(window, NULL, NULL, width, height);
1971 * Retrieves the geometry of the given window.
1972 * @param win The given window.
1973 * @param x Pointer to an integer in which the X position is to be stored.
1974 * @param y Pointer to an integer in which the Y position is to be stored.
1975 * @param w Pointer to an integer in which the width is to be stored.
1976 * @param h Pointer to an integer in which the height is to be stored.
1978 * To use this function, you must call before, and in order,
1979 * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
1980 * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
1981 * @ingroup Ecore_X_Window_Geometry_Group
1984 ecore_x_window_geometry_get(Ecore_X_Window window,
1991 window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1993 ecore_x_drawable_geometry_get(window, x, y, width, height);
1997 * Retrieves the width of the border of the given window.
1998 * @param win The given window.
1999 * @return Width of the border of @p win.
2000 * @ingroup Ecore_X_Window_Geometry_Group
2003 ecore_x_window_border_width_get(Ecore_X_Window win)
2005 /* doesn't make sense to call this on a root window */
2009 return ecore_x_drawable_border_width_get(win);
2013 * Retrieves the depth of the given window.
2014 * @param win The given window.
2015 * @return Depth of the window.
2018 ecore_x_window_depth_get(Ecore_X_Window win)
2020 return ecore_x_drawable_depth_get(win);