X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=main.c;h=bd19e49bd8f2eb4e7ad0f12857a74ae31f580efe;hb=5cc27f1b3c61df4f048cdac9e0feb31a2dd80c63;hp=97fdbaf7d912f84c2776028847f9970ff26d6631;hpb=a5cb80b86cdedb8cd1f3a02de47f204bd174f649;p=dwm.git diff --git a/main.c b/main.c index 97fdbaf..bd19e49 100644 --- a/main.c +++ b/main.c @@ -18,11 +18,11 @@ /* extern */ char stext[256]; -Bool *seltag; int bh, bmw, screen, sx, sy, sw, sh, wax, way, waw, wah; unsigned int master, nmaster, ntags, numlockmask; Atom wmatom[WMLast], netatom[NetLast]; Bool running = True; +Bool *seltag; Bool selscreen = True; Client *clients = NULL; Client *sel = NULL; @@ -41,7 +41,8 @@ static void cleanup(void) { close(STDIN_FILENO); while(stack) { - resize(stack, True); + if(stack->isbanned) + XMoveWindow(dpy, stack->win, stack->x, stack->y); unmanage(stack); } if(dc.font.set) @@ -69,9 +70,8 @@ scan(void) { wins = NULL; if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) { for(i = 0; i < num; i++) { - if(!XGetWindowAttributes(dpy, wins[i], &wa)) - continue; - if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1)) + if(!XGetWindowAttributes(dpy, wins[i], &wa) + || wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1)) continue; if(wa.map_state == IsViewable) manage(wins[i], &wa); @@ -104,12 +104,12 @@ setup(void) { /* init modifier map */ numlockmask = 0; modmap = XGetModifierMapping(dpy); - for (i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) for (j = 0; j < modmap->max_keypermod; j++) { - if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dpy, XK_Num_Lock)) + if(modmap->modifiermap[i * modmap->max_keypermod + j] + == XKeysymToKeycode(dpy, XK_Num_Lock)) numlockmask = (1 << i); } - } XFreeModifiermap(modmap); /* select for events */ wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask @@ -117,7 +117,7 @@ setup(void) { wa.cursor = cursor[CurNormal]; XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); grabkeys(); - initrregs(); + compileregexps(); for(ntags = 0; tags[ntags]; ntags++); seltag = emallocz(sizeof(Bool) * ntags); seltag[0] = True; @@ -141,15 +141,15 @@ setup(void) { wa.override_redirect = 1; wa.background_pixmap = ParentRelative; wa.event_mask = ButtonPressMask | ExposureMask; - barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0, DefaultDepth(dpy, screen), - CopyFromParent, DefaultVisual(dpy, screen), + barwin = XCreateWindow(dpy, root, sx, sy + (TOPBAR ? 0 : sh - bh), sw, bh, 0, + DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); XDefineCursor(dpy, barwin, cursor[CurNormal]); XMapRaised(dpy, barwin); strcpy(stext, "dwm-"VERSION); /* windowarea */ wax = sx; - way = sy + bh; + way = sy + (TOPBAR ? bh : 0); wah = sh - bh; waw = sw; /* pixmap for everything */ @@ -172,24 +172,6 @@ xerrorstart(Display *dsply, XErrorEvent *ee) { /* extern */ -int -getproto(Window w) { - int i, format, protos, status; - unsigned long extra, res; - Atom *protocols, real; - - protos = 0; - status = XGetWindowProperty(dpy, w, wmatom[WMProtocols], 0L, 20L, False, - XA_ATOM, &real, &format, &res, &extra, (unsigned char **)&protocols); - if(status != Success || protocols == 0) - return protos; - for(i = 0; i < res; i++) - if(protocols[i] == wmatom[WMDelete]) - protos |= PROTODELWIN; - free(protocols); - return protos; -} - void sendevent(Window w, Atom a, long value) { XEvent e; @@ -291,7 +273,7 @@ main(int argc, char *argv[]) { break; default: for(stext[r] = '\0', p = stext + strlen(stext) - 1; p >= stext && *p == '\n'; *p-- = '\0'); - for(p = stext + strlen(stext) - 1; p >= stext && *p != '\n'; --p); + for(; p >= stext && *p != '\n'; --p); if(p > stext) strncpy(stext, p + 1, sizeof stext); }