X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=main.c;h=9127d163abb27b6cf2994c679be0d1ca1b6c85ec;hb=96d7fe16eaf6b656800f08da3156bacd75ca3b08;hp=0ae288c50c4ec8d647a58e478c143663034b2576;hpb=86953bd68249662b5d7a9ae6741744ab8bf30aa1;p=dwm.git diff --git a/main.c b/main.c index 0ae288c..9127d16 100644 --- a/main.c +++ b/main.c @@ -20,7 +20,7 @@ int screen, sx, sy, sw, sh, wax, way, waw, wah; unsigned int bh, ntags; unsigned int bpos = BARPOS; unsigned int numlockmask = 0; -Atom dwmconfig, wmatom[WMLast], netatom[NetLast]; +Atom dwmprops, wmatom[WMLast], netatom[NetLast]; Bool *seltags; Bool selscreen = True; Client *clients = NULL; @@ -140,9 +140,10 @@ setup(void) { XSetWindowAttributes wa; /* init atoms */ - dwmconfig = XInternAtom(dpy, "_DWM_CONFIG", False); + dwmprops = XInternAtom(dpy, "_DWM_PROPERTIES", False); wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); + wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False); wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False); netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); @@ -205,6 +206,7 @@ setup(void) { XSetFont(dpy, dc.gc, dc.font.xfont->fid); /* multihead support */ selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); + loaddwmprops(); } /* @@ -219,6 +221,33 @@ xerrorstart(Display *dsply, XErrorEvent *ee) { /* extern */ +Bool +gettextprop(Window w, Atom atom, char *text, unsigned int size) { + char **list = NULL; + int n; + XTextProperty name; + + if(!text || size == 0) + return False; + text[0] = '\0'; + XGetTextProperty(dpy, w, &name, atom); + if(!name.nitems) + return False; + if(name.encoding == XA_STRING) + strncpy(text, (char *)name.value, size - 1); + else { + if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success + && n > 0 && *list) + { + strncpy(text, *list, size - 1); + XFreeStringList(list); + } + } + text[size - 1] = '\0'; + XFree(name.value); + return True; +} + void quit(const char *arg) { readin = running = False;