2 * ion/ioncore/xwindow.c
4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
14 #include <libtu/minmax.h>
22 /*{{{ X window->region mapping */
25 WRegion *xwindow_region_of(Window win)
29 if(XFindContext(ioncore_g.dpy, win, ioncore_g.win_context,
37 WRegion *xwindow_region_of_t(Window win, const ClassDescr *descr)
39 WRegion *reg=xwindow_region_of(win);
44 if(!obj_is((Obj*)reg, descr))
57 Window create_xwindow(WRootWin *rw, Window par, const WRectangle *geom)
59 int w=maxof(1, geom->w);
60 int h=maxof(1, geom->h);
62 return XCreateSimpleWindow(ioncore_g.dpy, par, geom->x, geom->y, w, h,
63 0, 0, BlackPixel(ioncore_g.dpy, rw->xscr));
73 void xwindow_restack(Window win, Window other, int stack_mode)
79 wc.stack_mode=stack_mode;
85 XConfigureWindow(ioncore_g.dpy, win, wcmask, &wc);
95 void xwindow_do_set_focus(Window win)
97 XSetInputFocus(ioncore_g.dpy, win, RevertToParent, CurrentTime);
104 /*{{{ Pointer and cursors */
106 void xwindow_set_cursor(Window win, int cursor)
108 XDefineCursor(ioncore_g.dpy, win, ioncore_xcursor(cursor));
112 bool xwindow_pointer_pos(Window rel, int *px, int *py)
114 Window win=None, realroot=None;
117 return XQueryPointer(ioncore_g.dpy, rel, &realroot, &win,
118 &rx, &ry, px, py, &mask);
127 void xwindow_get_sizehints(Window win, XSizeHints *hints)
132 memset(hints, 0, sizeof(*hints));
133 XGetWMNormalHints(ioncore_g.dpy, win, hints, &supplied);
135 xsizehints_sanity_adjust(hints);