aewl

diff main.c @ 164:21071ae1fe68

made fullscreen apps working fine in floating mode (there is no sane way to make them work in tiled mode, thus I switch to floating mode if I run such kind of app), also fixed the xterm issue reported by Sander
author arg@10ksloc.org
date Wed, 02 Aug 2006 16:32:05 +0200
parents a6a31e485fbd
children e848966a1ac6
line diff
     1.1 --- a/main.c	Wed Aug 02 13:05:04 2006 +0200
     1.2 +++ b/main.c	Wed Aug 02 16:32:05 2006 +0200
     1.3 @@ -4,7 +4,6 @@
     1.4   */
     1.5  
     1.6  #include "dwm.h"
     1.7 -
     1.8  #include <errno.h>
     1.9  #include <stdio.h>
    1.10  #include <stdlib.h>
    1.11 @@ -15,7 +14,6 @@
    1.12  #include <X11/Xatom.h>
    1.13  #include <X11/Xproto.h>
    1.14  
    1.15 -
    1.16  /* static */
    1.17  
    1.18  static int (*xerrorxlib)(Display *, XErrorEvent *);
    1.19 @@ -165,6 +163,7 @@
    1.20  	int i;
    1.21  	unsigned int mask;
    1.22  	fd_set rd;
    1.23 +	Bool readin = True;
    1.24  	Window w;
    1.25  	XEvent ev;
    1.26  	XSetWindowAttributes wa;
    1.27 @@ -251,7 +250,8 @@
    1.28  	/* main event loop, reads status text from stdin as well */
    1.29  	while(running) {
    1.30  		FD_ZERO(&rd);
    1.31 -		FD_SET(STDIN_FILENO, &rd);
    1.32 +		if(readin)
    1.33 +			FD_SET(STDIN_FILENO, &rd);
    1.34  		FD_SET(ConnectionNumber(dpy), &rd);
    1.35  
    1.36  		i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0);
    1.37 @@ -267,11 +267,12 @@
    1.38  						(handler[ev.type])(&ev); /* call handler */
    1.39  				}
    1.40  			}
    1.41 -			if(FD_ISSET(STDIN_FILENO, &rd)) {
    1.42 -				if(!fgets(stext, sizeof(stext), stdin))
    1.43 -					break;
    1.44 +			if(readin && FD_ISSET(STDIN_FILENO, &rd)) {
    1.45 +				readin = NULL != fgets(stext, sizeof(stext), stdin);
    1.46 +				if(readin)
    1.47 +					stext[strlen(stext) - 1] = 0;
    1.48  				else 
    1.49 -					stext[strlen(stext) - 1] = 0;
    1.50 +					strcpy(stext, "broken pipe");
    1.51  				drawstatus();
    1.52  			}
    1.53  		}