2 * ion/ioncore/xwindow.c
4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
11 #include <libtu/minmax.h>
13 #include <ioncore/property.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
, const char *name
)
59 int w
=maxof(1, geom
->w
);
60 int h
=maxof(1, geom
->h
);
64 window
= XCreateSimpleWindow(ioncore_g
.dpy
, par
, geom
->x
, geom
->y
, w
, h
,
65 0, 0, BlackPixel(ioncore_g
.dpy
, rw
->xscr
));
67 xwindow_set_text_property(window
, XA_WM_NAME
, p
, 1);
79 void xwindow_restack(Window win
, Window other
, int stack_mode
)
85 wc
.stack_mode
=stack_mode
;
91 XConfigureWindow(ioncore_g
.dpy
, win
, wcmask
, &wc
);
101 void xwindow_do_set_focus(Window win
)
103 XSetInputFocus(ioncore_g
.dpy
, win
, RevertToParent
, CurrentTime
);
110 /*{{{ Pointer and cursors */
112 void xwindow_set_cursor(Window win
, int cursor
)
114 XDefineCursor(ioncore_g
.dpy
, win
, ioncore_xcursor(cursor
));
118 bool xwindow_pointer_pos(Window rel
, int *px
, int *py
)
120 Window win
=None
, realroot
=None
;
123 return XQueryPointer(ioncore_g
.dpy
, rel
, &realroot
, &win
,
124 &rx
, &ry
, px
, py
, &mask
);
133 int xwindow_get_sizehints(Window win
, XSizeHints
*hints
)
137 if (XGetWMNormalHints(ioncore_g
.dpy
, win
, hints
, &supplied
)!=0){
138 xsizehints_sanity_adjust(hints
);
141 memset(hints
, 0, sizeof(*hints
));