3 #endif /* ifdef HAVE_CONFIG_H */
10 #include "ecore_x_private.h"
12 #include "Ecore_X_Atoms.h"
14 static int ignore_num = 0;
15 static Ecore_X_Window *ignore_list = NULL;
18 * @defgroup Ecore_X_Window_Create_Group X Window Creation Functions
20 * Functions that can be used to create an X window.
24 * Creates a new window.
25 * @param parent The parent window to use. If @p parent is @c 0, the root
26 * window of the default display is used.
27 * @param x X position.
28 * @param y Y position.
31 * @return The new window handle.
32 * @ingroup Ecore_X_Window_Create_Group
35 ecore_x_window_new(Ecore_X_Window parent, int x, int y, int w, int h)
38 XSetWindowAttributes attr;
40 LOGFN(__FILE__, __LINE__, __FUNCTION__);
42 parent = DefaultRootWindow(_ecore_x_disp);
44 attr.backing_store = NotUseful;
45 attr.override_redirect = False;
46 attr.border_pixel = 0;
47 attr.background_pixmap = None;
48 attr.bit_gravity = NorthWestGravity;
49 attr.win_gravity = NorthWestGravity;
50 attr.save_under = False;
51 attr.do_not_propagate_mask = NoEventMask;
52 attr.event_mask = KeyPressMask |
60 VisibilityChangeMask |
65 win = XCreateWindow(_ecore_x_disp, parent,
67 CopyFromParent, /*DefaultDepth(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
69 CopyFromParent, /*DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
82 if (parent == DefaultRootWindow(_ecore_x_disp))
83 ecore_x_window_defaults_set(win);
86 } /* ecore_x_window_new */
89 * Creates a window with the override redirect attribute set to @c True.
90 * @param parent The parent window to use. If @p parent is @c 0, the root
91 * window of the default display is used.
92 * @param x X position.
93 * @param y Y position.
96 * @return The new window handle.
97 * @ingroup Ecore_X_Window_Create_Group
100 ecore_x_window_override_new(Ecore_X_Window parent, int x, int y, int w, int h)
103 XSetWindowAttributes attr;
105 LOGFN(__FILE__, __LINE__, __FUNCTION__);
107 parent = DefaultRootWindow(_ecore_x_disp);
109 attr.backing_store = NotUseful;
110 attr.override_redirect = True;
111 attr.border_pixel = 0;
112 attr.background_pixmap = None;
113 attr.bit_gravity = NorthWestGravity;
114 attr.win_gravity = NorthWestGravity;
115 attr.save_under = False;
116 attr.do_not_propagate_mask = NoEventMask;
117 attr.event_mask = KeyPressMask |
125 VisibilityChangeMask |
126 StructureNotifyMask |
130 win = XCreateWindow(_ecore_x_disp, parent,
132 CopyFromParent, /*DefaultDepth(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
134 CopyFromParent, /*DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
147 } /* ecore_x_window_override_new */
150 * Creates a new input window.
151 * @param parent The parent window to use. If @p parent is @c 0, the root
152 * window of the default display is used.
153 * @param x X position.
154 * @param y Y position.
157 * @return The new window.
158 * @ingroup Ecore_X_Window_Create_Group
161 ecore_x_window_input_new(Ecore_X_Window parent, int x, int y, int w, int h)
164 XSetWindowAttributes attr;
166 LOGFN(__FILE__, __LINE__, __FUNCTION__);
168 parent = DefaultRootWindow(_ecore_x_disp);
170 attr.override_redirect = True;
171 attr.do_not_propagate_mask = NoEventMask;
172 attr.event_mask = KeyPressMask |
180 VisibilityChangeMask |
181 StructureNotifyMask |
185 win = XCreateWindow(_ecore_x_disp, parent,
189 CopyFromParent, /*DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
195 if (parent == DefaultRootWindow(_ecore_x_disp))
200 } /* ecore_x_window_input_new */
203 * @defgroup Ecore_X_Window_Properties_Group X Window Property Functions
205 * Functions that set window properties.
209 * Sets the default properties for the given window.
211 * The default properties set for the window are @c WM_CLIENT_MACHINE and
214 * @param win The given window.
215 * @ingroup Ecore_X_Window_Properties_Groups
218 ecore_x_window_defaults_set(Ecore_X_Window win)
221 char buf[MAXHOSTNAMELEN];
227 LOGFN(__FILE__, __LINE__, __FUNCTION__);
229 * Set WM_CLIENT_MACHINE.
231 gethostname(buf, MAXHOSTNAMELEN);
232 buf[MAXHOSTNAMELEN - 1] = '\0';
234 /* The ecore function uses UTF8 which Xlib may not like (especially
235 * with older clients) */
236 /* ecore_x_window_prop_string_set(win, ECORE_X_ATOM_WM_CLIENT_MACHINE,
238 if (XStringListToTextProperty(hostname, 1, &xprop))
240 XSetWMClientMachine(_ecore_x_disp, win, &xprop);
248 ecore_x_netwm_pid_set(win, pid);
250 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL);
252 ecore_app_args_get(&argc, &argv);
253 ecore_x_icccm_command_set(win, argc, argv);
254 } /* ecore_x_window_defaults_set */
257 ecore_x_window_configure(Ecore_X_Window win,
258 Ecore_X_Window_Configure_Mask mask,
259 int x, int y, int w, int h,
260 int border_width, Ecore_X_Window sibling,
268 LOGFN(__FILE__, __LINE__, __FUNCTION__);
274 xwc.border_width = border_width;
275 xwc.sibling = sibling;
276 xwc.stack_mode = stack_mode;
278 XConfigureWindow(_ecore_x_disp, win, mask, &xwc);
279 } /* ecore_x_window_configure */
282 * @defgroup Ecore_X_Window_Destroy_Group X Window Destroy Functions
284 * Functions to destroy X windows.
288 * Deletes the given window.
289 * @param win The given window.
290 * @ingroup Ecore_X_Window_Destroy_Group
293 ecore_x_window_free(Ecore_X_Window win)
295 /* sorry sir, deleting the root window doesn't sound like
298 LOGFN(__FILE__, __LINE__, __FUNCTION__);
300 XDestroyWindow(_ecore_x_disp, win);
301 } /* ecore_x_window_free */
304 * Set if a window should be ignored.
305 * @param win The given window.
306 * @param ignore if to ignore
309 ecore_x_window_ignore_set(Ecore_X_Window win, int ignore)
314 LOGFN(__FILE__, __LINE__, __FUNCTION__);
319 for (i = 0; i < ignore_num; i++)
321 if (win == ignore_list[i])
324 t = realloc(ignore_list, (ignore_num + 1) * sizeof(Ecore_X_Window));
327 ignore_list[ignore_num++] = win;
332 ignore_list = malloc(sizeof(Ecore_X_Window));
334 ignore_list[ignore_num++] = win;
342 for (i = 0, j = 0; i < ignore_num; i++)
344 if (win != ignore_list[i])
345 ignore_list[i] = ignore_list[j++];
355 t = realloc(ignore_list, ignore_num * sizeof(Ecore_X_Window));
356 if (t) ignore_list = t;
358 } /* ecore_x_window_ignore_set */
361 * Get the ignore list
362 * @param num number of windows in the list
363 * @return list of windows to ignore
365 EAPI Ecore_X_Window *
366 ecore_x_window_ignore_list(int *num)
372 } /* ecore_x_window_ignore_list */
375 * Sends a delete request to the given window.
376 * @param win The given window.
377 * @ingroup Ecore_X_Window_Destroy_Group
380 ecore_x_window_delete_request_send(Ecore_X_Window win)
384 /* sorry sir, deleting the root window doesn't sound like
390 LOGFN(__FILE__, __LINE__, __FUNCTION__);
391 xev.xclient.type = ClientMessage;
392 xev.xclient.display = _ecore_x_disp;
393 xev.xclient.window = win;
394 xev.xclient.message_type = ECORE_X_ATOM_WM_PROTOCOLS;
395 xev.xclient.format = 32;
396 xev.xclient.data.l[0] = ECORE_X_ATOM_WM_DELETE_WINDOW;
397 xev.xclient.data.l[1] = CurrentTime;
399 XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev);
400 } /* ecore_x_window_delete_request_send */
403 * @defgroup Ecore_X_Window_Visibility_Group X Window Visibility Functions
405 * Functions to access and change the visibility of X windows.
411 * Synonymous to "mapping" a window in X Window System terminology.
413 * @param win The window to show.
414 * @ingroup Ecore_X_Window_Visibility
417 ecore_x_window_show(Ecore_X_Window win)
419 LOGFN(__FILE__, __LINE__, __FUNCTION__);
420 XMapWindow(_ecore_x_disp, win);
421 } /* ecore_x_window_show */
426 * Synonymous to "unmapping" a window in X Window System terminology.
428 * @param win The window to hide.
429 * @ingroup Ecore_X_Window_Visibility
432 ecore_x_window_hide(Ecore_X_Window win)
439 /* ICCCM: SEND unmap event... */
440 LOGFN(__FILE__, __LINE__, __FUNCTION__);
442 if (ScreenCount(_ecore_x_disp) == 1)
443 root = DefaultRootWindow(_ecore_x_disp);
445 XGetGeometry(_ecore_x_disp,
455 xev.xunmap.type = UnmapNotify;
456 xev.xunmap.serial = 0;
457 xev.xunmap.send_event = True;
458 xev.xunmap.display = _ecore_x_disp;
459 xev.xunmap.event = root;
460 xev.xunmap.window = win;
461 xev.xunmap.from_configure = False;
462 XSendEvent(_ecore_x_disp, xev.xunmap.event, False,
463 SubstructureRedirectMask | SubstructureNotifyMask, &xev);
464 XUnmapWindow(_ecore_x_disp, win);
465 } /* ecore_x_window_hide */
468 * @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions
470 * Functions that change or retrieve the geometry of X windows.
474 * Moves a window to the position @p x, @p y.
476 * The position is relative to the upper left hand corner of the
479 * @param win The window to move.
480 * @param x X position.
481 * @param y Y position.
482 * @ingroup Ecore_X_Window_Geometry_Group
485 ecore_x_window_move(Ecore_X_Window win, int x, int y)
487 LOGFN(__FILE__, __LINE__, __FUNCTION__);
488 XMoveWindow(_ecore_x_disp, win, x, y);
489 } /* ecore_x_window_move */
493 * @param win The window to resize.
494 * @param w New width of the window.
495 * @param h New height of the window.
496 * @ingroup Ecore_X_Window_Geometry_Group
499 ecore_x_window_resize(Ecore_X_Window win, int w, int h)
501 LOGFN(__FILE__, __LINE__, __FUNCTION__);
508 XResizeWindow(_ecore_x_disp, win, w, h);
509 } /* ecore_x_window_resize */
512 * Moves and resizes a window.
513 * @param win The window to move and resize.
514 * @param x New X position of the window.
515 * @param y New Y position of the window.
516 * @param w New width of the window.
517 * @param h New height of the window.
518 * @ingroup Ecore_X_Window_Geometry_Group
521 ecore_x_window_move_resize(Ecore_X_Window win, int x, int y, int w, int h)
523 LOGFN(__FILE__, __LINE__, __FUNCTION__);
530 XMoveResizeWindow(_ecore_x_disp, win, x, y, w, h);
531 } /* ecore_x_window_move_resize */
534 * @defgroup Ecore_X_Window_Focus_Functions X Window Focus Functions
536 * Functions that give the focus to an X Window.
540 * Sets the focus to the window @p win.
541 * @param win The window to focus.
542 * @ingroup Ecore_X_Window_Focus_Functions
545 ecore_x_window_focus(Ecore_X_Window win)
547 LOGFN(__FILE__, __LINE__, __FUNCTION__);
549 win = DefaultRootWindow(_ecore_x_disp); // XSetInputFocus(_ecore_x_disp, win, RevertToNone, CurrentTime);
551 // XSetInputFocus(_ecore_x_disp, win, RevertToPointerRoot, CurrentTime);
552 XSetInputFocus(_ecore_x_disp, win, RevertToParent, CurrentTime);
553 } /* ecore_x_window_focus */
556 * Sets the focus to the given window at a specific time.
557 * @param win The window to focus.
558 * @param t When to set the focus to the window.
559 * @ingroup Ecore_X_Window_Focus_Functions
562 ecore_x_window_focus_at_time(Ecore_X_Window win, Ecore_X_Time t)
564 LOGFN(__FILE__, __LINE__, __FUNCTION__);
566 win = DefaultRootWindow(_ecore_x_disp); // XSetInputFocus(_ecore_x_disp, win, RevertToNone, t);
568 // XSetInputFocus(_ecore_x_disp, win, PointerRoot, t);
569 XSetInputFocus(_ecore_x_disp, win, RevertToParent, t);
570 } /* ecore_x_window_focus_at_time */
573 * gets the focus to the window @p win.
574 * @return The window that has focus.
575 * @ingroup Ecore_X_Window_Focus_Functions
578 ecore_x_window_focus_get(void)
583 LOGFN(__FILE__, __LINE__, __FUNCTION__);
585 XGetInputFocus(_ecore_x_disp, &win, &revert_mode);
587 } /* ecore_x_window_focus_get */
590 * @defgroup Ecore_X_Window_Z_Order_Group X Window Z Order Functions
592 * Functions that change the Z order of X windows.
596 * Raises the given window.
597 * @param win The window to raise.
598 * @ingroup Ecore_X_Window_Z_Order_Group
601 ecore_x_window_raise(Ecore_X_Window win)
603 LOGFN(__FILE__, __LINE__, __FUNCTION__);
604 XRaiseWindow(_ecore_x_disp, win);
605 } /* ecore_x_window_raise */
608 * Lowers the given window.
609 * @param win The window to lower.
610 * @ingroup Ecore_X_Window_Z_Order_Group
613 ecore_x_window_lower(Ecore_X_Window win)
615 LOGFN(__FILE__, __LINE__, __FUNCTION__);
616 XLowerWindow(_ecore_x_disp, win);
617 } /* ecore_x_window_lower */
620 * @defgroup Ecore_X_Window_Parent_Group X Window Parent Functions
622 * Functions that retrieve or changes the parent window of a window.
626 * Moves a window to within another window at a given position.
627 * @param win The window to reparent.
628 * @param new_parent The new parent window.
629 * @param x X position within new parent window.
630 * @param y Y position within new parent window.
631 * @ingroup Ecore_X_Window_Parent_Group
634 ecore_x_window_reparent(Ecore_X_Window win,
635 Ecore_X_Window new_parent,
639 LOGFN(__FILE__, __LINE__, __FUNCTION__);
641 new_parent = DefaultRootWindow(_ecore_x_disp);
643 XReparentWindow(_ecore_x_disp, win, new_parent, x, y);
644 } /* ecore_x_window_reparent */
647 * Retrieves the size of the given window.
648 * @param win The given window.
649 * @param w Pointer to an integer into which the width is to be stored.
650 * @param h Pointer to an integer into which the height is to be stored.
651 * @ingroup Ecore_X_Window_Geometry_Group
654 ecore_x_window_size_get(Ecore_X_Window win, int *w, int *h)
656 int dummy_x, dummy_y;
658 LOGFN(__FILE__, __LINE__, __FUNCTION__);
660 win = DefaultRootWindow(_ecore_x_disp);
662 ecore_x_drawable_geometry_get(win, &dummy_x, &dummy_y, w, h);
663 } /* ecore_x_window_size_get */
666 * Retrieves the geometry of the given window.
668 * Note that the x & y coordingates are relative to your parent. In
669 * particular for reparenting window managers - relative to you window border.
670 * If you want screen coordinates either walk the window tree to the root,
671 * else for ecore_evas applications see ecore_evas_geometry_get(). Elementary
672 * applications can use elm_win_screen_position_get().
674 * @param win The given window.
675 * @param x Pointer to an integer in which the X position is to be stored.
676 * @param y Pointer to an integer in which the Y position is to be stored.
677 * @param w Pointer to an integer in which the width is to be stored.
678 * @param h Pointer to an integer in which the height is to be stored.
679 * @ingroup Ecore_X_Window_Geometry_Group
682 ecore_x_window_geometry_get(Ecore_X_Window win, int *x, int *y, int *w, int *h)
684 LOGFN(__FILE__, __LINE__, __FUNCTION__);
686 win = DefaultRootWindow(_ecore_x_disp);
688 ecore_x_drawable_geometry_get(win, x, y, w, h);
689 } /* ecore_x_window_geometry_get */
692 * Retrieves the width of the border of the given window.
693 * @param win The given window.
694 * @return Width of the border of @p win.
695 * @ingroup Ecore_X_Window_Geometry_Group
698 ecore_x_window_border_width_get(Ecore_X_Window win)
700 LOGFN(__FILE__, __LINE__, __FUNCTION__);
701 /* doesn't make sense to call this on a root window */
705 return ecore_x_drawable_border_width_get(win);
706 } /* ecore_x_window_border_width_get */
709 * Sets the width of the border of the given window.
710 * @param win The given window.
711 * @param width The new border width.
712 * @ingroup Ecore_X_Window_Geometry_Group
715 ecore_x_window_border_width_set(Ecore_X_Window win, int width)
717 LOGFN(__FILE__, __LINE__, __FUNCTION__);
718 /* doesn't make sense to call this on a root window */
722 XSetWindowBorderWidth (_ecore_x_disp, win, width);
723 } /* ecore_x_window_border_width_set */
726 * Retrieves the depth of the given window.
727 * @param win The given window.
728 * @return Depth of the window.
731 ecore_x_window_depth_get(Ecore_X_Window win)
733 LOGFN(__FILE__, __LINE__, __FUNCTION__);
734 return ecore_x_drawable_depth_get(win);
735 } /* ecore_x_window_depth_get */
740 * FIXME: To be fixed.
743 ecore_x_window_cursor_show(Ecore_X_Window win, Eina_Bool show)
745 LOGFN(__FILE__, __LINE__, __FUNCTION__);
747 win = DefaultRootWindow(_ecore_x_disp);
757 p = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
758 m = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
759 gc = XCreateGC(_ecore_x_disp, m, 0, &gcv);
760 XSetForeground(_ecore_x_disp, gc, 0);
761 XDrawPoint(_ecore_x_disp, m, gc, 0, 0);
762 XFreeGC(_ecore_x_disp, gc);
763 c = XCreatePixmapCursor(_ecore_x_disp, p, m, &cl, &cl, 0, 0);
764 XDefineCursor(_ecore_x_disp, win, c);
765 XFreeCursor(_ecore_x_disp, c);
766 XFreePixmap(_ecore_x_disp, p);
767 XFreePixmap(_ecore_x_disp, m);
770 XDefineCursor(_ecore_x_disp, win, 0);
771 } /* ecore_x_window_cursor_show */
774 ecore_x_window_cursor_set(Ecore_X_Window win, Ecore_X_Cursor c)
776 LOGFN(__FILE__, __LINE__, __FUNCTION__);
778 XUndefineCursor(_ecore_x_disp, win);
780 XDefineCursor(_ecore_x_disp, win, c);
781 } /* ecore_x_window_cursor_set */
784 * Finds out whether the given window is currently visible.
785 * @param win The given window.
786 * @return 1 if the window is visible, otherwise 0.
787 * @ingroup Ecore_X_Window_Visibility_Group
790 ecore_x_window_visible_get(Ecore_X_Window win)
792 XWindowAttributes attr;
794 LOGFN(__FILE__, __LINE__, __FUNCTION__);
795 return (XGetWindowAttributes(_ecore_x_disp, win, &attr) &&
796 (attr.map_state == IsViewable));
797 } /* ecore_x_window_visible_get */
799 typedef struct _Shadow Shadow;
810 static Shadow **shadow_base = NULL;
811 static int shadow_num = 0;
814 _ecore_x_window_tree_walk(Window win)
817 Window parent_win = 0, root_win = 0;
820 XWindowAttributes att;
822 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
823 return NULL; // if (att.class == InputOnly) return NULL;
825 if (att.map_state != IsViewable)
828 s = calloc(1, sizeof(Shadow));
837 if (XQueryTree(_ecore_x_disp, s->win, &root_win, &parent_win,
840 s->children = calloc(1, sizeof(Shadow *) * num);
844 s->children_num = num;
845 for (i = 0; i < num; i++)
847 s->children[i] = _ecore_x_window_tree_walk(list[i]);
849 s->children[i]->parent = s;
851 /* compress list down */
853 for (i = 0; i < num; i++)
857 s->children[j] = s->children[i];
870 sl = realloc(s->children, sizeof(Shadow *) * j);
881 } /* _ecore_x_window_tree_walk */
884 _ecore_x_window_tree_shadow_free1(Shadow *s)
893 for (i = 0; i < s->children_num; i++)
896 _ecore_x_window_tree_shadow_free1(s->children[i]);
902 } /* _ecore_x_window_tree_shadow_free1 */
905 _ecore_x_window_tree_shadow_free(void)
912 for (i = 0; i < shadow_num; i++)
917 _ecore_x_window_tree_shadow_free1(shadow_base[i]);
922 } /* _ecore_x_window_tree_shadow_free */
925 _ecore_x_window_tree_shadow_populate(void)
927 Ecore_X_Window *roots;
930 roots = ecore_x_window_root_list(&num);
933 shadow_base = calloc(1, sizeof(Shadow *) * num);
937 for (i = 0; i < num; i++)
938 shadow_base[i] = _ecore_x_window_tree_walk(roots[i]);
943 } /* _ecore_x_window_tree_shadow_populate */
946 static int shadow_count = 0;
949 _ecore_x_window_tree_shadow_start(void)
952 if (shadow_count > 1) return;
953 _ecore_x_window_tree_shadow_populate();
957 _ecore_x_window_tree_shadow_stop(void)
960 if (shadow_count != 0) return;
961 _ecore_x_window_tree_shadow_free();
966 _ecore_x_window_shadow_tree_find_shadow(Shadow *s, Window win)
975 for (i = 0; i < s->children_num; i++)
981 _ecore_x_window_shadow_tree_find_shadow(s->children[i], win)))
986 } /* _ecore_x_window_shadow_tree_find_shadow */
989 _ecore_x_window_shadow_tree_find(Window base)
994 for (i = 0; i < shadow_num; i++)
999 if ((s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], base)))
1003 } /* _ecore_x_window_shadow_tree_find */
1006 _ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow *s,
1011 Ecore_X_Window *skip,
1020 if (!((x >= wx) && (y >= wy) && (x < (wx + s->w)) && (y < (wy + s->h))))
1027 for (i = s->children_num - 1; i >= 0; --i)
1029 if (!s->children[i])
1034 for (j = 0; j < skip_num; j++)
1036 if (s->children[i]->win == skip[j])
1046 _ecore_x_window_shadow_tree_at_xy_get_shadow(s->
1057 } /* _ecore_x_window_shadow_tree_at_xy_get_shadow */
1060 _ecore_x_window_shadow_tree_at_xy_get(Window base, int bx, int by, int x, int y,
1061 Ecore_X_Window *skip, int skip_num)
1067 _ecore_x_window_tree_shadow_populate();
1072 s = _ecore_x_window_shadow_tree_find(base);
1076 return _ecore_x_window_shadow_tree_at_xy_get_shadow(s,
1083 } /* _ecore_x_window_shadow_tree_at_xy_get */
1086 * Retrieves the top, visible window at the given location,
1087 * but skips the windows in the list. This uses a shadow tree built from the
1088 * window tree that is only updated the first time
1089 * ecore_x_window_shadow_tree_at_xy_with_skip_get() is called, or the next time
1090 * it is called after a ecore_x_window_shadow_tree_flush()
1091 * @param base The base window to start searching from (normally root).
1092 * @param x The given X position.
1093 * @param y The given Y position.
1094 * @return The window at that position.
1095 * @ingroup Ecore_X_Window_Geometry_Group
1098 ecore_x_window_shadow_tree_at_xy_with_skip_get(Ecore_X_Window base,
1101 Ecore_X_Window *skip,
1104 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1105 return _ecore_x_window_shadow_tree_at_xy_get(base,
1112 } /* ecore_x_window_shadow_tree_at_xy_with_skip_get */
1115 * Retrieves the parent window a given window has. This uses the shadow window
1117 * @param root The root window of @p win - if 0, this will be automatically determined with extra processing overhead
1118 * @param win The window to get the parent window of
1119 * @return The parent window of @p win
1120 * @ingroup Ecore_X_Window_Geometry_Group
1123 ecore_x_window_shadow_parent_get(Ecore_X_Window root __UNUSED__,
1129 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1132 _ecore_x_window_tree_shadow_populate();
1137 for (i = 0; i < shadow_num; i++)
1139 if (!shadow_base[i])
1142 s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], win);
1148 return s->parent->win;
1152 } /* ecore_x_window_shadow_parent_get */
1155 * Flushes the window shadow tree so nothing is stored.
1156 * @ingroup Ecore_X_Window_Geometry_Group
1159 ecore_x_window_shadow_tree_flush(void)
1161 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1162 _ecore_x_window_tree_shadow_free();
1163 } /* ecore_x_window_shadow_tree_flush */
1166 * Retrieves the root window a given window is on.
1167 * @param win The window to get the root window of
1168 * @return The root window of @p win
1169 * @ingroup Ecore_X_Window_Geometry_Group
1172 ecore_x_window_root_get(Ecore_X_Window win)
1174 XWindowAttributes att;
1176 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1177 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
1181 } /* ecore_x_window_root_get */
1184 _ecore_x_window_at_xy_get(Window base, int bx, int by, int x, int y,
1185 Ecore_X_Window *skip, int skip_num)
1187 Window *list = NULL;
1188 Window parent_win = 0, child = 0, root_win = 0;
1189 int i, j, wx, wy, ww, wh;
1192 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1193 if (!ecore_x_window_visible_get(base))
1196 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1197 ecore_x_window_geometry_get(base, &wx, &wy, &ww, &wh);
1201 if (!((x >= wx) && (y >= wy) && (x < (wx + ww)) && (y < (wy + wh))))
1204 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1205 if (!XQueryTree(_ecore_x_disp, base, &root_win, &parent_win, &list, &num))
1212 for (i = num - 1; i >= 0; --i)
1217 for (j = 0; j < skip_num; j++)
1219 if (list[i] == skip[j])
1229 _ecore_x_window_at_xy_get(list[i], wx, wy, x, y, skip,
1241 } /* _ecore_x_window_at_xy_get */
1244 * Retrieves the top, visible window at the given location.
1245 * @param x The given X position.
1246 * @param y The given Y position.
1247 * @return The window at that position.
1248 * @ingroup Ecore_X_Window_Geometry_Group
1251 ecore_x_window_at_xy_get(int x, int y)
1253 Ecore_X_Window win, root;
1255 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1256 /* FIXME: Proper function to determine current root/virtual root
1257 * window missing here */
1258 root = DefaultRootWindow(_ecore_x_disp);
1261 win = _ecore_x_window_at_xy_get(root, 0, 0, x, y, NULL, 0);
1264 return win ? win : root;
1265 } /* ecore_x_window_at_xy_get */
1268 * Retrieves the top, visible window at the given location,
1269 * but skips the windows in the list.
1270 * @param x The given X position.
1271 * @param y The given Y position.
1272 * @return The window at that position.
1273 * @ingroup Ecore_X_Window_Geometry_Group
1276 ecore_x_window_at_xy_with_skip_get(int x,
1278 Ecore_X_Window *skip,
1281 Ecore_X_Window win, root;
1283 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1284 /* FIXME: Proper function to determine current root/virtual root
1285 * window missing here */
1286 root = DefaultRootWindow(_ecore_x_disp);
1289 win = _ecore_x_window_at_xy_get(root, 0, 0, x, y, skip, skip_num);
1292 return win ? win : root;
1293 } /* ecore_x_window_at_xy_with_skip_get */
1296 ecore_x_window_at_xy_begin_get(Ecore_X_Window begin, int x, int y)
1300 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1302 win = _ecore_x_window_at_xy_get(begin, 0, 0, x, y, NULL, 0);
1305 return win ? win : begin;
1306 } /* ecore_x_window_at_xy_begin_get */
1309 * Retrieves the parent window of the given window.
1310 * @param win The given window.
1311 * @return The parent window of @p win.
1312 * @ingroup Ecore_X_Window_Parent_Group
1315 ecore_x_window_parent_get(Ecore_X_Window win)
1317 Window root, parent, *children = NULL;
1320 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1321 if (!XQueryTree(_ecore_x_disp, win, &root, &parent, &children, &num))
1328 } /* ecore_x_window_parent_get */
1331 * Sets the background color of the given window.
1332 * @param win The given window
1333 * @param r red value (0...65536, 16 bits)
1334 * @param g green value (0...65536, 16 bits)
1335 * @param b blue value (0...65536, 16 bits)
1338 ecore_x_window_background_color_set(Ecore_X_Window win, unsigned short r,
1339 unsigned short g, unsigned short b)
1341 XSetWindowAttributes attr;
1345 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1350 map = DefaultColormap(_ecore_x_disp, DefaultScreen(_ecore_x_disp));
1351 XAllocColor(_ecore_x_disp, map, &col);
1353 attr.background_pixel = col.pixel;
1354 XChangeWindowAttributes(_ecore_x_disp, win, CWBackPixel, &attr);
1355 } /* ecore_x_window_background_color_set */
1358 ecore_x_window_gravity_set(Ecore_X_Window win, Ecore_X_Gravity grav)
1360 XSetWindowAttributes att;
1362 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1363 att.win_gravity = grav;
1364 XChangeWindowAttributes(_ecore_x_disp, win, CWWinGravity, &att);
1365 } /* ecore_x_window_gravity_set */
1368 ecore_x_window_pixel_gravity_set(Ecore_X_Window win, Ecore_X_Gravity grav)
1370 XSetWindowAttributes att;
1372 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1373 att.bit_gravity = grav;
1374 XChangeWindowAttributes(_ecore_x_disp, win, CWBitGravity, &att);
1375 } /* ecore_x_window_pixel_gravity_set */
1378 ecore_x_window_pixmap_set(Ecore_X_Window win, Ecore_X_Pixmap pmap)
1380 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1381 XSetWindowBackgroundPixmap(_ecore_x_disp, win, pmap);
1382 } /* ecore_x_window_pixmap_set */
1385 ecore_x_window_area_clear(Ecore_X_Window win, int x, int y, int w, int h)
1387 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1388 XClearArea(_ecore_x_disp, win, x, y, w, h, False);
1389 } /* ecore_x_window_area_clear */
1392 ecore_x_window_area_expose(Ecore_X_Window win, int x, int y, int w, int h)
1394 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1395 XClearArea(_ecore_x_disp, win, x, y, w, h, True);
1396 } /* ecore_x_window_area_expose */
1399 ecore_x_window_override_set(Ecore_X_Window win, Eina_Bool override)
1401 XSetWindowAttributes att;
1403 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1404 att.override_redirect = override;
1405 XChangeWindowAttributes(_ecore_x_disp, win, CWOverrideRedirect, &att);
1406 } /* ecore_x_window_override_set */
1408 #ifdef ECORE_XRENDER
1409 static Ecore_X_Window
1410 _ecore_x_window_argb_internal_new(Ecore_X_Window parent,
1416 Eina_Bool saveunder)
1419 XSetWindowAttributes attr;
1420 XWindowAttributes att;
1423 int nvi, i, scr = 0;
1424 XRenderPictFormat *fmt;
1429 parent = DefaultRootWindow(_ecore_x_disp);
1430 scr = DefaultScreen(_ecore_x_disp);
1434 /* ewww - round trip */
1435 XGetWindowAttributes(_ecore_x_disp, parent, &att);
1436 for (i = 0; i < ScreenCount(_ecore_x_disp); i++)
1438 if (att.screen == ScreenOfDisplay(_ecore_x_disp, i))
1448 vi_in.class = TrueColor;
1449 xvi = XGetVisualInfo(_ecore_x_disp,
1459 for (i = 0; i < nvi; i++)
1461 fmt = XRenderFindVisualFormat(_ecore_x_disp, xvi[i].visual);
1462 if ((fmt->type == PictTypeDirect) && (fmt->direct.alphaMask))
1464 vis = xvi[i].visual;
1470 attr.backing_store = NotUseful;
1471 attr.override_redirect = override;
1472 attr.colormap = XCreateColormap(_ecore_x_disp, parent,
1474 attr.border_pixel = 0;
1475 attr.background_pixmap = None;
1476 attr.bit_gravity = NorthWestGravity;
1477 attr.win_gravity = NorthWestGravity;
1478 attr.save_under = saveunder;
1479 attr.do_not_propagate_mask = NoEventMask;
1480 attr.event_mask = KeyPressMask |
1488 VisibilityChangeMask |
1489 StructureNotifyMask |
1491 PropertyChangeMask |
1493 win = XCreateWindow(_ecore_x_disp, parent,
1499 CWOverrideRedirect |
1509 XFreeColormap(_ecore_x_disp, attr.colormap);
1511 if (parent == DefaultRootWindow(_ecore_x_disp))
1512 ecore_x_window_defaults_set(win);
1515 } /* _ecore_x_window_argb_internal_new */
1517 #endif /* ifdef ECORE_XRENDER */
1520 ecore_x_window_argb_get(Ecore_X_Window win)
1522 #ifdef ECORE_XRENDER
1523 XWindowAttributes att;
1524 XRenderPictFormat *fmt;
1527 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
1530 fmt = XRenderFindVisualFormat(_ecore_x_disp, att.visual);
1534 if ((fmt->type == PictTypeDirect) && (fmt->direct.alphaMask))
1538 #else /* ifdef ECORE_XRENDER */
1540 #endif /* ifdef ECORE_XRENDER */
1541 } /* ecore_x_window_argb_get */
1544 * Creates a new window.
1545 * @param parent The parent window to use. If @p parent is @c 0, the root
1546 * window of the default display is used.
1547 * @param x X position.
1548 * @param y Y position.
1551 * @return The new window handle.
1552 * @ingroup Ecore_X_Window_Create_Group
1555 ecore_x_window_manager_argb_new(Ecore_X_Window parent,
1561 #ifdef ECORE_XRENDER
1562 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1563 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 1, 0);
1564 #else /* ifdef ECORE_XRENDER */
1566 #endif /* ifdef ECORE_XRENDER */
1567 } /* ecore_x_window_manager_argb_new */
1570 * Creates a new window.
1571 * @param parent The parent window to use. If @p parent is @c 0, the root
1572 * window of the default display is used.
1573 * @param x X position.
1574 * @param y Y position.
1577 * @return The new window handle.
1578 * @ingroup Ecore_X_Window_Create_Group
1581 ecore_x_window_argb_new(Ecore_X_Window parent, int x, int y, int w, int h)
1583 #ifdef ECORE_XRENDER
1584 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1585 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 0, 0);
1586 #else /* ifdef ECORE_XRENDER */
1588 #endif /* ifdef ECORE_XRENDER */
1589 } /* ecore_x_window_argb_new */
1592 * Creates a window with the override redirect attribute set to @c True.
1593 * @param parent The parent window to use. If @p parent is @c 0, the root
1594 * window of the default display is used.
1595 * @param x X position.
1596 * @param y Y position.
1599 * @return The new window handle.
1600 * @ingroup Ecore_X_Window_Create_Group
1603 ecore_x_window_override_argb_new(Ecore_X_Window parent,
1609 #ifdef ECORE_XRENDER
1610 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1611 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 1, 0);
1612 #else /* ifdef ECORE_XRENDER */
1614 #endif /* ifdef ECORE_XRENDER */
1615 } /* ecore_x_window_override_argb_new */