 ! 	|| (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",
+! 	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 ----
+! 	return xerrorxlib(dpy, ee); /* 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)
-! 		 || (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;
+! xerrordummy(Display *dpy, XErrorEvent *ee) {
+  	return 0;
+  }
+  
+- /* Startup Error handler to check if another window manager
+-  * is already running. */
+  int
+! xerrorstart(Display *dpy, XErrorEvent *ee) {
+! 	otherwm = True;
+  	return -1;
+  }
+  
+  void
+  zoom(const Arg *arg) {
+! 	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(c == nexttiled(selmon->clients))
+! 		if(!c || !(c = nexttiled(c->next)))
+  			return;
+  	detach(c);
+  	attach(c);
+--- 1938,2004 ----
+  	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;
+  }
+  
+  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);
+  }
+  
+  int
+! xerrordummy(Display *dpy,XErrorEvent *ee) {
+  	return 0;
+  }
+  
+  int
+! xerrorstart(Display *dpy,XErrorEvent *ee) {
+! 	otherwm=True;
+  	return -1;
+  }
+  
+  void
+  zoom(const Arg *arg) {
+! 	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)))
+! 		 ||selmon->lt[selmon->sellt]->arrange==monocle
+! 		 ||(selmon->sel&&selmon->sel->isfloating))
+  		return;
+! 	if(c==nexttiled(selmon->clients))
+! 		if(!c||!(c=nexttiled(c->next)))
+  			return;
+  	detach(c);
+  	attach(c);
+***************
+*** 2046,2059 ****
+  }
+  
+  int
+! main(int argc, char *argv[]) {
+! 	if(argc == 2 && !strcmp("-v", argv[1]))
+! 		die("dwm-"VERSION", © 2006-2010 dwm engineers, see LICENSE for details\n");
+  	else if(argc != 1)
+  		die("usage: dwm [-v]\n");
+! 	if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
+! 		fputs("warning: no locale support\n", stderr);
+! 	if(!(dpy = XOpenDisplay(NULL)))
+  		die("dwm: cannot open display\n");
+  	checkotherwm();
+  	setup();
+--- 2007,2020 ----
+  }
+  
+  int
+! main(int argc,char *argv[]) {
+! 	if(argc==2&&!strcmp("-v",argv[1]))
+! 		die("dwm-"VERSION",© 2006-2010 dwm engineers,see LICENSE for details\n");
+  	else if(argc != 1)
+  		die("usage: dwm [-v]\n");
+! 	if(!setlocale(LC_CTYPE,"")||!XSupportsLocale())
+! 		fputs("warning: no locale support\n",stderr);
+! 	if(!(dpy=XOpenDisplay(NULL)))
+  		die("dwm: cannot open display\n");
+  	checkotherwm();
+  	setup();

*** 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))
! 			&& (!r->class || strstr(class, r->class))
! 			&& (!r->instance || strstr(instance, r->instance)))
! 			{

  		}
- 	}
  	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)
