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,
42 XSetWindowAttributes attr;
44 LOGFN(__FILE__, __LINE__, __FUNCTION__);
46 parent = DefaultRootWindow(_ecore_x_disp);
48 attr.backing_store = NotUseful;
49 attr.override_redirect = False;
50 attr.border_pixel = 0;
51 attr.background_pixmap = None;
52 attr.bit_gravity = NorthWestGravity;
53 attr.win_gravity = NorthWestGravity;
54 attr.save_under = False;
55 attr.do_not_propagate_mask = NoEventMask;
56 attr.event_mask = KeyPressMask |
64 VisibilityChangeMask |
69 win = XCreateWindow(_ecore_x_disp, parent,
71 CopyFromParent, /*DefaultDepth(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
73 CopyFromParent, /*DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
86 if (parent == DefaultRootWindow(_ecore_x_disp))
87 ecore_x_window_defaults_set(win);
93 * Creates a window with the override redirect attribute set to @c True.
94 * @param parent The parent window to use. If @p parent is @c 0, the root
95 * window of the default display is used.
96 * @param x X position.
97 * @param y Y position.
100 * @return The new window handle.
101 * @ingroup Ecore_X_Window_Create_Group
104 ecore_x_window_override_new(Ecore_X_Window parent,
111 XSetWindowAttributes attr;
113 LOGFN(__FILE__, __LINE__, __FUNCTION__);
115 parent = DefaultRootWindow(_ecore_x_disp);
117 attr.backing_store = NotUseful;
118 attr.override_redirect = True;
119 attr.border_pixel = 0;
120 attr.background_pixmap = None;
121 attr.bit_gravity = NorthWestGravity;
122 attr.win_gravity = NorthWestGravity;
123 attr.save_under = False;
124 attr.do_not_propagate_mask = NoEventMask;
125 attr.event_mask = KeyPressMask |
133 VisibilityChangeMask |
134 StructureNotifyMask |
138 win = XCreateWindow(_ecore_x_disp, parent,
140 CopyFromParent, /*DefaultDepth(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
142 CopyFromParent, /*DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
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,
176 XSetWindowAttributes attr;
178 LOGFN(__FILE__, __LINE__, __FUNCTION__);
180 parent = DefaultRootWindow(_ecore_x_disp);
182 attr.override_redirect = True;
183 attr.do_not_propagate_mask = NoEventMask;
184 attr.event_mask = KeyPressMask |
192 VisibilityChangeMask |
193 StructureNotifyMask |
197 win = XCreateWindow(_ecore_x_disp, parent,
201 CopyFromParent, /*DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
207 if (parent == DefaultRootWindow(_ecore_x_disp))
215 * @defgroup Ecore_X_Window_Properties_Group X Window Property Functions
217 * Functions that set window properties.
221 * Sets the default properties for the given window.
223 * The default properties set for the window are @c WM_CLIENT_MACHINE and
226 * @param win The given window.
227 * @ingroup Ecore_X_Window_Properties_Group
230 ecore_x_window_defaults_set(Ecore_X_Window win)
233 char buf[MAXHOSTNAMELEN];
239 LOGFN(__FILE__, __LINE__, __FUNCTION__);
241 * Set WM_CLIENT_MACHINE.
243 gethostname(buf, MAXHOSTNAMELEN);
244 buf[MAXHOSTNAMELEN - 1] = '\0';
246 /* The ecore function uses UTF8 which Xlib may not like (especially
247 * with older clients) */
248 /* ecore_x_window_prop_string_set(win, ECORE_X_ATOM_WM_CLIENT_MACHINE,
250 if (XStringListToTextProperty(hostname, 1, &xprop))
252 XSetWMClientMachine(_ecore_x_disp, win, &xprop);
260 ecore_x_netwm_pid_set(win, pid);
262 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL);
264 ecore_app_args_get(&argc, &argv);
265 ecore_x_icccm_command_set(win, argc, argv);
269 ecore_x_window_configure(Ecore_X_Window win,
270 Ecore_X_Window_Configure_Mask mask,
276 Ecore_X_Window sibling,
284 LOGFN(__FILE__, __LINE__, __FUNCTION__);
290 xwc.border_width = border_width;
291 xwc.sibling = sibling;
292 xwc.stack_mode = stack_mode;
294 XConfigureWindow(_ecore_x_disp, win, mask, &xwc);
298 * @defgroup Ecore_X_Window_Destroy_Group X Window Destroy Functions
300 * Functions to destroy X windows.
304 * Deletes the given window.
305 * @param win The given window.
306 * @ingroup Ecore_X_Window_Destroy_Group
309 ecore_x_window_free(Ecore_X_Window win)
311 /* sorry sir, deleting the root window doesn't sound like
314 LOGFN(__FILE__, __LINE__, __FUNCTION__);
316 XDestroyWindow(_ecore_x_disp, win);
320 * Set if a window should be ignored.
321 * @param win The given window.
322 * @param ignore if to ignore
325 ecore_x_window_ignore_set(Ecore_X_Window win,
331 LOGFN(__FILE__, __LINE__, __FUNCTION__);
336 for (i = 0; i < ignore_num; i++)
338 if (win == ignore_list[i])
341 t = realloc(ignore_list, (ignore_num + 1) * sizeof(Ecore_X_Window));
344 ignore_list[ignore_num++] = win;
349 ignore_list = malloc(sizeof(Ecore_X_Window));
351 ignore_list[ignore_num++] = win;
359 for (cnt = ignore_num, i = 0, j = 0; i < cnt; i++)
361 if (win != ignore_list[i])
362 ignore_list[j++] = ignore_list[i];
373 t = realloc(ignore_list, ignore_num * sizeof(Ecore_X_Window));
374 if (t) ignore_list = t;
379 * Get the ignore list
380 * @param num number of windows in the list
381 * @return list of windows to ignore
383 EAPI Ecore_X_Window *
384 ecore_x_window_ignore_list(int *num)
393 * Sends a delete request to the given window.
394 * @param win The given window.
395 * @ingroup Ecore_X_Window_Destroy_Group
398 ecore_x_window_delete_request_send(Ecore_X_Window win)
402 /* sorry sir, deleting the root window doesn't sound like
408 LOGFN(__FILE__, __LINE__, __FUNCTION__);
409 xev.xclient.type = ClientMessage;
410 xev.xclient.display = _ecore_x_disp;
411 xev.xclient.window = win;
412 xev.xclient.message_type = ECORE_X_ATOM_WM_PROTOCOLS;
413 xev.xclient.format = 32;
414 xev.xclient.data.l[0] = ECORE_X_ATOM_WM_DELETE_WINDOW;
415 xev.xclient.data.l[1] = CurrentTime;
417 XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev);
421 * @defgroup Ecore_X_Window_Visibility_Group X Window Visibility Functions
423 * Functions to access and change the visibility of X windows.
429 * Synonymous to "mapping" a window in X Window System terminology.
431 * @param win The window to show.
432 * @ingroup Ecore_X_Window_Visibility
435 ecore_x_window_show(Ecore_X_Window win)
437 LOGFN(__FILE__, __LINE__, __FUNCTION__);
438 XMapWindow(_ecore_x_disp, win);
444 * Synonymous to "unmapping" a window in X Window System terminology.
446 * @param win The window to hide.
447 * @ingroup Ecore_X_Window_Visibility
450 ecore_x_window_hide(Ecore_X_Window win)
457 /* ICCCM: SEND unmap event... */
458 LOGFN(__FILE__, __LINE__, __FUNCTION__);
460 if (ScreenCount(_ecore_x_disp) == 1)
461 root = DefaultRootWindow(_ecore_x_disp);
463 XGetGeometry(_ecore_x_disp,
473 xev.xunmap.type = UnmapNotify;
474 xev.xunmap.serial = 0;
475 xev.xunmap.send_event = True;
476 xev.xunmap.display = _ecore_x_disp;
477 xev.xunmap.event = root;
478 xev.xunmap.window = win;
479 xev.xunmap.from_configure = False;
480 XSendEvent(_ecore_x_disp, xev.xunmap.event, False,
481 SubstructureRedirectMask | SubstructureNotifyMask, &xev);
482 XUnmapWindow(_ecore_x_disp, win);
486 * @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions
488 * Functions that change or retrieve the geometry of X windows.
492 * Moves a window to the position @p x, @p y.
494 * The position is relative to the upper left hand corner of the
497 * @param win The window to move.
498 * @param x X position.
499 * @param y Y position.
500 * @ingroup Ecore_X_Window_Geometry_Group
503 ecore_x_window_move(Ecore_X_Window win,
507 LOGFN(__FILE__, __LINE__, __FUNCTION__);
508 XMoveWindow(_ecore_x_disp, win, x, y);
513 * @param win The window to resize.
514 * @param w New width of the window.
515 * @param h New height of the window.
516 * @ingroup Ecore_X_Window_Geometry_Group
519 ecore_x_window_resize(Ecore_X_Window win,
523 LOGFN(__FILE__, __LINE__, __FUNCTION__);
530 XResizeWindow(_ecore_x_disp, win, w, h);
534 * Moves and resizes a window.
535 * @param win The window to move and resize.
536 * @param x New X position of the window.
537 * @param y New Y position of the window.
538 * @param w New width of the window.
539 * @param h New height of the window.
540 * @ingroup Ecore_X_Window_Geometry_Group
543 ecore_x_window_move_resize(Ecore_X_Window win,
549 LOGFN(__FILE__, __LINE__, __FUNCTION__);
556 XMoveResizeWindow(_ecore_x_disp, win, x, y, w, h);
560 * @defgroup Ecore_X_Window_Focus_Functions X Window Focus Functions
562 * Functions that give the focus to an X Window.
566 * Sets the focus to the window @p win.
567 * @param win The window to focus.
568 * @ingroup Ecore_X_Window_Focus_Functions
571 ecore_x_window_focus(Ecore_X_Window win)
573 LOGFN(__FILE__, __LINE__, __FUNCTION__);
575 win = DefaultRootWindow(_ecore_x_disp); // XSetInputFocus(_ecore_x_disp, win, RevertToNone, CurrentTime);
577 // XSetInputFocus(_ecore_x_disp, win, RevertToPointerRoot, CurrentTime);
578 XSetInputFocus(_ecore_x_disp, win, RevertToParent, CurrentTime);
582 * Sets the focus to the given window at a specific time.
583 * @param win The window to focus.
584 * @param t When to set the focus to the window.
585 * @ingroup Ecore_X_Window_Focus_Functions
588 ecore_x_window_focus_at_time(Ecore_X_Window win,
591 LOGFN(__FILE__, __LINE__, __FUNCTION__);
593 win = DefaultRootWindow(_ecore_x_disp); // XSetInputFocus(_ecore_x_disp, win, RevertToNone, t);
595 // XSetInputFocus(_ecore_x_disp, win, PointerRoot, t);
596 XSetInputFocus(_ecore_x_disp, win, RevertToParent, t);
600 * gets the window that has focus.
601 * @return The window that has focus.
602 * @ingroup Ecore_X_Window_Focus_Functions
605 ecore_x_window_focus_get(void)
610 LOGFN(__FILE__, __LINE__, __FUNCTION__);
612 XGetInputFocus(_ecore_x_disp, &win, &revert_mode);
617 * @defgroup Ecore_X_Window_Z_Order_Group X Window Z Order Functions
619 * Functions that change the Z order of X windows.
623 * Raises the given window.
624 * @param win The window to raise.
625 * @ingroup Ecore_X_Window_Z_Order_Group
628 ecore_x_window_raise(Ecore_X_Window win)
630 LOGFN(__FILE__, __LINE__, __FUNCTION__);
631 XRaiseWindow(_ecore_x_disp, win);
635 * Lowers the given window.
636 * @param win The window to lower.
637 * @ingroup Ecore_X_Window_Z_Order_Group
640 ecore_x_window_lower(Ecore_X_Window win)
642 LOGFN(__FILE__, __LINE__, __FUNCTION__);
643 XLowerWindow(_ecore_x_disp, win);
647 * @defgroup Ecore_X_Window_Parent_Group X Window Parent Functions
649 * Functions that retrieve or changes the parent window of a window.
653 * Moves a window to within another window at a given position.
654 * @param win The window to reparent.
655 * @param new_parent The new parent window.
656 * @param x X position within new parent window.
657 * @param y Y position within new parent window.
658 * @ingroup Ecore_X_Window_Parent_Group
661 ecore_x_window_reparent(Ecore_X_Window win,
662 Ecore_X_Window new_parent,
666 LOGFN(__FILE__, __LINE__, __FUNCTION__);
668 new_parent = DefaultRootWindow(_ecore_x_disp);
670 XReparentWindow(_ecore_x_disp, win, new_parent, x, y);
674 * Retrieves the size of the given window.
675 * @param win The given window.
676 * @param w Pointer to an integer into which the width is to be stored.
677 * @param h Pointer to an integer into which the height is to be stored.
678 * @ingroup Ecore_X_Window_Geometry_Group
681 ecore_x_window_size_get(Ecore_X_Window win,
685 int dummy_x, dummy_y;
687 LOGFN(__FILE__, __LINE__, __FUNCTION__);
689 win = DefaultRootWindow(_ecore_x_disp);
691 ecore_x_drawable_geometry_get(win, &dummy_x, &dummy_y, w, h);
695 * Retrieves the geometry of the given window.
697 * Note that the x & y coordinates are relative to your parent. In
698 * particular for reparenting window managers - relative to you window border.
699 * If you want screen coordinates either walk the window tree to the root,
700 * else for ecore_evas applications see ecore_evas_geometry_get(). Elementary
701 * applications can use elm_win_screen_position_get().
703 * @param win The given window.
704 * @param x Pointer to an integer in which the X position is to be stored.
705 * @param y Pointer to an integer in which the Y position is to be stored.
706 * @param w Pointer to an integer in which the width is to be stored.
707 * @param h Pointer to an integer in which the height is to be stored.
708 * @ingroup Ecore_X_Window_Geometry_Group
711 ecore_x_window_geometry_get(Ecore_X_Window win,
717 LOGFN(__FILE__, __LINE__, __FUNCTION__);
719 win = DefaultRootWindow(_ecore_x_disp);
721 ecore_x_drawable_geometry_get(win, x, y, w, h);
725 * Retrieves the width of the border of the given window.
726 * @param win The given window.
727 * @return Width of the border of @p win.
728 * @ingroup Ecore_X_Window_Geometry_Group
731 ecore_x_window_border_width_get(Ecore_X_Window win)
733 LOGFN(__FILE__, __LINE__, __FUNCTION__);
734 /* doesn't make sense to call this on a root window */
738 return ecore_x_drawable_border_width_get(win);
742 * Sets the width of the border of the given window.
743 * @param win The given window.
744 * @param width The new border width.
745 * @ingroup Ecore_X_Window_Geometry_Group
748 ecore_x_window_border_width_set(Ecore_X_Window win,
751 LOGFN(__FILE__, __LINE__, __FUNCTION__);
752 /* doesn't make sense to call this on a root window */
756 XSetWindowBorderWidth (_ecore_x_disp, win, width);
760 * Retrieves the depth of the given window.
761 * @param win The given window.
762 * @return Depth of the window.
765 ecore_x_window_depth_get(Ecore_X_Window win)
767 LOGFN(__FILE__, __LINE__, __FUNCTION__);
768 return ecore_x_drawable_depth_get(win);
772 * @brief Show the cursor on a window of type Ecore_X_Window.
773 * @param win The window for which the cursor will be showed.
774 * @param show Enables the show of the cursor on the window if equals EINA_TRUE, disables if equals EINA_FALSE.
777 ecore_x_window_cursor_show(Ecore_X_Window win,
780 LOGFN(__FILE__, __LINE__, __FUNCTION__);
782 win = DefaultRootWindow(_ecore_x_disp);
792 p = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
793 m = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
794 gc = XCreateGC(_ecore_x_disp, m, 0, &gcv);
795 XSetForeground(_ecore_x_disp, gc, 0);
796 XDrawPoint(_ecore_x_disp, m, gc, 0, 0);
797 XFreeGC(_ecore_x_disp, gc);
798 c = XCreatePixmapCursor(_ecore_x_disp, p, m, &cl, &cl, 0, 0);
799 XDefineCursor(_ecore_x_disp, win, c);
800 XFreeCursor(_ecore_x_disp, c);
801 XFreePixmap(_ecore_x_disp, p);
802 XFreePixmap(_ecore_x_disp, m);
805 XDefineCursor(_ecore_x_disp, win, 0);
809 ecore_x_window_cursor_set(Ecore_X_Window win,
812 LOGFN(__FILE__, __LINE__, __FUNCTION__);
814 XUndefineCursor(_ecore_x_disp, win);
816 XDefineCursor(_ecore_x_disp, win, c);
820 * Finds out whether the given window is currently visible.
821 * @param win The given window.
822 * @return 1 if the window is visible, otherwise 0.
823 * @ingroup Ecore_X_Window_Visibility_Group
826 ecore_x_window_visible_get(Ecore_X_Window win)
828 XWindowAttributes attr;
830 LOGFN(__FILE__, __LINE__, __FUNCTION__);
831 return XGetWindowAttributes(_ecore_x_disp, win, &attr) &&
832 (attr.map_state == IsViewable);
835 typedef struct _Shadow Shadow;
846 static Shadow **shadow_base = NULL;
847 static int shadow_num = 0;
850 _ecore_x_window_tree_walk(Window win)
853 Window parent_win = 0, root_win = 0;
856 XWindowAttributes att;
858 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
859 return NULL; // if (att.class == InputOnly) return NULL;
861 if (att.map_state != IsViewable)
864 s = calloc(1, sizeof(Shadow));
873 if (XQueryTree(_ecore_x_disp, s->win, &root_win, &parent_win,
876 s->children = calloc(1, sizeof(Shadow *) * num);
880 s->children_num = num;
881 for (i = 0; i < num; i++)
883 s->children[i] = _ecore_x_window_tree_walk(list[i]);
885 s->children[i]->parent = s;
887 /* compress list down */
889 for (i = 0; i < num; i++)
893 s->children[j] = s->children[i];
906 sl = realloc(s->children, sizeof(Shadow *) * j);
920 _ecore_x_window_tree_shadow_free1(Shadow *s)
929 for (i = 0; i < s->children_num; i++)
932 _ecore_x_window_tree_shadow_free1(s->children[i]);
941 _ecore_x_window_tree_shadow_free(void)
948 for (i = 0; i < shadow_num; i++)
953 _ecore_x_window_tree_shadow_free1(shadow_base[i]);
961 _ecore_x_window_tree_shadow_populate(void)
963 Ecore_X_Window *roots;
966 roots = ecore_x_window_root_list(&num);
969 shadow_base = calloc(1, sizeof(Shadow *) * num);
973 for (i = 0; i < num; i++)
974 shadow_base[i] = _ecore_x_window_tree_walk(roots[i]);
982 static int shadow_count = 0;
985 _ecore_x_window_tree_shadow_start(void)
988 if (shadow_count > 1) return;
989 _ecore_x_window_tree_shadow_populate();
993 _ecore_x_window_tree_shadow_stop(void)
996 if (shadow_count != 0) return;
997 _ecore_x_window_tree_shadow_free();
1002 _ecore_x_window_shadow_tree_find_shadow(Shadow *s,
1012 for (i = 0; i < s->children_num; i++)
1014 if (!s->children[i])
1018 _ecore_x_window_shadow_tree_find_shadow(s->children[i], win)))
1026 _ecore_x_window_shadow_tree_find(Window base)
1031 for (i = 0; i < shadow_num; i++)
1033 if (!shadow_base[i])
1036 if ((s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], base)))
1043 _inside_rects(Shadow *s,
1048 Ecore_X_Rectangle *rects,
1053 if (!rects) return 0;
1055 for (i = 0; i < num; i++)
1057 if ((x >= s->x + bx + rects[i].x) &&
1058 (y >= s->y + by + rects[i].y) &&
1059 (x < (int)(s->x + bx + rects[i].x + rects[i].width)) &&
1060 (y < (int)(s->y + by + rects[i].y + rects[i].height)))
1071 _ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow *s,
1076 Ecore_X_Window *skip,
1085 if (!((x >= wx) && (y >= wy) && (x < (wx + s->w)) && (y < (wy + s->h))))
1088 /* FIXME: get shape */
1091 Ecore_X_Rectangle *rects;
1094 rects = ecore_x_window_shape_rectangles_get(s->win, &num);
1095 if (!_inside_rects(s, x, y, bx, by, rects, num)) return 0;
1097 rects = ecore_x_window_shape_input_rectangles_get(s->win, &num);
1098 if (!_inside_rects(s, x, y, bx, by, rects, num)) return 0;
1105 for (i = s->children_num - 1; i >= 0; --i)
1107 if (!s->children[i])
1112 for (j = 0; j < skip_num; j++)
1114 if (s->children[i]->win == skip[j])
1124 _ecore_x_window_shadow_tree_at_xy_get_shadow(s->
1137 _ecore_x_window_shadow_tree_at_xy_get(Window base,
1142 Ecore_X_Window *skip,
1149 _ecore_x_window_tree_shadow_populate();
1154 s = _ecore_x_window_shadow_tree_find(base);
1158 return _ecore_x_window_shadow_tree_at_xy_get_shadow(s,
1168 * Retrieves the top, visible window at the given location,
1169 * but skips the windows in the list. This uses a shadow tree built from the
1170 * window tree that is only updated the first time
1171 * ecore_x_window_shadow_tree_at_xy_with_skip_get() is called, or the next time
1172 * it is called after a ecore_x_window_shadow_tree_flush()
1173 * @param base The base window to start searching from (normally root).
1174 * @param x The given X position.
1175 * @param y The given Y position.
1176 * @param skip The list of windows to be skipped.
1177 * @param skip_num The number of windows to be skipped.
1178 * @return The window at that position.
1179 * @ingroup Ecore_X_Window_Geometry_Group
1182 ecore_x_window_shadow_tree_at_xy_with_skip_get(Ecore_X_Window base,
1185 Ecore_X_Window *skip,
1188 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1189 return _ecore_x_window_shadow_tree_at_xy_get(base,
1199 * Retrieves the parent window a given window has. This uses the shadow window
1201 * @param root The root window of @p win - if 0, this will be automatically determined with extra processing overhead
1202 * @param win The window to get the parent window of
1203 * @return The parent window of @p win
1204 * @ingroup Ecore_X_Window_Geometry_Group
1207 ecore_x_window_shadow_parent_get(Ecore_X_Window root __UNUSED__,
1213 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1216 _ecore_x_window_tree_shadow_populate();
1221 for (i = 0; i < shadow_num; i++)
1223 if (!shadow_base[i])
1226 s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], win);
1232 return s->parent->win;
1239 * Flushes the window shadow tree so nothing is stored.
1240 * @ingroup Ecore_X_Window_Geometry_Group
1243 ecore_x_window_shadow_tree_flush(void)
1245 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1246 _ecore_x_window_tree_shadow_free();
1250 * Retrieves the root window a given window is on.
1251 * @param win The window to get the root window of
1252 * @return The root window of @p win
1253 * @ingroup Ecore_X_Window_Geometry_Group
1256 ecore_x_window_root_get(Ecore_X_Window win)
1258 XWindowAttributes att;
1260 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1261 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
1268 _ecore_x_window_at_xy_get(Window base,
1273 Ecore_X_Window *skip,
1276 Window *list = NULL;
1277 Window parent_win = 0, child = 0, root_win = 0;
1278 int i, j, wx, wy, ww, wh;
1281 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1282 if (!ecore_x_window_visible_get(base))
1285 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1286 ecore_x_window_geometry_get(base, &wx, &wy, &ww, &wh);
1290 if (!((x >= wx) && (y >= wy) && (x < (wx + ww)) && (y < (wy + wh))))
1293 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1294 if (!XQueryTree(_ecore_x_disp, base, &root_win, &parent_win, &list, &num))
1301 for (i = num - 1; i >= 0; --i)
1306 for (j = 0; j < skip_num; j++)
1308 if (list[i] == skip[j])
1318 _ecore_x_window_at_xy_get(list[i], wx, wy, x, y, skip,
1332 * Retrieves the top, visible window at the given location.
1333 * @param x The given X position.
1334 * @param y The given Y position.
1335 * @return The window at that position.
1336 * @ingroup Ecore_X_Window_Geometry_Group
1339 ecore_x_window_at_xy_get(int x,
1342 Ecore_X_Window win, root;
1344 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1345 /* FIXME: Proper function to determine current root/virtual root
1346 * window missing here */
1347 root = DefaultRootWindow(_ecore_x_disp);
1350 win = _ecore_x_window_at_xy_get(root, 0, 0, x, y, NULL, 0);
1353 return win ? win : root;
1357 * Retrieves the top, visible window at the given location,
1358 * but skips the windows in the list.
1359 * @param x The given X position.
1360 * @param y The given Y position.
1361 * @param skip The list of windows to be skipped.
1362 * @param skip_num The number of windows to be skipped.
1363 * @return The window at that position.
1364 * @ingroup Ecore_X_Window_Geometry_Group
1367 ecore_x_window_at_xy_with_skip_get(int x,
1369 Ecore_X_Window *skip,
1372 Ecore_X_Window win, root;
1374 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1375 /* FIXME: Proper function to determine current root/virtual root
1376 * window missing here */
1377 root = DefaultRootWindow(_ecore_x_disp);
1380 win = _ecore_x_window_at_xy_get(root, 0, 0, x, y, skip, skip_num);
1383 return win ? win : root;
1387 ecore_x_window_at_xy_begin_get(Ecore_X_Window begin,
1393 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1395 win = _ecore_x_window_at_xy_get(begin, 0, 0, x, y, NULL, 0);
1398 return win ? win : begin;
1402 * Retrieves the parent window of the given window.
1403 * @param win The given window.
1404 * @return The parent window of @p win.
1405 * @ingroup Ecore_X_Window_Parent_Group
1408 ecore_x_window_parent_get(Ecore_X_Window win)
1410 Window root, parent, *children = NULL;
1413 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1414 if (!XQueryTree(_ecore_x_disp, win, &root, &parent, &children, &num))
1424 * Sets the background color of the given window.
1425 * @param win The given window
1426 * @param r red value (0...65536, 16 bits)
1427 * @param g green value (0...65536, 16 bits)
1428 * @param b blue value (0...65536, 16 bits)
1431 ecore_x_window_background_color_set(Ecore_X_Window win,
1436 XSetWindowAttributes attr;
1440 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1445 map = DefaultColormap(_ecore_x_disp, DefaultScreen(_ecore_x_disp));
1446 XAllocColor(_ecore_x_disp, map, &col);
1448 attr.background_pixel = col.pixel;
1449 XChangeWindowAttributes(_ecore_x_disp, win, CWBackPixel, &attr);
1453 ecore_x_window_gravity_set(Ecore_X_Window win,
1454 Ecore_X_Gravity grav)
1456 XSetWindowAttributes att;
1458 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1459 att.win_gravity = grav;
1460 XChangeWindowAttributes(_ecore_x_disp, win, CWWinGravity, &att);
1464 ecore_x_window_pixel_gravity_set(Ecore_X_Window win,
1465 Ecore_X_Gravity grav)
1467 XSetWindowAttributes att;
1469 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1470 att.bit_gravity = grav;
1471 XChangeWindowAttributes(_ecore_x_disp, win, CWBitGravity, &att);
1475 ecore_x_window_pixmap_set(Ecore_X_Window win,
1476 Ecore_X_Pixmap pmap)
1478 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1479 XSetWindowBackgroundPixmap(_ecore_x_disp, win, pmap);
1483 ecore_x_window_area_clear(Ecore_X_Window win,
1489 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1490 XClearArea(_ecore_x_disp, win, x, y, w, h, False);
1494 ecore_x_window_area_expose(Ecore_X_Window win,
1500 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1501 XClearArea(_ecore_x_disp, win, x, y, w, h, True);
1505 ecore_x_window_override_set(Ecore_X_Window win,
1508 XSetWindowAttributes att;
1510 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1511 att.override_redirect = override;
1512 XChangeWindowAttributes(_ecore_x_disp, win, CWOverrideRedirect, &att);
1515 #ifdef ECORE_XRENDER
1516 static Ecore_X_Window
1517 _ecore_x_window_argb_internal_new(Ecore_X_Window parent,
1523 Eina_Bool saveunder)
1526 XSetWindowAttributes attr;
1527 XWindowAttributes att;
1530 int nvi, i, scr = 0;
1531 XRenderPictFormat *fmt;
1536 parent = DefaultRootWindow(_ecore_x_disp);
1537 scr = DefaultScreen(_ecore_x_disp);
1541 /* ewww - round trip */
1542 XGetWindowAttributes(_ecore_x_disp, parent, &att);
1543 for (i = 0; i < ScreenCount(_ecore_x_disp); i++)
1545 if (att.screen == ScreenOfDisplay(_ecore_x_disp, i))
1555 vi_in.class = TrueColor;
1556 xvi = XGetVisualInfo(_ecore_x_disp,
1566 for (i = 0; i < nvi; i++)
1568 fmt = XRenderFindVisualFormat(_ecore_x_disp, xvi[i].visual);
1569 if ((fmt->type == PictTypeDirect) && (fmt->direct.alphaMask))
1571 vis = xvi[i].visual;
1577 attr.backing_store = NotUseful;
1578 attr.override_redirect = override;
1579 attr.colormap = XCreateColormap(_ecore_x_disp, parent,
1581 attr.border_pixel = 0;
1582 attr.background_pixmap = None;
1583 attr.bit_gravity = NorthWestGravity;
1584 attr.win_gravity = NorthWestGravity;
1585 attr.save_under = saveunder;
1586 attr.do_not_propagate_mask = NoEventMask;
1587 attr.event_mask = KeyPressMask |
1595 VisibilityChangeMask |
1596 StructureNotifyMask |
1598 PropertyChangeMask |
1600 win = XCreateWindow(_ecore_x_disp, parent,
1606 CWOverrideRedirect |
1616 XFreeColormap(_ecore_x_disp, attr.colormap);
1618 if (parent == DefaultRootWindow(_ecore_x_disp))
1619 ecore_x_window_defaults_set(win);
1624 #endif /* ifdef ECORE_XRENDER */
1627 ecore_x_window_argb_get(Ecore_X_Window win)
1629 #ifdef ECORE_XRENDER
1630 XWindowAttributes att;
1631 XRenderPictFormat *fmt;
1634 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
1637 fmt = XRenderFindVisualFormat(_ecore_x_disp, att.visual);
1641 if ((fmt->type == PictTypeDirect) && (fmt->direct.alphaMask))
1645 #else /* ifdef ECORE_XRENDER */
1647 #endif /* ifdef ECORE_XRENDER */
1651 * Creates a new window.
1652 * @param parent The parent window to use. If @p parent is @c 0, the root
1653 * window of the default display is used.
1654 * @param x X position.
1655 * @param y Y position.
1658 * @return The new window handle.
1659 * @ingroup Ecore_X_Window_Create_Group
1662 ecore_x_window_manager_argb_new(Ecore_X_Window parent,
1668 #ifdef ECORE_XRENDER
1669 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1670 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 1, 0);
1671 #else /* ifdef ECORE_XRENDER */
1673 #endif /* ifdef ECORE_XRENDER */
1677 * Creates a new window.
1678 * @param parent The parent window to use. If @p parent is @c 0, the root
1679 * window of the default display is used.
1680 * @param x X position.
1681 * @param y Y position.
1684 * @return The new window handle.
1685 * @ingroup Ecore_X_Window_Create_Group
1688 ecore_x_window_argb_new(Ecore_X_Window parent,
1694 #ifdef ECORE_XRENDER
1695 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1696 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 0, 0);
1697 #else /* ifdef ECORE_XRENDER */
1699 #endif /* ifdef ECORE_XRENDER */
1703 * Creates a window with the override redirect attribute set to @c True.
1704 * @param parent The parent window to use. If @p parent is @c 0, the root
1705 * window of the default display is used.
1706 * @param x X position.
1707 * @param y Y position.
1710 * @return The new window handle.
1711 * @ingroup Ecore_X_Window_Create_Group
1714 ecore_x_window_override_argb_new(Ecore_X_Window parent,
1720 #ifdef ECORE_XRENDER
1721 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1722 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 1, 0);
1723 #else /* ifdef ECORE_XRENDER */
1725 #endif /* ifdef ECORE_XRENDER */