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)
313 LOGFN(__FILE__, __LINE__, __FUNCTION__);
318 for (i = 0; i < ignore_num; i++)
320 if (win == ignore_list[i])
324 realloc(ignore_list, (ignore_num + 1) * sizeof(Ecore_X_Window));
328 ignore_list[ignore_num++] = win;
333 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++];
349 ignore_list = realloc(ignore_list, ignore_num * sizeof(Ecore_X_Window));
351 } /* ecore_x_window_ignore_set */
354 * Get the ignore list
355 * @param num number of windows in the list
356 * @return list of windows to ignore
358 EAPI Ecore_X_Window *
359 ecore_x_window_ignore_list(int *num)
365 } /* ecore_x_window_ignore_list */
368 * Sends a delete request to the given window.
369 * @param win The given window.
370 * @ingroup Ecore_X_Window_Destroy_Group
373 ecore_x_window_delete_request_send(Ecore_X_Window win)
377 /* sorry sir, deleting the root window doesn't sound like
383 LOGFN(__FILE__, __LINE__, __FUNCTION__);
384 xev.xclient.type = ClientMessage;
385 xev.xclient.display = _ecore_x_disp;
386 xev.xclient.window = win;
387 xev.xclient.message_type = ECORE_X_ATOM_WM_PROTOCOLS;
388 xev.xclient.format = 32;
389 xev.xclient.data.l[0] = ECORE_X_ATOM_WM_DELETE_WINDOW;
390 xev.xclient.data.l[1] = CurrentTime;
392 XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev);
393 } /* ecore_x_window_delete_request_send */
396 * @defgroup Ecore_X_Window_Visibility_Group X Window Visibility Functions
398 * Functions to access and change the visibility of X windows.
404 * Synonymous to "mapping" a window in X Window System terminology.
406 * @param win The window to show.
407 * @ingroup Ecore_X_Window_Visibility
410 ecore_x_window_show(Ecore_X_Window win)
412 LOGFN(__FILE__, __LINE__, __FUNCTION__);
413 XMapWindow(_ecore_x_disp, win);
414 } /* ecore_x_window_show */
419 * Synonymous to "unmapping" a window in X Window System terminology.
421 * @param win The window to hide.
422 * @ingroup Ecore_X_Window_Visibility
425 ecore_x_window_hide(Ecore_X_Window win)
432 /* ICCCM: SEND unmap event... */
433 LOGFN(__FILE__, __LINE__, __FUNCTION__);
435 if (ScreenCount(_ecore_x_disp) == 1)
436 root = DefaultRootWindow(_ecore_x_disp);
438 XGetGeometry(_ecore_x_disp,
448 xev.xunmap.type = UnmapNotify;
449 xev.xunmap.serial = 0;
450 xev.xunmap.send_event = True;
451 xev.xunmap.display = _ecore_x_disp;
452 xev.xunmap.event = root;
453 xev.xunmap.window = win;
454 xev.xunmap.from_configure = False;
455 XSendEvent(_ecore_x_disp, xev.xunmap.event, False,
456 SubstructureRedirectMask | SubstructureNotifyMask, &xev);
457 XUnmapWindow(_ecore_x_disp, win);
458 } /* ecore_x_window_hide */
461 * @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions
463 * Functions that change or retrieve the geometry of X windows.
467 * Moves a window to the position @p x, @p y.
469 * The position is relative to the upper left hand corner of the
472 * @param win The window to move.
473 * @param x X position.
474 * @param y Y position.
475 * @ingroup Ecore_X_Window_Geometry_Group
478 ecore_x_window_move(Ecore_X_Window win, int x, int y)
480 LOGFN(__FILE__, __LINE__, __FUNCTION__);
481 XMoveWindow(_ecore_x_disp, win, x, y);
482 } /* ecore_x_window_move */
486 * @param win The window to resize.
487 * @param w New width of the window.
488 * @param h New height of the window.
489 * @ingroup Ecore_X_Window_Geometry_Group
492 ecore_x_window_resize(Ecore_X_Window win, int w, int h)
494 LOGFN(__FILE__, __LINE__, __FUNCTION__);
501 XResizeWindow(_ecore_x_disp, win, w, h);
502 } /* ecore_x_window_resize */
505 * Moves and resizes a window.
506 * @param win The window to move and resize.
507 * @param x New X position of the window.
508 * @param y New Y position of the window.
509 * @param w New width of the window.
510 * @param h New height of the window.
511 * @ingroup Ecore_X_Window_Geometry_Group
514 ecore_x_window_move_resize(Ecore_X_Window win, int x, int y, int w, int h)
516 LOGFN(__FILE__, __LINE__, __FUNCTION__);
523 XMoveResizeWindow(_ecore_x_disp, win, x, y, w, h);
524 } /* ecore_x_window_move_resize */
527 * @defgroup Ecore_X_Window_Focus_Functions X Window Focus Functions
529 * Functions that give the focus to an X Window.
533 * Sets the focus to the window @p win.
534 * @param win The window to focus.
535 * @ingroup Ecore_X_Window_Focus_Functions
538 ecore_x_window_focus(Ecore_X_Window win)
540 LOGFN(__FILE__, __LINE__, __FUNCTION__);
542 win = DefaultRootWindow(_ecore_x_disp); // XSetInputFocus(_ecore_x_disp, win, RevertToNone, CurrentTime);
544 // XSetInputFocus(_ecore_x_disp, win, RevertToPointerRoot, CurrentTime);
545 XSetInputFocus(_ecore_x_disp, win, RevertToParent, CurrentTime);
546 } /* ecore_x_window_focus */
549 * Sets the focus to the given window at a specific time.
550 * @param win The window to focus.
551 * @param t When to set the focus to the window.
552 * @ingroup Ecore_X_Window_Focus_Functions
555 ecore_x_window_focus_at_time(Ecore_X_Window win, Ecore_X_Time t)
557 LOGFN(__FILE__, __LINE__, __FUNCTION__);
559 win = DefaultRootWindow(_ecore_x_disp); // XSetInputFocus(_ecore_x_disp, win, RevertToNone, t);
561 // XSetInputFocus(_ecore_x_disp, win, PointerRoot, t);
562 XSetInputFocus(_ecore_x_disp, win, RevertToParent, t);
563 } /* ecore_x_window_focus_at_time */
566 * gets the focus to the window @p win.
567 * @return The window that has focus.
568 * @ingroup Ecore_X_Window_Focus_Functions
571 ecore_x_window_focus_get(void)
576 LOGFN(__FILE__, __LINE__, __FUNCTION__);
578 XGetInputFocus(_ecore_x_disp, &win, &revert_mode);
580 } /* ecore_x_window_focus_get */
583 * @defgroup Ecore_X_Window_Z_Order_Group X Window Z Order Functions
585 * Functions that change the Z order of X windows.
589 * Raises the given window.
590 * @param win The window to raise.
591 * @ingroup Ecore_X_Window_Z_Order_Group
594 ecore_x_window_raise(Ecore_X_Window win)
596 LOGFN(__FILE__, __LINE__, __FUNCTION__);
597 XRaiseWindow(_ecore_x_disp, win);
598 } /* ecore_x_window_raise */
601 * Lowers the given window.
602 * @param win The window to lower.
603 * @ingroup Ecore_X_Window_Z_Order_Group
606 ecore_x_window_lower(Ecore_X_Window win)
608 LOGFN(__FILE__, __LINE__, __FUNCTION__);
609 XLowerWindow(_ecore_x_disp, win);
610 } /* ecore_x_window_lower */
613 * @defgroup Ecore_X_Window_Parent_Group X Window Parent Functions
615 * Functions that retrieve or changes the parent window of a window.
619 * Moves a window to within another window at a given position.
620 * @param win The window to reparent.
621 * @param new_parent The new parent window.
622 * @param x X position within new parent window.
623 * @param y Y position within new parent window.
624 * @ingroup Ecore_X_Window_Parent_Group
627 ecore_x_window_reparent(Ecore_X_Window win,
628 Ecore_X_Window new_parent,
632 LOGFN(__FILE__, __LINE__, __FUNCTION__);
634 new_parent = DefaultRootWindow(_ecore_x_disp);
636 XReparentWindow(_ecore_x_disp, win, new_parent, x, y);
637 } /* ecore_x_window_reparent */
640 * Retrieves the size of the given window.
641 * @param win The given window.
642 * @param w Pointer to an integer into which the width is to be stored.
643 * @param h Pointer to an integer into which the height is to be stored.
644 * @ingroup Ecore_X_Window_Geometry_Group
647 ecore_x_window_size_get(Ecore_X_Window win, int *w, int *h)
649 int dummy_x, dummy_y;
651 LOGFN(__FILE__, __LINE__, __FUNCTION__);
653 win = DefaultRootWindow(_ecore_x_disp);
655 ecore_x_drawable_geometry_get(win, &dummy_x, &dummy_y, w, h);
656 } /* ecore_x_window_size_get */
659 * Retrieves the geometry of the given window.
661 * Note that the x & y coordingates are relative to your parent. In
662 * particular for reparenting window managers - relative to you window border.
663 * If you want screen coordinates either walk the window tree to the root,
664 * else for ecore_evas applications see ecore_evas_geometry_get(). Elementary
665 * applications can use elm_win_screen_position_get().
667 * @param win The given window.
668 * @param x Pointer to an integer in which the X position is to be stored.
669 * @param y Pointer to an integer in which the Y position is to be stored.
670 * @param w Pointer to an integer in which the width is to be stored.
671 * @param h Pointer to an integer in which the height is to be stored.
672 * @ingroup Ecore_X_Window_Geometry_Group
675 ecore_x_window_geometry_get(Ecore_X_Window win, int *x, int *y, int *w, int *h)
677 LOGFN(__FILE__, __LINE__, __FUNCTION__);
679 win = DefaultRootWindow(_ecore_x_disp);
681 ecore_x_drawable_geometry_get(win, x, y, w, h);
682 } /* ecore_x_window_geometry_get */
685 * Retrieves the width of the border of the given window.
686 * @param win The given window.
687 * @return Width of the border of @p win.
688 * @ingroup Ecore_X_Window_Geometry_Group
691 ecore_x_window_border_width_get(Ecore_X_Window win)
693 LOGFN(__FILE__, __LINE__, __FUNCTION__);
694 /* doesn't make sense to call this on a root window */
698 return ecore_x_drawable_border_width_get(win);
699 } /* ecore_x_window_border_width_get */
702 * Sets the width of the border of the given window.
703 * @param win The given window.
704 * @param width The new border width.
705 * @ingroup Ecore_X_Window_Geometry_Group
708 ecore_x_window_border_width_set(Ecore_X_Window win, int width)
710 LOGFN(__FILE__, __LINE__, __FUNCTION__);
711 /* doesn't make sense to call this on a root window */
715 XSetWindowBorderWidth (_ecore_x_disp, win, width);
716 } /* ecore_x_window_border_width_set */
719 * Retrieves the depth of the given window.
720 * @param win The given window.
721 * @return Depth of the window.
724 ecore_x_window_depth_get(Ecore_X_Window win)
726 LOGFN(__FILE__, __LINE__, __FUNCTION__);
727 return ecore_x_drawable_depth_get(win);
728 } /* ecore_x_window_depth_get */
733 * FIXME: To be fixed.
736 ecore_x_window_cursor_show(Ecore_X_Window win, int show)
738 LOGFN(__FILE__, __LINE__, __FUNCTION__);
740 win = DefaultRootWindow(_ecore_x_disp);
750 p = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
751 m = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
752 gc = XCreateGC(_ecore_x_disp, m, 0, &gcv);
753 XSetForeground(_ecore_x_disp, gc, 0);
754 XDrawPoint(_ecore_x_disp, m, gc, 0, 0);
755 XFreeGC(_ecore_x_disp, gc);
756 c = XCreatePixmapCursor(_ecore_x_disp, p, m, &cl, &cl, 0, 0);
757 XDefineCursor(_ecore_x_disp, win, c);
758 XFreeCursor(_ecore_x_disp, c);
759 XFreePixmap(_ecore_x_disp, p);
760 XFreePixmap(_ecore_x_disp, m);
763 XDefineCursor(_ecore_x_disp, win, 0);
764 } /* ecore_x_window_cursor_show */
767 ecore_x_window_cursor_set(Ecore_X_Window win, Ecore_X_Cursor c)
769 LOGFN(__FILE__, __LINE__, __FUNCTION__);
771 XUndefineCursor(_ecore_x_disp, win);
773 XDefineCursor(_ecore_x_disp, win, c);
774 } /* ecore_x_window_cursor_set */
777 * Finds out whether the given window is currently visible.
778 * @param win The given window.
779 * @return 1 if the window is visible, otherwise 0.
780 * @ingroup Ecore_X_Window_Visibility_Group
783 ecore_x_window_visible_get(Ecore_X_Window win)
785 XWindowAttributes attr;
787 LOGFN(__FILE__, __LINE__, __FUNCTION__);
788 return (XGetWindowAttributes(_ecore_x_disp, win, &attr) &&
789 (attr.map_state == IsViewable));
790 } /* ecore_x_window_visible_get */
792 typedef struct _Shadow Shadow;
803 static Shadow **shadow_base = NULL;
804 static int shadow_num = 0;
807 _ecore_x_window_tree_walk(Window win)
810 Window parent_win = 0, root_win = 0;
813 XWindowAttributes att;
815 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
816 return NULL; // if (att.class == InputOnly) return NULL;
818 if (att.map_state != IsViewable)
821 s = calloc(1, sizeof(Shadow));
830 if (XQueryTree(_ecore_x_disp, s->win, &root_win, &parent_win,
833 s->children = calloc(1, sizeof(Shadow *) * num);
837 s->children_num = num;
838 for (i = 0; i < num; i++)
840 s->children[i] = _ecore_x_window_tree_walk(list[i]);
842 s->children[i]->parent = s;
844 /* compress list down */
846 for (i = 0; i < num; i++)
850 s->children[j] = s->children[i];
863 sl = realloc(s->children, sizeof(Shadow *) * j);
874 } /* _ecore_x_window_tree_walk */
877 _ecore_x_window_tree_shadow_free1(Shadow *s)
886 for (i = 0; i < s->children_num; i++)
889 _ecore_x_window_tree_shadow_free1(s->children[i]);
895 } /* _ecore_x_window_tree_shadow_free1 */
898 _ecore_x_window_tree_shadow_free(void)
905 for (i = 0; i < shadow_num; i++)
910 _ecore_x_window_tree_shadow_free1(shadow_base[i]);
915 } /* _ecore_x_window_tree_shadow_free */
918 _ecore_x_window_tree_shadow_populate(void)
920 Ecore_X_Window *roots;
923 roots = ecore_x_window_root_list(&num);
926 shadow_base = calloc(1, sizeof(Shadow *) * num);
930 for (i = 0; i < num; i++)
931 shadow_base[i] = _ecore_x_window_tree_walk(roots[i]);
936 } /* _ecore_x_window_tree_shadow_populate */
939 static int shadow_count = 0;
942 _ecore_x_window_tree_shadow_start(void)
945 if (shadow_count > 1) return;
946 _ecore_x_window_tree_shadow_populate();
950 _ecore_x_window_tree_shadow_stop(void)
953 if (shadow_count != 0) return;
954 _ecore_x_window_tree_shadow_free();
959 _ecore_x_window_shadow_tree_find_shadow(Shadow *s, Window win)
968 for (i = 0; i < s->children_num; i++)
974 _ecore_x_window_shadow_tree_find_shadow(s->children[i], win)))
979 } /* _ecore_x_window_shadow_tree_find_shadow */
982 _ecore_x_window_shadow_tree_find(Window base)
987 for (i = 0; i < shadow_num; i++)
992 if ((s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], base)))
996 } /* _ecore_x_window_shadow_tree_find */
999 _ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow *s,
1004 Ecore_X_Window *skip,
1013 if (!((x >= wx) && (y >= wy) && (x < (wx + s->w)) && (y < (wy + s->h))))
1020 for (i = s->children_num - 1; i >= 0; --i)
1022 if (!s->children[i])
1027 for (j = 0; j < skip_num; j++)
1029 if (s->children[i]->win == skip[j])
1039 _ecore_x_window_shadow_tree_at_xy_get_shadow(s->
1050 } /* _ecore_x_window_shadow_tree_at_xy_get_shadow */
1053 _ecore_x_window_shadow_tree_at_xy_get(Window base, int bx, int by, int x, int y,
1054 Ecore_X_Window *skip, int skip_num)
1060 _ecore_x_window_tree_shadow_populate();
1065 s = _ecore_x_window_shadow_tree_find(base);
1069 return _ecore_x_window_shadow_tree_at_xy_get_shadow(s,
1076 } /* _ecore_x_window_shadow_tree_at_xy_get */
1079 * Retrieves the top, visible window at the given location,
1080 * but skips the windows in the list. This uses a shadow tree built from the
1081 * window tree that is only updated the first time
1082 * ecore_x_window_shadow_tree_at_xy_with_skip_get() is called, or the next time
1083 * it is called after a ecore_x_window_shadow_tree_flush()
1084 * @param base The base window to start searching from (normally root).
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_shadow_tree_at_xy_with_skip_get(Ecore_X_Window base,
1094 Ecore_X_Window *skip,
1097 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1098 return _ecore_x_window_shadow_tree_at_xy_get(base,
1105 } /* ecore_x_window_shadow_tree_at_xy_with_skip_get */
1108 * Retrieves the parent window a given window has. This uses the shadow window
1110 * @param root The root window of @p win - if 0, this will be automatically determined with extra processing overhead
1111 * @param win The window to get the parent window of
1112 * @return The parent window of @p win
1113 * @ingroup Ecore_X_Window_Geometry_Group
1116 ecore_x_window_shadow_parent_get(Ecore_X_Window root __UNUSED__,
1122 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1125 _ecore_x_window_tree_shadow_populate();
1130 for (i = 0; i < shadow_num; i++)
1132 if (!shadow_base[i])
1135 s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], win);
1141 return s->parent->win;
1145 } /* ecore_x_window_shadow_parent_get */
1148 * Flushes the window shadow tree so nothing is stored.
1149 * @ingroup Ecore_X_Window_Geometry_Group
1152 ecore_x_window_shadow_tree_flush(void)
1154 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1155 _ecore_x_window_tree_shadow_free();
1156 } /* ecore_x_window_shadow_tree_flush */
1159 * Retrieves the root window a given window is on.
1160 * @param win The window to get the root window of
1161 * @return The root window of @p win
1162 * @ingroup Ecore_X_Window_Geometry_Group
1165 ecore_x_window_root_get(Ecore_X_Window win)
1167 XWindowAttributes att;
1169 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1170 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
1174 } /* ecore_x_window_root_get */
1177 _ecore_x_window_at_xy_get(Window base, int bx, int by, int x, int y,
1178 Ecore_X_Window *skip, int skip_num)
1180 Window *list = NULL;
1181 Window parent_win = 0, child = 0, root_win = 0;
1182 int i, j, wx, wy, ww, wh;
1185 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1186 if (!ecore_x_window_visible_get(base))
1189 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1190 ecore_x_window_geometry_get(base, &wx, &wy, &ww, &wh);
1194 if (!((x >= wx) && (y >= wy) && (x < (wx + ww)) && (y < (wy + wh))))
1197 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1198 if (!XQueryTree(_ecore_x_disp, base, &root_win, &parent_win, &list, &num))
1205 for (i = num - 1; i >= 0; --i)
1210 for (j = 0; j < skip_num; j++)
1212 if (list[i] == skip[j])
1222 _ecore_x_window_at_xy_get(list[i], wx, wy, x, y, skip,
1234 } /* _ecore_x_window_at_xy_get */
1237 * Retrieves the top, visible window at the given location.
1238 * @param x The given X position.
1239 * @param y The given Y position.
1240 * @return The window at that position.
1241 * @ingroup Ecore_X_Window_Geometry_Group
1244 ecore_x_window_at_xy_get(int x, int y)
1246 Ecore_X_Window win, root;
1248 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1249 /* FIXME: Proper function to determine current root/virtual root
1250 * window missing here */
1251 root = DefaultRootWindow(_ecore_x_disp);
1254 win = _ecore_x_window_at_xy_get(root, 0, 0, x, y, NULL, 0);
1257 return win ? win : root;
1258 } /* ecore_x_window_at_xy_get */
1261 * Retrieves the top, visible window at the given location,
1262 * but skips the windows in the list.
1263 * @param x The given X position.
1264 * @param y The given Y position.
1265 * @return The window at that position.
1266 * @ingroup Ecore_X_Window_Geometry_Group
1269 ecore_x_window_at_xy_with_skip_get(int x,
1271 Ecore_X_Window *skip,
1274 Ecore_X_Window win, root;
1276 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1277 /* FIXME: Proper function to determine current root/virtual root
1278 * window missing here */
1279 root = DefaultRootWindow(_ecore_x_disp);
1282 win = _ecore_x_window_at_xy_get(root, 0, 0, x, y, skip, skip_num);
1285 return win ? win : root;
1286 } /* ecore_x_window_at_xy_with_skip_get */
1289 ecore_x_window_at_xy_begin_get(Ecore_X_Window begin, int x, int y)
1293 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1295 win = _ecore_x_window_at_xy_get(begin, 0, 0, x, y, NULL, 0);
1298 return win ? win : begin;
1299 } /* ecore_x_window_at_xy_begin_get */
1302 * Retrieves the parent window of the given window.
1303 * @param win The given window.
1304 * @return The parent window of @p win.
1305 * @ingroup Ecore_X_Window_Parent_Group
1308 ecore_x_window_parent_get(Ecore_X_Window win)
1310 Window root, parent, *children = NULL;
1313 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1314 if (!XQueryTree(_ecore_x_disp, win, &root, &parent, &children, &num))
1321 } /* ecore_x_window_parent_get */
1324 * Sets the background color of the given window.
1325 * @param win The given window
1326 * @param r red value (0...65536, 16 bits)
1327 * @param g green value (0...65536, 16 bits)
1328 * @param b blue value (0...65536, 16 bits)
1331 ecore_x_window_background_color_set(Ecore_X_Window win, unsigned short r,
1332 unsigned short g, unsigned short b)
1334 XSetWindowAttributes attr;
1338 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1343 map = DefaultColormap(_ecore_x_disp, DefaultScreen(_ecore_x_disp));
1344 XAllocColor(_ecore_x_disp, map, &col);
1346 attr.background_pixel = col.pixel;
1347 XChangeWindowAttributes(_ecore_x_disp, win, CWBackPixel, &attr);
1348 } /* ecore_x_window_background_color_set */
1351 ecore_x_window_gravity_set(Ecore_X_Window win, Ecore_X_Gravity grav)
1353 XSetWindowAttributes att;
1355 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1356 att.win_gravity = grav;
1357 XChangeWindowAttributes(_ecore_x_disp, win, CWWinGravity, &att);
1358 } /* ecore_x_window_gravity_set */
1361 ecore_x_window_pixel_gravity_set(Ecore_X_Window win, Ecore_X_Gravity grav)
1363 XSetWindowAttributes att;
1365 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1366 att.bit_gravity = grav;
1367 XChangeWindowAttributes(_ecore_x_disp, win, CWBitGravity, &att);
1368 } /* ecore_x_window_pixel_gravity_set */
1371 ecore_x_window_pixmap_set(Ecore_X_Window win, Ecore_X_Pixmap pmap)
1373 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1374 XSetWindowBackgroundPixmap(_ecore_x_disp, win, pmap);
1375 } /* ecore_x_window_pixmap_set */
1378 ecore_x_window_area_clear(Ecore_X_Window win, int x, int y, int w, int h)
1380 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1381 XClearArea(_ecore_x_disp, win, x, y, w, h, False);
1382 } /* ecore_x_window_area_clear */
1385 ecore_x_window_area_expose(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, True);
1389 } /* ecore_x_window_area_expose */
1392 ecore_x_window_override_set(Ecore_X_Window win, int override)
1394 XSetWindowAttributes att;
1396 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1397 att.override_redirect = override;
1398 XChangeWindowAttributes(_ecore_x_disp, win, CWOverrideRedirect, &att);
1399 } /* ecore_x_window_override_set */
1401 #ifdef ECORE_XRENDER
1402 static Ecore_X_Window
1403 _ecore_x_window_argb_internal_new(Ecore_X_Window parent,
1412 XSetWindowAttributes attr;
1413 XWindowAttributes att;
1416 int nvi, i, scr = 0;
1417 XRenderPictFormat *fmt;
1422 parent = DefaultRootWindow(_ecore_x_disp);
1423 scr = DefaultScreen(_ecore_x_disp);
1427 /* ewww - round trip */
1428 XGetWindowAttributes(_ecore_x_disp, parent, &att);
1429 for (i = 0; i < ScreenCount(_ecore_x_disp); i++)
1431 if (att.screen == ScreenOfDisplay(_ecore_x_disp, i))
1441 vi_in.class = TrueColor;
1442 xvi = XGetVisualInfo(_ecore_x_disp,
1452 for (i = 0; i < nvi; i++)
1454 fmt = XRenderFindVisualFormat(_ecore_x_disp, xvi[i].visual);
1455 if ((fmt->type == PictTypeDirect) && (fmt->direct.alphaMask))
1457 vis = xvi[i].visual;
1463 attr.backing_store = NotUseful;
1464 attr.override_redirect = override;
1465 attr.colormap = XCreateColormap(_ecore_x_disp, parent,
1467 attr.border_pixel = 0;
1468 attr.background_pixmap = None;
1469 attr.bit_gravity = NorthWestGravity;
1470 attr.win_gravity = NorthWestGravity;
1471 attr.save_under = saveunder;
1472 attr.do_not_propagate_mask = NoEventMask;
1473 attr.event_mask = KeyPressMask |
1481 VisibilityChangeMask |
1482 StructureNotifyMask |
1484 PropertyChangeMask |
1486 win = XCreateWindow(_ecore_x_disp, parent,
1492 CWOverrideRedirect |
1502 XFreeColormap(_ecore_x_disp, attr.colormap);
1504 if (parent == DefaultRootWindow(_ecore_x_disp))
1505 ecore_x_window_defaults_set(win);
1508 } /* _ecore_x_window_argb_internal_new */
1510 #endif /* ifdef ECORE_XRENDER */
1513 ecore_x_window_argb_get(Ecore_X_Window win)
1515 #ifdef ECORE_XRENDER
1516 XWindowAttributes att;
1517 XRenderPictFormat *fmt;
1520 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
1523 fmt = XRenderFindVisualFormat(_ecore_x_disp, att.visual);
1527 if ((fmt->type == PictTypeDirect) && (fmt->direct.alphaMask))
1531 #else /* ifdef ECORE_XRENDER */
1533 #endif /* ifdef ECORE_XRENDER */
1534 } /* ecore_x_window_argb_get */
1537 * Creates a new window.
1538 * @param parent The parent window to use. If @p parent is @c 0, the root
1539 * window of the default display is used.
1540 * @param x X position.
1541 * @param y Y position.
1544 * @return The new window handle.
1545 * @ingroup Ecore_X_Window_Create_Group
1548 ecore_x_window_manager_argb_new(Ecore_X_Window parent,
1554 #ifdef ECORE_XRENDER
1555 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1556 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 1, 0);
1557 #else /* ifdef ECORE_XRENDER */
1559 #endif /* ifdef ECORE_XRENDER */
1560 } /* ecore_x_window_manager_argb_new */
1563 * Creates a new window.
1564 * @param parent The parent window to use. If @p parent is @c 0, the root
1565 * window of the default display is used.
1566 * @param x X position.
1567 * @param y Y position.
1570 * @return The new window handle.
1571 * @ingroup Ecore_X_Window_Create_Group
1574 ecore_x_window_argb_new(Ecore_X_Window parent, int x, int y, int w, int h)
1576 #ifdef ECORE_XRENDER
1577 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1578 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 0, 0);
1579 #else /* ifdef ECORE_XRENDER */
1581 #endif /* ifdef ECORE_XRENDER */
1582 } /* ecore_x_window_argb_new */
1585 * Creates a window with the override redirect attribute set to @c True.
1586 * @param parent The parent window to use. If @p parent is @c 0, the root
1587 * window of the default display is used.
1588 * @param x X position.
1589 * @param y Y position.
1592 * @return The new window handle.
1593 * @ingroup Ecore_X_Window_Create_Group
1596 ecore_x_window_override_argb_new(Ecore_X_Window parent,
1602 #ifdef ECORE_XRENDER
1603 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1604 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 1, 0);
1605 #else /* ifdef ECORE_XRENDER */
1607 #endif /* ifdef ECORE_XRENDER */
1608 } /* ecore_x_window_override_argb_new */