 *** dwm.c	2011-05-30 00:05:45.926195438 -0500
---- DWM.c	2011-05-30 00:13:14.580431536 -0500
-***************
-*** 298,312 ****
-  		for(i = 0; i < LENGTH(rules); i++) {
-  			r = &rules[i];
-  			if((!r->title || strstr(c->name, r->title))
+--- DWM.c	2011-05-30 00:30:28.284831477 -0500
+***************
+*** 38,67 ****
+  #include <X11/Xutil.h>
+  #ifdef XINERAMA
+  #include <X11/extensions/Xinerama.h>
+! #endif /* XINERAMA */
+  
+- /* macros */
+  #define BUTTONMASK              (ButtonPressMask|ButtonReleaseMask)
+! #define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask))
+! #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
+! #define ISVISIBLE(C)            ((C->tags & C->mon->tagset[C->mon->seltags]))
+  #define LENGTH(X)               (sizeof X / sizeof X[0])
+! #define MAX(A, B)               ((A) > (B) ? (A) : (B))
+! #define MIN(A, B)               ((A) < (B) ? (A) : (B))
+  #define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
+! #define WIDTH(X)                ((X)->w + 2 * (X)->bw)
+! #define HEIGHT(X)               ((X)->h + 2 * (X)->bw)
+  #define TAGMASK                 ((1 << LENGTH(tags)) - 1)
+! #define TEXTW(X)                (textnw(X, strlen(X)) + dc.font.height)
+  
+! /* enums */
+! enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
+! enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
+! enum { NetSupported, NetWMName, NetWMState,
+!        NetWMFullscreen, NetLast };                      /* EWMH atoms */
+! enum { WMProtocols, WMDelete, WMState, WMLast };        /* default atoms */
+! enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
+!        ClkClientWin, ClkRootWin, ClkLast };             /* clicks */
+  
+  typedef union {
+  	int i;
+--- 38,65 ----
+  #include <X11/Xutil.h>
+  #ifdef XINERAMA
+  #include <X11/extensions/Xinerama.h>
+! #endif
+  
+  #define BUTTONMASK              (ButtonPressMask|ButtonReleaseMask)
+! #define CLEANMASK(mask)         (mask&~(numlockmask|LockMask))
+! #define INRECT(X,Y,RX,RY,RW,RH) ((X)>=(RX)&&(X)<(RX)(RW)&&(Y)>=(RY)&&(Y)<(RY)(RH))
+! #define ISVISIBLE(C)            ((C->tags&C->mon->tagset[C->mon->seltags]))
+  #define LENGTH(X)               (sizeof X / sizeof X[0])
+! #define MAX(A,B)               ((A)>(B)?(A):(B))
+! #define MIN(A,B)               ((A)<(B)?(A):(B))
+  #define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
+! #define WIDTH(X)                ((X)->w2*(X)->bw)
+! #define HEIGHT(X)               ((X)->h2*(X)->bw)
+  #define TAGMASK                 ((1 << LENGTH(tags)) - 1)
+! #define TEXTW(X)                (textnw(X,strlen(X))dc.font.height)
+  
+! enum { CurNormal,CurResize,CurMove,CurLast };
+! enum { ColBorder,ColFG,ColBG,ColLast };
+! enum { NetSupported,NetWMName,NetWMState,
+!        NetWMFullscreen,NetLast };
+! enum { WMProtocols,WMDelete,WMState,WMLast };
+! enum { ClkTagBar,ClkLtSymbol,ClkStatusText,ClkWinTitle,
+!        ClkClientWin,ClkRootWin,ClkLast };
+  
+  typedef union {
+  	int i;
+***************
+*** 82,94 ****
+  typedef struct Client Client;
+  struct Client {
+  	char name[256];
+! 	float mina, maxa;
+! 	int x, y, w, h;
+! 	int oldx, oldy, oldw, oldh;
+! 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
+! 	int bw, oldbw;
+  	unsigned int tags;
+! 	Bool isfixed, isfloating, isurgent, oldstate;
+  	Client *next;
+  	Client *snext;
+  	Monitor *mon;
+--- 80,92 ----
+  typedef struct Client Client;
+  struct Client {
+  	char name[256];
+! 	float mina,maxa;
+! 	int x,y,w,h;
+! 	int oldx,oldy,oldw,oldh;
+! 	int basew,baseh,incw,inch,maxw,maxh,minw,minh;
+! 	int bw,oldbw;
+  	unsigned int tags;
+! 	Bool isfixed,isfloating,isurgent,oldstate;
+  	Client *next;
+  	Client *snext;
+  	Monitor *mon;
+***************
+*** 96,102 ****
+  };
+  
+  typedef struct {
+! 	int x, y, w, h;
+  	unsigned long norm[ColLast];
+  	unsigned long sel[ColLast];
+  	Drawable drawable;
+--- 94,100 ----
+  };
+  
+  typedef struct {
+! 	int x,y,w,h;
+  	unsigned long norm[ColLast];
+  	unsigned long sel[ColLast];
+  	Drawable drawable;
+***************
+*** 108,114 ****
+  		XFontSet set;
+  		XFontStruct *xfont;
+  	} font;
+! } DC; /* draw context */
+  
+  typedef struct {
+  	unsigned int mod;
+--- 106,112 ----
+  		XFontSet set;
+  		XFontStruct *xfont;
+  	} font;
+! } DC;
+  
+  typedef struct {
+  	unsigned int mod;
+***************
+*** 126,134 ****
+  	char ltsymbol[16];
+  	float mfact;
+  	int num;
+! 	int by;               /* bar geometry */
+! 	int mx, my, mw, mh;   /* screen size */
+! 	int wx, wy, ww, wh;   /* window area  */
+  	unsigned int seltags;
+  	unsigned int sellt;
+  	unsigned int tagset[2];
+--- 124,132 ----
+  	char ltsymbol[16];
+  	float mfact;
+  	int num;
+! 	int by;
+! 	int mx,my,mw,mh;
+! 	int wx,wy,ww,wh;
+  	unsigned int seltags;
+  	unsigned int sellt;
+  	unsigned int tagset[2];
+***************
+*** 151,159 ****
+  	int monitor;
+  } Rule;
+  
+- /* function declarations */
+  static void applyrules(Client *c);
+! static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
+  static void arrange(Monitor *m);
+  static void arrangemon(Monitor *m);
+  static void attach(Client *c);
+--- 149,156 ----
+  	int monitor;
+  } Rule;
+  
+  static void applyrules(Client *c);
+! static Bool applysizehints(Client *c,int *x,int *y,int *w,int *h,Bool interact);
+  static void arrange(Monitor *m);
+  static void arrangemon(Monitor *m);
+  static void attach(Client *c);
+***************
+*** 171,182 ****
+  static void destroynotify(XEvent *e);
+  static void detach(Client *c);
+  static void detachstack(Client *c);
+! static void die(const char *errstr, ...);
+  static Monitor *dirtomon(int dir);
+  static void drawbar(Monitor *m);
+  static void drawbars(void);
+! static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
+! static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
+  static void enternotify(XEvent *e);
+  static void expose(XEvent *e);
+  static void focus(Client *c);
+--- 168,179 ----
+  static void destroynotify(XEvent *e);
+  static void detach(Client *c);
+  static void detachstack(Client *c);
+! static void die(const char *errstr,...);
+  static Monitor *dirtomon(int dir);
+  static void drawbar(Monitor *m);
+  static void drawbars(void);
+! static void drawsquare(Bool filled,Bool empty,Bool invert,unsigned long col[ColLast]);
+! static void drawtext(const char *text,unsigned long col[ColLast],Bool invert);
+  static void enternotify(XEvent *e);
+  static void expose(XEvent *e);
+  static void focus(Client *c);
+***************
+*** 184,215 ****
+  static void focusmon(const Arg *arg);
+  static void focusstack(const Arg *arg);
+  static unsigned long getcolor(const char *colstr);
+! static Bool getrootptr(int *x, int *y);
+  static long getstate(Window w);
+! static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
+! static void grabbuttons(Client *c, Bool focused);
+  static void grabkeys(void);
+  static void initfont(const char *fontstr);
+  static Bool isprotodel(Client *c);
+  static void keypress(XEvent *e);
+  static void killclient(const Arg *arg);
+! static void manage(Window w, XWindowAttributes *wa);
+  static void mappingnotify(XEvent *e);
+  static void maprequest(XEvent *e);
+  static void monocle(Monitor *m);
+  static void movemouse(const Arg *arg);
+  static Client *nexttiled(Client *c);
+! static Monitor *ptrtomon(int x, int y);
+  static void propertynotify(XEvent *e);
+  static void quit(const Arg *arg);
+! static void resize(Client *c, int x, int y, int w, int h, Bool interact);
+! static void resizeclient(Client *c, int x, int y, int w, int h);
+  static void resizemouse(const Arg *arg);
+  static void restack(Monitor *m);
+  static void run(void);
+  static void scan(void);
+! static void sendmon(Client *c, Monitor *m);
+! static void setclientstate(Client *c, long state);
+  static void setlayout(const Arg *arg);
+  static void setmfact(const Arg *arg);
+  static void setup(void);
+--- 181,212 ----
+  static void focusmon(const Arg *arg);
+  static void focusstack(const Arg *arg);
+  static unsigned long getcolor(const char *colstr);
+! static Bool getrootptr(int *x,int *y);
+  static long getstate(Window w);
+! static Bool gettextprop(Window w,Atom atom,char *text,unsigned int size);
+! static void grabbuttons(Client *c,Bool focused);
+  static void grabkeys(void);
+  static void initfont(const char *fontstr);
+  static Bool isprotodel(Client *c);
+  static void keypress(XEvent *e);
+  static void killclient(const Arg *arg);
+! static void manage(Window w,XWindowAttributes *wa);
+  static void mappingnotify(XEvent *e);
+  static void maprequest(XEvent *e);
+  static void monocle(Monitor *m);
+  static void movemouse(const Arg *arg);
+  static Client *nexttiled(Client *c);
+! static Monitor *ptrtomon(int x,int y);
+  static void propertynotify(XEvent *e);
+  static void quit(const Arg *arg);
+! static void resize(Client *c,int x,int y,int w,int h,Bool interact);
+! static void resizeclient(Client *c,int x,int y,int w,int h);
+  static void resizemouse(const Arg *arg);
+  static void restack(Monitor *m);
+  static void run(void);
+  static void scan(void);
+! static void sendmon(Client *c,Monitor *m);
+! static void setclientstate(Client *c,long state);
+  static void setlayout(const Arg *arg);
+  static void setmfact(const Arg *arg);
+  static void setup(void);
+***************
+*** 218,231 ****
+  static void spawn(const Arg *arg);
+  static void tag(const Arg *arg);
+  static void tagmon(const Arg *arg);
+! static int textnw(const char *text, unsigned int len);
+  static void tile(Monitor *);
+  static void togglebar(const Arg *arg);
+  static void togglefloating(const Arg *arg);
+  static void toggletag(const Arg *arg);
+  static void toggleview(const Arg *arg);
+! static void unfocus(Client *c, Bool setfocus);
+! static void unmanage(Client *c, Bool destroyed);
+  static void unmapnotify(XEvent *e);
+  static Bool updategeom(void);
+  static void updatebarpos(Monitor *m);
+--- 215,228 ----
+  static void spawn(const Arg *arg);
+  static void tag(const Arg *arg);
+  static void tagmon(const Arg *arg);
+! static int textnw(const char *text,unsigned int len);
+  static void tile(Monitor *);
+  static void togglebar(const Arg *arg);
+  static void togglefloating(const Arg *arg);
+  static void toggletag(const Arg *arg);
+  static void toggleview(const Arg *arg);
+! static void unfocus(Client *c,Bool setfocus);
+! static void unmanage(Client *c,Bool destroyed);
+  static void unmapnotify(XEvent *e);
+  static Bool updategeom(void);
+  static void updatebarpos(Monitor *m);
+***************
+*** 238,405 ****
+  static void view(const Arg *arg);
+  static Client *wintoclient(Window w);
+  static Monitor *wintomon(Window w);
+! static int xerror(Display *dpy, XErrorEvent *ee);
+! static int xerrordummy(Display *dpy, XErrorEvent *ee);
+! static int xerrorstart(Display *dpy, XErrorEvent *ee);
+  static void zoom(const Arg *arg);
+  
+! /* variables */
+! static const char broken[] = "broken";
+  static char stext[256];
+  static int screen;
+! static int sw, sh;           /* X display screen geometry width, height */
+! static int bh, blw = 0;      /* bar geometry */
+! static int (*xerrorxlib)(Display *, XErrorEvent *);
+! static unsigned int numlockmask = 0;
+! static void (*handler[LASTEvent]) (XEvent *) = {
+! 	[ButtonPress] = buttonpress,
+! 	[ClientMessage] = clientmessage,
+! 	[ConfigureRequest] = configurerequest,
+! 	[ConfigureNotify] = configurenotify,
+! 	[DestroyNotify] = destroynotify,
+! 	[EnterNotify] = enternotify,
+! 	[Expose] = expose,
+! 	[FocusIn] = focusin,
+! 	[KeyPress] = keypress,
+! 	[MappingNotify] = mappingnotify,
+! 	[MapRequest] = maprequest,
+! 	[PropertyNotify] = propertynotify,
+! 	[UnmapNotify] = unmapnotify
+  };
+! static Atom wmatom[WMLast], netatom[NetLast];
+  static Bool otherwm;
+! static Bool running = True;
+  static Cursor cursor[CurLast];
+  static Display *dpy;
+  static DC dc;
+! static Monitor *mons = NULL, *selmon = NULL;
+  static Window root;
+  
+- /* configuration, allows nested code to access above variables */
+  #include "config.h"
+  
+! /* compile-time check if all tags fit into an unsigned int bit array. */
+! struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+  
+- /* function implementations */
+  void
+  applyrules(Client *c) {
+! 	const char *class, *instance;
+  	unsigned int i;
+  	const Rule *r;
+  	Monitor *m;
+! 	XClassHint ch = { 0 };
+  
+! 	/* rule matching */
+! 	c->isfloating = c->tags = 0;
+! 	if(XGetClassHint(dpy, c->win, &ch)) {
+! 		class = ch.res_class ? ch.res_class : broken;
+! 		instance = ch.res_name ? ch.res_name : broken;
+! 		for(i = 0; i < LENGTH(rules); i++) {
+! 			r = &rules[i];
+! 			if((!r->title || strstr(c->name, r->title))
 ! 			&& (!r->class || strstr(class, r->class))
 ! 			&& (!r->instance || strstr(instance, r->instance)))
 ! 			{

! 	|| (ee->request_code == X_GrabKey && ee->error_code == BadAccess)
! 	|| (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
  		return 0;
  	fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
! 			ee->request_code, ee->error_code);
  	return xerrorxlib(dpy, ee); /* may call exit */
  }
  
--- 2001,2017 ----
  int
  xerror(Display *dpy, XErrorEvent *ee) {
  	if(ee->error_code == BadWindow
! 		 || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
! 		 || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
! 		 || (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
! 		 || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
! 		 || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
! 		 || (ee->request_code == X_GrabButton && ee->error_code == BadAccess)
! 		 || (ee->request_code == X_GrabKey && ee->error_code == BadAccess)
! 		 || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
  		return 0;
  	fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
! 					ee->request_code, ee->error_code);
  	return xerrorxlib(dpy, ee); /* may call exit */
  }
  
***************
*** 2033,2040 ****
  	Client *c = selmon->sel;
  
  	if(!selmon->lt[selmon->sellt]->arrange
! 	|| selmon->lt[selmon->sellt]->arrange == monocle
! 	|| (selmon->sel && selmon->sel->isfloating))
  		return;
  	if(c == nexttiled(selmon->clients))
  		if(!c || !(c = nexttiled(c->next)))
--- 2033,2040 ----
  	Client *c = selmon->sel;
  
  	if(!selmon->lt[selmon->sellt]->arrange
! 		 || selmon->lt[selmon->sellt]->arrange == monocle
! 		 || (selmon->sel && selmon->sel->isfloating))
  		return;
  	if(c == nexttiled(selmon->clients))
  		if(!c || !(c = nexttiled(c->next)))

  		}
- 	}
  	if(dirty) {
! 		selmon = mons;
! 		selmon = wintomon(root);
  	}
  	return dirty;
  }
  
  void
  updatenumlockmask(void) {
! 	unsigned int i, j;
  	XModifierKeymap *modmap;
  
! 	numlockmask = 0;
! 	modmap = XGetModifierMapping(dpy);
! 	for(i = 0; i < 8; i++)
! 		for(j = 0; j < modmap->max_keypermod; j++)
! 			if(modmap->modifiermap[i * modmap->max_keypermod + j]
! 			   == XKeysymToKeycode(dpy, XK_Num_Lock))
! 				numlockmask = (1 << i);
  	XFreeModifiermap(modmap);
  }
  
--- 1723,1846 ----
  	Monitor *m;
  	XSetWindowAttributes wa;
  
! 	wa.override_redirect=True;
! 	wa.background_pixmap=ParentRelative;
! 	wa.event_mask=ButtonPressMask|ExposureMask;
! 	for(m=mons;m;m=m->next) {
! 		m->barwin=XCreateWindow(dpy,root,m->wx,m->by,m->ww,bh,0,DefaultDepth(dpy,screen),
! 														CopyFromParent,DefaultVisual(dpy,screen),
! 														CWOverrideRedirect|CWBackPixmap|CWEventMask,&wa);
! 		XDefineCursor(dpy,m->barwin,cursor[CurNormal]);
! 		XMapRaised(dpy,m->barwin);
  	}
  }
  
  void
  updatebarpos(Monitor *m) {
! 	m->wy=m->my;
! 	m->wh=m->mh;
  	if(m->showbar) {
  		m->wh -= bh;
! 		m->by=m->topbar?m->wy:m->wym->wh;
! 		m->wy=m->topbar?m->wybh:m->wy;
  	}
  	else
! 		m->by=-bh;
  }
  
  Bool
  updategeom(void) {
! 	Bool dirty=False;
  
  #ifdef XINERAMA
  	if(XineramaIsActive(dpy)) {
! 		int i,j,n,nn;
  		Client *c;
  		Monitor *m;
! 		XineramaScreenInfo *info=XineramaQueryScreens(dpy,&nn);
! 		XineramaScreenInfo *unique=NULL;
  
! 		info=XineramaQueryScreens(dpy,&nn);
! 		for(n=0,m=mons;m;m=m->next,n++);
! 		if(!(unique=(XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo)*nn)))
! 			die("fatal: could not malloc() %u bytes\n",sizeof(XineramaScreenInfo)*nn);
! 		for(i=0,j=0;i<nn;i++)
! 			if(isuniquegeom(unique,j,&info[i]))
! 				memcpy(&unique[j++],&info[i],sizeof(XineramaScreenInfo));
  		XFree(info);
! 		nn=j;
  		if(n <= nn) {
! 			for(i=0;i<(nn - n);i++) {
! 				for(m=mons;m&&m->next;m=m->next);
  				if(m)
! 					m->next=createmon();
  				else
! 					mons=createmon();
  			}
! 			for(i=0,m=mons;i<nn&&m;m=m->next,i++)
! 				if(i>=n
! 					 ||(unique[i].x_org != m->mx||unique[i].y_org != m->my
! 							||unique[i].width != m->mw||unique[i].height != m->mh))
! 					{
! 						dirty=True;
! 						m->num=i;
! 						m->mx=m->wx=unique[i].x_org;
! 						m->my=m->wy=unique[i].y_org;
! 						m->mw=m->ww=unique[i].width;
! 						m->mh=m->wh=unique[i].height;
! 						updatebarpos(m);
! 					}
  		}
! 		else {
! 			for(i=nn;i<n;i++) {
! 				for(m=mons;m&&m->next;m=m->next);
  				while(m->clients) {
! 					dirty=True;
! 					c=m->clients;
! 					m->clients=c->next;
  					detachstack(c);
! 					c->mon=mons;
  					attach(c);
  					attachstack(c);
  				}
! 				if(m==selmon)
! 					selmon=mons;
  				cleanupmon(m);
  			}
  		}
  		free(unique);
  	}
  	else
! #endif
! 		{
! 			if(!mons)
! 				mons=createmon();
! 			if(mons->mw != sw||mons->mh != sh) {
! 				dirty=True;
! 				mons->mw=mons->ww=sw;
! 				mons->mh=mons->wh=sh;
! 				updatebarpos(mons);
! 			}
  		}
  	if(dirty) {
! 		selmon=mons;
! 		selmon=wintomon(root);
  	}
  	return dirty;
  }
  
  void
  updatenumlockmask(void) {
! 	unsigned int i,j;
  	XModifierKeymap *modmap;
  
! 	numlockmask=0;
! 	modmap=XGetModifierMapping(dpy);
! 	for(i=0;i<8;i++)
! 		for(j=0;j<modmap->max_keypermod;j++)
! 			if(modmap->modifiermap[i*modmap->max_keypermodj]
! 				 ==XKeysymToKeycode(dpy,XK_Num_Lock))
! 				numlockmask=(1 << i);
  	XFreeModifiermap(modmap);
  }
  
***************
*** 1882,1944 ****
  	long msize;
  	XSizeHints size;
  
! 	if(!XGetWMNormalHints(dpy, c->win, &size, &msize))
! 		/* size is uninitialized, ensure that size.flags aren't used */
! 		size.flags = PSize;
! 	if(size.flags & PBaseSize) {
! 		c->basew = size.base_width;
! 		c->baseh = size.base_height;
! 	}
! 	else if(size.flags & PMinSize) {
! 		c->basew = size.min_width;
! 		c->baseh = size.min_height;
  	}
  	else
! 		c->basew = c->baseh = 0;
! 	if(size.flags & PResizeInc) {
! 		c->incw = size.width_inc;
! 		c->inch = size.height_inc;
  	}
  	else
! 		c->incw = c->inch = 0;
! 	if(size.flags & PMaxSize) {
! 		c->maxw = size.max_width;
! 		c->maxh = size.max_height;
  	}
  	else
! 		c->maxw = c->maxh = 0;
! 	if(size.flags & PMinSize) {
! 		c->minw = size.min_width;
! 		c->minh = size.min_height;
! 	}
! 	else if(size.flags & PBaseSize) {
! 		c->minw = size.base_width;
! 		c->minh = size.base_height;
  	}
  	else
! 		c->minw = c->minh = 0;
! 	if(size.flags & PAspect) {
! 		c->mina = (float)size.min_aspect.y / size.min_aspect.x;
! 		c->maxa = (float)size.max_aspect.x / size.max_aspect.y;
  	}
  	else
! 		c->maxa = c->mina = 0.0;
! 	c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
! 	             && c->maxw == c->minw && c->maxh == c->minh);
  }
  
  void
  updatetitle(Client *c) {
! 	if(!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
! 		gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
! 	if(c->name[0] == '\0') /* hack to mark broken clients */
! 		strcpy(c->name, broken);
  }
  
  void
  updatestatus(void) {
! 	if(!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
! 		strcpy(stext, "dwm-"VERSION);
  	drawbar(selmon);
  }
  
--- 1849,1910 ----
  	long msize;
  	XSizeHints size;
  
! 	if(!XGetWMNormalHints(dpy,c->win,&size,&msize))
! 		size.flags=PSize;
! 	if(size.flags&PBaseSize) {
! 		c->basew=size.base_width;
! 		c->baseh=size.base_height;
! 	}
! 	else if(size.flags&PMinSize) {
! 		c->basew=size.min_width;
! 		c->baseh=size.min_height;
  	}
  	else
! 		c->basew=c->baseh=0;
! 	if(size.flags&PResizeInc) {
! 		c->incw=size.width_inc;
! 		c->inch=size.height_inc;
  	}
  	else
! 		c->incw=c->inch=0;
! 	if(size.flags&PMaxSize) {
! 		c->maxw=size.max_width;
! 		c->maxh=size.max_height;
  	}
  	else
! 		c->maxw=c->maxh=0;
! 	if(size.flags&PMinSize) {
! 		c->minw=size.min_width;
! 		c->minh=size.min_height;
! 	}
! 	else if(size.flags&PBaseSize) {
! 		c->minw=size.base_width;
! 		c->minh=size.base_height;
  	}
  	else
! 		c->minw=c->minh=0;
! 	if(size.flags&PAspect) {
! 		c->mina=(float)size.min_aspect.y / size.min_aspect.x;
! 		c->maxa=(float)size.max_aspect.x / size.max_aspect.y;
  	}
  	else
! 		c->maxa=c->mina=0.0;
! 	c->isfixed=(c->maxw&&c->minw&&c->maxh&&c->minh
! 							&& c->maxw==c->minw&&c->maxh==c->minh);
  }
  
  void
  updatetitle(Client *c) {
! 	if(!gettextprop(c->win,netatom[NetWMName],c->name,sizeof c->name))
! 		gettextprop(c->win,XA_WM_NAME,c->name,sizeof c->name);
! 	if(c->name[0]=='\0')
! 		strcpy(c->name,broken);
  }
  
  void
  updatestatus(void) {
! 	if(!gettextprop(root,XA_WM_NAME,stext,sizeof(stext)))
! 		strcpy(stext,"dwm-"VERSION);
  	drawbar(selmon);
  }
  
***************
*** 1946,1969 ****
  updatewmhints(Client *c) {
  	XWMHints *wmh;
  
! 	if((wmh = XGetWMHints(dpy, c->win))) {
! 		if(c == selmon->sel && wmh->flags & XUrgencyHint) {
! 			wmh->flags &= ~XUrgencyHint;
! 			XSetWMHints(dpy, c->win, wmh);
  		}
  		else
! 			c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
  		XFree(wmh);
  	}
  }
  
  void
  view(const Arg *arg) {
! 	if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
  		return;
! 	selmon->seltags ^= 1; /* toggle sel tagset */
! 	if(arg->ui & TAGMASK)
! 		selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
  	arrange(selmon);
  }
  
--- 1912,1935 ----
  updatewmhints(Client *c) {
  	XWMHints *wmh;
  
! 	if((wmh=XGetWMHints(dpy,c->win))) {
! 		if(c==selmon->sel&&wmh->flags&XUrgencyHint) {
! 			wmh->flags&=~XUrgencyHint;
! 			XSetWMHints(dpy,c->win,wmh);
  		}
  		else
! 			c->isurgent=(wmh->flags&XUrgencyHint)?True:False;
  		XFree(wmh);
  	}
  }
  
  void
  view(const Arg *arg) {
! 	if((arg->ui&TAGMASK)==selmon->tagset[selmon->seltags])
  		return;
! 	selmon->seltags^=1;
! 	if(arg->ui&TAGMASK)
! 		selmon->tagset[selmon->seltags]=arg->ui&TAGMASK;
  	arrange(selmon);
  }
  
***************
*** 1972,2043 ****
  	Client *c;
  	Monitor *m;
  
! 	for(m = mons; m; m = m->next)
! 		for(c = m->clients; c; c = c->next)
! 			if(c->win == w)
  				return c;
  	return NULL;
  }
  
  Monitor *
  wintomon(Window w) {
! 	int x, y;
  	Client *c;
  	Monitor *m;
  
! 	if(w == root && getrootptr(&x, &y))
! 		return ptrtomon(x, y);
! 	for(m = mons; m; m = m->next)
! 		if(w == m->barwin)
  			return m;
! 	if((c = wintoclient(w)))
  		return c->mon;
  	return selmon;
  }
  
- /* There's no way to check accesses to destroyed windows, thus those cases are
-  * ignored (especially on UnmapNotify's).  Other types of errors call Xlibs
-  * default error handler, which may call exit.  */
  int
! xerror(Display *dpy, XErrorEvent *ee) {
! 	if(ee->error_code == BadWindow
! 	|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
! 	|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
! 	|| (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable)
