2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
9 #include "ecore_xcb_private.h"
10 #include "Ecore_X_Atoms.h"
13 static int ignore_num = 0;
14 static Ecore_X_Window *ignore_list = NULL;
16 static Ecore_X_Window _ecore_x_window_at_xy_get(Ecore_X_Window base,
24 #ifdef ECORE_XCB_RENDER
25 static Ecore_X_Window _ecore_x_window_argb_internal_new(Ecore_X_Window parent,
30 uint8_t override_redirect,
32 #endif /* ECORE_XCB_RENDER */
36 * @defgroup Ecore_X_Window_Create_Group X Window Creation Functions
38 * Functions that can be used to create an X window.
42 * Creates a new window.
43 * @param parent The parent window to use. If @p parent is @c 0, the root
44 * window of the default display is used.
45 * @param x X position.
46 * @param y Y position.
49 * @return The new window handle.
50 * @ingroup Ecore_X_Window_Create_Group
53 ecore_x_window_new(Ecore_X_Window parent,
59 uint32_t value_list[9];
60 Ecore_X_Window window;
61 xcb_visualid_t vis = { XCB_WINDOW_CLASS_COPY_FROM_PARENT };
64 if (parent == 0) parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
67 XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
68 XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_OVERRIDE_REDIRECT |
69 XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE;
71 value_list[0] = XCB_NONE;
73 value_list[2] = XCB_GRAVITY_NORTH_WEST;
74 value_list[3] = XCB_GRAVITY_NORTH_WEST;
75 value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
79 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
80 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
81 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
82 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
83 XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
84 XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
85 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
86 value_list[8] = XCB_EVENT_MASK_NO_EVENT;
88 window = xcb_generate_id(_ecore_xcb_conn);
89 xcb_create_window(_ecore_xcb_conn,
90 XCB_WINDOW_CLASS_COPY_FROM_PARENT,
91 window, parent, x, y, width, height, 0,
92 XCB_WINDOW_CLASS_INPUT_OUTPUT,
97 if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root) ecore_x_window_defaults_set(window);
102 * Creates a window with the override redirect attribute set to @c True.
103 * @param parent The parent window to use. If @p parent is @c 0, the root
104 * window of the default display is used.
105 * @param x X position.
106 * @param y Y position.
109 * @return The new window handle.
110 * @ingroup Ecore_X_Window_Create_Group
113 ecore_x_window_override_new(Ecore_X_Window parent,
119 uint32_t value_list[9];
120 Ecore_X_Window window;
121 xcb_visualid_t vis = { XCB_WINDOW_CLASS_COPY_FROM_PARENT };
124 if (parent == 0) parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
127 XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
128 XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_OVERRIDE_REDIRECT |
129 XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE;
131 value_list[0] = XCB_NONE;
133 value_list[2] = XCB_GRAVITY_NORTH_WEST;
134 value_list[3] = XCB_GRAVITY_NORTH_WEST;
135 value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
139 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
140 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
141 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
142 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
143 XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
144 XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
145 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
146 value_list[8] = XCB_EVENT_MASK_NO_EVENT;
148 window = xcb_generate_id(_ecore_xcb_conn);
149 xcb_create_window(_ecore_xcb_conn,
150 XCB_WINDOW_CLASS_COPY_FROM_PARENT,
151 window, parent, x, y, width, height, 0,
152 XCB_WINDOW_CLASS_INPUT_OUTPUT,
160 * Creates a new input window.
161 * @param parent The parent window to use. If @p parent is @c 0, the root
162 * window of the default display is used.
163 * @param x X position.
164 * @param y Y position.
167 * @return The new window.
168 * @ingroup Ecore_X_Window_Create_Group
171 ecore_x_window_input_new(Ecore_X_Window parent,
177 uint32_t value_list[3];
178 Ecore_X_Window window;
179 xcb_visualid_t vis = { XCB_WINDOW_CLASS_COPY_FROM_PARENT };
182 if (parent == 0) parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
184 value_mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE;
188 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
189 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
190 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
191 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
192 XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
193 XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
194 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
195 value_list[2] = XCB_EVENT_MASK_NO_EVENT;
197 window = xcb_generate_id(_ecore_xcb_conn);
198 xcb_create_window(_ecore_xcb_conn,
199 XCB_WINDOW_CLASS_COPY_FROM_PARENT,
200 window, parent, x, y, width, height, 0,
201 XCB_WINDOW_CLASS_INPUT_OUTPUT,
206 if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root)
214 * Creates a new window.
215 * @param parent The parent window to use. If @p parent is @c 0, the root
216 * window of the default display is used.
217 * @param x X position.
218 * @param y Y position.
219 * @param width Width.
220 * @param height Height.
221 * @return The new window handle.
222 * @ingroup Ecore_X_Window_Create_Group
225 ecore_x_window_manager_argb_new(Ecore_X_Window parent,
231 Ecore_X_Window window = 0;
233 #ifdef ECORE_XCB_RENDER
234 window = _ecore_x_window_argb_internal_new(parent,
237 #endif /* ECORE_XCB_RENDER */
243 * Creates a new window.
244 * @param parent The parent window to use. If @p parent is @c 0, the root
245 * window of the default display is used.
246 * @param x X position.
247 * @param y Y position.
248 * @param width Width.
249 * @param height Height.
250 * @return The new window handle.
251 * @ingroup Ecore_X_Window_Create_Group
254 ecore_x_window_argb_new(Ecore_X_Window parent,
260 Ecore_X_Window window = 0;
262 #ifdef ECORE_XCB_RENDER
263 window = _ecore_x_window_argb_internal_new(parent,
266 #endif /* ECORE_XCB_RENDER */
272 * Creates a window with the override redirect attribute set to @c True.
273 * @param parent The parent window to use. If @p parent is @c 0, the root
274 * window of the default display is used.
275 * @param x X position.
276 * @param y Y position.
277 * @param width Width.
278 * @param height Height.
279 * @return The new window handle.
280 * @ingroup Ecore_X_Window_Create_Group
283 ecore_x_window_override_argb_new(Ecore_X_Window parent,
289 Ecore_X_Window window = 0;
291 #ifdef ECORE_XCB_RENDER
292 window = _ecore_x_window_argb_internal_new(parent,
295 #endif /* ECORE_XCB_RENDER */
301 * @defgroup Ecore_X_Window_Destroy_Group X Window Destroy Functions
303 * Functions to destroy X windows.
307 * Deletes the given window.
308 * @param window The given window.
309 * @ingroup Ecore_X_Window_Destroy_Group
312 ecore_x_window_free(Ecore_X_Window window)
314 /* sorry sir, deleting the root window doesn't sound like
318 xcb_destroy_window(_ecore_xcb_conn, window);
322 * Sends a delete request to the given window.
323 * @param window The given window.
324 * @ingroup Ecore_X_Window_Destroy_Group
327 ecore_x_window_delete_request_send(Ecore_X_Window window)
329 xcb_client_message_event_t ev;
331 /* sorry sir, deleting the root window doesn't sound like
337 ev.response_type = XCB_CLIENT_MESSAGE;
341 ev.type = ECORE_X_ATOM_WM_PROTOCOLS;
342 ev.data.data32[0] = ECORE_X_ATOM_WM_DELETE_WINDOW;
343 ev.data.data32[1] = XCB_CURRENT_TIME;
345 xcb_send_event(_ecore_xcb_conn, 0, window,
346 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
350 * @defgroup Ecore_X_Window_Configure_Group X Window Configure Functions
352 * Functions to configure X windows.
357 * Configures the given window with the given mask.
358 * @param window The given window.
359 * @param mask The given mask.
360 * @param x The X coordinate of the window.
361 * @param y The Y coordinate of the window.
362 * @param width The width of the window.
363 * @param height The height of the window.
364 * @param border_width The border width of the window.
365 * @param sibling The sibling window of the window.
366 * @param stack_mode The stack mode of the window.
367 * @ingroup Ecore_X_Window_Configure_Group
370 ecore_x_window_configure(Ecore_X_Window window,
371 Ecore_X_Window_Configure_Mask mask,
377 Ecore_X_Window sibling,
380 uint32_t *value_list;
388 for ( ; value_mask; value_mask >>= 1)
391 value_list = (uint32_t *)malloc(sizeof(uint32_t) * length);
396 for ( ; value_mask; value_mask >>= 1, value_list++)
399 switch (value_mask) {
400 case XCB_CONFIG_WINDOW_X:
403 case XCB_CONFIG_WINDOW_Y:
406 case XCB_CONFIG_WINDOW_WIDTH:
409 case XCB_CONFIG_WINDOW_HEIGHT:
410 *value_list = height;
412 case XCB_CONFIG_WINDOW_BORDER_WIDTH:
413 *value_list = border_width;
415 case XCB_CONFIG_WINDOW_SIBLING:
416 *value_list = sibling;
418 case XCB_CONFIG_WINDOW_STACK_MODE:
419 *value_list = stack_mode;
424 xcb_configure_window(_ecore_xcb_conn, window, mask, value_list);
429 * Moves a window to the position @p x, @p y.
431 * The position is relative to the upper left hand corner of the
434 * @param window The window to move.
435 * @param x X position.
436 * @param y Y position.
437 * @ingroup Ecore_X_Window_Configure_Group
440 ecore_x_window_move(Ecore_X_Window window,
444 uint32_t value_list[2];
450 value_mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
455 xcb_configure_window(_ecore_xcb_conn, window, value_mask, value_list);
460 * @param window The window to resize.
461 * @param width New width of the window.
462 * @param height New height of the window.
463 * @ingroup Ecore_X_Window_Configure_Group
466 ecore_x_window_resize(Ecore_X_Window window,
470 uint32_t value_list[2];
476 if (width < 1) width = 1;
477 if (height < 1) height = 1;
479 value_mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
481 value_list[0] = width;
482 value_list[1] = height;
484 xcb_configure_window(_ecore_xcb_conn, window, value_mask, value_list);
488 * Moves and resizes a window.
489 * @param window The window to move and resize.
490 * @param x New X position of the window.
491 * @param y New Y position of the window.
492 * @param width New width of the window.
493 * @param height New height of the window.
494 * @ingroup Ecore_X_Window_Configure_Group
497 ecore_x_window_move_resize(Ecore_X_Window window,
503 uint32_t value_list[4];
509 if (width < 1) width = 1;
510 if (height < 1) height = 1;
513 XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y |
514 XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
518 value_list[2] = width;
519 value_list[3] = height;
521 xcb_configure_window(_ecore_xcb_conn, window, value_mask, value_list);
525 * Sets the width of the border of the given window.
526 * @param window The given window.
527 * @param border_width The new border width.
528 * @ingroup Ecore_X_Window_Configure_Group
531 ecore_x_window_border_width_set(Ecore_X_Window window,
536 /* doesn't make sense to call this on a root window */
540 value_list = border_width;
542 xcb_configure_window(_ecore_xcb_conn, window, XCB_CONFIG_WINDOW_BORDER_WIDTH, &value_list);
546 * Raises the given window.
547 * @param window The window to raise.
548 * @ingroup Ecore_X_Window_Configure_Group
551 ecore_x_window_raise(Ecore_X_Window window)
558 value_list = XCB_STACK_MODE_ABOVE;
560 xcb_configure_window(_ecore_xcb_conn, window, XCB_CONFIG_WINDOW_STACK_MODE, &value_list);
564 * Lowers the given window.
565 * @param window The window to lower.
566 * @ingroup Ecore_X_Window_Configure_Group
569 ecore_x_window_lower(Ecore_X_Window window)
576 value_list = XCB_STACK_MODE_BELOW;
578 xcb_configure_window(_ecore_xcb_conn, window, XCB_CONFIG_WINDOW_STACK_MODE, &value_list);
582 * @defgroup Ecore_X_Window_Change_Properties_Group X Window Change Property Functions
584 * Functions that change window properties.
588 * Sets the default properties for the given window.
590 * The default properties set for the window are @c WM_CLIENT_MACHINE and
593 * @param window The given window.
594 * @ingroup Ecore_X_Window_Change_Property_Group
597 ecore_x_window_defaults_set(Ecore_X_Window window)
599 char buf[MAXHOSTNAMELEN];
605 * Set WM_CLIENT_MACHINE.
607 gethostname(buf, MAXHOSTNAMELEN);
608 buf[MAXHOSTNAMELEN - 1] = '\0';
609 /* The ecore function uses UTF8 which Xlib may not like (especially
610 * with older clients) */
611 /* ecore_xcb_window_prop_string_set(win, ECORE_X_ATOM_WM_CLIENT_MACHINE,
613 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
614 ECORE_X_ATOM_WM_CLIENT_MACHINE,
616 8, strlen(buf), buf);
622 ecore_x_netwm_pid_set(window, pid);
624 ecore_x_netwm_window_type_set(window, ECORE_X_WINDOW_TYPE_NORMAL);
626 ecore_app_args_get(&argc, &argv);
627 ecore_x_icccm_command_set(window, argc, argv);
631 * @defgroup Ecore_X_Window_Visibility_Group X Window Visibility Functions
633 * Functions to change the visibility of X windows.
639 * Synonymous to "mapping" a window in X Window System terminology.
641 * @param window The window to show.
642 * @ingroup Ecore_X_Window_Visibility_Group
645 ecore_x_window_show(Ecore_X_Window window)
647 xcb_map_window(_ecore_xcb_conn, window);
653 * Synonymous to "unmapping" a window in X Window System terminology.
655 * @param window The window to hide.
656 * @ingroup Ecore_X_Window_Visibility_Group
659 ecore_x_window_hide(Ecore_X_Window window)
661 xcb_unmap_notify_event_t ev;
664 /* ICCCM: SEND unmap event... */
666 /* FIXME: is it correct ? */
667 if (xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).rem == 1)
668 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
671 xcb_get_geometry_cookie_t cookie;
672 xcb_get_geometry_reply_t *rep;
673 Ecore_X_Drawable draw;
675 /* FIXME: can we avoid round trips, here ? */
677 cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, draw);
678 rep = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
684 ev.response_type = XCB_UNMAP_NOTIFY;
689 ev.from_configure = 0;
691 xcb_send_event(_ecore_xcb_conn, 0, root,
692 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
694 xcb_unmap_window(_ecore_xcb_conn, window);
698 * @defgroup Ecore_X_Window_Input_Focus_Group X Window Input Focus Functions
700 * Functions that manage the focus of an X Window.
704 * Sets the focus to the window @p window.
705 * @param window The window to focus.
706 * @ingroup Ecore_X_Window_Input_Focus_Group
709 ecore_x_window_focus(Ecore_X_Window window)
711 Ecore_X_Time time = XCB_CURRENT_TIME;
713 if (window == 0) window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
715 /* xcb_set_input_focus(_ecore_xcb_conn, XCB_INPUT_FOCUS_NONE, win, time); */
716 xcb_set_input_focus(_ecore_xcb_conn,
717 XCB_INPUT_FOCUS_POINTER_ROOT, window, time);
721 * Sets the focus to the given window at a specific time.
722 * @param window The window to focus.
723 * @param time When to set the focus to the window.
724 * @ingroup Ecore_X_Window_Input_Focus_Group
727 ecore_x_window_focus_at_time(Ecore_X_Window window,
730 if (window == 0) window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
732 /* xcb_set_input_focus(_ecore_xcb_conn, XCB_INPUT_FOCUS_NONE, win, time); */
733 xcb_set_input_focus(_ecore_xcb_conn,
734 XCB_INPUT_FOCUS_POINTER_ROOT, window, time);
738 * @defgroup Ecore_X_Window_Reparent_Group X Window Reparent Functions
740 * Functions that retrieve or changes the parent window of a window.
744 * Moves a window to within another window at a given position.
745 * @param window The window to reparent.
746 * @param new_parent The new parent window.
747 * @param x X position within new parent window.
748 * @param y Y position within new parent window.
749 * @ingroup Ecore_X_Window_Reparent_Group
752 ecore_x_window_reparent(Ecore_X_Window window,
753 Ecore_X_Window new_parent,
757 if (new_parent == 0) new_parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
759 xcb_reparent_window(_ecore_xcb_conn, window, new_parent, x, y);
764 * @defgroup Ecore_X_Window_Change_Attributes_Group X Window Change Attributes Functions
766 * Functions that change the attributes of a window.
770 * Sets the background pixmap of the given window.
771 * @param window The given window.
772 * @param pixmap The pixmap to set to.
773 * @ingroup Ecore_X_Window_Change_Attributes_Group
776 ecore_x_window_pixmap_set(Ecore_X_Window window,
777 Ecore_X_Pixmap pixmap)
782 xcb_change_window_attributes(_ecore_xcb_conn, window,
783 XCB_CW_BACK_PIXMAP, &value_list);
787 * Sets the background color of the given window.
788 * @param window The given window.
789 * @param red The red component of the color to set to.
790 * @param green The green component of the color to set to.
791 * @param blue The blue component of the color to set to.
792 * @ingroup Ecore_X_Window_Change_Attributes_Group
795 ecore_x_window_background_color_set(Ecore_X_Window window,
797 unsigned short green,
800 xcb_alloc_color_cookie_t cookie;
801 xcb_alloc_color_reply_t *rep;
804 /* FIXME: should I provide a reply, and not the color components, here ? */
805 /* (because of roundtrips) */
806 cookie = xcb_alloc_color_unchecked(_ecore_xcb_conn,
807 ((xcb_screen_t *)_ecore_xcb_screen)->default_colormap,
809 rep = xcb_alloc_color_reply(_ecore_xcb_conn, cookie, NULL);
813 value_list = rep->pixel;
814 xcb_change_window_attributes(_ecore_xcb_conn, window,
815 XCB_CW_BACK_PIXEL, &value_list);
820 * Sets the bit gravity of the given window.
821 * @param window The given window.
822 * @param gravity The gravity.
823 * @ingroup Ecore_X_Window_Change_Attributes_Group
826 ecore_x_window_pixel_gravity_set(Ecore_X_Window window,
827 Ecore_X_Gravity gravity)
831 value_list = gravity;
832 xcb_change_window_attributes(_ecore_xcb_conn, window,
833 XCB_CW_BIT_GRAVITY, &value_list);
837 * Sets the gravity of the given window.
838 * @param window The given window.
839 * @param gravity The gravity.
840 * @ingroup Ecore_X_Window_Change_Attributes_Group
843 ecore_x_window_gravity_set(Ecore_X_Window window,
844 Ecore_X_Gravity gravity)
848 value_list = gravity;
849 xcb_change_window_attributes(_ecore_xcb_conn, window,
850 XCB_CW_WIN_GRAVITY, &value_list);
854 * Sets the override attribute of the given window.
855 * @param window The given window.
856 * @param override_redirect The override_redirect boolean.
857 * @ingroup Ecore_X_Window_Change_Attributes_Group
860 ecore_x_window_override_set(Ecore_X_Window window,
861 int override_redirect)
865 value_list = override_redirect;
866 xcb_change_window_attributes(_ecore_xcb_conn, window,
867 XCB_CW_OVERRIDE_REDIRECT, &value_list);
871 * Shows the cursor of the given window.
872 * @param window The given window.
873 * @param show If set to @c 0, hide the cursor. Show it otherwise.
874 * @ingroup Ecore_X_Window_Change_Attributes_Group
877 ecore_x_window_cursor_show(Ecore_X_Window window,
880 if (window == 0) window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
884 Ecore_X_Cursor cursor;
885 Ecore_X_Drawable draw;
886 Ecore_X_Pixmap pixmap;
893 pixmap = xcb_generate_id(_ecore_xcb_conn);
894 xcb_create_pixmap(_ecore_xcb_conn,
897 mask = xcb_generate_id(_ecore_xcb_conn);
898 xcb_create_pixmap(_ecore_xcb_conn,
902 gc = xcb_generate_id(_ecore_xcb_conn);
903 xcb_create_gc (_ecore_xcb_conn, gc, draw, 0, NULL);
905 xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_FOREGROUND, &value_list);
910 xcb_poly_point(_ecore_xcb_conn, XCB_COORD_MODE_ORIGIN, draw,
913 xcb_free_gc(_ecore_xcb_conn, gc);
915 cursor = xcb_generate_id(_ecore_xcb_conn);
916 xcb_create_cursor(_ecore_xcb_conn, cursor,
922 xcb_change_window_attributes(_ecore_xcb_conn, window,
923 XCB_CW_CURSOR, &value_list);
925 xcb_free_cursor(_ecore_xcb_conn, cursor);
926 xcb_free_pixmap(_ecore_xcb_conn, mask);
927 xcb_free_pixmap(_ecore_xcb_conn, pixmap);
934 xcb_change_window_attributes(_ecore_xcb_conn, window,
935 XCB_CW_CURSOR, &value_list);
940 * Sets the cursor of the given window.
941 * @param window The given window.
942 * @param cursor The given cursor.
943 * @ingroup Ecore_X_Window_Change_Attributes_Group
946 ecore_x_window_cursor_set(Ecore_X_Window window,
947 Ecore_X_Cursor cursor)
952 xcb_change_window_attributes(_ecore_xcb_conn, window,
953 XCB_CW_CURSOR, &value_list);
958 * @param window The given window.
959 * @ingroup Ecore_X_Window_Change_Attributes_Group
962 ecore_x_window_container_manage(Ecore_X_Window window)
967 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
968 XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
969 xcb_change_window_attributes(_ecore_xcb_conn, window,
970 XCB_CW_EVENT_MASK, &value_list);
976 * @param window The given window.
977 * @ingroup Ecore_X_Window_Change_Attributes_Group
980 ecore_x_window_client_manage(Ecore_X_Window window)
985 XCB_EVENT_MASK_VISIBILITY_CHANGE |
986 /* XCB_EVENT_MASK_RESIZE_REDIRECT | */
987 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
988 XCB_EVENT_MASK_FOCUS_CHANGE |
989 XCB_EVENT_MASK_PROPERTY_CHANGE |
990 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
991 xcb_change_window_attributes(_ecore_xcb_conn, window,
992 XCB_CW_EVENT_MASK, &value_list);
993 #ifdef ECORE_XCB_SHAPE
994 xcb_shape_select_input(_ecore_xcb_conn, window, 1);
995 #endif /* ECORE_XCB_SHAPE */
1000 * @param window The given window.
1001 * @ingroup Ecore_X_Window_Change_Attributes_Group
1004 ecore_x_window_sniff(Ecore_X_Window window)
1006 uint32_t value_list;
1009 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
1010 XCB_EVENT_MASK_PROPERTY_CHANGE;
1011 xcb_change_window_attributes(_ecore_xcb_conn, window,
1012 XCB_CW_EVENT_MASK, &value_list);
1017 * @param window The given window.
1018 * @ingroup Ecore_X_Window_Change_Attributes_Group
1021 ecore_x_window_client_sniff(Ecore_X_Window window)
1023 uint32_t value_list;
1026 XCB_EVENT_MASK_VISIBILITY_CHANGE |
1027 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
1028 XCB_EVENT_MASK_FOCUS_CHANGE |
1029 XCB_EVENT_MASK_PROPERTY_CHANGE |
1030 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
1031 xcb_change_window_attributes(_ecore_xcb_conn, window,
1032 XCB_CW_EVENT_MASK, &value_list);
1033 #ifdef ECORE_XCB_SHAPE
1034 xcb_shape_select_input(_ecore_xcb_conn, window, 1);
1035 #endif /* ECORE_XCB_SHAPE */
1039 * Clears an area of the given window.
1040 * @param window The given window.
1041 * @param x The X coordinate of the area.
1042 * @param y The Y coordinate of the area.
1043 * @param width The width of the area.
1044 * @param height The height of the area.
1045 * @ingroup Ecore_X_Window_Clear_Area_Group
1048 ecore_x_window_area_clear(Ecore_X_Window window,
1054 xcb_clear_area(_ecore_xcb_conn, 0, window, x, y, width, height);
1058 * Exposes an area of the given window.
1059 * @param window The given window.
1060 * @param x The X coordinate of the area.
1061 * @param y The Y coordinate of the area.
1062 * @param width The width of the area.
1063 * @param height The height of the area.
1064 * @ingroup Ecore_X_Window_Clear_Area_Group
1067 ecore_x_window_area_expose(Ecore_X_Window window,
1073 xcb_clear_area(_ecore_xcb_conn, 1, window, x, y, width, height);
1078 * @defgroup Ecore_X_Window_Save_Set_Group X Window Change Save Set Functions
1080 * Functions that either inserts or deletes the specified window from
1081 * the client's save-set.
1085 * Inserts the window in the client's save-set.
1086 * @param window The window to insert in the client's save-set.
1087 * @ingroup Ecore_X_Window_Save_Set_Group
1090 ecore_x_window_save_set_add(Ecore_X_Window window)
1092 xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_INSERT, window);
1096 * Deletes the window from the client's save-set.
1097 * @param window The window to delete from the client's save-set.
1098 * @ingroup Ecore_X_Window_Save_Set_Group
1101 ecore_x_window_save_set_del(Ecore_X_Window window)
1103 xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_DELETE, window);
1106 /******************************
1108 * Request that have a reply
1110 ******************************/
1114 * Sends the GetInputFocus request.
1115 * @ingroup Ecore_X_Window_Input_Focus_Group
1118 ecore_x_get_input_focus_prefetch(void)
1120 xcb_get_input_focus_cookie_t cookie;
1122 cookie = xcb_get_input_focus_unchecked(_ecore_xcb_conn);
1123 _ecore_xcb_cookie_cache(cookie.sequence);
1127 * Gets the reply of the GetInputFocus request sent by ecore_x_get_input_focus_prefetch().
1128 * @ingroup Ecore_X_Window_Input_Focus_Group
1131 ecore_x_get_input_focus_fetch(void)
1133 xcb_get_input_focus_cookie_t cookie;
1134 xcb_get_input_focus_reply_t *reply;
1136 cookie.sequence = _ecore_xcb_cookie_get();
1137 reply = xcb_get_input_focus_reply(_ecore_xcb_conn, cookie, NULL);
1138 _ecore_xcb_reply_cache(reply);
1142 * Gets the window that has focus.
1143 * @return The window that has focus.
1145 * Returns the window that has the focus. If an error aoocured, @c 0
1146 * is returned, otherwise the function returns the window that has focus.
1148 * To use this function, you must call before, and in order,
1149 * ecore_x_get_input_focus_prefetch(), which sends the GetInputFocus request,
1150 * then ecore_x_get_input_focus_fetch(), which gets the reply.
1151 * @ingroup Ecore_X_Window_Input_Focus_Group
1154 ecore_x_window_focus_get(void)
1156 xcb_get_input_focus_reply_t *reply;
1157 Ecore_X_Window window = 0;
1159 reply = _ecore_xcb_reply_get();
1160 if (!reply) return window;
1162 return reply->focus;
1167 * @defgroup Ecore_X_Window_Get_Attributes_Group X Window Get Attributes Functions
1169 * Functions that get the attributes of a window.
1174 * Sends the GetWindowAttributes request.
1175 * @ingroup Ecore_X_Window_Get_Attributes_Group
1178 ecore_x_get_window_attributes_prefetch(Ecore_X_Window window)
1180 xcb_get_window_attributes_cookie_t cookie;
1182 cookie = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, window);
1183 _ecore_xcb_cookie_cache(cookie.sequence);
1187 * Gets the reply of the GetWindowAttributes request sent by ecore_x_get_window_attributes_prefetch().
1188 * @ingroup Ecore_X_Window_Get_Attributes_Group
1191 ecore_x_get_window_attributes_fetch(void)
1193 xcb_get_window_attributes_cookie_t cookie;
1194 xcb_get_window_attributes_reply_t *reply;
1196 cookie.sequence = _ecore_xcb_cookie_get();
1197 reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL);
1198 _ecore_xcb_reply_cache(reply);
1202 * Retrieves the attributes of a window.
1203 * @param windows Unused.
1204 * @param att_ret Pointer to an Ecore_X_Window_Attributes
1205 * structure in which the attributes of a window
1208 * Retrieves the attributes of a window. If
1209 * @p att_ret is @c NULL, the function does nothing. If an error
1210 * occurred, @p att_ret is set to 0. Otherwise, the @p att_ret structure
1211 * is filled with the attributes os the requested window.
1213 * To use this function, you must call before, and in order,
1214 * ecore_x_get_window_attributes_prefetch(), which sends the GetWindowAttributes request,
1215 * then ecore_x_get_window_attributes_fetch(), which gets the reply.
1216 * @ingroup Ecore_X_Window_Get_Attributes_Group
1219 ecore_x_window_attributes_get(Ecore_X_Window window __UNUSED__,
1220 Ecore_X_Window_Attributes *att_ret)
1222 xcb_get_window_attributes_reply_t *reply;
1224 if (!att_ret) return 0;
1226 reply = _ecore_xcb_reply_get();
1227 if (!reply) return 0;
1229 memset(att_ret, 0, sizeof(Ecore_X_Window_Attributes));
1231 if (reply->map_state != XCB_MAP_STATE_UNMAPPED) att_ret->visible = 1;
1232 if (reply->map_state == XCB_MAP_STATE_VIEWABLE) att_ret->viewable = 1;
1233 if (reply->override_redirect) att_ret->override = 1;
1234 if (reply->_class == XCB_WINDOW_CLASS_INPUT_ONLY) att_ret->input_only = 1;
1235 if (reply->save_under) att_ret->save_under = 1;
1237 att_ret->event_mask.mine = reply->your_event_mask;
1238 att_ret->event_mask.all = reply->all_event_masks;
1239 att_ret->event_mask.no_propagate = reply->do_not_propagate_mask;
1240 att_ret->window_gravity = reply->win_gravity;
1241 att_ret->pixel_gravity = reply->bit_gravity;
1242 att_ret->colormap = reply->colormap;
1243 att_ret->visual = reply->visual;
1249 * Finds out whether the given window is currently visible.
1250 * @param window Unused.
1251 * @return 1 if the window is visible, otherwise 0.
1253 * Finds out whether the given window is currently visible.
1254 * If an error occurred, or if the window is not visible, 0 is
1255 * returned. Otherwise 1 is returned.
1257 * To use this function, you must call before, and in order,
1258 * ecore_x_get_window_attributes_prefetch(), which sends the GetWindowAttributes request,
1259 * then ecore_x_get_window_attributes_fetch(), which gets the reply.
1260 * @ingroup Ecore_X_Window_Get_Attributes_Group
1263 ecore_x_window_visible_get(Ecore_X_Window window __UNUSED__)
1265 xcb_get_window_attributes_reply_t *reply;
1267 reply = _ecore_xcb_reply_get();
1268 if (!reply) return 0;
1270 return (reply->map_state == XCB_MAP_STATE_VIEWABLE) ? 1 : 0;
1275 * Sends the QueryPointer request.
1276 * @ingroup Ecore_X_Window_Parent_Group
1279 ecore_x_pointer_xy_get_prefetch(Ecore_X_Window window)
1281 xcb_query_pointer_cookie_t cookie;
1283 cookie = xcb_query_pointer_unchecked(_ecore_xcb_conn, window);
1284 _ecore_xcb_cookie_cache(cookie.sequence);
1288 * Gets the reply of the QueryPointer request sent by ecore_x_query_pointer_prefetch().
1289 * @ingroup Ecore_X_Window_Parent_Group
1292 ecore_x_pointer_xy_get_fetch(void)
1294 xcb_query_pointer_cookie_t cookie;
1295 xcb_query_pointer_reply_t *reply;
1297 cookie.sequence = _ecore_xcb_cookie_get();
1298 reply = xcb_query_pointer_reply(_ecore_xcb_conn, cookie, NULL);
1299 _ecore_xcb_reply_cache(reply);
1303 * Retrieves the coordinates of the pointer.
1304 * @param window Unused.
1305 * @param x The X coordinate of the pointer.
1306 * @param y The Y coordinate of the pointer.
1308 * Retrieves the coordinates of the pointer.
1309 * If the window used in
1310 * ecore_x_query_pointer_prefetch() is not on the same screen than
1311 * the root window or if an error occured, @p x and @p y are set
1312 * to 0. Otherwise, they are respectively set to the X and Y
1313 * coordinates of the pointer.
1315 * To use this function, you must call before, and in order,
1316 * ecore_x_query_pointer_prefetch(), which sends the QueryPointer request,
1317 * then ecore_x_query_pointer_fetch(), which gets the reply.
1318 * @ingroup Ecore_X_Window_Parent_Group
1321 ecore_x_pointer_xy_get(Ecore_X_Window window __UNUSED__,
1325 xcb_query_pointer_reply_t *reply;
1327 reply = _ecore_xcb_reply_get();
1336 if (x) *x = reply->win_x;
1337 if (y) *y = reply->win_y;
1342 * Sends the QueryTree request.
1343 * @ingroup Ecore_X_Window_Parent_Group
1346 ecore_x_query_tree_prefetch(Ecore_X_Window window)
1348 xcb_query_tree_cookie_t cookie;
1350 cookie = xcb_query_tree_unchecked(_ecore_xcb_conn, window);
1351 _ecore_xcb_cookie_cache(cookie.sequence);
1355 * Gets the reply of the QueryTree request sent by ecore_x_query_tree_prefetch().
1356 * @ingroup Ecore_X_Window_Parent_Group
1359 ecore_x_query_tree_fetch(void)
1361 xcb_query_tree_cookie_t cookie;
1362 xcb_query_tree_reply_t *reply;
1364 cookie.sequence = _ecore_xcb_cookie_get();
1365 reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL);
1366 _ecore_xcb_reply_cache(reply);
1370 * Retrieves the parent window of the given window.
1371 * @param window Unused.
1372 * @return The parent window of @p window.
1374 * Retrieves the parent window of the given window. If
1375 * an error occured, @c 0 is returned.
1377 * To use this function, you must call before, and in order,
1378 * ecore_x_query_tree_prefetch(), which sends the QueryTree request,
1379 * then ecore_x_query_tree_fetch(), which gets the reply.
1380 * @ingroup Ecore_X_Window_Parent_Group
1383 ecore_x_window_parent_get(Ecore_X_Window window __UNUSED__)
1385 xcb_query_tree_reply_t *reply;
1387 reply = _ecore_xcb_reply_get();
1388 if (!reply) return 0;
1390 return reply->parent;
1395 * Retrieves the children windows of the given window.
1396 * @param window Unused.
1397 * @param num children windows count.
1398 * @return The children windows.
1400 * Retrieves the children windows of the given window. If
1401 * an error occured, @c 0 is returned.
1403 * To use this function, you must call before, and in order,
1404 * ecore_x_query_tree_prefetch(), which sends the QueryTree request,
1405 * then ecore_x_query_tree_fetch(), which gets the reply.
1406 * @ingroup Ecore_X_Window_Parent_Group
1408 EAPI Ecore_X_Window *
1409 ecore_x_window_children_get(Ecore_X_Window window __UNUSED__,
1412 xcb_query_tree_reply_t *reply;
1413 Ecore_X_Window *windows = NULL;
1416 reply = _ecore_xcb_reply_get();
1417 if (!reply) return NULL;
1419 windows = malloc(sizeof(Ecore_X_Window) * reply->children_len);
1423 if (num) *num = reply->children_len;
1425 xcb_query_tree_children(reply),
1426 sizeof(Ecore_X_Window) * reply->children_len);
1431 /* FIXME: I've tried to remove the round trips. 3 cookies are */
1432 /* created at the beginning of the function. Because of */
1433 /* the recursivity of the algo, I can't find better trick */
1434 static Ecore_X_Window
1435 _ecore_x_window_at_xy_get(Ecore_X_Window base,
1440 Ecore_X_Window *skip,
1443 xcb_window_iterator_t iter_children;
1444 xcb_get_window_attributes_cookie_t cookie_get_window_attributes;
1445 xcb_get_geometry_cookie_t cookie_get_geometry;
1446 xcb_query_tree_cookie_t cookie_query_tree;
1447 xcb_get_window_attributes_reply_t *reply_get_window_attributes;
1448 xcb_get_geometry_reply_t *reply_get_geometry;
1449 xcb_query_tree_reply_t *reply_query_tree;
1450 Ecore_X_Window window = 0;
1451 Ecore_X_Window child = 0;
1455 uint16_t win_height;
1457 cookie_get_window_attributes = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, base);
1458 cookie_get_geometry = xcb_get_geometry_unchecked(_ecore_xcb_conn, base);
1459 cookie_query_tree = xcb_query_tree_unchecked(_ecore_xcb_conn, base);
1461 reply_get_window_attributes = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie_get_window_attributes, NULL);
1462 if (!reply_get_window_attributes)
1464 reply_get_geometry = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_get_geometry, NULL);
1465 if (reply_get_geometry) free(reply_get_geometry);
1466 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1467 if (reply_query_tree) free(reply_query_tree);
1471 if (reply_get_window_attributes->map_state != XCB_MAP_STATE_VIEWABLE)
1473 free(reply_get_window_attributes);
1474 reply_get_geometry = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_get_geometry, NULL);
1475 if (reply_get_geometry) free(reply_get_geometry);
1476 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1477 if (reply_query_tree) free(reply_query_tree);
1481 free(reply_get_window_attributes);
1483 reply_get_geometry = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_get_geometry, NULL);
1484 if (!reply_get_geometry)
1486 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1487 if (reply_query_tree) free(reply_query_tree);
1491 win_x = reply_get_geometry->x;
1492 win_y = reply_get_geometry->y;
1493 win_width = reply_get_geometry->width;
1494 win_height = reply_get_geometry->height;
1496 free(reply_get_geometry);
1501 if (!((x >= win_x) &&
1503 (x < (int16_t)(win_x + win_width)) &&
1504 (y < (int16_t)(win_y + win_height))))
1506 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1507 if (reply_query_tree) free(reply_query_tree);
1511 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1512 if (!reply_query_tree)
1518 for (i = 0; i < skip_num; i++)
1519 if (base == skip[i])
1525 iter_children = xcb_query_tree_children_iterator(reply_query_tree);
1526 for (; iter_children.rem; xcb_window_next(&iter_children))
1532 for (j = 0; j < skip_num; j++)
1533 if (*iter_children.data == skip[j])
1536 child = _ecore_x_window_at_xy_get(*iter_children.data, win_x, win_y, x, y, skip, skip_num);
1539 free(reply_query_tree);
1549 for (i = 0; i < skip_num; i++)
1550 if (base == skip[i])
1552 /* We return 0. child has an xid equal to 0 */
1553 free(reply_query_tree);
1558 free(reply_query_tree);
1564 * @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions
1566 * Functions that change or retrieve the geometry of X windows.
1570 * Retrieves the top, visible window at the given location.
1571 * @param x The given X position.
1572 * @param y The given Y position.
1573 * @return The window at that position.
1574 * @ingroup Ecore_X_Window_Geometry_Group
1577 ecore_x_window_at_xy_get(int x,
1580 Ecore_X_Window window;
1581 Ecore_X_Window root;
1583 /* FIXME: Proper function to determine current root/virtual root
1584 * window missing here */
1585 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1588 window = _ecore_x_window_at_xy_get(root, 0, 0, x, y, NULL, 0);
1591 return window ? window : root;
1595 * Retrieves the top, visible window at the given location,
1596 * but skips the windows in the list.
1597 * @param x The given X position.
1598 * @param y The given Y position.
1599 * @return The window at that position.
1600 * @ingroup Ecore_X_Window_Geometry_Group
1603 ecore_x_window_at_xy_with_skip_get(int x,
1605 Ecore_X_Window *skip,
1608 Ecore_X_Window window;
1609 Ecore_X_Window root;
1611 /* FIXME: Proper function to determine current root/virtual root
1612 * window missing here */
1613 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1616 window = _ecore_x_window_at_xy_get(root, 0, 0, x, y, skip, skip_num);
1619 return window ? window : root;
1623 * Retrieves the top, visible window at the given location,
1624 * but begins at the @p begin window instead of the root one.
1625 * @param begin The window from which we begin.
1626 * @param x The given X position.
1627 * @param y The given Y position.
1628 * @return The window at that position.
1629 * @ingroup Ecore_X_Window_Geometry_Group
1632 ecore_x_window_at_xy_begin_get(Ecore_X_Window begin,
1636 Ecore_X_Window window;
1639 window = _ecore_x_window_at_xy_get(begin, 0, 0, x, y, NULL, 0);
1642 return window ? window : begin;
1647 /* FIXME: Should I provide the replies (or the cookies), instead of
1648 creating them in the function ? */
1649 #ifdef ECORE_XCB_RENDER
1650 static Ecore_X_Window
1651 _ecore_x_window_argb_internal_new(Ecore_X_Window parent,
1656 uint8_t override_redirect,
1659 uint32_t value_list[10];
1660 xcb_depth_iterator_t iter_depth;
1661 xcb_visualtype_iterator_t iter_visualtype;
1662 xcb_render_query_pict_formats_cookie_t cookie_pict_format;
1663 xcb_render_query_pict_formats_reply_t *rep_pict_format;
1664 Ecore_X_Screen *screen = NULL;
1665 Ecore_X_Window win = { 0 };
1666 xcb_visualid_t vis = { 0 };
1667 Ecore_X_Colormap colormap;
1668 uint32_t value_mask;
1670 cookie_pict_format = xcb_render_query_pict_formats_unchecked(_ecore_xcb_conn);
1674 parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1675 screen = ((xcb_screen_t *)_ecore_xcb_screen);
1679 xcb_screen_iterator_t iter_screen;
1680 xcb_get_geometry_reply_t *rep;
1681 Ecore_X_Drawable draw;
1682 Ecore_X_Window root;
1685 rep = xcb_get_geometry_reply(_ecore_xcb_conn,
1686 xcb_get_geometry_unchecked(_ecore_xcb_conn,
1696 for (; iter_screen.rem; xcb_screen_next(&iter_screen))
1698 if (iter_screen.data->root == root)
1700 screen = iter_screen.data;
1707 /* we get the X visual types */
1708 iter_depth = xcb_screen_allowed_depths_iterator(screen);
1709 for (; iter_depth.rem; xcb_depth_next(&iter_depth)) {
1710 if (iter_depth.data->depth == 32) {
1711 iter_visualtype = xcb_depth_visuals_iterator(iter_depth.data);
1716 /* we get the X render visual id */
1717 rep_pict_format = xcb_render_query_pict_formats_reply(_ecore_xcb_conn,
1720 if (!rep_pict_format)
1723 for (; iter_visualtype.rem; xcb_visualtype_next(&iter_visualtype)) {
1724 if (iter_visualtype.data->_class == XCB_VISUAL_CLASS_TRUE_COLOR) {
1725 xcb_render_pictforminfo_iterator_t iter_forminfo;
1726 xcb_render_pictscreen_iterator_t iter_pictscreen;
1727 xcb_render_pictformat_t pict_format = { 0 };
1729 iter_forminfo = xcb_render_query_pict_formats_formats_iterator(rep_pict_format);
1730 for (; iter_forminfo.rem; xcb_render_pictforminfo_next(&iter_forminfo)) {
1731 if (iter_forminfo.data->type == XCB_RENDER_PICT_TYPE_DIRECT &&
1732 iter_forminfo.data->direct.alpha_mask && iter_forminfo.data->depth == 32) {
1733 pict_format = iter_forminfo.data->id;
1737 if (pict_format == 0) {
1738 free(rep_pict_format);
1741 iter_pictscreen = xcb_render_query_pict_formats_screens_iterator(rep_pict_format);
1742 for (; iter_pictscreen.rem; xcb_render_pictscreen_next(&iter_pictscreen)) {
1743 xcb_render_pictdepth_iterator_t iter_depth;
1745 iter_depth = xcb_render_pictscreen_depths_iterator(iter_pictscreen.data);
1746 for (; iter_depth.rem; xcb_render_pictdepth_next(&iter_depth)) {
1747 xcb_render_pictvisual_iterator_t iter_visual;
1749 iter_visual = xcb_render_pictdepth_visuals_iterator(iter_depth.data);
1750 for (; iter_visual.rem; xcb_render_pictvisual_next(&iter_visual)) {
1751 if ((iter_visual.data->visual == iter_visualtype.data->visual_id) &&
1752 (pict_format == iter_visual.data->format)) {
1753 vis = iter_visual.data->visual;
1762 free(rep_pict_format);
1767 colormap = xcb_generate_id(_ecore_xcb_conn);
1768 xcb_create_colormap(_ecore_xcb_conn, XCB_COLORMAP_ALLOC_NONE, colormap, parent, vis);
1771 XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
1772 XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_OVERRIDE_REDIRECT |
1773 XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE |
1776 value_list[0] = XCB_NONE;
1778 value_list[2] = XCB_GRAVITY_NORTH_WEST;
1779 value_list[3] = XCB_GRAVITY_NORTH_WEST;
1780 value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
1781 value_list[5] = override_redirect;
1782 value_list[6] = save_under;
1784 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
1785 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
1786 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
1787 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
1788 XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
1789 XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
1790 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
1791 value_list[8] = XCB_EVENT_MASK_NO_EVENT;
1792 value_list[9] = colormap;
1794 win = xcb_generate_id(_ecore_xcb_conn);
1795 xcb_create_window(_ecore_xcb_conn,
1799 XCB_WINDOW_CLASS_INPUT_OUTPUT,
1804 xcb_free_colormap(_ecore_xcb_conn, colormap);
1806 if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root)
1807 ecore_x_window_defaults_set(win);
1811 #endif /* ECORE_XCB_RENDER */
1815 /* FIXME: round trip */
1817 ecore_x_window_argb_get(Ecore_X_Window win)
1820 #ifdef ECORE_XCB_RENDER
1821 xcb_render_pictforminfo_iterator_t iter_forminfo;
1822 xcb_render_pictscreen_iterator_t iter_pictscreen;
1823 xcb_render_pictformat_t pict_format = { 0 };
1824 xcb_render_query_pict_formats_reply_t *rep_pictformat;
1825 xcb_get_window_attributes_reply_t *rep;
1826 xcb_visualid_t visual;
1828 rep = xcb_get_window_attributes_reply(_ecore_xcb_conn,
1829 xcb_get_window_attributes_unchecked(_ecore_xcb_conn,
1835 visual = rep->visual;
1839 rep_pictformat = xcb_render_query_pict_formats_reply(_ecore_xcb_conn,
1840 xcb_render_query_pict_formats_unchecked(_ecore_xcb_conn),
1842 if (!rep_pictformat)
1845 iter_forminfo = xcb_render_query_pict_formats_formats_iterator(rep_pictformat);
1846 for (; iter_forminfo.rem; xcb_render_pictforminfo_next(&iter_forminfo))
1848 if ((iter_forminfo.data->type == XCB_RENDER_PICT_TYPE_DIRECT) &&
1849 (iter_forminfo.data->direct.alpha_mask))
1851 pict_format = iter_forminfo.data->id;
1855 if (pict_format == 0)
1857 free(rep_pictformat);
1862 iter_pictscreen = xcb_render_query_pict_formats_screens_iterator(rep_pictformat);
1863 for (; iter_pictscreen.rem; xcb_render_pictscreen_next(&iter_pictscreen))
1865 xcb_render_pictdepth_iterator_t iter_depth;
1867 iter_depth = xcb_render_pictscreen_depths_iterator(iter_pictscreen.data);
1868 for (; iter_depth.rem; xcb_render_pictdepth_next(&iter_depth))
1870 xcb_render_pictvisual_iterator_t iter_visual;
1872 iter_visual = xcb_render_pictdepth_visuals_iterator(iter_depth.data);
1873 for (; iter_visual.rem; xcb_render_pictvisual_next(&iter_visual))
1875 if ((iter_visual.data->visual == visual) &&
1876 (pict_format == iter_visual.data->format))
1885 free(rep_pictformat);
1886 #endif /* ECORE_XCB_RENDER */
1895 * Set if a window should be ignored.
1896 * @param window The given window.
1897 * @param ignore if to ignore
1900 ecore_x_window_ignore_set(Ecore_X_Window window,
1909 for (i = 0; i < ignore_num; i++)
1911 if (window == ignore_list[i])
1914 ignore_list = realloc(ignore_list, (ignore_num + 1) * sizeof(Ecore_X_Window));
1915 if (!ignore_list) return;
1916 ignore_list[ignore_num++] = window;
1921 ignore_list = malloc(sizeof(Ecore_X_Window));
1922 ignore_list[ignore_num++] = window;
1927 if (!ignore_list) return;
1928 for (i = 0, j = 0; i < ignore_num; i++)
1930 if (window != ignore_list[i])
1931 ignore_list[i] = ignore_list[j++];
1935 ignore_list = realloc(ignore_list, ignore_num * sizeof(Ecore_X_Window));
1940 * Get the ignore list
1941 * @param num number of windows in the list
1942 * @return list of windows to ignore
1944 EAPI Ecore_X_Window *
1945 ecore_x_window_ignore_list(int *num)
1947 if (num) *num = ignore_num;
1952 * Retrieves the size of the given window.
1953 * @param win The given window.
1954 * @param w Pointer to an integer into which the width is to be stored.
1955 * @param h Pointer to an integer into which the height is to be stored.
1957 * To use this function, you must call before, and in order,
1958 * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
1959 * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
1960 * @ingroup Ecore_X_Window_Geometry_Group
1963 ecore_x_window_size_get(Ecore_X_Window window,
1968 window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1970 ecore_x_drawable_geometry_get(window, NULL, NULL, width, height);
1974 * Retrieves the geometry of the given window.
1975 * @param win The given window.
1976 * @param x Pointer to an integer in which the X position is to be stored.
1977 * @param y Pointer to an integer in which the Y position is to be stored.
1978 * @param w Pointer to an integer in which the width is to be stored.
1979 * @param h Pointer to an integer in which the height is to be stored.
1981 * To use this function, you must call before, and in order,
1982 * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
1983 * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
1984 * @ingroup Ecore_X_Window_Geometry_Group
1987 ecore_x_window_geometry_get(Ecore_X_Window window,
1994 window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1996 ecore_x_drawable_geometry_get(window, x, y, width, height);
2000 * Retrieves the width of the border of the given window.
2001 * @param win The given window.
2002 * @return Width of the border of @p win.
2003 * @ingroup Ecore_X_Window_Geometry_Group
2006 ecore_x_window_border_width_get(Ecore_X_Window win)
2008 /* doesn't make sense to call this on a root window */
2012 return ecore_x_drawable_border_width_get(win);
2016 * Retrieves the depth of the given window.
2017 * @param win The given window.
2018 * @return Depth of the window.
2021 ecore_x_window_depth_get(Ecore_X_Window win)
2023 return ecore_x_drawable_depth_get(win);