2 * ion/ioncore/xwindow.c
4 * Copyright (c) Tuomo Valkonen 1999-2008.
6 * See the included file LICENSE for details.
11 #include <libtu/minmax.h>
19 /*{{{ X window->region mapping */
22 WRegion *xwindow_region_of(Window win)
26 if(XFindContext(ioncore_g.dpy, win, ioncore_g.win_context,
34 WRegion *xwindow_region_of_t(Window win, const ClassDescr *descr)
36 WRegion *reg=xwindow_region_of(win);
41 if(!obj_is((Obj*)reg, descr))
54 Window create_xwindow(WRootWin *rw, Window par, const WRectangle *geom)
56 int w=maxof(1, geom->w);
57 int h=maxof(1, geom->h);
59 return XCreateSimpleWindow(ioncore_g.dpy, par, geom->x, geom->y, w, h,
60 0, 0, BlackPixel(ioncore_g.dpy, rw->xscr));
70 void xwindow_restack(Window win, Window other, int stack_mode)
76 wc.stack_mode=stack_mode;
82 XConfigureWindow(ioncore_g.dpy, win, wcmask, &wc);
92 void xwindow_do_set_focus(Window win)
94 XSetInputFocus(ioncore_g.dpy, win, RevertToParent, CurrentTime);
101 /*{{{ Pointer and cursors */
103 void xwindow_set_cursor(Window win, int cursor)
105 XDefineCursor(ioncore_g.dpy, win, ioncore_xcursor(cursor));
109 bool xwindow_pointer_pos(Window rel, int *px, int *py)
111 Window win=None, realroot=None;
114 return XQueryPointer(ioncore_g.dpy, rel, &realroot, &win,
115 &rx, &ry, px, py, &mask);
124 void xwindow_get_sizehints(Window win, XSizeHints *hints)
129 memset(hints, 0, sizeof(*hints));
130 XGetWMNormalHints(ioncore_g.dpy, win, hints, &supplied);
132 xsizehints_sanity_adjust(hints);