X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=main.c;h=b56e333d54fd4300876bbcf45406c49de7aed4d8;hb=b975c4728046052a32626378df193217a96fbefc;hp=2140d897a106ad3699070df01c43c1fe173a64d0;hpb=9e56e1ded6889335035c8ffbe2763d3d83978673;p=dwm.git diff --git a/main.c b/main.c index 2140d89..b56e333 100644 --- a/main.c +++ b/main.c @@ -11,6 +11,7 @@ #include #include #include +#include /* extern */ @@ -19,8 +20,8 @@ int screen, sx, sy, sw, sh, wax, way, waw, wah; unsigned int bh, ntags; unsigned int bpos = BARPOS; unsigned int numlockmask = 0; -Atom dwmtags, wmatom[WMLast], netatom[NetLast]; -Bool *seltag; +Atom dwmprops, wmatom[WMLast], netatom[NetLast]; +Bool *seltags; Bool selscreen = True; Client *clients = NULL; Client *sel = NULL; @@ -41,7 +42,7 @@ cleanup(void) { close(STDIN_FILENO); while(stack) { unban(stack); - unmanage(stack); + unmanage(stack, NormalState); } if(dc.font.set) XFreeFontSet(dpy, dc.font.set); @@ -56,7 +57,7 @@ cleanup(void) { XFreeCursor(dpy, cursor[CurMove]); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); XSync(dpy, False); - free(seltag); + free(seltags); } static unsigned long @@ -139,9 +140,10 @@ setup(void) { XSetWindowAttributes wa; /* init atoms */ - dwmtags = XInternAtom(dpy, "__DWM_TAGS", 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); @@ -169,8 +171,8 @@ setup(void) { grabkeys(); compileregs(); for(ntags = 0; tags[ntags]; ntags++); - seltag = emallocz(sizeof(Bool) * ntags); - seltag[0] = True; + seltags = emallocz(sizeof(Bool) * ntags); + seltags[0] = True; /* style */ dc.norm[ColBorder] = initcolor(NORMBORDERCOLOR); dc.norm[ColBG] = initcolor(NORMBGCOLOR); @@ -204,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); + getdwmprops(); } /* @@ -218,35 +221,36 @@ xerrorstart(Display *dsply, XErrorEvent *ee) { /* extern */ -void -quit(const char *arg) { - readin = running = False; +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 -updatebarpos(void) { - XEvent ev; - - wax = sx; - way = sy; - wah = sh; - waw = sw; - switch(bpos) { - default: - wah -= bh; - way += bh; - XMoveWindow(dpy, barwin, sx, sy); - break; - case BarBot: - wah -= bh; - XMoveWindow(dpy, barwin, sx, sy + wah); - break; - case BarOff: - XMoveWindow(dpy, barwin, sx, sy - bh); - break; - } - XSync(dpy, False); - while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); +quit(const char *arg) { + readin = running = False; } /* There's no way to check accesses to destroyed windows, thus those cases are