]> git.decadent.org.uk Git - ion3.git/blob - ioncore/xwindow.c
Update cfg_kludge_flash for Flash 10
[ion3.git] / ioncore / xwindow.c
1 /*
2  * ion/ioncore/xwindow.c
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2009. 
5  *
6  * See the included file LICENSE for details.
7  */
8
9 #include <string.h>
10
11 #include <libtu/minmax.h>
12 #include "common.h"
13 #include "global.h"
14 #include "xwindow.h"
15 #include "cursor.h"
16 #include "sizehint.h"
17
18
19 /*{{{ X window->region mapping */
20
21
22 WRegion *xwindow_region_of(Window win)
23 {
24     WRegion *reg;
25     
26     if(XFindContext(ioncore_g.dpy, win, ioncore_g.win_context,
27                     (XPointer*)&reg)!=0)
28         return NULL;
29     
30     return reg;
31 }
32
33
34 WRegion *xwindow_region_of_t(Window win, const ClassDescr *descr)
35 {
36     WRegion *reg=xwindow_region_of(win);
37     
38     if(reg==NULL)
39         return NULL;
40     
41     if(!obj_is((Obj*)reg, descr))
42         return NULL;
43     
44     return reg;
45 }
46
47
48 /*}}}*/
49
50
51 /*{{{ Create */
52
53
54 Window create_xwindow(WRootWin *rw, Window par, const WRectangle *geom)
55 {
56     int w=maxof(1, geom->w);
57     int h=maxof(1, geom->h);
58     
59     return XCreateSimpleWindow(ioncore_g.dpy, par, geom->x, geom->y, w, h,
60                                0, 0, BlackPixel(ioncore_g.dpy, rw->xscr));
61 }
62
63
64 /*}}}*/
65
66
67 /*{{{ Restack */
68
69
70 void xwindow_restack(Window win, Window other, int stack_mode)
71 {
72     XWindowChanges wc;
73     int wcmask;
74     
75     wcmask=CWStackMode;
76     wc.stack_mode=stack_mode;
77     if(other!=None){
78         wc.sibling=other;
79         wcmask|=CWSibling;
80     }
81
82     XConfigureWindow(ioncore_g.dpy, win, wcmask, &wc);
83 }
84
85
86 /*}}}*/
87
88
89 /*{{{ Focus */
90
91
92 void xwindow_do_set_focus(Window win)
93 {
94     XSetInputFocus(ioncore_g.dpy, win, RevertToParent, CurrentTime);
95 }
96
97
98 /*}}}*/
99
100
101 /*{{{ Pointer and cursors */
102
103 void xwindow_set_cursor(Window win, int cursor)
104 {
105     XDefineCursor(ioncore_g.dpy, win, ioncore_xcursor(cursor));
106 }
107
108
109 bool xwindow_pointer_pos(Window rel, int *px, int *py)
110 {
111     Window win=None, realroot=None;
112     int rx=0, ry=0;
113     uint mask=0;
114     return XQueryPointer(ioncore_g.dpy, rel, &realroot, &win,
115                          &rx, &ry, px, py, &mask);
116 }
117
118 /*}}}*/
119
120
121 /*{{{ Size hints */
122
123
124 void xwindow_get_sizehints(Window win, XSizeHints *hints)
125 {
126     int minh, minw;
127     long supplied=0;
128     
129     memset(hints, 0, sizeof(*hints));
130     XGetWMNormalHints(ioncore_g.dpy, win, hints, &supplied);
131     
132     xsizehints_sanity_adjust(hints);
133 }
134
135
136 /*}}}*/
137