aewl

diff main.c @ 123:61490330e90a

cleaned up code
author arg@10ksloc.org
date Thu, 20 Jul 2006 12:18:06 +0200
parents a19556fe83b5
children 1489f6b97714
line diff
     1.1 --- a/main.c	Thu Jul 20 10:48:22 2006 +0200
     1.2 +++ b/main.c	Thu Jul 20 12:18:06 2006 +0200
     1.3 @@ -17,8 +17,8 @@
     1.4  
     1.5  /* static */
     1.6  
     1.7 +static int (*xerrorxlib)(Display *, XErrorEvent *);
     1.8  static Bool otherwm;
     1.9 -static int (*xerrorxlib)(Display *, XErrorEvent *);
    1.10  
    1.11  static void
    1.12  cleanup()
    1.13 @@ -34,9 +34,8 @@
    1.14  scan()
    1.15  {
    1.16  	unsigned int i, num;
    1.17 -	Window *wins;
    1.18 +	Window *wins, d1, d2;
    1.19  	XWindowAttributes wa;
    1.20 -	Window d1, d2;
    1.21  
    1.22  	if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) {
    1.23  		for(i = 0; i < num; i++) {
    1.24 @@ -55,10 +54,9 @@
    1.25  static int
    1.26  win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
    1.27  {
    1.28 +	int status, format;
    1.29 +	unsigned long res, extra;
    1.30  	Atom real;
    1.31 -	int format;
    1.32 -	unsigned long res, extra;
    1.33 -	int status;
    1.34  
    1.35  	status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format,
    1.36  			&res, &extra, prop);
    1.37 @@ -101,10 +99,10 @@
    1.38  int
    1.39  getproto(Window w)
    1.40  {
    1.41 -	unsigned char *protocols;
    1.42 -	long res;
    1.43  	int protos = 0;
    1.44  	int i;
    1.45 +	long res;
    1.46 +	unsigned char *protocols;
    1.47  
    1.48  	res = win_property(w, wmatom[WMProtocols], XA_ATOM, 20L, &protocols);
    1.49  	if(res <= 0) {
    1.50 @@ -148,21 +146,15 @@
    1.51  xerror(Display *dpy, XErrorEvent *ee)
    1.52  {
    1.53  	if(ee->error_code == BadWindow
    1.54 -			|| (ee->request_code == X_SetInputFocus
    1.55 -				&& ee->error_code == BadMatch)
    1.56 -			|| (ee->request_code == X_PolyText8
    1.57 -				&& ee->error_code == BadDrawable)
    1.58 -			|| (ee->request_code == X_PolyFillRectangle
    1.59 -				&& ee->error_code == BadDrawable)
    1.60 -			|| (ee->request_code == X_PolySegment
    1.61 -				&& ee->error_code == BadDrawable)
    1.62 -			|| (ee->request_code == X_ConfigureWindow
    1.63 -				&& ee->error_code == BadMatch)
    1.64 -			|| (ee->request_code == X_GrabKey
    1.65 -				&& ee->error_code == BadAccess))
    1.66 +	|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
    1.67 +	|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
    1.68 +	|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
    1.69 +	|| (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
    1.70 +	|| (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
    1.71 +	|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess))
    1.72  		return 0;
    1.73  	fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
    1.74 -			ee->request_code, ee->error_code);
    1.75 +		ee->request_code, ee->error_code);
    1.76  	return xerrorxlib(dpy, ee); /* may call exit() */
    1.77  }
    1.78  
    1.79 @@ -170,12 +162,12 @@
    1.80  main(int argc, char *argv[])
    1.81  {
    1.82  	int i, n;
    1.83 +	unsigned int mask;
    1.84  	fd_set rd;
    1.85 -	XSetWindowAttributes wa;
    1.86 -	unsigned int mask;
    1.87  	Bool readstdin = True;
    1.88  	Window w;
    1.89  	XEvent ev;
    1.90 +	XSetWindowAttributes wa;
    1.91  
    1.92  	for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
    1.93  		switch (argv[i][1]) {
    1.94 @@ -254,14 +246,11 @@
    1.95  
    1.96  	issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
    1.97  
    1.98 -	wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
    1.99 -					| LeaveWindowMask;
   1.100 +	wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
   1.101  	wa.cursor = cursor[CurNormal];
   1.102 -
   1.103  	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
   1.104  
   1.105  	strcpy(stext, "dwm-"VERSION);
   1.106 -
   1.107  	scan();
   1.108  
   1.109  	/* main event loop, reads status text from stdin as well */