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_ABOVE] = |
net_atoms[NET_WM_STATE_ABOVE] = |
112 |
XInternAtom (dpy, "_NET_WM_STATE_ABOVE", False); |
XInternAtom (dpy, "_NET_WM_STATE_ABOVE", 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 |
net_atoms[NET_WM_STRUT] = XInternAtom (dpy, "_NET_WM_STRUT", False); |
net_atoms[NET_WM_STRUT] = XInternAtom (dpy, "_NET_WM_STRUT", False); |
127 |
XChangeProperty (dpy, root, XInternAtom (dpy, "_NET_SUPPORTED", False), |
XChangeProperty (dpy, root, XInternAtom (dpy, "_NET_SUPPORTED", False), |
128 |
XA_ATOM, 32, PropModeReplace, (unsigned char *) net_atoms, |
XA_ATOM, 32, PropModeReplace, (unsigned char *) net_atoms, |
129 |
NET_ATOM_COUNT); |
NET_ATOM_COUNT); |
130 |
} |
} |
131 |
|
|
132 |
void |
void |
133 |
initMotifHints () |
initMotifHints () |
134 |
{ |
{ |
135 |
#ifdef DEBUG |
#ifdef DEBUG |
136 |
printf ("entering initMotifHints\n"); |
printf ("entering initMotifHints\n"); |
137 |
#endif |
#endif |
138 |
|
|
139 |
motif_wm_hints = XInternAtom (dpy, "_MOTIF_WM_HINTS", False); |
motif_wm_hints = XInternAtom (dpy, "_MOTIF_WM_HINTS", False); |
140 |
} |
} |
141 |
|
|
142 |
void |
void |
143 |
initGnomeHints () |
initGnomeHints () |
144 |
{ |
{ |
145 |
Window root; |
Window root; |
146 |
|
|
147 |
#ifdef DEBUG |
#ifdef DEBUG |
148 |
printf ("entering initGnomeHints\n"); |
printf ("entering initGnomeHints\n"); |
149 |
#endif |
#endif |
150 |
|
|
151 |
root = XDefaultRootWindow (dpy); |
root = XDefaultRootWindow (dpy); |
152 |
win_hints = XInternAtom (dpy, "_WIN_HINTS", False); |
win_hints = XInternAtom (dpy, "_WIN_HINTS", False); |
153 |
win_state = XInternAtom (dpy, "_WIN_STATE", False); |
win_state = XInternAtom (dpy, "_WIN_STATE", False); |
154 |
win_client_list = XInternAtom (dpy, "_WIN_CLIENT_LIST", False); |
win_client_list = XInternAtom (dpy, "_WIN_CLIENT_LIST", False); |
155 |
win_layer = XInternAtom (dpy, "_WIN_LAYER", False); |
win_layer = XInternAtom (dpy, "_WIN_LAYER", False); |
156 |
win_workspace = XInternAtom (dpy, "_WIN_WORKSPACE", False); |
win_workspace = XInternAtom (dpy, "_WIN_WORKSPACE", False); |
157 |
win_workspace_count = XInternAtom (dpy, "_WIN_WORKSPACE_COUNT", False); |
win_workspace_count = XInternAtom (dpy, "_WIN_WORKSPACE_COUNT", False); |
158 |
win_desktop_button_proxy = |
win_desktop_button_proxy = |
159 |
XInternAtom (dpy, "_WIN_DESKTOP_BUTTON_PROXY", False); |
XInternAtom (dpy, "_WIN_DESKTOP_BUTTON_PROXY", False); |
160 |
win_supporting_wm_check = |
win_supporting_wm_check = |
161 |
XInternAtom (dpy, "_WIN_SUPPORTING_WM_CHECK", False); |
XInternAtom (dpy, "_WIN_SUPPORTING_WM_CHECK", False); |
162 |
gnome_panel_desktop_area = |
gnome_panel_desktop_area = |
163 |
XInternAtom (dpy, "GNOME_PANEL_DESKTOP_AREA", False); |
XInternAtom (dpy, "GNOME_PANEL_DESKTOP_AREA", False); |
164 |
} |
} |
165 |
|
|
166 |
long |
long |
167 |
getWMState (Window w) |
getWMState (Window w) |
168 |
{ |
{ |
169 |
unsigned long *data = NULL, state = WithdrawnState; |
unsigned long *data = NULL, state = WithdrawnState; |
170 |
|
|
171 |
#ifdef DEBUG |
#ifdef DEBUG |
172 |
printf ("entering getWmState\n"); |
printf ("entering getWmState\n"); |
173 |
#endif |
#endif |
174 |
|
|
175 |
data = getPropData (w, wm_state, wm_state, NULL); |
data = getPropData (w, wm_state, wm_state, NULL); |
176 |
if (data) |
if (data) |
177 |
{ |
{ |
178 |
state = *data; |
state = *data; |
179 |
XFree (data); |
XFree (data); |
180 |
} |
} |
181 |
return state; |
return state; |
182 |
} |
} |
183 |
|
|
184 |
void |
void |
185 |
setWMState (Window w, long state) |
setWMState (Window w, long state) |
186 |
{ |
{ |
187 |
CARD32 data[2]; |
CARD32 data[2]; |
188 |
|
|
189 |
#ifdef DEBUG |
#ifdef DEBUG |
190 |
printf ("entering setWmState\n"); |
printf ("entering setWmState\n"); |
191 |
#endif |
#endif |
192 |
|
|
193 |
data[0] = state; |
data[0] = state; |
194 |
data[1] = None; |
data[1] = None; |
195 |
|
|
196 |
XChangeProperty (dpy, w, wm_state, wm_state, 32, PropModeReplace, |
XChangeProperty (dpy, w, wm_state, wm_state, 32, PropModeReplace, |
197 |
(unsigned char *) data, 2); |
(unsigned char *) data, 2); |
198 |
} |
} |
199 |
|
|
200 |
PropMwmHints * |
PropMwmHints * |
201 |
getMotifHints (Window w) |
getMotifHints (Window w) |
202 |
{ |
{ |
203 |
#ifdef DEBUG |
#ifdef DEBUG |
204 |
printf ("entering getMotifHints\n"); |
printf ("entering getMotifHints\n"); |
205 |
#endif |
#endif |
206 |
|
|
207 |
return getPropData (w, motif_wm_hints, motif_wm_hints, NULL); |
return getPropData (w, motif_wm_hints, motif_wm_hints, NULL); |
208 |
} |
} |
209 |
|
|
210 |
int |
int |
211 |
getGnomeHint (Window w, Atom a, long *value) |
getGnomeHint (Window w, Atom a, long *value) |
212 |
{ |
{ |
213 |
int success = False; |
int success = False; |
214 |
long *data = NULL; |
long *data = NULL; |
215 |
|
|
216 |
#ifdef DEBUG |
#ifdef DEBUG |
217 |
printf ("entering getGnomeHint\n"); |
printf ("entering getGnomeHint\n"); |
218 |
#endif |
#endif |
219 |
|
|
220 |
if (a == win_layer) |
if (a == win_layer) |
221 |
*value = WIN_LAYER_NORMAL; |
*value = WIN_LAYER_NORMAL; |
222 |
else |
else |
223 |
*value = 0; |
*value = 0; |
224 |
|
|
225 |
data = getPropData (w, a, XA_CARDINAL, NULL); |
data = getPropData (w, a, XA_CARDINAL, NULL); |
226 |
if (data) |
if (data) |
227 |
{ |
{ |
228 |
*value = *data; |
*value = *data; |
229 |
success = True; |
success = True; |
230 |
XFree (data); |
XFree (data); |
231 |
} |
} |
232 |
return success; |
return success; |
233 |
} |
} |
234 |
|
|
235 |
void |
void |
236 |
setGnomeHint (Window w, Atom a, long value) |
setGnomeHint (Window w, Atom a, long value) |
237 |
{ |
{ |
238 |
#ifdef DEBUG |
#ifdef DEBUG |
239 |
printf ("entering setGnomeHint\n"); |
printf ("entering setGnomeHint\n"); |
240 |
#endif |
#endif |
241 |
|
|
242 |
XChangeProperty (dpy, w, a, XA_CARDINAL, 32, PropModeReplace, |
XChangeProperty (dpy, w, a, XA_CARDINAL, 32, PropModeReplace, |
243 |
(unsigned char *) &value, 1); |
(unsigned char *) &value, 1); |
244 |
} |
} |
245 |
|
|
246 |
void |
void |
247 |
setNetWmName (Window w, Atom a, char *value) |
setNetWmName (Window w, Atom a, char *value) |
248 |
{ |
{ |
249 |
#ifdef DEBUG |
#ifdef DEBUG |
250 |
printf ("entering setNetWmName\n"); |
printf ("entering setNetWmName\n"); |
251 |
#endif |
#endif |
252 |
|
|
253 |
XChangeProperty (dpy, w, a, XA_STRING, 8, PropModeReplace, |
XChangeProperty (dpy, w, a, XA_STRING, 8, PropModeReplace, |
254 |
(unsigned char *) value, strlen (value)); |
(unsigned char *) value, strlen (value)); |
255 |
} |
} |
256 |
|
|
257 |
void |
void |
258 |
setSupportingWmCheck (Window w, Window w2) |
setSupportingWmCheck (Window w, Window w2) |
259 |
{ |
{ |
260 |
#ifdef DEBUG |
#ifdef DEBUG |
261 |
printf ("entering setSupportingWmCheck\n"); |
printf ("entering setSupportingWmCheck\n"); |
262 |
#endif |
#endif |
263 |
|
|
264 |
XChangeProperty (dpy, w, net_atoms[NET_SUPPORTING_WM_CHECK], XA_WINDOW, 32, |
XChangeProperty (dpy, w, net_atoms[NET_SUPPORTING_WM_CHECK], XA_WINDOW, 32, |
265 |
PropModeReplace, (unsigned char *) &w2, 1); |
PropModeReplace, (unsigned char *) &w2, 1); |
266 |
} |
} |
267 |
|
|
268 |
void |
void |
269 |
getEWMHState (Window w, long *value) |
getEWMHState (Window w, long *value) |
270 |
{ |
{ |
271 |
unsigned long *data; |
unsigned long *data; |
272 |
unsigned long items = 0; |
unsigned long items = 0; |
273 |
unsigned long i; |
unsigned long i; |
274 |
|
|
275 |
data = getPropData (w, net_atoms[NET_WM_STATE], XA_ATOM, &items); |
data = getPropData (w, net_atoms[NET_WM_STATE], XA_ATOM, &items); |
276 |
if (data) |
if (data) |
277 |
{ |
{ |
278 |
for (i = 0; i < items; i++) |
for (i = 0; i < items; i++) |
279 |
{ |
{ |
280 |
char *currentName = XGetAtomName (dpy, data[i]); |
char *currentName = XGetAtomName (dpy, data[i]); |
281 |
char *configuredName = |
char *configuredName = |
282 |
XGetAtomName (dpy, net_atoms[NET_WM_STATE_STICKY]); |
XGetAtomName (dpy, net_atoms[NET_WM_STATE_STICKY]); |
283 |
if (equals (currentName, configuredName)) |
if (equals (currentName, configuredName)) |
284 |
*value |= WIN_STATE_STICKY; |
*value |= WIN_STATE_STICKY; |
285 |
XFree (currentName); |
XFree (currentName); |
286 |
XFree (configuredName); |
XFree (configuredName); |
287 |
} |
} |
288 |
XFree (data); |
XFree (data); |
289 |
} |
} |
290 |
} |
} |
291 |
|
|
292 |
void |
void |
293 |
getGnomeDesktopMargins (CARD32 * margins) |
getGnomeDesktopMargins (CARD32 * margins) |
294 |
{ |
{ |
295 |
unsigned long items_read; |
unsigned long items_read; |
296 |
CARD32 *data = NULL; |
CARD32 *data = NULL; |
297 |
|
|
298 |
#ifdef DEBUG |
#ifdef DEBUG |
299 |
printf ("entering getGnomeDesktopMargins\n"); |
printf ("entering getGnomeDesktopMargins\n"); |
300 |
#endif |
#endif |
301 |
|
|
302 |
data = |
data = |
303 |
getPropData (XDefaultRootWindow (dpy), gnome_panel_desktop_area, |
getPropData (XDefaultRootWindow (dpy), gnome_panel_desktop_area, |
304 |
XA_CARDINAL, &items_read); |
XA_CARDINAL, &items_read); |
305 |
if (data && items_read >= 4) |
if (data && items_read >= 4) |
306 |
{ |
{ |
307 |
margins[0] = data[0]; |
margins[0] = data[0]; |
308 |
margins[1] = data[1]; |
margins[1] = data[1]; |
309 |
margins[2] = data[2]; |
margins[2] = data[2]; |
310 |
margins[3] = data[3]; |
margins[3] = data[3]; |
311 |
XFree (data); |
XFree (data); |
312 |
} |
} |
313 |
else |
else |
314 |
{ |
{ |
315 |
margins[0] = 0; |
margins[0] = 0; |
316 |
margins[1] = 0; |
margins[1] = 0; |
317 |
margins[2] = 0; |
margins[2] = 0; |
318 |
margins[3] = 0; |
margins[3] = 0; |
319 |
} |
} |
320 |
} |
} |
321 |
|
|
322 |
void |
void |
323 |
getNetWMStrut (Window win, CARD32 * margins, CARD32 * window_margins) |
getNetWMStrut (Window win, CARD32 * margins, CARD32 * window_margins) |
324 |
{ |
{ |
325 |
unsigned long items_read; |
unsigned long items_read; |
326 |
CARD32 *data = NULL; |
CARD32 *data = NULL; |
327 |
|
|
328 |
#ifdef DEBUG |
#ifdef DEBUG |
329 |
printf ("entering getGnomeDesktopMargins\n"); |
printf ("entering getGnomeDesktopMargins\n"); |
330 |
#endif |
#endif |
331 |
|
|
332 |
data = getPropData (win, net_atoms[NET_WM_STRUT], XA_CARDINAL, &items_read); |
data = getPropData (win, net_atoms[NET_WM_STRUT], XA_CARDINAL, &items_read); |
333 |
if (data && items_read >= 4) |
if (data && items_read >= 4) |
334 |
{ |
{ |
335 |
window_margins[0] = data[0]; |
window_margins[0] = data[0]; |
336 |
window_margins[1] = data[1]; |
window_margins[1] = data[1]; |
337 |
window_margins[2] = data[2]; |
window_margins[2] = data[2]; |
338 |
window_margins[3] = data[3]; |
window_margins[3] = data[3]; |
339 |
margins[0] += data[0]; |
margins[0] += data[0]; |
340 |
margins[1] += data[1]; |
margins[1] += data[1]; |
341 |
margins[2] += data[2]; |
margins[2] += data[2]; |
342 |
margins[3] += data[3]; |
margins[3] += data[3]; |
343 |
XFree (data); |
XFree (data); |
344 |
} |
} |
345 |
else |
else |
346 |
{ |
{ |
347 |
window_margins[0] = 0; |
window_margins[0] = 0; |
348 |
window_margins[1] = 0; |
window_margins[1] = 0; |
349 |
window_margins[2] = 0; |
window_margins[2] = 0; |
350 |
window_margins[3] = 0; |
window_margins[3] = 0; |
351 |
} |
} |
352 |
} |
} |
353 |
|
|
354 |
void |
void |
355 |
delNetWMStrut (CARD32 * margins, CARD32 * data) |
delNetWMStrut (CARD32 * margins, CARD32 * data) |
356 |
{ |
{ |
357 |
#ifdef DEBUG |
#ifdef DEBUG |
358 |
printf ("entering delNetWMStrut\n"); |
printf ("entering delNetWMStrut\n"); |
359 |
#endif |
#endif |
360 |
|
|
361 |
if (data[0] || data[1] || data[2] || data[3]) |
if (data[0] || data[1] || data[2] || data[3]) |
362 |
{ |
{ |
363 |
margins[0] -= data[0]; |
margins[0] -= data[0]; |
364 |
margins[1] -= data[1]; |
margins[1] -= data[1]; |
365 |
margins[2] -= data[2]; |
margins[2] -= data[2]; |
366 |
margins[3] -= data[3]; |
margins[3] -= data[3]; |
367 |
} |
} |
368 |
} |
} |
369 |
|
|
370 |
void |
void |
371 |
setNetWorkarea (CARD32 * margins, int workspaces) |
setNetWorkarea (CARD32 * margins, int workspaces) |
372 |
{ |
{ |
373 |
struct workarea |
struct workarea |
374 |
{ |
{ |
375 |
CARD32 left, top, right, bottom; |
CARD32 left, top, right, bottom; |
376 |
} |
} |
377 |
*workarea; |
*workarea; |
378 |
int i; |
int i; |
379 |
|
|
380 |
if (workspaces <= 0) |
if (workspaces <= 0) |
381 |
return; |
return; |
382 |
|
|
383 |
workarea = xcalloc (workspaces, sizeof (struct workarea)); |
workarea = xcalloc (workspaces, sizeof (struct workarea)); |
384 |
|
|
385 |
for (i = 0; i < workspaces; i++) |
for (i = 0; i < workspaces; i++) |
386 |
{ |
{ |
387 |
workarea[i].left = margins[0]; |
workarea[i].left = margins[0]; |
388 |
workarea[i].top = margins[1]; |
workarea[i].top = margins[1]; |
389 |
workarea[i].right = |
workarea[i].right = |
390 |
XDisplayWidth (dpy, XDefaultScreen (dpy)) - margins[1]; |
XDisplayWidth (dpy, XDefaultScreen (dpy)) - margins[1]; |
391 |
workarea[i].bottom = |
workarea[i].bottom = |
392 |
XDisplayHeight (dpy, XDefaultScreen (dpy)) - margins[3]; |
XDisplayHeight (dpy, XDefaultScreen (dpy)) - margins[3]; |
393 |
} |
} |
394 |
|
|
395 |
XChangeProperty (dpy, XDefaultRootWindow (dpy), |
XChangeProperty (dpy, XDefaultRootWindow (dpy), |
396 |
net_atoms[NET_WORKAREA], XA_CARDINAL, 32, |
net_atoms[NET_WORKAREA], XA_CARDINAL, 32, |
397 |
PropModeReplace, (unsigned char *) workarea, |
PropModeReplace, (unsigned char *) workarea, |
398 |
4 * workspaces); |
4 * workspaces); |
399 |
XChangeProperty (dpy, XDefaultRootWindow (dpy), net_atoms[NET_WM_WORKAREA], |
XChangeProperty (dpy, XDefaultRootWindow (dpy), net_atoms[NET_WM_WORKAREA], |
400 |
XA_CARDINAL, 32, PropModeReplace, |
XA_CARDINAL, 32, PropModeReplace, |
401 |
(unsigned char *) workarea, 4 * workspaces); |
(unsigned char *) workarea, 4 * workspaces); |
402 |
free (workarea); |
free (workarea); |
403 |
} |
} |
404 |
|
|
405 |
int |
int |
406 |
typeDesktop (Window w) |
typeDesktop (Window w) |
407 |
{ |
{ |
408 |
return typeEWMH (w, "_NET_WM_WINDOW_TYPE_DESKTOP"); |
return typeEWMH (w, "_NET_WM_WINDOW_TYPE_DESKTOP"); |
409 |
} |
} |
410 |
|
|
411 |
int |
int |
412 |
typeDock (Window w) |
typeDock (Window w) |
413 |
{ |
{ |
414 |
return typeEWMH (w, "_NET_WM_WINDOW_TYPE_DOCK"); |
return typeEWMH (w, "_NET_WM_WINDOW_TYPE_DOCK"); |
415 |
} |
} |
416 |
|
|
417 |
int |
int |
418 |
typeAbove (Window w) |
typeAbove (Window w) |
419 |
{ |
{ |
420 |
return typeEWMH (w, "_NET_WM_STATE_ABOVE"); |
return typeEWMH (w, "_NET_WM_STATE_ABOVE"); |
421 |
} |
} |
422 |
|
|
423 |
int |
int |
424 |
typeEWMH (Window w, char *type) |
typeEWMH (Window w, char *type) |
425 |
{ |
{ |
426 |
unsigned long *data; |
unsigned long *data; |
427 |
unsigned long items = 0; |
unsigned long items = 0; |
428 |
unsigned long item = 0; |
unsigned long item = 0; |
429 |
int ret = 0; |
int ret = 0; |
430 |
|
|
431 |
#ifdef DEBUG |
#ifdef DEBUG |
432 |
printf ("entering typeEWMH\n"); |
printf ("entering typeEWMH\n"); |
433 |
#endif |
#endif |
434 |
|
|
435 |
data = getPropData (w, net_atoms[NET_WM_WINDOW_TYPE], XA_ATOM, &items); |
data = getPropData (w, net_atoms[NET_WM_WINDOW_TYPE], XA_ATOM, &items); |
436 |
while (data && items && item < items && !ret) |
while (data && items && item < items && !ret) |
437 |
{ |
{ |
438 |
char *name; |
char *name; |
439 |
name = XGetAtomName (dpy, data[item]); |
name = XGetAtomName (dpy, data[item]); |
440 |
#ifdef DEBUG |
#ifdef DEBUG |
441 |
printf ("%s\n", name); |
printf ("%s\n", name); |
442 |
#endif |
#endif |
443 |
ret = equals (name, type); |
ret = equals (name, type); |
444 |
XFree (name); |
XFree (name); |
445 |
item++; |
item++; |
446 |
} |
} |
447 |
if (data) |
if (data) |
448 |
XFree (data); |
XFree (data); |
449 |
|
|
450 |
return ret; |
return ret; |
451 |
} |
} |
452 |
|
|
453 |
void * |
void * |
454 |
getPropData (Window w, Atom prop, Atom type, unsigned long *items_ret) |
getPropData (Window w, Atom prop, Atom type, unsigned long *items_ret) |
455 |
{ |
{ |
456 |
Atom type_ret; |
Atom type_ret; |
457 |
int format_ret; |
int format_ret; |
458 |
unsigned long after_ret; |
unsigned long after_ret; |
459 |
unsigned char *prop_data; |
unsigned char *prop_data; |
460 |
|
|
461 |
#ifdef DEBUG |
#ifdef DEBUG |
462 |
printf ("entering getPropData\n"); |
printf ("entering getPropData\n"); |
463 |
#endif |
#endif |
464 |
prop_data = NULL; |
prop_data = NULL; |
465 |
|
|
466 |
if (items_ret == NULL) |
if (items_ret == NULL) |
467 |
{ |
{ |
468 |
items_ret = (unsigned long *) xmalloc (sizeof (unsigned long)); |
items_ret = (unsigned long *) xmalloc (sizeof (unsigned long)); |
469 |
XGetWindowProperty (dpy, w, prop, 0, 0x7fffffff, False, |
XGetWindowProperty (dpy, w, prop, 0, 0x7fffffff, False, |
470 |
type, &type_ret, &format_ret, items_ret, |
type, &type_ret, &format_ret, items_ret, |
471 |
&after_ret, &prop_data); |
&after_ret, &prop_data); |
472 |
if (prop_data && *items_ret) |
if (prop_data && *items_ret) |
473 |
{ |
{ |
474 |
free (items_ret); |
free (items_ret); |
475 |
return prop_data; |
return prop_data; |
476 |
} |
} |
477 |
else |
else |
478 |
{ |
{ |
479 |
free (items_ret); |
free (items_ret); |
480 |
return NULL; |
return NULL; |
481 |
} |
} |
482 |
} |
} |
483 |
else |
else |
484 |
{ |
{ |
485 |
XGetWindowProperty (dpy, w, prop, 0, 0x7fffffff, False, |
XGetWindowProperty (dpy, w, prop, 0, 0x7fffffff, False, |
486 |
type, &type_ret, &format_ret, items_ret, |
type, &type_ret, &format_ret, items_ret, |
487 |
&after_ret, &prop_data); |
&after_ret, &prop_data); |
488 |
if (prop_data && *items_ret) |
if (prop_data && *items_ret) |
489 |
return prop_data; |
return prop_data; |
490 |
else |
else |
491 |
return NULL; |
return NULL; |
492 |
} |
} |
493 |
} |
} |
494 |
|
|
495 |
void |
void |
496 |
setFocusHint (Window w) |
setFocusHint (Window w) |
497 |
{ |
{ |
498 |
#ifdef DEBUG |
#ifdef DEBUG |
499 |
printf ("entering setFocusHint\n"); |
printf ("entering setFocusHint\n"); |
500 |
#endif |
#endif |
501 |
|
|
502 |
XChangeProperty (dpy, XDefaultRootWindow (dpy), |
XChangeProperty (dpy, XDefaultRootWindow (dpy), |
503 |
net_atoms[NET_ACTIVE_WINDOW], XA_WINDOW, 32, |
net_atoms[NET_ACTIVE_WINDOW], XA_WINDOW, 32, |
504 |
PropModeReplace, (unsigned char *) &w, 1); |
PropModeReplace, (unsigned char *) &w, 1); |
505 |
} |
} |
506 |
|
|
507 |
int |
int |
508 |
equals (char *left, char *right) |
equals (char *left, char *right) |
509 |
{ |
{ |
510 |
if (left && right && (strcmp (left, right) == 0)) |
if (left && right && (strcmp (left, right) == 0)) |
511 |
return 1; |
return 1; |
512 |
else |
else |
513 |
return 0; |
return 0; |
514 |
} |
} |
515 |
|
|
516 |
/***This must remain at the end of the file.**************************************************** |
/***This must remain at the end of the file.*********************************************** |
517 |
* vi:set sw=2 ts=2 cindent cinoptions={1s,>2s,^-1s,n-1s foldmethod=marker foldmarker=«««,»»»: * |
* vi:set sw=2 cindent cinoptions={1s,>2s,^-1s,n-1s foldmethod=marker foldmarker=«««,»»»: * |
518 |
***********************************************************************************************/ |
******************************************************************************************/ |