--- a/dwm.c	2011-12-19 16:02:46.000000000 +0100
+++ b/dwm.c	2012-09-05 18:27:57.112057118 +0200
@@ -424,6 +424,18 @@
 }
 
 void
+attach2stack(Client *c) {
+	Client *t;
+
+	for(t = c->mon->stack; t && t->snext; t = t->snext);
+	if (t)
+		t->snext = c;
+	else
+		c->mon->stack = c;
+	c->snext = NULL;
+}
+
+void
 buttonpress(XEvent *e) {
 	unsigned int i, x, click;
 	Arg arg = {0};
@@ -853,7 +865,10 @@
 		if(c->isurgent)
 			clearurgent(c);
 		detachstack(c);
-		attachstack(c);
+		if(c->tags != TAGMASK)
+			attachstack(c);
+		else
+			attach2stack(c);
 		grabbuttons(c, True);
 		XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
 		setfocus(c);
