aewl

changeset 578:8cb54d02a5b6

applied Manuels patch (thanks to Manuel!)
author arg@mig29
date Sat, 25 Nov 2006 19:26:16 +0100
parents f01c0466cf00
children 010118c94013
files dwm.1 main.c
diffstat 2 files changed, 22 insertions(+), 15 deletions(-) [+]
line diff
     1.1 --- a/dwm.1	Fri Nov 24 17:02:41 2006 +0100
     1.2 +++ b/dwm.1	Sat Nov 25 19:26:16 2006 +0100
     1.3 @@ -22,7 +22,7 @@
     1.4  the title of the focused window, and the text read from standard input. The
     1.5  selected tags are indicated with a different color. The tags of the focused
     1.6  window are indicated with a small point in the top left corner.  The tags which
     1.7 -are applied to any client are indicated with a small point in the bottom
     1.8 +are applied to one or more clients are indicated with a small point in the bottom
     1.9  right corner.
    1.10  .P
    1.11  dwm draws a 1-pixel border around windows to indicate the focus state.
     2.1 --- a/main.c	Fri Nov 24 17:02:41 2006 +0100
     2.2 +++ b/main.c	Sat Nov 25 19:26:16 2006 +0100
     2.3 @@ -267,22 +267,29 @@
     2.4  		if(readin)
     2.5  			FD_SET(STDIN_FILENO, &rd);
     2.6  		FD_SET(xfd, &rd);
     2.7 -		r = select(xfd + 1, &rd, NULL, NULL, NULL);
     2.8 -		if((r == -1) && (errno == EINTR))
     2.9 -			continue;
    2.10 -		if(r > 0) {
    2.11 -			if(readin && FD_ISSET(STDIN_FILENO, &rd)) {
    2.12 -				readin = NULL != fgets(stext, sizeof(stext), stdin);
    2.13 -				if(readin)
    2.14 -					stext[strlen(stext) - 1] = 0;
    2.15 -				else 
    2.16 -					strcpy(stext, "broken pipe");
    2.17 -				drawstatus();
    2.18 +		if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
    2.19 +			if(errno == EINTR)
    2.20 +				continue;
    2.21 +			else
    2.22 +				eprint("select failed\n");
    2.23 +		}
    2.24 +		if(FD_ISSET(STDIN_FILENO, &rd)) {
    2.25 +			switch(r = read(STDIN_FILENO, stext, sizeof(stext))) {
    2.26 +			case -1:
    2.27 +				strncpy(stext, strerror(errno), sizeof(stext));
    2.28 +				readin = False;
    2.29 +				break;
    2.30 +			case 0:
    2.31 +				strncpy(stext, "EOF", sizeof(stext));
    2.32 +				readin = False;
    2.33 +				break;
    2.34 +			default:
    2.35 +				stext[r-1] = 0;
    2.36  			}
    2.37 +			drawstatus();
    2.38  		}
    2.39 -		else if(r < 0)
    2.40 -			eprint("select failed\n");
    2.41 -		procevent();
    2.42 +		if(FD_ISSET(xfd, &rd))
    2.43 +			procevent();
    2.44  	}
    2.45  	cleanup();
    2.46  	XCloseDisplay(dpy);