5 #include "ecore_xcb_private.h"
6 #include "Ecore_X_Atoms.h"
8 static int ignore_num = 0;
9 static Ecore_X_Window *ignore_list = NULL;
11 static Ecore_X_Window _ecore_x_window_at_xy_get(Ecore_X_Window base,
19 #ifdef ECORE_XCB_RENDER
20 static Ecore_X_Window _ecore_x_window_argb_internal_new(Ecore_X_Window parent,
25 uint8_t override_redirect,
27 #endif /* ECORE_XCB_RENDER */
30 * @defgroup Ecore_X_Window_Create_Group X Window Creation Functions
32 * Functions that can be used to create an X window.
36 * Creates a new window.
37 * @param parent The parent window to use. If @p parent is @c 0, the root
38 * window of the default display is used.
39 * @param x X position.
40 * @param y Y position.
43 * @return The new window handle.
44 * @ingroup Ecore_X_Window_Create_Group
47 ecore_x_window_new(Ecore_X_Window parent,
53 uint32_t value_list[9];
54 Ecore_X_Window window;
55 xcb_visualid_t vis = { XCB_WINDOW_CLASS_COPY_FROM_PARENT };
59 parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
62 XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
63 XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_OVERRIDE_REDIRECT |
64 XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE;
66 value_list[0] = XCB_NONE;
68 value_list[2] = XCB_GRAVITY_NORTH_WEST;
69 value_list[3] = XCB_GRAVITY_NORTH_WEST;
70 value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
74 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
75 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
76 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
77 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
78 XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
79 XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
80 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
81 value_list[8] = XCB_EVENT_MASK_NO_EVENT;
83 window = xcb_generate_id(_ecore_xcb_conn);
84 xcb_create_window(_ecore_xcb_conn,
85 XCB_WINDOW_CLASS_COPY_FROM_PARENT,
86 window, parent, x, y, width, height, 0,
87 XCB_WINDOW_CLASS_INPUT_OUTPUT,
92 if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root)
93 ecore_x_window_defaults_set(window);
96 } /* ecore_x_window_new */
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 };
122 parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
125 XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
126 XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_OVERRIDE_REDIRECT |
127 XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE;
129 value_list[0] = XCB_NONE;
131 value_list[2] = XCB_GRAVITY_NORTH_WEST;
132 value_list[3] = XCB_GRAVITY_NORTH_WEST;
133 value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
137 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
138 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
139 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
140 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
141 XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
142 XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
143 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
144 value_list[8] = XCB_EVENT_MASK_NO_EVENT;
146 window = xcb_generate_id(_ecore_xcb_conn);
147 xcb_create_window(_ecore_xcb_conn,
148 XCB_WINDOW_CLASS_COPY_FROM_PARENT,
149 window, parent, x, y, width, height, 0,
150 XCB_WINDOW_CLASS_INPUT_OUTPUT,
155 } /* ecore_x_window_override_new */
158 * Creates a new input window.
159 * @param parent The parent window to use. If @p parent is @c 0, the root
160 * window of the default display is used.
161 * @param x X position.
162 * @param y Y position.
165 * @return The new window.
166 * @ingroup Ecore_X_Window_Create_Group
169 ecore_x_window_input_new(Ecore_X_Window parent,
175 uint32_t value_list[3];
176 Ecore_X_Window window;
177 xcb_visualid_t vis = { XCB_WINDOW_CLASS_COPY_FROM_PARENT };
181 parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
183 value_mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE;
187 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
188 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
189 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
190 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
191 XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
192 XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
193 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
194 value_list[2] = XCB_EVENT_MASK_NO_EVENT;
196 window = xcb_generate_id(_ecore_xcb_conn);
197 xcb_create_window(_ecore_xcb_conn,
198 XCB_WINDOW_CLASS_COPY_FROM_PARENT,
199 window, parent, x, y, width, height, 0,
200 XCB_WINDOW_CLASS_INPUT_OUTPUT,
205 if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root)
210 } /* ecore_x_window_input_new */
213 * Creates a new window.
214 * @param parent The parent window to use. If @p parent is @c 0, the root
215 * window of the default display is used.
216 * @param x X position.
217 * @param y Y position.
218 * @param width Width.
219 * @param height Height.
220 * @return The new window handle.
221 * @ingroup Ecore_X_Window_Create_Group
224 ecore_x_window_manager_argb_new(Ecore_X_Window parent,
230 Ecore_X_Window window = 0;
232 #ifdef ECORE_XCB_RENDER
233 window = _ecore_x_window_argb_internal_new(parent,
236 #endif /* ECORE_XCB_RENDER */
239 } /* ecore_x_window_manager_argb_new */
242 * Creates a new window.
243 * @param parent The parent window to use. If @p parent is @c 0, the root
244 * window of the default display is used.
245 * @param x X position.
246 * @param y Y position.
247 * @param width Width.
248 * @param height Height.
249 * @return The new window handle.
250 * @ingroup Ecore_X_Window_Create_Group
253 ecore_x_window_argb_new(Ecore_X_Window parent,
259 Ecore_X_Window window = 0;
261 #ifdef ECORE_XCB_RENDER
262 window = _ecore_x_window_argb_internal_new(parent,
265 #endif /* ECORE_XCB_RENDER */
268 } /* ecore_x_window_argb_new */
271 * Creates a window with the override redirect attribute set to @c True.
272 * @param parent The parent window to use. If @p parent is @c 0, the root
273 * window of the default display is used.
274 * @param x X position.
275 * @param y Y position.
276 * @param width Width.
277 * @param height Height.
278 * @return The new window handle.
279 * @ingroup Ecore_X_Window_Create_Group
282 ecore_x_window_override_argb_new(Ecore_X_Window parent,
288 Ecore_X_Window window = 0;
290 #ifdef ECORE_XCB_RENDER
291 window = _ecore_x_window_argb_internal_new(parent,
294 #endif /* ECORE_XCB_RENDER */
297 } /* ecore_x_window_override_argb_new */
300 * @defgroup Ecore_X_Window_Destroy_Group X Window Destroy Functions
302 * Functions to destroy X windows.
306 * Deletes the given window.
307 * @param window The given window.
308 * @ingroup Ecore_X_Window_Destroy_Group
311 ecore_x_window_free(Ecore_X_Window window)
313 /* sorry sir, deleting the root window doesn't sound like
317 xcb_destroy_window(_ecore_xcb_conn, window);
318 } /* ecore_x_window_free */
321 * Sends a delete request to the given window.
322 * @param window The given window.
323 * @ingroup Ecore_X_Window_Destroy_Group
326 ecore_x_window_delete_request_send(Ecore_X_Window window)
328 xcb_client_message_event_t ev;
330 /* sorry sir, deleting the root window doesn't sound like
336 ev.response_type = XCB_CLIENT_MESSAGE;
340 ev.type = ECORE_X_ATOM_WM_PROTOCOLS;
341 ev.data.data32[0] = ECORE_X_ATOM_WM_DELETE_WINDOW;
342 ev.data.data32[1] = XCB_CURRENT_TIME;
344 xcb_send_event(_ecore_xcb_conn, 0, window,
345 XCB_EVENT_MASK_NO_EVENT, (const char *)&ev);
346 } /* ecore_x_window_delete_request_send */
349 * @defgroup Ecore_X_Window_Configure_Group X Window Configure Functions
351 * Functions to configure X windows.
355 * Configures the given window with the given mask.
356 * @param window The given window.
357 * @param mask The given mask.
358 * @param x The X coordinate of the window.
359 * @param y The Y coordinate of the window.
360 * @param width The width of the window.
361 * @param height The height of the window.
362 * @param border_width The border width of the window.
363 * @param sibling The sibling window of the window.
364 * @param stack_mode The stack mode of the window.
365 * @ingroup Ecore_X_Window_Configure_Group
368 ecore_x_window_configure(Ecore_X_Window window,
369 Ecore_X_Window_Configure_Mask mask,
375 Ecore_X_Window sibling,
378 uint32_t *value_list;
386 for (; value_mask; value_mask >>= 1)
390 value_list = (uint32_t *)malloc(sizeof(uint32_t) * length);
395 for (; value_mask; value_mask >>= 1, value_list++)
398 switch (value_mask) {
399 case XCB_CONFIG_WINDOW_X:
403 case XCB_CONFIG_WINDOW_Y:
407 case XCB_CONFIG_WINDOW_WIDTH:
411 case XCB_CONFIG_WINDOW_HEIGHT:
412 *value_list = height;
415 case XCB_CONFIG_WINDOW_BORDER_WIDTH:
416 *value_list = border_width;
419 case XCB_CONFIG_WINDOW_SIBLING:
420 *value_list = sibling;
423 case XCB_CONFIG_WINDOW_STACK_MODE:
424 *value_list = stack_mode;
429 xcb_configure_window(_ecore_xcb_conn, window, mask, value_list);
431 } /* ecore_x_window_configure */
434 * Moves a window to the position @p x, @p y.
436 * The position is relative to the upper left hand corner of the
439 * @param window The window to move.
440 * @param x X position.
441 * @param y Y position.
442 * @ingroup Ecore_X_Window_Configure_Group
445 ecore_x_window_move(Ecore_X_Window window,
449 uint32_t value_list[2];
455 value_mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
460 xcb_configure_window(_ecore_xcb_conn, window, value_mask, value_list);
461 } /* ecore_x_window_move */
465 * @param window The window to resize.
466 * @param width New width of the window.
467 * @param height New height of the window.
468 * @ingroup Ecore_X_Window_Configure_Group
471 ecore_x_window_resize(Ecore_X_Window window,
475 uint32_t value_list[2];
487 value_mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
489 value_list[0] = width;
490 value_list[1] = height;
492 xcb_configure_window(_ecore_xcb_conn, window, value_mask, value_list);
493 } /* ecore_x_window_resize */
496 * Moves and resizes a window.
497 * @param window The window to move and resize.
498 * @param x New X position of the window.
499 * @param y New Y position of the window.
500 * @param width New width of the window.
501 * @param height New height of the window.
502 * @ingroup Ecore_X_Window_Configure_Group
505 ecore_x_window_move_resize(Ecore_X_Window window,
511 uint32_t value_list[4];
524 XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y |
525 XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
529 value_list[2] = width;
530 value_list[3] = height;
532 xcb_configure_window(_ecore_xcb_conn, window, value_mask, value_list);
533 } /* ecore_x_window_move_resize */
536 * Sets the width of the border of the given window.
537 * @param window The given window.
538 * @param border_width The new border width.
539 * @ingroup Ecore_X_Window_Configure_Group
542 ecore_x_window_border_width_set(Ecore_X_Window window,
547 /* doesn't make sense to call this on a root window */
551 value_list = border_width;
553 xcb_configure_window(_ecore_xcb_conn, window, XCB_CONFIG_WINDOW_BORDER_WIDTH, &value_list);
554 } /* ecore_x_window_border_width_set */
557 * Raises the given window.
558 * @param window The window to raise.
559 * @ingroup Ecore_X_Window_Configure_Group
562 ecore_x_window_raise(Ecore_X_Window window)
569 value_list = XCB_STACK_MODE_ABOVE;
571 xcb_configure_window(_ecore_xcb_conn, window, XCB_CONFIG_WINDOW_STACK_MODE, &value_list);
572 } /* ecore_x_window_raise */
575 * Lowers the given window.
576 * @param window The window to lower.
577 * @ingroup Ecore_X_Window_Configure_Group
580 ecore_x_window_lower(Ecore_X_Window window)
587 value_list = XCB_STACK_MODE_BELOW;
589 xcb_configure_window(_ecore_xcb_conn, window, XCB_CONFIG_WINDOW_STACK_MODE, &value_list);
590 } /* ecore_x_window_lower */
593 * @defgroup Ecore_X_Window_Change_Properties_Group X Window Change Property Functions
595 * Functions that change window properties.
599 * Sets the default properties for the given window.
601 * The default properties set for the window are @c WM_CLIENT_MACHINE and
604 * @param window The given window.
605 * @ingroup Ecore_X_Window_Change_Property_Group
608 ecore_x_window_defaults_set(Ecore_X_Window window)
610 char buf[MAXHOSTNAMELEN];
616 * Set WM_CLIENT_MACHINE.
618 gethostname(buf, MAXHOSTNAMELEN);
619 buf[MAXHOSTNAMELEN - 1] = '\0';
620 /* The ecore function uses UTF8 which Xlib may not like (especially
621 * with older clients) */
622 /* ecore_xcb_window_prop_string_set(win, ECORE_X_ATOM_WM_CLIENT_MACHINE,
624 xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
625 ECORE_X_ATOM_WM_CLIENT_MACHINE,
627 8, strlen(buf), buf);
633 ecore_x_netwm_pid_set(window, pid);
635 ecore_x_netwm_window_type_set(window, ECORE_X_WINDOW_TYPE_NORMAL);
637 ecore_app_args_get(&argc, &argv);
638 ecore_x_icccm_command_set(window, argc, argv);
639 } /* ecore_x_window_defaults_set */
642 * @defgroup Ecore_X_Window_Visibility_Group X Window Visibility Functions
644 * Functions to change the visibility of X windows.
650 * Synonymous to "mapping" a window in X Window System terminology.
652 * @param window The window to show.
653 * @ingroup Ecore_X_Window_Visibility_Group
656 ecore_x_window_show(Ecore_X_Window window)
658 xcb_map_window(_ecore_xcb_conn, window);
659 } /* ecore_x_window_show */
664 * Synonymous to "unmapping" a window in X Window System terminology.
666 * @param window The window to hide.
667 * @ingroup Ecore_X_Window_Visibility_Group
670 ecore_x_window_hide(Ecore_X_Window window)
672 xcb_unmap_notify_event_t ev;
675 /* ICCCM: SEND unmap event... */
677 /* FIXME: is it correct ? */
678 if (xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).rem == 1)
679 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
682 xcb_get_geometry_cookie_t cookie;
683 xcb_get_geometry_reply_t *rep;
684 Ecore_X_Drawable draw;
686 /* FIXME: can we avoid round trips, here ? */
688 cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, draw);
689 rep = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
697 ev.response_type = XCB_UNMAP_NOTIFY;
702 ev.from_configure = 0;
704 xcb_send_event(_ecore_xcb_conn, 0, root,
705 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT,
707 xcb_unmap_window(_ecore_xcb_conn, window);
708 } /* ecore_x_window_hide */
711 * @defgroup Ecore_X_Window_Input_Focus_Group X Window Input Focus Functions
713 * Functions that manage the focus of an X Window.
717 * Sets the focus to the window @p window.
718 * @param window The window to focus.
719 * @ingroup Ecore_X_Window_Input_Focus_Group
722 ecore_x_window_focus(Ecore_X_Window window)
724 Ecore_X_Time time = XCB_CURRENT_TIME;
727 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);
732 } /* ecore_x_window_focus */
735 * Sets the focus to the given window at a specific time.
736 * @param window The window to focus.
737 * @param time When to set the focus to the window.
738 * @ingroup Ecore_X_Window_Input_Focus_Group
741 ecore_x_window_focus_at_time(Ecore_X_Window window,
745 window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
747 /* xcb_set_input_focus(_ecore_xcb_conn, XCB_INPUT_FOCUS_NONE, win, time); */
748 xcb_set_input_focus(_ecore_xcb_conn,
749 XCB_INPUT_FOCUS_POINTER_ROOT, window, time);
750 } /* ecore_x_window_focus_at_time */
753 * @defgroup Ecore_X_Window_Reparent_Group X Window Reparent Functions
755 * Functions that retrieve or changes the parent window of a window.
759 * Moves a window to within another window at a given position.
760 * @param window The window to reparent.
761 * @param new_parent The new parent window.
762 * @param x X position within new parent window.
763 * @param y Y position within new parent window.
764 * @ingroup Ecore_X_Window_Reparent_Group
767 ecore_x_window_reparent(Ecore_X_Window window,
768 Ecore_X_Window new_parent,
773 new_parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
775 xcb_reparent_window(_ecore_xcb_conn, window, new_parent, x, y);
776 } /* ecore_x_window_reparent */
779 * @defgroup Ecore_X_Window_Change_Attributes_Group X Window Change Attributes Functions
781 * Functions that change the attributes of a window.
785 * Sets the background pixmap of the given window.
786 * @param window The given window.
787 * @param pixmap The pixmap to set to.
788 * @ingroup Ecore_X_Window_Change_Attributes_Group
791 ecore_x_window_pixmap_set(Ecore_X_Window window,
792 Ecore_X_Pixmap pixmap)
797 xcb_change_window_attributes(_ecore_xcb_conn, window,
798 XCB_CW_BACK_PIXMAP, &value_list);
799 } /* ecore_x_window_pixmap_set */
802 * Sets the background color of the given window.
803 * @param window The given window.
804 * @param red The red component of the color to set to.
805 * @param green The green component of the color to set to.
806 * @param blue The blue component of the color to set to.
807 * @ingroup Ecore_X_Window_Change_Attributes_Group
810 ecore_x_window_background_color_set(Ecore_X_Window window,
812 unsigned short green,
815 xcb_alloc_color_cookie_t cookie;
816 xcb_alloc_color_reply_t *rep;
819 /* FIXME: should I provide a reply, and not the color components, here ? */
820 /* (because of roundtrips) */
821 cookie = xcb_alloc_color_unchecked(_ecore_xcb_conn,
822 ((xcb_screen_t *)_ecore_xcb_screen)->default_colormap,
824 rep = xcb_alloc_color_reply(_ecore_xcb_conn, cookie, NULL);
828 value_list = rep->pixel;
829 xcb_change_window_attributes(_ecore_xcb_conn, window,
830 XCB_CW_BACK_PIXEL, &value_list);
832 } /* ecore_x_window_background_color_set */
835 * Sets the bit gravity of the given window.
836 * @param window The given window.
837 * @param gravity The gravity.
838 * @ingroup Ecore_X_Window_Change_Attributes_Group
841 ecore_x_window_pixel_gravity_set(Ecore_X_Window window,
842 Ecore_X_Gravity gravity)
846 value_list = gravity;
847 xcb_change_window_attributes(_ecore_xcb_conn, window,
848 XCB_CW_BIT_GRAVITY, &value_list);
849 } /* ecore_x_window_pixel_gravity_set */
852 * Sets the gravity of the given window.
853 * @param window The given window.
854 * @param gravity The gravity.
855 * @ingroup Ecore_X_Window_Change_Attributes_Group
858 ecore_x_window_gravity_set(Ecore_X_Window window,
859 Ecore_X_Gravity gravity)
863 value_list = gravity;
864 xcb_change_window_attributes(_ecore_xcb_conn, window,
865 XCB_CW_WIN_GRAVITY, &value_list);
866 } /* ecore_x_window_gravity_set */
869 * Sets the override attribute of the given window.
870 * @param window The given window.
871 * @param override_redirect The override_redirect boolean.
872 * @ingroup Ecore_X_Window_Change_Attributes_Group
875 ecore_x_window_override_set(Ecore_X_Window window,
876 int override_redirect)
880 value_list = override_redirect;
881 xcb_change_window_attributes(_ecore_xcb_conn, window,
882 XCB_CW_OVERRIDE_REDIRECT, &value_list);
883 } /* ecore_x_window_override_set */
886 * Shows the cursor of the given window.
887 * @param window The given window.
888 * @param show If set to @c 0, hide the cursor. Show it otherwise.
889 * @ingroup Ecore_X_Window_Change_Attributes_Group
892 ecore_x_window_cursor_show(Ecore_X_Window window,
896 window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
900 Ecore_X_Cursor cursor;
901 Ecore_X_Drawable draw;
902 Ecore_X_Pixmap pixmap;
909 pixmap = xcb_generate_id(_ecore_xcb_conn);
910 xcb_create_pixmap(_ecore_xcb_conn,
913 mask = xcb_generate_id(_ecore_xcb_conn);
914 xcb_create_pixmap(_ecore_xcb_conn,
918 gc = xcb_generate_id(_ecore_xcb_conn);
919 xcb_create_gc (_ecore_xcb_conn, gc, draw, 0, NULL);
921 xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_FOREGROUND, &value_list);
926 xcb_poly_point(_ecore_xcb_conn, XCB_COORD_MODE_ORIGIN, draw,
929 xcb_free_gc(_ecore_xcb_conn, gc);
931 cursor = xcb_generate_id(_ecore_xcb_conn);
932 xcb_create_cursor(_ecore_xcb_conn, cursor,
938 xcb_change_window_attributes(_ecore_xcb_conn, window,
939 XCB_CW_CURSOR, &value_list);
941 xcb_free_cursor(_ecore_xcb_conn, cursor);
942 xcb_free_pixmap(_ecore_xcb_conn, mask);
943 xcb_free_pixmap(_ecore_xcb_conn, pixmap);
950 xcb_change_window_attributes(_ecore_xcb_conn, window,
951 XCB_CW_CURSOR, &value_list);
953 } /* ecore_x_window_cursor_show */
956 * Sets the cursor of the given window.
957 * @param window The given window.
958 * @param cursor The given cursor.
959 * @ingroup Ecore_X_Window_Change_Attributes_Group
962 ecore_x_window_cursor_set(Ecore_X_Window window,
963 Ecore_X_Cursor cursor)
968 xcb_change_window_attributes(_ecore_xcb_conn, window,
969 XCB_CW_CURSOR, &value_list);
970 } /* ecore_x_window_cursor_set */
974 * @param window The given window.
975 * @ingroup Ecore_X_Window_Change_Attributes_Group
978 ecore_x_window_container_manage(Ecore_X_Window window)
983 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
984 XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;
985 xcb_change_window_attributes(_ecore_xcb_conn, window,
986 XCB_CW_EVENT_MASK, &value_list);
987 } /* ecore_x_window_container_manage */
991 * @param window The given window.
992 * @ingroup Ecore_X_Window_Change_Attributes_Group
995 ecore_x_window_client_manage(Ecore_X_Window window)
1000 XCB_EVENT_MASK_VISIBILITY_CHANGE |
1001 /* XCB_EVENT_MASK_RESIZE_REDIRECT | */
1002 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
1003 XCB_EVENT_MASK_FOCUS_CHANGE |
1004 XCB_EVENT_MASK_PROPERTY_CHANGE |
1005 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
1006 xcb_change_window_attributes(_ecore_xcb_conn, window,
1007 XCB_CW_EVENT_MASK, &value_list);
1008 #ifdef ECORE_XCB_SHAPE
1009 xcb_shape_select_input(_ecore_xcb_conn, window, 1);
1010 #endif /* ECORE_XCB_SHAPE */
1011 } /* ecore_x_window_client_manage */
1015 * @param window The given window.
1016 * @ingroup Ecore_X_Window_Change_Attributes_Group
1019 ecore_x_window_sniff(Ecore_X_Window window)
1021 uint32_t value_list;
1024 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
1025 XCB_EVENT_MASK_PROPERTY_CHANGE;
1026 xcb_change_window_attributes(_ecore_xcb_conn, window,
1027 XCB_CW_EVENT_MASK, &value_list);
1028 } /* ecore_x_window_sniff */
1032 * @param window The given window.
1033 * @ingroup Ecore_X_Window_Change_Attributes_Group
1036 ecore_x_window_client_sniff(Ecore_X_Window window)
1038 uint32_t value_list;
1041 XCB_EVENT_MASK_VISIBILITY_CHANGE |
1042 XCB_EVENT_MASK_STRUCTURE_NOTIFY |
1043 XCB_EVENT_MASK_FOCUS_CHANGE |
1044 XCB_EVENT_MASK_PROPERTY_CHANGE |
1045 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
1046 xcb_change_window_attributes(_ecore_xcb_conn, window,
1047 XCB_CW_EVENT_MASK, &value_list);
1048 #ifdef ECORE_XCB_SHAPE
1049 xcb_shape_select_input(_ecore_xcb_conn, window, 1);
1050 #endif /* ECORE_XCB_SHAPE */
1051 } /* ecore_x_window_client_sniff */
1054 * Clears an area of the given window.
1055 * @param window The given window.
1056 * @param x The X coordinate of the area.
1057 * @param y The Y coordinate of the area.
1058 * @param width The width of the area.
1059 * @param height The height of the area.
1060 * @ingroup Ecore_X_Window_Clear_Area_Group
1063 ecore_x_window_area_clear(Ecore_X_Window window,
1069 xcb_clear_area(_ecore_xcb_conn, 0, window, x, y, width, height);
1070 } /* ecore_x_window_area_clear */
1073 * Exposes an area of the given window.
1074 * @param window The given window.
1075 * @param x The X coordinate of the area.
1076 * @param y The Y coordinate of the area.
1077 * @param width The width of the area.
1078 * @param height The height of the area.
1079 * @ingroup Ecore_X_Window_Clear_Area_Group
1082 ecore_x_window_area_expose(Ecore_X_Window window,
1088 xcb_clear_area(_ecore_xcb_conn, 1, window, x, y, width, height);
1089 } /* ecore_x_window_area_expose */
1092 * @defgroup Ecore_X_Window_Save_Set_Group X Window Change Save Set Functions
1094 * Functions that either inserts or deletes the specified window from
1095 * the client's save-set.
1099 * Inserts the window in the client's save-set.
1100 * @param window The window to insert in the client's save-set.
1101 * @ingroup Ecore_X_Window_Save_Set_Group
1104 ecore_x_window_save_set_add(Ecore_X_Window window)
1106 xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_INSERT, window);
1107 } /* ecore_x_window_save_set_add */
1110 * Deletes the window from the client's save-set.
1111 * @param window The window to delete from the client's save-set.
1112 * @ingroup Ecore_X_Window_Save_Set_Group
1115 ecore_x_window_save_set_del(Ecore_X_Window window)
1117 xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_DELETE, window);
1118 } /* ecore_x_window_save_set_del */
1120 /******************************
1122 * Request that have a reply
1124 ******************************/
1127 * Sends the GetInputFocus request.
1128 * @ingroup Ecore_X_Window_Input_Focus_Group
1131 ecore_x_get_input_focus_prefetch(void)
1133 xcb_get_input_focus_cookie_t cookie;
1135 cookie = xcb_get_input_focus_unchecked(_ecore_xcb_conn);
1136 _ecore_xcb_cookie_cache(cookie.sequence);
1137 } /* ecore_x_get_input_focus_prefetch */
1140 * Gets the reply of the GetInputFocus request sent by ecore_x_get_input_focus_prefetch().
1141 * @ingroup Ecore_X_Window_Input_Focus_Group
1144 ecore_x_get_input_focus_fetch(void)
1146 xcb_get_input_focus_cookie_t cookie;
1147 xcb_get_input_focus_reply_t *reply;
1149 cookie.sequence = _ecore_xcb_cookie_get();
1150 reply = xcb_get_input_focus_reply(_ecore_xcb_conn, cookie, NULL);
1151 _ecore_xcb_reply_cache(reply);
1152 } /* ecore_x_get_input_focus_fetch */
1155 * Gets the window that has focus.
1156 * @return The window that has focus.
1158 * Returns the window that has the focus. If an error aoocured, @c 0
1159 * is returned, otherwise the function returns the window that has focus.
1161 * To use this function, you must call before, and in order,
1162 * ecore_x_get_input_focus_prefetch(), which sends the GetInputFocus request,
1163 * then ecore_x_get_input_focus_fetch(), which gets the reply.
1164 * @ingroup Ecore_X_Window_Input_Focus_Group
1167 ecore_x_window_focus_get(void)
1169 xcb_get_input_focus_reply_t *reply;
1170 Ecore_X_Window window = 0;
1172 reply = _ecore_xcb_reply_get();
1176 return reply->focus;
1177 } /* ecore_x_window_focus_get */
1180 * @defgroup Ecore_X_Window_Get_Attributes_Group X Window Get Attributes Functions
1182 * Functions that get the attributes of a window.
1186 * Sends the GetWindowAttributes request.
1187 * @ingroup Ecore_X_Window_Get_Attributes_Group
1190 ecore_x_get_window_attributes_prefetch(Ecore_X_Window window)
1192 xcb_get_window_attributes_cookie_t cookie;
1194 cookie = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, window);
1195 _ecore_xcb_cookie_cache(cookie.sequence);
1196 } /* ecore_x_get_window_attributes_prefetch */
1199 * Gets the reply of the GetWindowAttributes request sent by ecore_x_get_window_attributes_prefetch().
1200 * @ingroup Ecore_X_Window_Get_Attributes_Group
1203 ecore_x_get_window_attributes_fetch(void)
1205 xcb_get_window_attributes_cookie_t cookie;
1206 xcb_get_window_attributes_reply_t *reply;
1208 cookie.sequence = _ecore_xcb_cookie_get();
1209 reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL);
1210 _ecore_xcb_reply_cache(reply);
1211 } /* ecore_x_get_window_attributes_fetch */
1214 * Retrieves the attributes of a window.
1215 * @param windows Unused.
1216 * @param att_ret Pointer to an Ecore_X_Window_Attributes
1217 * structure in which the attributes of a window
1220 * Retrieves the attributes of a window. If
1221 * @p att_ret is @c NULL, the function does nothing. If an error
1222 * occurred, @p att_ret is set to 0. Otherwise, the @p att_ret structure
1223 * is filled with the attributes os the requested window.
1225 * To use this function, you must call before, and in order,
1226 * ecore_x_get_window_attributes_prefetch(), which sends the GetWindowAttributes request,
1227 * then ecore_x_get_window_attributes_fetch(), which gets the reply.
1228 * @ingroup Ecore_X_Window_Get_Attributes_Group
1231 ecore_x_window_attributes_get(Ecore_X_Window window __UNUSED__,
1232 Ecore_X_Window_Attributes *att_ret)
1234 xcb_get_window_attributes_reply_t *reply;
1239 reply = _ecore_xcb_reply_get();
1243 memset(att_ret, 0, sizeof(Ecore_X_Window_Attributes));
1245 if (reply->map_state != XCB_MAP_STATE_UNMAPPED)
1246 att_ret->visible = 1;
1248 if (reply->map_state == XCB_MAP_STATE_VIEWABLE)
1249 att_ret->viewable = 1;
1251 if (reply->override_redirect)
1252 att_ret->override = 1;
1254 if (reply->_class == XCB_WINDOW_CLASS_INPUT_ONLY)
1255 att_ret->input_only = 1;
1257 if (reply->save_under)
1258 att_ret->save_under = 1;
1260 att_ret->event_mask.mine = reply->your_event_mask;
1261 att_ret->event_mask.all = reply->all_event_masks;
1262 att_ret->event_mask.no_propagate = reply->do_not_propagate_mask;
1263 att_ret->window_gravity = reply->win_gravity;
1264 att_ret->pixel_gravity = reply->bit_gravity;
1265 att_ret->colormap = reply->colormap;
1266 att_ret->visual = reply->visual;
1269 } /* ecore_x_window_attributes_get */
1272 * Finds out whether the given window is currently visible.
1273 * @param window Unused.
1274 * @return 1 if the window is visible, otherwise 0.
1276 * Finds out whether the given window is currently visible.
1277 * If an error occurred, or if the window is not visible, 0 is
1278 * returned. Otherwise 1 is returned.
1280 * To use this function, you must call before, and in order,
1281 * ecore_x_get_window_attributes_prefetch(), which sends the GetWindowAttributes request,
1282 * then ecore_x_get_window_attributes_fetch(), which gets the reply.
1283 * @ingroup Ecore_X_Window_Get_Attributes_Group
1286 ecore_x_window_visible_get(Ecore_X_Window window __UNUSED__)
1288 xcb_get_window_attributes_reply_t *reply;
1290 reply = _ecore_xcb_reply_get();
1294 return (reply->map_state == XCB_MAP_STATE_VIEWABLE) ? 1 : 0;
1295 } /* ecore_x_window_visible_get */
1298 * Sends the QueryPointer request.
1299 * @ingroup Ecore_X_Window_Parent_Group
1302 ecore_x_pointer_xy_get_prefetch(Ecore_X_Window window)
1304 xcb_query_pointer_cookie_t cookie;
1306 cookie = xcb_query_pointer_unchecked(_ecore_xcb_conn, window);
1307 _ecore_xcb_cookie_cache(cookie.sequence);
1308 } /* ecore_x_pointer_xy_get_prefetch */
1311 * Gets the reply of the QueryPointer request sent by ecore_x_query_pointer_prefetch().
1312 * @ingroup Ecore_X_Window_Parent_Group
1315 ecore_x_pointer_xy_get_fetch(void)
1317 xcb_query_pointer_cookie_t cookie;
1318 xcb_query_pointer_reply_t *reply;
1320 cookie.sequence = _ecore_xcb_cookie_get();
1321 reply = xcb_query_pointer_reply(_ecore_xcb_conn, cookie, NULL);
1322 _ecore_xcb_reply_cache(reply);
1323 } /* ecore_x_pointer_xy_get_fetch */
1326 * Retrieves the coordinates of the pointer.
1327 * @param window Unused.
1328 * @param x The X coordinate of the pointer.
1329 * @param y The Y coordinate of the pointer.
1331 * Retrieves the coordinates of the pointer.
1332 * If the window used in
1333 * ecore_x_query_pointer_prefetch() is not on the same screen than
1334 * the root window or if an error occured, @p x and @p y are set
1335 * to 0. Otherwise, they are respectively set to the X and Y
1336 * coordinates of the pointer.
1338 * To use this function, you must call before, and in order,
1339 * ecore_x_query_pointer_prefetch(), which sends the QueryPointer request,
1340 * then ecore_x_query_pointer_fetch(), which gets the reply.
1341 * @ingroup Ecore_X_Window_Parent_Group
1344 ecore_x_pointer_xy_get(Ecore_X_Window window __UNUSED__,
1348 xcb_query_pointer_reply_t *reply;
1350 reply = _ecore_xcb_reply_get();
1367 } /* ecore_x_pointer_xy_get */
1370 * Sends the QueryTree request.
1371 * @ingroup Ecore_X_Window_Parent_Group
1374 ecore_x_query_tree_prefetch(Ecore_X_Window window)
1376 xcb_query_tree_cookie_t cookie;
1378 cookie = xcb_query_tree_unchecked(_ecore_xcb_conn, window);
1379 _ecore_xcb_cookie_cache(cookie.sequence);
1380 } /* ecore_x_query_tree_prefetch */
1383 * Gets the reply of the QueryTree request sent by ecore_x_query_tree_prefetch().
1384 * @ingroup Ecore_X_Window_Parent_Group
1387 ecore_x_query_tree_fetch(void)
1389 xcb_query_tree_cookie_t cookie;
1390 xcb_query_tree_reply_t *reply;
1392 cookie.sequence = _ecore_xcb_cookie_get();
1393 reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL);
1394 _ecore_xcb_reply_cache(reply);
1395 } /* ecore_x_query_tree_fetch */
1398 * Retrieves the parent window of the given window.
1399 * @param window Unused.
1400 * @return The parent window of @p window.
1402 * Retrieves the parent window of the given window. If
1403 * an error occured, @c 0 is returned.
1405 * To use this function, you must call before, and in order,
1406 * ecore_x_query_tree_prefetch(), which sends the QueryTree request,
1407 * then ecore_x_query_tree_fetch(), which gets the reply.
1408 * @ingroup Ecore_X_Window_Parent_Group
1411 ecore_x_window_parent_get(Ecore_X_Window window __UNUSED__)
1413 xcb_query_tree_reply_t *reply;
1415 reply = _ecore_xcb_reply_get();
1419 return reply->parent;
1420 } /* ecore_x_window_parent_get */
1423 * Retrieves the children windows of the given window.
1424 * @param window Unused.
1425 * @param num children windows count.
1426 * @return The children windows.
1428 * Retrieves the children windows of the given window. If
1429 * an error occured, @c 0 is returned.
1431 * To use this function, you must call before, and in order,
1432 * ecore_x_query_tree_prefetch(), which sends the QueryTree request,
1433 * then ecore_x_query_tree_fetch(), which gets the reply.
1434 * @ingroup Ecore_X_Window_Parent_Group
1436 EAPI Ecore_X_Window *
1437 ecore_x_window_children_get(Ecore_X_Window window __UNUSED__,
1440 xcb_query_tree_reply_t *reply;
1441 Ecore_X_Window *windows = NULL;
1446 reply = _ecore_xcb_reply_get();
1450 windows = malloc(sizeof(Ecore_X_Window) * reply->children_len);
1455 *num = reply->children_len;
1458 xcb_query_tree_children(reply),
1459 sizeof(Ecore_X_Window) * reply->children_len);
1462 } /* ecore_x_window_children_get */
1464 /* FIXME: I've tried to remove the round trips. 3 cookies are */
1465 /* created at the beginning of the function. Because of */
1466 /* the recursivity of the algo, I can't find better trick */
1467 static Ecore_X_Window
1468 _ecore_x_window_at_xy_get(Ecore_X_Window base,
1473 Ecore_X_Window *skip,
1476 xcb_get_window_attributes_cookie_t cookie_get_window_attributes;
1477 xcb_get_geometry_cookie_t cookie_get_geometry;
1478 xcb_query_tree_cookie_t cookie_query_tree;
1479 xcb_get_window_attributes_reply_t *reply_get_window_attributes;
1480 xcb_get_geometry_reply_t *reply_get_geometry;
1481 xcb_query_tree_reply_t *reply_query_tree;
1482 Ecore_X_Window window = 0;
1483 Ecore_X_Window child = 0;
1487 uint16_t win_height;
1488 xcb_window_t *wins = NULL;
1492 cookie_get_window_attributes = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, base);
1493 cookie_get_geometry = xcb_get_geometry_unchecked(_ecore_xcb_conn, base);
1494 cookie_query_tree = xcb_query_tree_unchecked(_ecore_xcb_conn, base);
1496 reply_get_window_attributes = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie_get_window_attributes, NULL);
1497 if (!reply_get_window_attributes)
1499 reply_get_geometry = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_get_geometry, NULL);
1500 if (reply_get_geometry)
1501 free(reply_get_geometry);
1503 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1504 if (reply_query_tree)
1505 free(reply_query_tree);
1510 if (reply_get_window_attributes->map_state != XCB_MAP_STATE_VIEWABLE)
1512 free(reply_get_window_attributes);
1513 reply_get_geometry = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_get_geometry, NULL);
1514 if (reply_get_geometry)
1515 free(reply_get_geometry);
1517 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1518 if (reply_query_tree)
1519 free(reply_query_tree);
1524 free(reply_get_window_attributes);
1526 reply_get_geometry = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_get_geometry, NULL);
1527 if (!reply_get_geometry)
1529 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1530 if (reply_query_tree)
1531 free(reply_query_tree);
1536 win_x = reply_get_geometry->x;
1537 win_y = reply_get_geometry->y;
1538 win_width = reply_get_geometry->width;
1539 win_height = reply_get_geometry->height;
1541 free(reply_get_geometry);
1546 if (!((x >= win_x) &&
1548 (x < (int16_t)(win_x + win_width)) &&
1549 (y < (int16_t)(win_y + win_height))))
1551 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1552 if (reply_query_tree)
1553 free(reply_query_tree);
1558 reply_query_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_query_tree, NULL);
1559 if (!reply_query_tree)
1565 for (i = 0; i < skip_num; i++)
1566 if (base == skip[i])
1574 wins = xcb_query_tree_children(reply_query_tree);
1575 tree_c_len = xcb_query_tree_children_length(reply_query_tree);
1576 for(i = 0; i < tree_c_len; i++)
1582 for (j = 0; j < skip_num; j++)
1583 if (wins[i] == skip[j])
1588 child = _ecore_x_window_at_xy_get(wins[i], win_x, win_y, x, y, skip, skip_num);
1591 free(reply_query_tree);
1601 for (i = 0; i < skip_num; i++)
1602 if (base == skip[i])
1604 /* We return 0. child has an xid equal to 0 */
1605 free(reply_query_tree);
1611 free(reply_query_tree);
1614 } /* _ecore_x_window_at_xy_get */
1617 * @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions
1619 * Functions that change or retrieve the geometry of X windows.
1623 * Retrieves the top, visible window at the given location.
1624 * @param x The given X position.
1625 * @param y The given Y position.
1626 * @return The window at that position.
1627 * @ingroup Ecore_X_Window_Geometry_Group
1630 ecore_x_window_at_xy_get(int x,
1633 Ecore_X_Window window;
1634 Ecore_X_Window root;
1636 /* FIXME: Proper function to determine current root/virtual root
1637 * window missing here */
1638 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1641 window = _ecore_x_window_at_xy_get(root, 0, 0, x, y, NULL, 0);
1644 return window ? window : root;
1645 } /* ecore_x_window_at_xy_get */
1648 * Retrieves the top, visible window at the given location,
1649 * but skips the windows in the list.
1650 * @param x The given X position.
1651 * @param y The given Y position.
1652 * @return The window at that position.
1653 * @ingroup Ecore_X_Window_Geometry_Group
1656 ecore_x_window_at_xy_with_skip_get(int x,
1658 Ecore_X_Window *skip,
1661 Ecore_X_Window window;
1662 Ecore_X_Window root;
1664 /* FIXME: Proper function to determine current root/virtual root
1665 * window missing here */
1666 root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1669 window = _ecore_x_window_at_xy_get(root, 0, 0, x, y, skip, skip_num);
1672 return window ? window : root;
1673 } /* ecore_x_window_at_xy_with_skip_get */
1676 * Retrieves the top, visible window at the given location,
1677 * but begins at the @p begin window instead of the root one.
1678 * @param begin The window from which we begin.
1679 * @param x The given X position.
1680 * @param y The given Y position.
1681 * @return The window at that position.
1682 * @ingroup Ecore_X_Window_Geometry_Group
1685 ecore_x_window_at_xy_begin_get(Ecore_X_Window begin,
1689 Ecore_X_Window window;
1692 window = _ecore_x_window_at_xy_get(begin, 0, 0, x, y, NULL, 0);
1695 return window ? window : begin;
1696 } /* ecore_x_window_at_xy_begin_get */
1698 /* FIXME: Should I provide the replies (or the cookies), instead of
1699 creating them in the function ? */
1700 #ifdef ECORE_XCB_RENDER
1701 static Ecore_X_Window
1702 _ecore_x_window_argb_internal_new(Ecore_X_Window parent,
1707 uint8_t override_redirect,
1710 uint32_t value_list[10];
1711 xcb_depth_iterator_t iter_depth;
1712 xcb_visualtype_iterator_t iter_visualtype;
1713 xcb_render_query_pict_formats_cookie_t cookie_pict_format;
1714 xcb_render_query_pict_formats_reply_t *rep_pict_format;
1715 Ecore_X_Screen *screen = NULL;
1716 Ecore_X_Window win = { 0 };
1717 xcb_visualid_t vis = { 0 };
1718 Ecore_X_Colormap colormap;
1719 uint32_t value_mask;
1721 cookie_pict_format = xcb_render_query_pict_formats_unchecked(_ecore_xcb_conn);
1725 parent = ((xcb_screen_t *)_ecore_xcb_screen)->root;
1726 screen = ((xcb_screen_t *)_ecore_xcb_screen);
1730 xcb_screen_iterator_t iter_screen;
1731 xcb_get_geometry_reply_t *rep;
1732 Ecore_X_Drawable draw;
1733 Ecore_X_Window root;
1736 rep = xcb_get_geometry_reply(_ecore_xcb_conn,
1737 xcb_get_geometry_unchecked(_ecore_xcb_conn,
1747 for (; iter_screen.rem; xcb_screen_next(&iter_screen))
1749 if (iter_screen.data->root == root)
1751 screen = iter_screen.data;
1759 /* we get the X visual types */
1760 iter_depth = xcb_screen_allowed_depths_iterator(screen);
1761 for (; iter_depth.rem; xcb_depth_next(&iter_depth)) {
1762 if (iter_depth.data->depth == 32)
1764 iter_visualtype = xcb_depth_visuals_iterator(iter_depth.data);
1769 /* we get the X render visual id */
1770 rep_pict_format = xcb_render_query_pict_formats_reply(_ecore_xcb_conn,
1773 if (!rep_pict_format)
1776 for (; iter_visualtype.rem; xcb_visualtype_next(&iter_visualtype)) {
1777 if (iter_visualtype.data->_class == XCB_VISUAL_CLASS_TRUE_COLOR)
1779 xcb_render_pictforminfo_iterator_t iter_forminfo;
1780 xcb_render_pictscreen_iterator_t iter_pictscreen;
1781 xcb_render_pictformat_t pict_format = { 0 };
1783 iter_forminfo = xcb_render_query_pict_formats_formats_iterator(rep_pict_format);
1784 for (; iter_forminfo.rem; xcb_render_pictforminfo_next(&iter_forminfo)) {
1785 if (iter_forminfo.data->type == XCB_RENDER_PICT_TYPE_DIRECT &&
1786 iter_forminfo.data->direct.alpha_mask && iter_forminfo.data->depth == 32)
1788 pict_format = iter_forminfo.data->id;
1792 if (pict_format == 0)
1794 free(rep_pict_format);
1798 iter_pictscreen = xcb_render_query_pict_formats_screens_iterator(rep_pict_format);
1799 for (; iter_pictscreen.rem; xcb_render_pictscreen_next(&iter_pictscreen)) {
1800 xcb_render_pictdepth_iterator_t iter_depth;
1802 iter_depth = xcb_render_pictscreen_depths_iterator(iter_pictscreen.data);
1803 for (; iter_depth.rem; xcb_render_pictdepth_next(&iter_depth)) {
1804 xcb_render_pictvisual_iterator_t iter_visual;
1806 iter_visual = xcb_render_pictdepth_visuals_iterator(iter_depth.data);
1807 for (; iter_visual.rem; xcb_render_pictvisual_next(&iter_visual)) {
1808 if ((iter_visual.data->visual == iter_visualtype.data->visual_id) &&
1809 (pict_format == iter_visual.data->format))
1811 vis = iter_visual.data->visual;
1820 free(rep_pict_format);
1825 colormap = xcb_generate_id(_ecore_xcb_conn);
1826 xcb_create_colormap(_ecore_xcb_conn, XCB_COLORMAP_ALLOC_NONE, colormap, parent, vis);
1829 XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY |
1830 XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | XCB_CW_OVERRIDE_REDIRECT |
1831 XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE |
1834 value_list[0] = XCB_NONE;
1836 value_list[2] = XCB_GRAVITY_NORTH_WEST;
1837 value_list[3] = XCB_GRAVITY_NORTH_WEST;
1838 value_list[4] = XCB_BACKING_STORE_NOT_USEFUL;
1839 value_list[5] = override_redirect;
1840 value_list[6] = save_under;
1842 XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
1843 XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE |
1844 XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW |
1845 XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE |
1846 XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY |
1847 XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE |
1848 XCB_EVENT_MASK_COLOR_MAP_CHANGE;
1849 value_list[8] = XCB_EVENT_MASK_NO_EVENT;
1850 value_list[9] = colormap;
1852 win = xcb_generate_id(_ecore_xcb_conn);
1853 xcb_create_window(_ecore_xcb_conn,
1857 XCB_WINDOW_CLASS_INPUT_OUTPUT,
1862 xcb_free_colormap(_ecore_xcb_conn, colormap);
1864 if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root)
1865 ecore_x_window_defaults_set(win);
1868 } /* _ecore_x_window_argb_internal_new */
1870 #endif /* ECORE_XCB_RENDER */
1872 /* FIXME: round trip */
1874 ecore_x_window_argb_get(Ecore_X_Window win)
1877 #ifdef ECORE_XCB_RENDER
1878 xcb_render_pictforminfo_iterator_t iter_forminfo;
1879 xcb_render_pictscreen_iterator_t iter_pictscreen;
1880 xcb_render_pictformat_t pict_format = { 0 };
1881 xcb_render_query_pict_formats_reply_t *rep_pictformat;
1882 xcb_get_window_attributes_reply_t *rep;
1883 xcb_visualid_t visual;
1885 rep = xcb_get_window_attributes_reply(_ecore_xcb_conn,
1886 xcb_get_window_attributes_unchecked(_ecore_xcb_conn,
1892 visual = rep->visual;
1896 rep_pictformat = xcb_render_query_pict_formats_reply(_ecore_xcb_conn,
1897 xcb_render_query_pict_formats_unchecked(_ecore_xcb_conn),
1899 if (!rep_pictformat)
1902 iter_forminfo = xcb_render_query_pict_formats_formats_iterator(rep_pictformat);
1903 for (; iter_forminfo.rem; xcb_render_pictforminfo_next(&iter_forminfo))
1905 if ((iter_forminfo.data->type == XCB_RENDER_PICT_TYPE_DIRECT) &&
1906 (iter_forminfo.data->direct.alpha_mask))
1908 pict_format = iter_forminfo.data->id;
1912 if (pict_format == 0)
1914 free(rep_pictformat);
1919 iter_pictscreen = xcb_render_query_pict_formats_screens_iterator(rep_pictformat);
1920 for (; iter_pictscreen.rem; xcb_render_pictscreen_next(&iter_pictscreen))
1922 xcb_render_pictdepth_iterator_t iter_depth;
1924 iter_depth = xcb_render_pictscreen_depths_iterator(iter_pictscreen.data);
1925 for (; iter_depth.rem; xcb_render_pictdepth_next(&iter_depth))
1927 xcb_render_pictvisual_iterator_t iter_visual;
1929 iter_visual = xcb_render_pictdepth_visuals_iterator(iter_depth.data);
1930 for (; iter_visual.rem; xcb_render_pictvisual_next(&iter_visual))
1932 if ((iter_visual.data->visual == visual) &&
1933 (pict_format == iter_visual.data->format))
1942 free(rep_pictformat);
1943 #endif /* ECORE_XCB_RENDER */
1946 } /* ecore_x_window_argb_get */
1949 * Set if a window should be ignored.
1950 * @param window The given window.
1951 * @param ignore if to ignore
1954 ecore_x_window_ignore_set(Ecore_X_Window window,
1963 for (i = 0; i < ignore_num; i++)
1965 if (window == ignore_list[i])
1968 ignore_list = realloc(ignore_list, (ignore_num + 1) * sizeof(Ecore_X_Window));
1972 ignore_list[ignore_num++] = window;
1977 ignore_list = malloc(sizeof(Ecore_X_Window));
1978 ignore_list[ignore_num++] = window;
1986 for (i = 0, j = 0; i < ignore_num; i++)
1988 if (window != ignore_list[i])
1989 ignore_list[i] = ignore_list[j++];
1993 ignore_list = realloc(ignore_list, ignore_num * sizeof(Ecore_X_Window));
1995 } /* ecore_x_window_ignore_set */
1998 * Get the ignore list
1999 * @param num number of windows in the list
2000 * @return list of windows to ignore
2002 EAPI Ecore_X_Window *
2003 ecore_x_window_ignore_list(int *num)
2009 } /* ecore_x_window_ignore_list */
2012 * Retrieves the size of the given window.
2013 * @param win The given window.
2014 * @param w Pointer to an integer into which the width is to be stored.
2015 * @param h Pointer to an integer into which the height is to be stored.
2017 * To use this function, you must call before, and in order,
2018 * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
2019 * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
2020 * @ingroup Ecore_X_Window_Geometry_Group
2023 ecore_x_window_size_get(Ecore_X_Window window,
2028 window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
2030 ecore_x_drawable_geometry_get(window, NULL, NULL, width, height);
2031 } /* ecore_x_window_size_get */
2034 * Retrieves the geometry of the given window.
2035 * @param win The given window.
2036 * @param x Pointer to an integer in which the X position is to be stored.
2037 * @param y Pointer to an integer in which the Y position is to be stored.
2038 * @param w Pointer to an integer in which the width is to be stored.
2039 * @param h Pointer to an integer in which the height is to be stored.
2041 * To use this function, you must call before, and in order,
2042 * ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
2043 * then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
2044 * @ingroup Ecore_X_Window_Geometry_Group
2047 ecore_x_window_geometry_get(Ecore_X_Window window,
2054 window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
2056 ecore_x_drawable_geometry_get(window, x, y, width, height);
2057 } /* ecore_x_window_geometry_get */
2060 * Retrieves the width of the border of the given window.
2061 * @param win The given window.
2062 * @return Width of the border of @p win.
2063 * @ingroup Ecore_X_Window_Geometry_Group
2066 ecore_x_window_border_width_get(Ecore_X_Window win)
2068 /* doesn't make sense to call this on a root window */
2072 return ecore_x_drawable_border_width_get(win);
2073 } /* ecore_x_window_border_width_get */
2076 * Retrieves the depth of the given window.
2077 * @param win The given window.
2078 * @return Depth of the window.
2081 ecore_x_window_depth_get(Ecore_X_Window win)
2083 return ecore_x_drawable_depth_get(win);
2084 } /* ecore_x_window_depth_get */