2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 #include "ecore_x_private.h"
7 #include "Ecore_X_Atoms.h"
9 static int ignore_num = 0;
10 static Ecore_X_Window *ignore_list = NULL;
13 * @defgroup Ecore_X_Window_Create_Group X Window Creation Functions
15 * Functions that can be used to create an X window.
19 * Creates a new window.
20 * @param parent The parent window to use. If @p parent is @c 0, the root
21 * window of the default display is used.
22 * @param x X position.
23 * @param y Y position.
26 * @return The new window handle.
27 * @ingroup Ecore_X_Window_Create_Group
30 ecore_x_window_new(Ecore_X_Window parent, int x, int y, int w, int h)
33 XSetWindowAttributes attr;
35 if (parent == 0) parent = DefaultRootWindow(_ecore_x_disp);
36 attr.backing_store = NotUseful;
37 attr.override_redirect = False;
38 attr.border_pixel = 0;
39 attr.background_pixmap = None;
40 attr.bit_gravity = NorthWestGravity;
41 attr.win_gravity = NorthWestGravity;
42 attr.save_under = False;
43 attr.do_not_propagate_mask = NoEventMask;
44 attr.event_mask = KeyPressMask |
52 VisibilityChangeMask |
57 win = XCreateWindow(_ecore_x_disp, parent,
59 CopyFromParent, /*DefaultDepth(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
61 CopyFromParent, /*DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
74 if (parent == DefaultRootWindow(_ecore_x_disp)) ecore_x_window_defaults_set(win);
79 * Creates a window with the override redirect attribute set to @c True.
80 * @param parent The parent window to use. If @p parent is @c 0, the root
81 * window of the default display is used.
82 * @param x X position.
83 * @param y Y position.
86 * @return The new window handle.
87 * @ingroup Ecore_X_Window_Create_Group
90 ecore_x_window_override_new(Ecore_X_Window parent, int x, int y, int w, int h)
93 XSetWindowAttributes attr;
95 if (parent == 0) parent = DefaultRootWindow(_ecore_x_disp);
96 attr.backing_store = NotUseful;
97 attr.override_redirect = True;
98 attr.border_pixel = 0;
99 attr.background_pixmap = None;
100 attr.bit_gravity = NorthWestGravity;
101 attr.win_gravity = NorthWestGravity;
102 attr.save_under = False;
103 attr.do_not_propagate_mask = NoEventMask;
104 attr.event_mask = KeyPressMask |
112 VisibilityChangeMask |
113 StructureNotifyMask |
117 win = XCreateWindow(_ecore_x_disp, parent,
119 CopyFromParent, /*DefaultDepth(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
121 CopyFromParent, /*DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
137 * Creates a new input window.
138 * @param parent The parent window to use. If @p parent is @c 0, the root
139 * window of the default display is used.
140 * @param x X position.
141 * @param y Y position.
144 * @return The new window.
145 * @ingroup Ecore_X_Window_Create_Group
148 ecore_x_window_input_new(Ecore_X_Window parent, int x, int y, int w, int h)
151 XSetWindowAttributes attr;
153 if (parent == 0) parent = DefaultRootWindow(_ecore_x_disp);
154 attr.override_redirect = True;
155 attr.do_not_propagate_mask = NoEventMask;
156 attr.event_mask = KeyPressMask |
164 VisibilityChangeMask |
165 StructureNotifyMask |
169 win = XCreateWindow(_ecore_x_disp, parent,
173 CopyFromParent, /*DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
179 if (parent == DefaultRootWindow(_ecore_x_disp))
186 * @defgroup Evas_X_Window_Properties_Group X Window Property Functions
188 * Functions that set window properties.
192 * Sets the default properties for the given window.
194 * The default properties set for the window are @c WM_CLIENT_MACHINE and
197 * @param win The given window.
198 * @ingroup Evas_X_Window_Properties_Groups
201 ecore_x_window_defaults_set(Ecore_X_Window win)
204 char buf[MAXHOSTNAMELEN];
211 * Set WM_CLIENT_MACHINE.
213 gethostname(buf, MAXHOSTNAMELEN);
214 buf[MAXHOSTNAMELEN - 1] = '\0';
216 /* The ecore function uses UTF8 which Xlib may not like (especially
217 * with older clients) */
218 /* ecore_x_window_prop_string_set(win, ECORE_X_ATOM_WM_CLIENT_MACHINE,
220 if (XStringListToTextProperty(hostname, 1, &xprop))
222 XSetWMClientMachine(_ecore_x_disp, win, &xprop);
230 ecore_x_netwm_pid_set(win, pid);
232 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL);
234 ecore_app_args_get(&argc, &argv);
235 ecore_x_icccm_command_set(win, argc, argv);
239 ecore_x_window_configure(Ecore_X_Window win,
240 Ecore_X_Window_Configure_Mask mask,
241 int x, int y, int w, int h,
242 int border_width, Ecore_X_Window sibling,
254 xwc.border_width = border_width;
255 xwc.sibling = sibling;
256 xwc.stack_mode = stack_mode;
258 XConfigureWindow(_ecore_x_disp, win, mask, &xwc);
262 * @defgroup Evas_X_Window_Destroy_Group X Window Destroy Functions
264 * Functions to destroy X windows.
268 * Deletes the given window.
269 * @param win The given window.
270 * @ingroup Evas_X_Window_Destroy_Group
273 ecore_x_window_del(Ecore_X_Window win)
275 /* sorry sir, deleting the root window doesn't sound like
279 XDestroyWindow(_ecore_x_disp, win);
283 * Set if a window should be ignored.
284 * @param win The given window.
285 * @param ignore if to ignore
288 ecore_x_window_ignore_set(Ecore_X_Window win, int ignore)
296 for (i = 0; i < ignore_num; i++)
298 if (win == ignore_list[i])
301 ignore_list = realloc(ignore_list, (ignore_num + 1) * sizeof(Ecore_X_Window));
302 if (!ignore_list) return;
303 ignore_list[ignore_num++] = win;
308 ignore_list = malloc(sizeof(Ecore_X_Window));
309 ignore_list[ignore_num++] = win;
314 if (!ignore_list) return;
315 for (i = 0, j = 0; i < ignore_num; i++)
317 if (win != ignore_list[i])
318 ignore_list[i] = ignore_list[j++];
322 ignore_list = realloc(ignore_list, ignore_num * sizeof(Ecore_X_Window));
327 * Get the ignore list
328 * @param num number of windows in the list
329 * @return list of windows to ignore
331 EAPI Ecore_X_Window *
332 ecore_x_window_ignore_list(int *num)
334 if (num) *num = ignore_num;
339 * Sends a delete request to the given window.
340 * @param win The given window.
341 * @ingroup Evas_X_Window_Destroy_Group
344 ecore_x_window_delete_request_send(Ecore_X_Window win)
348 /* sorry sir, deleting the root window doesn't sound like
354 xev.xclient.type = ClientMessage;
355 xev.xclient.display = _ecore_x_disp;
356 xev.xclient.window = win;
357 xev.xclient.message_type = ECORE_X_ATOM_WM_PROTOCOLS;
358 xev.xclient.format = 32;
359 xev.xclient.data.l[0] = ECORE_X_ATOM_WM_DELETE_WINDOW;
360 xev.xclient.data.l[1] = CurrentTime;
362 XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev);
366 * @defgroup Evas_X_Window_Visibility_Group X Window Visibility Functions
368 * Functions to access and change the visibility of X windows.
374 * Synonymous to "mapping" a window in X Window System terminology.
376 * @param win The window to show.
377 * @ingroup Evas_X_Window_Visibility
380 ecore_x_window_show(Ecore_X_Window win)
382 XMapWindow(_ecore_x_disp, win);
388 * Synonymous to "unmapping" a window in X Window System terminology.
390 * @param win The window to hide.
391 * @ingroup Evas_X_Window_Visibility
394 ecore_x_window_hide(Ecore_X_Window win)
401 /* ICCCM: SEND unmap event... */
403 if (ScreenCount(_ecore_x_disp) == 1)
404 root = DefaultRootWindow(_ecore_x_disp);
406 XGetGeometry(_ecore_x_disp, win, &root, &idum, &idum, &uidum, &uidum, &uidum, &uidum);
407 xev.xunmap.type = UnmapNotify;
408 xev.xunmap.serial = 0;
409 xev.xunmap.send_event = True;
410 xev.xunmap.display = _ecore_x_disp;
411 xev.xunmap.event = root;
412 xev.xunmap.window = win;
413 xev.xunmap.from_configure = False;
414 XSendEvent(_ecore_x_disp, xev.xunmap.event, False,
415 SubstructureRedirectMask | SubstructureNotifyMask, &xev);
416 XUnmapWindow(_ecore_x_disp, win);
420 * @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions
422 * Functions that change or retrieve the geometry of X windows.
426 * Moves a window to the position @p x, @p y.
428 * The position is relative to the upper left hand corner of the
431 * @param win The window to move.
432 * @param x X position.
433 * @param y Y position.
434 * @ingroup Ecore_X_Window_Geometry_Group
437 ecore_x_window_move(Ecore_X_Window win, int x, int y)
439 XMoveWindow(_ecore_x_disp, win, x, y);
444 * @param win The window to resize.
445 * @param w New width of the window.
446 * @param h New height of the window.
447 * @ingroup Ecore_X_Window_Geometry_Group
450 ecore_x_window_resize(Ecore_X_Window win, int w, int h)
454 XResizeWindow(_ecore_x_disp, win, w, h);
458 * Moves and resizes a window.
459 * @param win The window to move and resize.
460 * @param x New X position of the window.
461 * @param y New Y position of the window.
462 * @param w New width of the window.
463 * @param h New height of the window.
464 * @ingroup Ecore_X_Window_Geometry_Group
467 ecore_x_window_move_resize(Ecore_X_Window win, int x, int y, int w, int h)
471 XMoveResizeWindow(_ecore_x_disp, win, x, y, w, h);
475 * @defgroup Ecore_X_Window_Focus_Functions X Window Focus Functions
477 * Functions that give the focus to an X Window.
481 * Sets the focus to the window @p win.
482 * @param win The window to focus.
483 * @ingroup Ecore_X_Window_Focus_Functions
486 ecore_x_window_focus(Ecore_X_Window win)
488 if (win == 0) win = DefaultRootWindow(_ecore_x_disp);
489 // XSetInputFocus(_ecore_x_disp, win, RevertToNone, CurrentTime);
490 XSetInputFocus(_ecore_x_disp, win, RevertToPointerRoot, CurrentTime);
494 * Sets the focus to the given window at a specific time.
495 * @param win The window to focus.
496 * @param t When to set the focus to the window.
497 * @ingroup Ecore_X_Window_Focus_Functions
500 ecore_x_window_focus_at_time(Ecore_X_Window win, Ecore_X_Time t)
502 if (win == 0) win = DefaultRootWindow(_ecore_x_disp);
503 // XSetInputFocus(_ecore_x_disp, win, RevertToNone, t);
504 XSetInputFocus(_ecore_x_disp, win, PointerRoot, t);
508 * gets the focus to the window @p win.
509 * @return The window that has focus.
510 * @ingroup Ecore_X_Window_Focus_Functions
513 ecore_x_window_focus_get(void)
520 XGetInputFocus(_ecore_x_disp, &win, &revert_mode);
525 * @defgroup Ecore_X_Window_Z_Order_Group X Window Z Order Functions
527 * Functions that change the Z order of X windows.
531 * Raises the given window.
532 * @param win The window to raise.
533 * @ingroup Ecore_X_Window_Z_Order_Group
536 ecore_x_window_raise(Ecore_X_Window win)
538 XRaiseWindow(_ecore_x_disp, win);
542 * Lowers the given window.
543 * @param win The window to lower.
544 * @ingroup Ecore_X_Window_Z_Order_Group
547 ecore_x_window_lower(Ecore_X_Window win)
549 XLowerWindow(_ecore_x_disp, win);
553 * @defgroup Ecore_X_Window_Parent_Group X Window Parent Functions
555 * Functions that retrieve or changes the parent window of a window.
559 * Moves a window to within another window at a given position.
560 * @param win The window to reparent.
561 * @param new_parent The new parent window.
562 * @param x X position within new parent window.
563 * @param y Y position within new parent window.
564 * @ingroup Ecore_X_Window_Parent_Group
567 ecore_x_window_reparent(Ecore_X_Window win, Ecore_X_Window new_parent, int x, int y)
569 if (new_parent == 0) new_parent = DefaultRootWindow(_ecore_x_disp);
570 XReparentWindow(_ecore_x_disp, win, new_parent, x, y);
574 * Retrieves the size of the given window.
575 * @param win The given window.
576 * @param w Pointer to an integer into which the width is to be stored.
577 * @param h Pointer to an integer into which the height is to be stored.
578 * @ingroup Ecore_X_Window_Geometry_Group
581 ecore_x_window_size_get(Ecore_X_Window win, int *w, int *h)
583 int dummy_x, dummy_y;
586 win = DefaultRootWindow(_ecore_x_disp);
588 ecore_x_drawable_geometry_get(win, &dummy_x, &dummy_y, w, h);
592 * Retrieves the geometry of the given window.
593 * @param win The given window.
594 * @param x Pointer to an integer in which the X position is to be stored.
595 * @param y Pointer to an integer in which the Y position is to be stored.
596 * @param w Pointer to an integer in which the width is to be stored.
597 * @param h Pointer to an integer in which the height is to be stored.
598 * @ingroup Ecore_X_Window_Geometry_Group
601 ecore_x_window_geometry_get(Ecore_X_Window win, int *x, int *y, int *w, int *h)
604 win = DefaultRootWindow(_ecore_x_disp);
606 ecore_x_drawable_geometry_get(win, x, y, w, h);
610 * Retrieves the width of the border of the given window.
611 * @param win The given window.
612 * @return Width of the border of @p win.
613 * @ingroup Ecore_X_Window_Geometry_Group
616 ecore_x_window_border_width_get(Ecore_X_Window win)
618 /* doesn't make sense to call this on a root window */
622 return ecore_x_drawable_border_width_get(win);
626 * Sets the width of the border of the given window.
627 * @param win The given window.
628 * @param width The new border width.
629 * @ingroup Ecore_X_Window_Geometry_Group
632 ecore_x_window_border_width_set(Ecore_X_Window win, int width)
634 /* doesn't make sense to call this on a root window */
638 XSetWindowBorderWidth (_ecore_x_disp, win, width);
642 * Retrieves the depth of the given window.
643 * @param win The given window.
644 * @return Depth of the window.
647 ecore_x_window_depth_get(Ecore_X_Window win)
649 return ecore_x_drawable_depth_get(win);
655 * FIXME: To be fixed.
658 ecore_x_window_cursor_show(Ecore_X_Window win, int show)
660 if (win == 0) win = DefaultRootWindow(_ecore_x_disp);
669 p = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
670 m = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
671 gc = XCreateGC(_ecore_x_disp, m, 0, &gcv);
672 XSetForeground(_ecore_x_disp, gc, 0);
673 XDrawPoint(_ecore_x_disp, m, gc, 0, 0);
674 XFreeGC(_ecore_x_disp, gc);
675 c = XCreatePixmapCursor(_ecore_x_disp, p, m, &cl, &cl, 0, 0);
676 XDefineCursor(_ecore_x_disp, win, c);
677 XFreeCursor(_ecore_x_disp, c);
678 XFreePixmap(_ecore_x_disp, p);
679 XFreePixmap(_ecore_x_disp, m);
683 XDefineCursor(_ecore_x_disp, win, 0);
688 ecore_x_window_cursor_set(Ecore_X_Window win, Ecore_X_Cursor c)
691 XUndefineCursor(_ecore_x_disp, win);
693 XDefineCursor(_ecore_x_disp, win, c);
697 * Finds out whether the given window is currently visible.
698 * @param win The given window.
699 * @return 1 if the window is visible, otherwise 0.
700 * @ingroup Ecore_X_Window_Visibility_Group
703 ecore_x_window_visible_get(Ecore_X_Window win)
705 XWindowAttributes attr;
707 return (XGetWindowAttributes(_ecore_x_disp, win, &attr) &&
708 (attr.map_state == IsViewable));
713 typedef struct _Shadow Shadow;
724 static int shadow_count = 0;
725 static Shadow **shadow_base = NULL;
726 static int shadow_num = 0;
729 _ecore_x_window_tree_walk(Window win)
732 Window parent_win = 0, root_win = 0;
736 XWindowAttributes att;
738 if (!XGetWindowAttributes(_ecore_x_disp, win, &att)) return NULL;
739 // if (att.class == InputOnly) return NULL;
740 if (att.map_state != IsViewable) return NULL;
742 s = calloc(1, sizeof(Shadow));
749 if (XQueryTree(_ecore_x_disp, s->win, &root_win, &parent_win,
752 s->children = calloc(1, sizeof(Shadow *) * num);
755 s->children_num = num;
756 for (i = 0; i < num; i++)
758 s->children[i] = _ecore_x_window_tree_walk(list[i]);
759 if (s->children[i]) s->children[i]->parent = s;
761 /* compress list down */
763 for (i = 0; i < num; i++)
767 s->children[j] = s->children[i];
780 sl = realloc(s->children, sizeof(Shadow *) * j);
781 if (sl) s->children = sl;
789 _ecore_x_window_tree_shadow_free1(Shadow *s)
796 for (i = 0; i < s->children_num; i++)
799 _ecore_x_window_tree_shadow_free1(s->children[i]);
807 _ecore_x_window_tree_shadow_free(void)
811 if (!shadow_base) return;
812 for (i = 0; i < shadow_num; i++)
814 if (!shadow_base[i]) continue;
815 _ecore_x_window_tree_shadow_free1(shadow_base[i]);
823 _ecore_x_window_tree_shadow_populate(void)
825 Ecore_X_Window *roots;
828 roots = ecore_x_window_root_list(&num);
831 shadow_base = calloc(1, sizeof(Shadow *) * num);
835 for (i = 0; i < num; i++)
836 shadow_base[i] = _ecore_x_window_tree_walk(roots[i]);
843 _ecore_x_window_tree_shadow_start(void)
846 if (shadow_count > 1) return;
847 _ecore_x_window_tree_shadow_populate();
851 _ecore_x_window_tree_shadow_stop(void)
854 if (shadow_count != 0) return;
855 _ecore_x_window_tree_shadow_free();
859 _ecore_x_window_shadow_tree_find_shadow(Shadow *s, Window win)
864 if (s->win == win) return s;
867 for (i = 0; i < s->children_num; i++)
869 if (!s->children[i]) continue;
870 if ((ss = _ecore_x_window_shadow_tree_find_shadow(s->children[i], win)))
878 _ecore_x_window_shadow_tree_find(Window base)
883 for (i = 0; i < shadow_num; i++)
885 if (!shadow_base[i]) continue;
886 if ((s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], base)))
893 _ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow *s, int bx, int by, int x, int y,
894 Ecore_X_Window *skip, int skip_num)
902 if (!((x >= wx) && (y >= wy) && (x < (wx + s->w)) && (y < (wy + s->h))))
908 for (i = s->children_num - 1; i >= 0; --i)
910 if (!s->children[i]) continue;
914 for (j = 0; j < skip_num; j++)
916 if (s->children[i]->win == skip[j])
926 if ((child = _ecore_x_window_shadow_tree_at_xy_get_shadow(s->children[i], wx, wy, x, y, skip, skip_num)))
937 _ecore_x_window_shadow_tree_at_xy_get(Window base, int bx, int by, int x, int y,
938 Ecore_X_Window *skip, int skip_num)
944 _ecore_x_window_tree_shadow_populate();
945 if (!shadow_base) return 0;
947 s = _ecore_x_window_shadow_tree_find(base);
949 return _ecore_x_window_shadow_tree_at_xy_get_shadow(s, bx, by, x, y, skip, skip_num);
953 * Retrieves the top, visible window at the given location,
954 * but skips the windows in the list. This uses a shadow tree built from the
955 * window tree that is only updated the first time
956 * ecore_x_window_shadow_tree_at_xy_with_skip_get() is called, or the next time
957 * it is called after a ecore_x_window_shadow_tree_flush()
958 * @param base The base window to start searching from (normally root).
959 * @param x The given X position.
960 * @param y The given Y position.
961 * @return The window at that position.
962 * @ingroup Ecore_X_Window_Geometry_Group
965 ecore_x_window_shadow_tree_at_xy_with_skip_get(Ecore_X_Window base, int x, int y, Ecore_X_Window *skip, int skip_num)
967 return _ecore_x_window_shadow_tree_at_xy_get(base, 0, 0, x, y, skip, skip_num);
971 * Retrieves the parent window a given window has. This uses the shadow window
973 * @param root The root window of @p win - if 0, this will be automatically determined with extra processing overhead
974 * @param win The window to get the parent window of
975 * @return The parent window of @p win
976 * @ingroup Ecore_X_Window_Geometry_Group
979 ecore_x_window_shadow_parent_get(Ecore_X_Window root, Ecore_X_Window win)
986 _ecore_x_window_tree_shadow_populate();
987 if (!shadow_base) return 0;
989 for (i = 0; i < shadow_num; i++)
991 if (!shadow_base[i]) continue;
992 s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], win);
995 if (!s->parent) return 0;
996 return s->parent->win;
1003 * Flushes the window shadow tree so nothing is stored.
1004 * @ingroup Ecore_X_Window_Geometry_Group
1007 ecore_x_window_shadow_tree_flush(void)
1009 _ecore_x_window_tree_shadow_free();
1013 * Retrieves the root window a given window is on.
1014 * @param win The window to get the root window of
1015 * @return The root window of @p win
1016 * @ingroup Ecore_X_Window_Geometry_Group
1019 ecore_x_window_root_get(Ecore_X_Window win)
1021 XWindowAttributes att;
1023 if (!XGetWindowAttributes(_ecore_x_disp, win, &att)) return 0;
1028 _ecore_x_window_at_xy_get(Window base, int bx, int by, int x, int y,
1029 Ecore_X_Window *skip, int skip_num)
1031 Window *list = NULL;
1032 Window parent_win = 0, child = 0, root_win = 0;
1033 int i, j, wx, wy, ww, wh;
1036 if (!ecore_x_window_visible_get(base))
1039 ecore_x_window_geometry_get(base, &wx, &wy, &ww, &wh);
1043 if (!((x >= wx) && (y >= wy) && (x < (wx + ww)) && (y < (wy + wh))))
1046 if (!XQueryTree(_ecore_x_disp, base, &root_win, &parent_win, &list, &num))
1053 for (i = num - 1; i >= 0; --i)
1059 for (j = 0; j < skip_num; j++)
1061 if (list[i] == skip[j])
1071 if ((child = _ecore_x_window_at_xy_get(list[i], wx, wy, x, y, skip, skip_num)))
1084 * Retrieves the top, visible window at the given location.
1085 * @param x The given X position.
1086 * @param y The given Y position.
1087 * @return The window at that position.
1088 * @ingroup Ecore_X_Window_Geometry_Group
1091 ecore_x_window_at_xy_get(int x, int y)
1093 Ecore_X_Window win, root;
1095 /* FIXME: Proper function to determine current root/virtual root
1096 * window missing here */
1097 root = DefaultRootWindow(_ecore_x_disp);
1100 win = _ecore_x_window_at_xy_get(root, 0, 0, x, y, NULL, 0);
1103 return win ? win : root;
1107 * Retrieves the top, visible window at the given location,
1108 * but skips the windows in the list.
1109 * @param x The given X position.
1110 * @param y The given Y position.
1111 * @return The window at that position.
1112 * @ingroup Ecore_X_Window_Geometry_Group
1115 ecore_x_window_at_xy_with_skip_get(int x, int y, Ecore_X_Window *skip, int skip_num)
1117 Ecore_X_Window win, root;
1119 /* FIXME: Proper function to determine current root/virtual root
1120 * window missing here */
1121 root = DefaultRootWindow(_ecore_x_disp);
1124 win = _ecore_x_window_at_xy_get(root, 0, 0, x, y, skip, skip_num);
1127 return win ? win : root;
1131 ecore_x_window_at_xy_begin_get(Ecore_X_Window begin, int x, int y)
1136 win = _ecore_x_window_at_xy_get(begin, 0, 0, x, y, NULL, 0);
1139 return win ? win : begin;
1143 * Retrieves the parent window of the given window.
1144 * @param win The given window.
1145 * @return The parent window of @p win.
1146 * @ingroup Ecore_X_Window_Parent_Group
1149 ecore_x_window_parent_get(Ecore_X_Window win)
1151 Window root, parent, *children = NULL;
1154 if (!XQueryTree(_ecore_x_disp, win, &root, &parent, &children, &num))
1163 * Sets the background color of the given window.
1164 * @param win The given window
1165 * @param r red value (0...65536, 16 bits)
1166 * @param g green value (0...65536, 16 bits)
1167 * @param b blue value (0...65536, 16 bits)
1170 ecore_x_window_background_color_set(Ecore_X_Window win, unsigned short r,
1171 unsigned short g, unsigned short b)
1173 XSetWindowAttributes attr;
1181 map = DefaultColormap(_ecore_x_disp, DefaultScreen(_ecore_x_disp));
1182 XAllocColor(_ecore_x_disp, map, &col);
1184 attr.background_pixel = col.pixel;
1185 XChangeWindowAttributes(_ecore_x_disp, win, CWBackPixel, &attr);
1189 ecore_x_window_gravity_set(Ecore_X_Window win, Ecore_X_Gravity grav)
1191 XSetWindowAttributes att;
1193 att.win_gravity = grav;
1194 XChangeWindowAttributes(_ecore_x_disp, win, CWWinGravity, &att);
1198 ecore_x_window_pixel_gravity_set(Ecore_X_Window win, Ecore_X_Gravity grav)
1200 XSetWindowAttributes att;
1202 att.bit_gravity = grav;
1203 XChangeWindowAttributes(_ecore_x_disp, win, CWBitGravity, &att);
1207 ecore_x_window_pixmap_set(Ecore_X_Window win, Ecore_X_Pixmap pmap)
1209 XSetWindowBackgroundPixmap(_ecore_x_disp, win, pmap);
1213 ecore_x_window_area_clear(Ecore_X_Window win, int x, int y, int w, int h)
1215 XClearArea(_ecore_x_disp, win, x, y, w, h, False);
1219 ecore_x_window_area_expose(Ecore_X_Window win, int x, int y, int w, int h)
1221 XClearArea(_ecore_x_disp, win, x, y, w, h, True);
1225 ecore_x_window_override_set(Ecore_X_Window win, int override)
1227 XSetWindowAttributes att;
1229 att.override_redirect = override;
1230 XChangeWindowAttributes(_ecore_x_disp, win, CWOverrideRedirect, &att);
1233 #ifdef ECORE_XRENDER
1234 static Ecore_X_Window
1235 _ecore_x_window_argb_internal_new(Ecore_X_Window parent, int x, int y, int w, int h, int override, int saveunder)
1238 XSetWindowAttributes attr;
1239 XWindowAttributes att;
1242 int nvi, i, scr = 0;
1243 XRenderPictFormat *fmt;
1248 parent = DefaultRootWindow(_ecore_x_disp);
1249 scr = DefaultScreen(_ecore_x_disp);
1253 /* ewww - round trip */
1254 XGetWindowAttributes(_ecore_x_disp, parent, &att);
1255 for (i = 0; i < ScreenCount(_ecore_x_disp); i++)
1257 if (att.screen == ScreenOfDisplay(_ecore_x_disp, i))
1266 vi_in.class = TrueColor;
1267 xvi = XGetVisualInfo(_ecore_x_disp,
1273 if (xvi == NULL) return 0;
1275 for (i = 0; i < nvi; i++)
1277 fmt = XRenderFindVisualFormat(_ecore_x_disp, xvi[i].visual);
1278 if ((fmt->type == PictTypeDirect) && (fmt->direct.alphaMask))
1280 vis = xvi[i].visual;
1286 attr.backing_store = NotUseful;
1287 attr.override_redirect = override;
1288 attr.colormap = XCreateColormap(_ecore_x_disp, parent,
1290 attr.border_pixel = 0;
1291 attr.background_pixmap = None;
1292 attr.bit_gravity = NorthWestGravity;
1293 attr.win_gravity = NorthWestGravity;
1294 attr.save_under = saveunder;
1295 attr.do_not_propagate_mask = NoEventMask;
1296 attr.event_mask = KeyPressMask |
1304 VisibilityChangeMask |
1305 StructureNotifyMask |
1307 PropertyChangeMask |
1309 win = XCreateWindow(_ecore_x_disp, parent,
1315 CWOverrideRedirect |
1325 XFreeColormap(_ecore_x_disp, attr.colormap);
1327 if (parent == DefaultRootWindow(_ecore_x_disp)) ecore_x_window_defaults_set(win);
1333 ecore_x_window_argb_get(Ecore_X_Window win)
1335 #ifdef ECORE_XRENDER
1336 XWindowAttributes att;
1337 XRenderPictFormat *fmt;
1339 XGetWindowAttributes(_ecore_x_disp, win, &att);
1340 fmt = XRenderFindVisualFormat(_ecore_x_disp, att.visual);
1342 if ((fmt->type == PictTypeDirect) && (fmt->direct.alphaMask)) return 1;
1350 * Creates a new window.
1351 * @param parent The parent window to use. If @p parent is @c 0, the root
1352 * window of the default display is used.
1353 * @param x X position.
1354 * @param y Y position.
1357 * @return The new window handle.
1358 * @ingroup Ecore_X_Window_Create_Group
1361 ecore_x_window_manager_argb_new(Ecore_X_Window parent, int x, int y, int w, int h)
1363 #ifdef ECORE_XRENDER
1364 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 1, 0);
1371 * Creates a new window.
1372 * @param parent The parent window to use. If @p parent is @c 0, the root
1373 * window of the default display is used.
1374 * @param x X position.
1375 * @param y Y position.
1378 * @return The new window handle.
1379 * @ingroup Ecore_X_Window_Create_Group
1382 ecore_x_window_argb_new(Ecore_X_Window parent, int x, int y, int w, int h)
1384 #ifdef ECORE_XRENDER
1385 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 0, 0);
1392 * Creates a window with the override redirect attribute set to @c True.
1393 * @param parent The parent window to use. If @p parent is @c 0, the root
1394 * window of the default display is used.
1395 * @param x X position.
1396 * @param y Y position.
1399 * @return The new window handle.
1400 * @ingroup Ecore_X_Window_Create_Group
1403 ecore_x_window_override_argb_new(Ecore_X_Window parent, int x, int y, int w, int h)
1405 #ifdef ECORE_XRENDER
1406 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 1, 0);