X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=main.c;h=b56e333d54fd4300876bbcf45406c49de7aed4d8;hb=b975c4728046052a32626378df193217a96fbefc;hp=021874f31f127e96098db20344f0a9d0a1302de4;hpb=8f5f7a5b5a40ee535305927dd12ba83891d1b0b1;p=dwm.git diff --git a/main.c b/main.c index 021874f..b56e333 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,4 @@ -/* © 2006-2007 Anselm R. Garbe - * © 2006-2007 Sander van Dijk - * See LICENSE file for license details. */ +/* See LICENSE file for copyright and license details. */ #include "dwm.h" #include #include @@ -13,14 +11,17 @@ #include #include #include +#include /* extern */ char stext[256]; int screen, sx, sy, sw, sh, wax, way, waw, wah; -unsigned int bh, bpos, ntags, numlockmask; -Atom wmatom[WMLast], netatom[NetLast]; -Bool *seltag; +unsigned int bh, ntags; +unsigned int bpos = BARPOS; +unsigned int numlockmask = 0; +Atom dwmprops, wmatom[WMLast], netatom[NetLast]; +Bool *seltags; Bool selscreen = True; Client *clients = NULL; Client *sel = NULL; @@ -40,9 +41,8 @@ static void cleanup(void) { close(STDIN_FILENO); while(stack) { - if(stack->isbanned) - XMoveWindow(dpy, stack->win, stack->x, stack->y); - unmanage(stack); + unban(stack); + unmanage(stack, NormalState); } if(dc.font.set) XFreeFontSet(dpy, dc.font.set); @@ -57,7 +57,7 @@ cleanup(void) { XFreeCursor(dpy, cursor[CurMove]); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); XSync(dpy, False); - free(seltag); + free(seltags); } static unsigned long @@ -140,8 +140,10 @@ setup(void) { XSetWindowAttributes wa; /* init atoms */ + 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); @@ -152,7 +154,6 @@ setup(void) { cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); /* init modifier map */ - numlockmask = 0; modmap = XGetModifierMapping(dpy); for (i = 0; i < 8; i++) for (j = 0; j < modmap->max_keypermod; j++) { @@ -170,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); @@ -194,7 +195,6 @@ setup(void) { DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); XDefineCursor(dpy, barwin, cursor[CurNormal]); - bpos = BARPOS; updatebarpos(); XMapRaised(dpy, barwin); strcpy(stext, "dwm-"VERSION); @@ -206,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(); } /* @@ -220,34 +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) { - 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; - } - XRaiseWindow(dpy, barwin); - 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 @@ -277,8 +280,8 @@ main(int argc, char *argv[]) { fd_set rd; XEvent ev; - if(argc == 2 && !strncmp("-v", argv[1], 3)) - eprint("dwm-"VERSION", © 2004-2007 Anselm R. Garbe, Sander van Dijk\n"); + if(argc == 2 && !strcmp("-v", argv[1])) + eprint("dwm-"VERSION", © 2006-2007 A. R. Garbe, S. van Dijk, J. Salmi, P. Hruby, S. Nagy\n"); else if(argc != 1) eprint("usage: dwm [-v]\n"); setlocale(LC_CTYPE, "");