X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=dwm.c;h=e5929f6c411211a4afb141a06766a794c48a4526;hb=951d022dfc1f74941f03dafd61e4f48bd7f45524;hp=c595a5154dc2654aeed771ce738d1789db8fde82;hpb=a98b5e59359173111322171187ccfd951df85a38;p=dwm.git diff --git a/dwm.c b/dwm.c index c595a51..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. * @@ -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; @@ -1280,15 +1279,19 @@ restack(void) { void run(void) { + char *p; fd_set rd; - int xfd; + 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; - stext[sizeof stext - 1] = '\0'; /* 0-terminator is never touched */ + offset = 0; + len = sizeof stext - 1; + stext[len] = '\0'; /* 0-terminator is never touched */ while(running) { FD_ZERO(&rd); if(readin) @@ -1300,14 +1303,24 @@ run(void) { eprint("select failed\n"); } if(FD_ISSET(STDIN_FILENO, &rd)) { - if(stext == fgets(stext, sizeof stext - 1, stdin)) - stext[strlen(stext) - 1] = '\0'; /* remove tailing '\n' */ - else { + switch((r = read(STDIN_FILENO, stext + offset, len - offset))) { + case -1: + strncpy(stext, strerror(errno), len); + readin = False; + break; + case 0: + strncpy(stext, "EOF", 4); readin = False; - if(feof(stdin)) - strncpy(stext, "EOF", 4); - else /* error occured */ - strncpy(stext, strerror(errno), sizeof stext - 1); + break; + default: + 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(); } @@ -1855,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");