X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=dwm.c;h=e5929f6c411211a4afb141a06766a794c48a4526;hb=951d022dfc1f74941f03dafd61e4f48bd7f45524;hp=8933e8e2df6982cb460d9b567c1ab36e9b55730c;hpb=34e7872c89613356293d554970d9d56adc4b0a4e;p=dwm.git diff --git a/dwm.c b/dwm.c index 8933e8e..e5929f6 100644 --- a/dwm.c +++ b/dwm.c @@ -17,9 +17,7 @@ * set the override_redirect flag. Clients are organized in a global * doubly-linked client list, the focus history is remembered through a global * stack list. Each client contains an array of Bools of the same size as the - * global tags array to indicate the tags of a client. For each client dwm - * creates a small title window, which is resized whenever the (_NET_)WM_NAME - * properties are updated or the client is moved/resized. + * global tags array to indicate the tags of a client. * * Keys and tagging rules are organized as arrays and defined in config.h. * @@ -340,7 +338,7 @@ buttonpress(XEvent *e) { movemouse(c); } else if(ev->button == Button2) { - if((floating != layout->arrange) && !c->isfixed && c->isfloating) + if((floating != layout->arrange) && c->isfloating) togglefloating(NULL); else zoom(NULL); @@ -1145,6 +1143,7 @@ quit(const char *arg) { readin = running = False; } + void resize(Client *c, int x, int y, int w, int h, Bool sizehints) { XWindowChanges wc; @@ -1281,14 +1280,18 @@ restack(void) { void run(void) { char *p; - int r, xfd; fd_set rd; + int r, xfd; + unsigned int len, offset; XEvent ev; /* main event loop, also reads status text from stdin */ XSync(dpy, False); xfd = ConnectionNumber(dpy); readin = True; + offset = 0; + len = sizeof stext - 1; + stext[len] = '\0'; /* 0-terminator is never touched */ while(running) { FD_ZERO(&rd); if(readin) @@ -1300,10 +1303,9 @@ run(void) { eprint("select failed\n"); } if(FD_ISSET(STDIN_FILENO, &rd)) { - switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) { + switch((r = read(STDIN_FILENO, stext + offset, len - offset))) { case -1: - strncpy(stext, strerror(errno), sizeof stext - 1); - stext[sizeof stext - 1] = '\0'; + strncpy(stext, strerror(errno), len); readin = False; break; case 0: @@ -1311,10 +1313,14 @@ run(void) { readin = False; break; default: - for(stext[r] = '\0', p = stext + strlen(stext) - 1; p >= stext && *p == '\n'; *p-- = '\0'); - for(; p >= stext && *p != '\n'; --p); - if(p > stext) - strncpy(stext, p + 1, sizeof stext); + stext[offset + r] = '\0'; + for(p = stext; *p && *p != '\n'; p++); + if(*p == '\n') { + *p = '\0'; + offset = 0; + } + else + offset = (offset + r < len - 1) ? offset + r : 0; } drawbar(); } @@ -1584,8 +1590,8 @@ tile(void) { else nh = th - 2 * c->border; } - resize(c, nx, ny, nw, nh, True); - if((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw)) + resize(c, nx, ny, nw, nh, RESIZEHINTS); + if((RESIZEHINTS) && ((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw))) /* client doesn't accept size constraints */ resize(c, nx, ny, nw, nh, False); if(n > 1 && th != wah) @@ -1862,7 +1868,8 @@ zoom(const char *arg) { int main(int argc, char *argv[]) { 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"); + eprint("dwm-"VERSION", © 2006-2007 Anselm R. Garbe, Sander van Dijk, " + "Jukka Salmi, Premysl Hruby, Szabolcs Nagy\n"); else if(argc != 1) eprint("usage: dwm [-v]\n");