141 |
141 |
142 /* init atoms */ |
142 /* init atoms */ |
143 dwmprops = XInternAtom(dpy, "_DWM_PROPERTIES", False); |
143 dwmprops = XInternAtom(dpy, "_DWM_PROPERTIES", False); |
144 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); |
144 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); |
145 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
145 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
|
146 wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False); |
146 wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); |
147 wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); |
147 netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); |
148 netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); |
148 netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); |
149 netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); |
149 XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, |
150 XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, |
150 PropModeReplace, (unsigned char *) netatom, NetLast); |
151 PropModeReplace, (unsigned char *) netatom, NetLast); |
218 return -1; |
219 return -1; |
219 } |
220 } |
220 |
221 |
221 /* extern */ |
222 /* extern */ |
222 |
223 |
|
224 Bool |
|
225 gettextprop(Window w, Atom atom, char *text, unsigned int size) { |
|
226 char **list = NULL; |
|
227 int n; |
|
228 XTextProperty name; |
|
229 |
|
230 if(!text || size == 0) |
|
231 return False; |
|
232 text[0] = '\0'; |
|
233 XGetTextProperty(dpy, w, &name, atom); |
|
234 if(!name.nitems) |
|
235 return False; |
|
236 if(name.encoding == XA_STRING) |
|
237 strncpy(text, (char *)name.value, size - 1); |
|
238 else { |
|
239 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success |
|
240 && n > 0 && *list) |
|
241 { |
|
242 strncpy(text, *list, size - 1); |
|
243 XFreeStringList(list); |
|
244 } |
|
245 } |
|
246 text[size - 1] = '\0'; |
|
247 XFree(name.value); |
|
248 return True; |
|
249 } |
|
250 |
223 void |
251 void |
224 quit(const char *arg) { |
252 quit(const char *arg) { |
225 readin = running = False; |
253 readin = running = False; |
226 } |
254 } |
227 |
255 |