32 |
Atom wm_state, wm_change_state, wm_delete_window, wm_protocols; |
Atom wm_state, wm_change_state, wm_delete_window, wm_protocols; |
33 |
Atom motif_wm_hints; |
Atom motif_wm_hints; |
34 |
Atom win_hints, win_state, win_client_list, win_layer, win_workspace, |
Atom win_hints, win_state, win_client_list, win_layer, win_workspace, |
35 |
win_workspace_count, win_desktop_button_proxy, win_supporting_wm_check, |
win_workspace_count, win_desktop_button_proxy, win_supporting_wm_check, |
36 |
gnome_panel_desktop_area; |
gnome_panel_desktop_area; |
37 |
Atom net_atoms[NET_ATOM_COUNT]; |
Atom net_atoms[NET_ATOM_COUNT]; |
38 |
Display *dpy; |
Display *dpy; |
39 |
|
|
40 |
void |
void |
41 |
initHints (Display * d) |
initHints (Display * d) |
42 |
{ |
{ |
43 |
dpy = d; |
dpy = d; |
44 |
initICCCMHints (); |
initICCCMHints (); |
45 |
initMotifHints (); |
initMotifHints (); |
46 |
initGnomeHints (); |
initGnomeHints (); |
47 |
initNETHints (); |
initNETHints (); |
48 |
} |
} |
49 |
|
|
50 |
void |
void |
51 |
initICCCMHints () |
initICCCMHints () |
52 |
{ |
{ |
53 |
#ifdef DEBUG |
#ifdef DEBUG |
54 |
printf ("entering initICCCMHints\n"); |
printf ("entering initICCCMHints\n"); |
55 |
#endif |
#endif |
56 |
|
|
57 |
wm_state = XInternAtom (dpy, "WM_STATE", False); |
wm_state = XInternAtom (dpy, "WM_STATE", False); |
58 |
wm_change_state = XInternAtom (dpy, "WM_CHANGE_STATE", False); |
wm_change_state = XInternAtom (dpy, "WM_CHANGE_STATE", False); |
59 |
wm_delete_window = XInternAtom (dpy, "WM_DELETE_WINDOW", False); |
wm_delete_window = XInternAtom (dpy, "WM_DELETE_WINDOW", False); |
60 |
wm_protocols = XInternAtom (dpy, "WM_PROTOCOLS", False); |
wm_protocols = XInternAtom (dpy, "WM_PROTOCOLS", False); |
61 |
} |
} |
62 |
|
|
63 |
void |
void |
64 |
initNETHints () |
initNETHints () |
65 |
{ |
{ |
66 |
Window root; |
Window root; |
67 |
#ifdef DEBUG |
#ifdef DEBUG |
68 |
printf ("entering initNETHints\n"); |
printf ("entering initNETHints\n"); |
69 |
#endif |
#endif |
70 |
|
|
71 |
root = XDefaultRootWindow (dpy); |
root = XDefaultRootWindow (dpy); |
72 |
|
|
73 |
net_atoms[NET_CLIENT_LIST] = XInternAtom (dpy, "_NET_CLIENT_LIST", False); |
net_atoms[NET_CLIENT_LIST] = XInternAtom (dpy, "_NET_CLIENT_LIST", False); |
74 |
net_atoms[NET_CLIENT_LIST_STACKING] = |
net_atoms[NET_CLIENT_LIST_STACKING] = |
75 |
XInternAtom (dpy, "_NET_CLIENT_LIST_STACKING", False); |
XInternAtom (dpy, "_NET_CLIENT_LIST_STACKING", False); |
76 |
net_atoms[NET_WM_WINDOW_TYPE] = |
net_atoms[NET_WM_WINDOW_TYPE] = |
77 |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE", False); |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE", False); |
78 |
net_atoms[NET_WM_WINDOW_TYPE_DESKTOP] = |
net_atoms[NET_WM_WINDOW_TYPE_DESKTOP] = |
79 |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DESKTOP", False); |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DESKTOP", False); |
80 |
net_atoms[NET_WM_WINDOW_TYPE_DOCK] = |
net_atoms[NET_WM_WINDOW_TYPE_DOCK] = |
81 |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DOCK", False); |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DOCK", False); |
82 |
net_atoms[NET_WM_WINDOW_TYPE_TOOLBAR] = |
net_atoms[NET_WM_WINDOW_TYPE_TOOLBAR] = |
83 |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_TOOLBAR", False); |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_TOOLBAR", False); |
84 |
net_atoms[NET_WM_WINDOW_TYPE_MENU] = |
net_atoms[NET_WM_WINDOW_TYPE_MENU] = |
85 |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_MENU", False); |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_MENU", False); |
86 |
net_atoms[NET_WM_WINDOW_TYPE_UTILITY] = |
net_atoms[NET_WM_WINDOW_TYPE_UTILITY] = |
87 |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_UTILITY", False); |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_UTILITY", False); |
88 |
net_atoms[NET_WM_WINDOW_TYPE_SPLASH] = |
net_atoms[NET_WM_WINDOW_TYPE_SPLASH] = |
89 |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_SPLASH", False); |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_SPLASH", False); |
90 |
net_atoms[NET_WM_WINDOW_TYPE_DIALOG] = |
net_atoms[NET_WM_WINDOW_TYPE_DIALOG] = |
91 |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); |
92 |
net_atoms[NET_WM_WINDOW_TYPE_NORMAL] = |
net_atoms[NET_WM_WINDOW_TYPE_NORMAL] = |
93 |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_NORMAL", False); |
XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_NORMAL", False); |
94 |
net_atoms[NET_WM_STATE] = XInternAtom (dpy, "_NET_WM_STATE", False); |
net_atoms[NET_WM_STATE] = XInternAtom (dpy, "_NET_WM_STATE", False); |
95 |
net_atoms[NET_WM_STATE_MODAL] = |
net_atoms[NET_WM_STATE_MODAL] = |
96 |
XInternAtom (dpy, "_NET_WM_STATE_MODAL", False); |
XInternAtom (dpy, "_NET_WM_STATE_MODAL", False); |
97 |
net_atoms[NET_WM_STATE_STICKY] = |
net_atoms[NET_WM_STATE_STICKY] = |
98 |
XInternAtom (dpy, "_NET_WM_STATE_STICKY", False); |
XInternAtom (dpy, "_NET_WM_STATE_STICKY", False); |
99 |
net_atoms[NET_WM_STATE_MAXIMIZED_VERT] = |
net_atoms[NET_WM_STATE_MAXIMIZED_VERT] = |
100 |
XInternAtom (dpy, "_NET_WM_STATE_MAXIMIZED_VERT", False); |
XInternAtom (dpy, "_NET_WM_STATE_MAXIMIZED_VERT", False); |
101 |
net_atoms[NET_WM_STATE_MAXIMIZED_HORZ] = |
net_atoms[NET_WM_STATE_MAXIMIZED_HORZ] = |
102 |
XInternAtom (dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", False); |
XInternAtom (dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", False); |
103 |
net_atoms[NET_WM_STATE_SHADED] = |
net_atoms[NET_WM_STATE_SHADED] = |
104 |
XInternAtom (dpy, "_NET_WM_STATE_SHADED", False); |
XInternAtom (dpy, "_NET_WM_STATE_SHADED", False); |
105 |
net_atoms[NET_WM_STATE_SKIP_TASKBAR] = |
net_atoms[NET_WM_STATE_SKIP_TASKBAR] = |
106 |
XInternAtom (dpy, "_NET_WM_STATE_SKIP_TASKBAR", False); |
XInternAtom (dpy, "_NET_WM_STATE_SKIP_TASKBAR", False); |
107 |
net_atoms[NET_WM_STATE_SKIP_PAGER] = |
net_atoms[NET_WM_STATE_SKIP_PAGER] = |
108 |
XInternAtom (dpy, "_NET_WM_STATE_SKIP_PAGER", False); |
XInternAtom (dpy, "_NET_WM_STATE_SKIP_PAGER", False); |
109 |
net_atoms[NET_WM_STATE_HIDDEN] = |
net_atoms[NET_WM_STATE_HIDDEN] = |
110 |
XInternAtom (dpy, "_NET_WM_STATE_HIDDEN", False); |
XInternAtom (dpy, "_NET_WM_STATE_HIDDEN", False); |
111 |
net_atoms[NET_WM_STATE_FULLSCREEN] = |
net_atoms[NET_WM_STATE_FULLSCREEN] = |
112 |
XInternAtom (dpy, "_NET_WM_STATE_FULLSCREEN", False); |
XInternAtom (dpy, "_NET_WM_STATE_FULLSCREEN", False); |
113 |
net_atoms[NET_WM_NAME] = XInternAtom (dpy, "_NET_WM_NAME", False); |
net_atoms[NET_WM_NAME] = XInternAtom (dpy, "_NET_WM_NAME", False); |
114 |
net_atoms[NET_WM_DESKTOP] = XInternAtom (dpy, "_NET_WM_DESKTOP", False); |
net_atoms[NET_WM_DESKTOP] = XInternAtom (dpy, "_NET_WM_DESKTOP", False); |
115 |
net_atoms[NET_NUMBER_OF_DESKTOPS] = |
net_atoms[NET_NUMBER_OF_DESKTOPS] = |
116 |
XInternAtom (dpy, "_NET_NUMBER_OF_DESKTOPS", False); |
XInternAtom (dpy, "_NET_NUMBER_OF_DESKTOPS", False); |
117 |
net_atoms[NET_CURRENT_DESKTOP] = |
net_atoms[NET_CURRENT_DESKTOP] = |
118 |
XInternAtom (dpy, "_NET_CURRENT_DESKTOP", False); |
XInternAtom (dpy, "_NET_CURRENT_DESKTOP", False); |
119 |
net_atoms[NET_ACTIVE_WINDOW] = |
net_atoms[NET_ACTIVE_WINDOW] = |
120 |
XInternAtom (dpy, "_NET_ACTIVE_WINDOW", False); |
XInternAtom (dpy, "_NET_ACTIVE_WINDOW", False); |
121 |
net_atoms[NET_SUPPORTING_WM_CHECK] = |
net_atoms[NET_SUPPORTING_WM_CHECK] = |
122 |
XInternAtom (dpy, "_NET_SUPPORTING_WM_CHECK", False); |
XInternAtom (dpy, "_NET_SUPPORTING_WM_CHECK", False); |
123 |
net_atoms[NET_WORKAREA] = XInternAtom (dpy, "_NET_WORKAREA", False); |
net_atoms[NET_WORKAREA] = XInternAtom (dpy, "_NET_WORKAREA", False); |
124 |
net_atoms[NET_WM_WORKAREA] = XInternAtom (dpy, "_NET_WM_WORKAREA", False); |
net_atoms[NET_WM_WORKAREA] = XInternAtom (dpy, "_NET_WM_WORKAREA", False); |
125 |
net_atoms[NET_CLOSE_WINDOW] = XInternAtom (dpy, "_NET_CLOSE_WINDOW", False); |
net_atoms[NET_CLOSE_WINDOW] = XInternAtom (dpy, "_NET_CLOSE_WINDOW", False); |
126 |
XChangeProperty (dpy, root, XInternAtom (dpy, "_NET_SUPPORTED", False), |
XChangeProperty (dpy, root, XInternAtom (dpy, "_NET_SUPPORTED", False), |
127 |
XA_ATOM, 32, PropModeReplace, (unsigned char *) net_atoms, |
XA_ATOM, 32, PropModeReplace, (unsigned char *) net_atoms, |
128 |
NET_ATOM_COUNT); |
NET_ATOM_COUNT); |
129 |
} |
} |
130 |
|
|
131 |
void |
void |
132 |
initMotifHints () |
initMotifHints () |
133 |
{ |
{ |
134 |
#ifdef DEBUG |
#ifdef DEBUG |
135 |
printf ("entering initMotifHints\n"); |
printf ("entering initMotifHints\n"); |
136 |
#endif |
#endif |
137 |
|
|
138 |
motif_wm_hints = XInternAtom (dpy, "_MOTIF_WM_HINTS", False); |
motif_wm_hints = XInternAtom (dpy, "_MOTIF_WM_HINTS", False); |
139 |
} |
} |
140 |
|
|
141 |
void |
void |
142 |
initGnomeHints () |
initGnomeHints () |
143 |
{ |
{ |
144 |
Window root; |
Window root; |
145 |
|
|
146 |
#ifdef DEBUG |
#ifdef DEBUG |
147 |
printf ("entering initGnomeHints\n"); |
printf ("entering initGnomeHints\n"); |
148 |
#endif |
#endif |
149 |
|
|
150 |
root = XDefaultRootWindow (dpy); |
root = XDefaultRootWindow (dpy); |
151 |
win_hints = XInternAtom (dpy, "_WIN_HINTS", False); |
win_hints = XInternAtom (dpy, "_WIN_HINTS", False); |
152 |
win_state = XInternAtom (dpy, "_WIN_STATE", False); |
win_state = XInternAtom (dpy, "_WIN_STATE", False); |
153 |
win_client_list = XInternAtom (dpy, "_WIN_CLIENT_LIST", False); |
win_client_list = XInternAtom (dpy, "_WIN_CLIENT_LIST", False); |
154 |
win_layer = XInternAtom (dpy, "_WIN_LAYER", False); |
win_layer = XInternAtom (dpy, "_WIN_LAYER", False); |
155 |
win_workspace = XInternAtom (dpy, "_WIN_WORKSPACE", False); |
win_workspace = XInternAtom (dpy, "_WIN_WORKSPACE", False); |
156 |
win_workspace_count = XInternAtom (dpy, "_WIN_WORKSPACE_COUNT", False); |
win_workspace_count = XInternAtom (dpy, "_WIN_WORKSPACE_COUNT", False); |
157 |
win_desktop_button_proxy = |
win_desktop_button_proxy = |
158 |
XInternAtom (dpy, "_WIN_DESKTOP_BUTTON_PROXY", False); |
XInternAtom (dpy, "_WIN_DESKTOP_BUTTON_PROXY", False); |
159 |
win_supporting_wm_check = |
win_supporting_wm_check = |
160 |
XInternAtom (dpy, "_WIN_SUPPORTING_WM_CHECK", False); |
XInternAtom (dpy, "_WIN_SUPPORTING_WM_CHECK", False); |
161 |
gnome_panel_desktop_area = |
gnome_panel_desktop_area = |
162 |
XInternAtom (dpy, "GNOME_PANEL_DESKTOP_AREA", False); |
XInternAtom (dpy, "GNOME_PANEL_DESKTOP_AREA", False); |
163 |
} |
} |
164 |
|
|
165 |
long |
long |
166 |
getWMState (Window w) |
getWMState (Window w) |
167 |
{ |
{ |
168 |
unsigned long *data = NULL, state = WithdrawnState; |
unsigned long *data = NULL, state = WithdrawnState; |
169 |
|
|
170 |
#ifdef DEBUG |
#ifdef DEBUG |
171 |
printf ("entering getWmState\n"); |
printf ("entering getWmState\n"); |
172 |
#endif |
#endif |
173 |
|
|
174 |
data = getPropData (w, wm_state, wm_state, NULL); |
data = getPropData (w, wm_state, wm_state, NULL); |
175 |
if (data) |
if (data) |
176 |
{ |
{ |
177 |
state = *data; |
state = *data; |
178 |
XFree (data); |
XFree (data); |
179 |
} |
} |
180 |
return state; |
return state; |
181 |
} |
} |
182 |
|
|
183 |
void |
void |
184 |
setWMState (Window w, long state) |
setWMState (Window w, long state) |
185 |
{ |
{ |
186 |
CARD32 data[2]; |
CARD32 data[2]; |
187 |
|
|
188 |
#ifdef DEBUG |
#ifdef DEBUG |
189 |
printf ("entering setWmState\n"); |
printf ("entering setWmState\n"); |
190 |
#endif |
#endif |
191 |
|
|
192 |
data[0] = state; |
data[0] = state; |
193 |
data[1] = None; |
data[1] = None; |
194 |
|
|
195 |
XChangeProperty (dpy, w, wm_state, wm_state, 32, PropModeReplace, |
XChangeProperty (dpy, w, wm_state, wm_state, 32, PropModeReplace, |
196 |
(unsigned char *) data, 2); |
(unsigned char *) data, 2); |
197 |
} |
} |
198 |
|
|
199 |
PropMwmHints * |
PropMwmHints * |
200 |
getMotifHints (Window w) |
getMotifHints (Window w) |
201 |
{ |
{ |
202 |
#ifdef DEBUG |
#ifdef DEBUG |
203 |
printf ("entering getMotifHints\n"); |
printf ("entering getMotifHints\n"); |
204 |
#endif |
#endif |
205 |
|
|
206 |
return getPropData (w, motif_wm_hints, motif_wm_hints, NULL); |
return getPropData (w, motif_wm_hints, motif_wm_hints, NULL); |
207 |
} |
} |
208 |
|
|
209 |
int |
int |
210 |
getGnomeHint (Window w, Atom a, long *value) |
getGnomeHint (Window w, Atom a, long *value) |
211 |
{ |
{ |
212 |
int success = False; |
int success = False; |
213 |
long *data = NULL; |
long *data = NULL; |
214 |
|
|
215 |
#ifdef DEBUG |
#ifdef DEBUG |
216 |
printf ("entering getGnomeHint\n"); |
printf ("entering getGnomeHint\n"); |
217 |
#endif |
#endif |
218 |
|
|
219 |
if (a == win_layer) |
if (a == win_layer) |
220 |
*value = WIN_LAYER_NORMAL; |
*value = WIN_LAYER_NORMAL; |
221 |
else |
else |
222 |
*value = 0; |
*value = 0; |
223 |
|
|
224 |
data = getPropData (w, a, XA_CARDINAL, NULL); |
data = getPropData (w, a, XA_CARDINAL, NULL); |
225 |
if (data) |
if (data) |
226 |
{ |
{ |
227 |
*value = *data; |
*value = *data; |
228 |
success = True; |
success = True; |
229 |
XFree (data); |
XFree (data); |
230 |
} |
} |
231 |
return success; |
return success; |
232 |
} |
} |
233 |
|
|
234 |
void |
void |
235 |
setGnomeHint (Window w, Atom a, long value) |
setGnomeHint (Window w, Atom a, long value) |
236 |
{ |
{ |
237 |
#ifdef DEBUG |
#ifdef DEBUG |
238 |
printf ("entering setGnomeHint\n"); |
printf ("entering setGnomeHint\n"); |
239 |
#endif |
#endif |
240 |
|
|
241 |
XChangeProperty (dpy, w, a, XA_CARDINAL, 32, PropModeReplace, |
XChangeProperty (dpy, w, a, XA_CARDINAL, 32, PropModeReplace, |
242 |
(unsigned char *) &value, 1); |
(unsigned char *) &value, 1); |
243 |
} |
} |
244 |
|
|
245 |
void |
void |
246 |
setSupportingWmCheck (Window w, Window w2) |
setSupportingWmCheck (Window w, Window w2) |
247 |
{ |
{ |
248 |
#ifdef DEBUG |
#ifdef DEBUG |
249 |
printf ("entering setSupportingWmCheck\n"); |
printf ("entering setSupportingWmCheck\n"); |
250 |
#endif |
#endif |
251 |
|
|
252 |
XChangeProperty (dpy, w, net_atoms[NET_SUPPORTING_WM_CHECK], XA_WINDOW, 32, |
XChangeProperty (dpy, w, net_atoms[NET_SUPPORTING_WM_CHECK], XA_WINDOW, 32, |
253 |
PropModeReplace, (unsigned char *) &w2, 1); |
PropModeReplace, (unsigned char *) &w2, 1); |
254 |
} |
} |
255 |
|
|
256 |
void |
void |
257 |
getEWMHState (Window w, long *value) |
getEWMHState (Window w, long *value) |
258 |
{ |
{ |
259 |
unsigned long *data; |
unsigned long *data; |
260 |
unsigned long items = 0; |
unsigned long items = 0; |
261 |
unsigned long i; |
unsigned long i; |
262 |
|
|
263 |
data = getPropData (w, net_atoms[NET_WM_STATE], XA_ATOM, &items); |
data = getPropData (w, net_atoms[NET_WM_STATE], XA_ATOM, &items); |
264 |
if (data) |
if (data) |
265 |
{ |
{ |
266 |
for (i = 0; i < items; i++) |
for (i = 0; i < items; i++) |
267 |
{ |
{ |
268 |
if (equals |
if (equals |
269 |
(XGetAtomName (dpy, data[i]), |
(XGetAtomName (dpy, data[i]), |
270 |
XGetAtomName (dpy, net_atoms[NET_WM_STATE_STICKY]))) |
XGetAtomName (dpy, net_atoms[NET_WM_STATE_STICKY]))) |
271 |
*value |= WIN_STATE_STICKY; |
*value |= WIN_STATE_STICKY; |
272 |
} |
} |
273 |
XFree (data); |
XFree (data); |
274 |
} |
} |
275 |
} |
} |
276 |
|
|
277 |
void |
void |
278 |
getGnomeDesktopMargins (CARD32 * margins) |
getGnomeDesktopMargins (CARD32 * margins) |
279 |
{ |
{ |
280 |
unsigned long items_read; |
unsigned long items_read; |
281 |
CARD32 *data = NULL; |
CARD32 *data = NULL; |
282 |
|
|
283 |
#ifdef DEBUG |
#ifdef DEBUG |
284 |
printf ("entering getGnomeDesktopMargins\n"); |
printf ("entering getGnomeDesktopMargins\n"); |
285 |
#endif |
#endif |
286 |
|
|
287 |
data = |
data = |
288 |
getPropData (XDefaultRootWindow (dpy), gnome_panel_desktop_area, |
getPropData (XDefaultRootWindow (dpy), gnome_panel_desktop_area, |
289 |
XA_CARDINAL, &items_read); |
XA_CARDINAL, &items_read); |
290 |
if (data && items_read >= 4) |
if (data && items_read >= 4) |
291 |
{ |
{ |
292 |
margins[0] = data[0]; |
margins[0] = data[0]; |
293 |
margins[1] = data[1]; |
margins[1] = data[1]; |
294 |
margins[2] = data[2]; |
margins[2] = data[2]; |
295 |
margins[3] = data[3]; |
margins[3] = data[3]; |
296 |
XFree (data); |
XFree (data); |
297 |
} |
} |
298 |
else |
else |
299 |
{ |
{ |
300 |
margins[0] = 0; |
margins[0] = 0; |
301 |
margins[1] = 0; |
margins[1] = 0; |
302 |
margins[2] = 0; |
margins[2] = 0; |
303 |
margins[3] = 0; |
margins[3] = 0; |
304 |
} |
} |
305 |
} |
} |
306 |
|
|
307 |
void |
void |
308 |
setNetWorkarea (CARD32 * margins, int workspaces) |
setNetWorkarea (CARD32 * margins, int workspaces) |
309 |
{ |
{ |
310 |
struct workarea |
struct workarea |
311 |
{ |
{ |
312 |
CARD32 left, top, right, bottom; |
CARD32 left, top, right, bottom; |
313 |
} |
} |
314 |
*workarea; |
*workarea; |
315 |
int i; |
int i; |
316 |
|
|
317 |
if (workspaces <= 0) |
if (workspaces <= 0) |
318 |
return; |
return; |
319 |
|
|
320 |
workarea = xcalloc (workspaces, sizeof (struct workarea)); |
workarea = xcalloc (workspaces, sizeof (struct workarea)); |
321 |
|
|
322 |
for (i = 0; i < workspaces; i++) |
for (i = 0; i < workspaces; i++) |
323 |
{ |
{ |
324 |
workarea[i].left = margins[0]; |
workarea[i].left = margins[0]; |
325 |
workarea[i].top = margins[1]; |
workarea[i].top = margins[1]; |
326 |
workarea[i].right = |
workarea[i].right = |
327 |
XDisplayWidth (dpy, XDefaultScreen (dpy)) - margins[1]; |
XDisplayWidth (dpy, XDefaultScreen (dpy)) - margins[1]; |
328 |
workarea[i].bottom = |
workarea[i].bottom = |
329 |
XDisplayHeight (dpy, XDefaultScreen (dpy)) - margins[3]; |
XDisplayHeight (dpy, XDefaultScreen (dpy)) - margins[3]; |
330 |
} |
} |
331 |
|
|
332 |
XChangeProperty (dpy, XDefaultRootWindow (dpy), |
XChangeProperty (dpy, XDefaultRootWindow (dpy), |
333 |
net_atoms[NET_WORKAREA], XA_CARDINAL, 32, |
net_atoms[NET_WORKAREA], XA_CARDINAL, 32, |
334 |
PropModeReplace, (unsigned char *) workarea, |
PropModeReplace, (unsigned char *) workarea, |
335 |
4 * workspaces); |
4 * workspaces); |
336 |
XChangeProperty (dpy, XDefaultRootWindow (dpy), net_atoms[NET_WM_WORKAREA], |
XChangeProperty (dpy, XDefaultRootWindow (dpy), net_atoms[NET_WM_WORKAREA], |
337 |
XA_CARDINAL, 32, PropModeReplace, |
XA_CARDINAL, 32, PropModeReplace, |
338 |
(unsigned char *) workarea, 4 * workspaces); |
(unsigned char *) workarea, 4 * workspaces); |
339 |
free (workarea); |
free (workarea); |
340 |
} |
} |
341 |
|
|
342 |
int |
int |
343 |
typeDesktop (Window w) |
typeDesktop (Window w) |
344 |
{ |
{ |
345 |
return typeEWMH (w, "_NET_WM_WINDOW_TYPE_DESKTOP"); |
return typeEWMH (w, "_NET_WM_WINDOW_TYPE_DESKTOP"); |
346 |
} |
} |
347 |
|
|
348 |
int |
int |
349 |
typeDock (Window w) |
typeDock (Window w) |
350 |
{ |
{ |
351 |
return typeEWMH (w, "_NET_WM_WINDOW_TYPE_DOCK"); |
return typeEWMH (w, "_NET_WM_WINDOW_TYPE_DOCK"); |
352 |
} |
} |
353 |
|
|
354 |
int |
int |
355 |
typeEWMH (Window w, char *type) |
typeEWMH (Window w, char *type) |
356 |
{ |
{ |
357 |
unsigned long *data; |
unsigned long *data; |
358 |
unsigned long items = 0; |
unsigned long items = 0; |
359 |
int ret = 0; |
int ret = 0; |
360 |
|
|
361 |
#ifdef DEBUG |
#ifdef DEBUG |
362 |
printf ("entering typeEWMH\n"); |
printf ("entering typeEWMH\n"); |
363 |
#endif |
#endif |
364 |
|
|
365 |
data = getPropData (w, net_atoms[NET_WM_WINDOW_TYPE], XA_ATOM, &items); |
data = getPropData (w, net_atoms[NET_WM_WINDOW_TYPE], XA_ATOM, &items); |
366 |
if (data) |
if (data) |
367 |
{ |
{ |
368 |
char *name; |
char *name; |
369 |
name = XGetAtomName (dpy, *data); |
name = XGetAtomName (dpy, *data); |
370 |
#ifdef DEBUG |
#ifdef DEBUG |
371 |
printf ("%s\n", name); |
printf ("%s\n", name); |
372 |
#endif |
#endif |
373 |
ret = equals (name, type); |
ret = equals (name, type); |
374 |
XFree (data); |
XFree (data); |
375 |
} |
} |
376 |
|
|
377 |
return ret; |
return ret; |
378 |
} |
} |
379 |
|
|
380 |
void * |
void * |
381 |
getPropData (Window w, Atom prop, Atom type, unsigned long *items_ret) |
getPropData (Window w, Atom prop, Atom type, unsigned long *items_ret) |
382 |
{ |
{ |
383 |
Atom type_ret; |
Atom type_ret; |
384 |
int format_ret; |
int format_ret; |
385 |
unsigned long after_ret; |
unsigned long after_ret; |
386 |
unsigned char *prop_data; |
unsigned char *prop_data; |
387 |
|
|
388 |
#ifdef DEBUG |
#ifdef DEBUG |
389 |
printf ("entering getPropData\n"); |
printf ("entering getPropData\n"); |
390 |
#endif |
#endif |
391 |
if (items_ret == NULL) |
if (items_ret == NULL) |
392 |
items_ret = (unsigned long *) xmalloc (sizeof (unsigned long)); |
items_ret = (unsigned long *) xmalloc (sizeof (unsigned long)); |
393 |
|
|
394 |
prop_data = 0; |
prop_data = 0; |
395 |
|
|
396 |
XGetWindowProperty (dpy, w, prop, 0, 0x7fffffff, False, |
XGetWindowProperty (dpy, w, prop, 0, 0x7fffffff, False, |
397 |
type, &type_ret, &format_ret, items_ret, |
type, &type_ret, &format_ret, items_ret, |
398 |
&after_ret, &prop_data); |
&after_ret, &prop_data); |
399 |
|
|
400 |
if (prop_data && *items_ret) |
if (prop_data && *items_ret) |
401 |
return prop_data; |
return prop_data; |
402 |
else |
else |
403 |
return NULL; |
return NULL; |
404 |
} |
} |
405 |
|
|
406 |
void |
void |
407 |
setFocusHint (Window w) |
setFocusHint (Window w) |
408 |
{ |
{ |
409 |
#ifdef DEBUG |
#ifdef DEBUG |
410 |
printf ("entering setFocusHint\n"); |
printf ("entering setFocusHint\n"); |
411 |
#endif |
#endif |
412 |
|
|
413 |
XChangeProperty (dpy, XDefaultRootWindow (dpy), |
XChangeProperty (dpy, XDefaultRootWindow (dpy), |
414 |
net_atoms[NET_ACTIVE_WINDOW], XA_WINDOW, 32, |
net_atoms[NET_ACTIVE_WINDOW], XA_WINDOW, 32, |
415 |
PropModeReplace, (unsigned char *) &w, 1); |
PropModeReplace, (unsigned char *) &w, 1); |
416 |
} |
} |
417 |
|
|
418 |
int |
int |
419 |
equals (char *left, char *right) |
equals (char *left, char *right) |
420 |
{ |
{ |
421 |
if (left && right && (strcmp (left, right) == 0)) |
if (left && right && (strcmp (left, right) == 0)) |
422 |
return 1; |
return 1; |
423 |
else |
else |
424 |
return 0; |
return 0; |
425 |
} |
} |
426 |
|
|
427 |
/**This must remain at the end of the file.********** |
/**This must remain at the end of the file.********** |
428 |
* vim600:set sw=2 ts=8: * |
* vim600:set sw=2 ts=2: * |
429 |
* vim600:set cindent cinoptions={1s,>2s,^-1s,n-1s: * |
* vim600:set cindent cinoptions={1s,>2s,^-1s,n-1s: * |
430 |
* vim600:set foldmethod=marker: * |
* vim600:set foldmethod=marker: * |
431 |
****************************************************/ |
****************************************************/ |