From b706893e0aadf5e9141b52d09e9ca12b261739f1 Mon Sep 17 00:00:00 2001
From: "Anselm R. Garbe" 
Date: Mon, 17 Jul 2006 10:00:55 +0200
Subject: [PATCH 01/16] updated html
---
 dwm.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dwm.html b/dwm.html
index 0df44b5..d11bf0d 100644
--- a/dwm.html
+++ b/dwm.html
@@ -93,7 +93,7 @@
 		
 		Download
 		
 		Miscellaneous
 		
-- 
2.20.1
From ee5ba1443142e8e8e69933874eaa5415dbb8d80d Mon Sep 17 00:00:00 2001
From: "Anselm R. Garbe" 
Date: Mon, 17 Jul 2006 10:00:59 +0200
Subject: [PATCH 02/16] Added tag 0.2 for changeset
 0a6472e2203994bc5738d40a340d26f7ec9d6062
---
 .hgtags | 1 +
 1 file changed, 1 insertion(+)
diff --git a/.hgtags b/.hgtags
index bdc7979..d6411ad 100644
--- a/.hgtags
+++ b/.hgtags
@@ -1 +1,2 @@
 d31b5ad96b0ba7b5b0a30928fcf000428339a577 0.1
+0a6472e2203994bc5738d40a340d26f7ec9d6062 0.2
-- 
2.20.1
From ed41473634058b3ffdee7c8eef39785defe9da65 Mon Sep 17 00:00:00 2001
From: "Anselm R. Garbe" 
Date: Mon, 17 Jul 2006 10:09:57 +0200
Subject: [PATCH 03/16] updated README
---
 README | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README b/README
index e6b06b0..a17b82a 100644
--- a/README
+++ b/README
@@ -36,5 +36,5 @@ This will start dwm on display :1 of the host foo.bar.
 
 Configuration
 -------------
-The configuration of dwm is done by customizing the wm.h source file. To
-customize the key bindings edit dev.c.
+The configuration of dwm is done by customizing source code,
+grep for CUSTOMIZE keyword.
-- 
2.20.1
From eb184e02eacaf49b71e1d841a9dfb94441247509 Mon Sep 17 00:00:00 2001
From: "Anselm R. Garbe" 
Date: Mon, 17 Jul 2006 11:36:07 +0200
Subject: [PATCH 04/16] patched dwm
---
 config.mk |  2 +-
 dwm.1     |  2 +-
 dwm.html  | 72 +++++++++++++++++++++++++++++++++----------------------
 3 files changed, 46 insertions(+), 30 deletions(-)
diff --git a/config.mk b/config.mk
index d4a7193..36199c3 100644
--- a/config.mk
+++ b/config.mk
@@ -8,7 +8,7 @@ MANPREFIX = ${PREFIX}/share/man
 X11INC = /usr/X11R6/include
 X11LIB = /usr/X11R6/lib
 
-VERSION = 0.2
+VERSION = 0.3
 
 # includes and libs
 LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
diff --git a/dwm.1 b/dwm.1
index 689ddd4..e1379ba 100644
--- a/dwm.1
+++ b/dwm.1
@@ -90,7 +90,7 @@ Lock
 .B Control-[0..n]
 Append
 .B nth
-tag to cureent
+tag to current
 .B window
 .TP
 .B Control-Button1
diff --git a/dwm.html b/dwm.html
index d11bf0d..22f2cb3 100644
--- a/dwm.html
+++ b/dwm.html
@@ -28,58 +28,74 @@
 		and all this hype about remote control through a 9P service, I only
 		want to manage my windows in a simple, but dynamic way. wmii never got
 		finished because I listened to users, who proposed arbitrary ideas I
-		considered useful. This resulted in an extreme CADT
-		development model, which was a mistake. Thus the philosophy of
-		dwm is simply to fit my needs (maybe yours as well). That's it.
+		considered useful. This resulted in an extreme CADT development model,
+		which was a mistake. Thus the philosophy of dwm is simply to fit my
+		needs (maybe yours as well). That's it.
 		
-		Differences to wmii
Differences to ion, larswm, and wmii
 		
-		In contrast to wmii, dwm is only a window manager, and nothing else.
-		Hence, it is much smaller, faster and simpler.
+		In contrast to ion, larswm, and wmii, dwm is much smaller, faster and simpler.
 		
 		
 			- 
-			dwm has no 9P support, no editable tagbars, no shell-based
-			configuration and remote control and comes without any additional
-			tools like printing the selection or warping the mouse.
+			dwm has no Lua integration, no 9P support, no menu, no editable
+			tagbars, no shell-based configuration, no remote control, and comes
+			without any additional tools like printing the selection or warping
+			the mouse.
 			
 
 			- 
 			dwm is only a single binary, it's source code is intended to never
 			exceed 2000 SLOC.
 			
 
 			- 
-			dwm is customized through editing its source code, that makes it
-			extremely fast and secure - it does not process any input data which
-			hasn't been known at compile time, except window title names.
+			dwm is based on tagging and dynamic window management (however
+			simpler than ion, wmii or larswm). It manages windows in
+			tiling and floating modes. Either mode can be applied dynamically,
+			depending on the application in use and the task performed.
 			
 
 			- 
-			dwm is based on tagging and dynamic window management (however simpler
-			than wmii or larswm).
+			dwm don't distinguishes between layers, there is no floating or
+			tiled layer. Wether the clients of currently selected tag are in
+			tiled mode or not, you can re-arrange all clients on the fly.
+			Popup- and fixed-size windows are treated floating, however. 
 			
 
 			- 
-			dwm don't distinguishes between layers, there is no floating or
-			managed layer. Wether the clients of currently selected tag are
-			managed or not, you can re-arrange all clients on the fly. Popup-
-			and fixed-size windows are treated unmanaged. 
+			dwm is customized through editing its source code, that makes it
+			extremely fast and secure - it does not process any input data
+			which hasn't been known at compile time, except window title names
+			and status text read from standard input. You don't have to learn
+			Lua/sh/ruby or some weird configuration file format (like X
+			resource files), beside C to customize it for your needs,
+			you only have to learn C.
+			
 
+			- 
+			Because dwm is customized through editing its source code, it's
+			pointless to make binary packages of it. This keeps its userbase
+			small and elitist. No novices asking stupid questions.
 			
 
 			- 
 			dwm uses 1-pixel borders to provide the maximum of screen real
-			estate to clients. Small titlebars are only drawn in front of unfocused
-			clients.
+			estate to clients. Small titlebars are only drawn in front of
+			unfocused clients.
 			
 
 			- 
-			dwm reads from stdin to print arbitrary status text (like the
-			date, load, battery charge). That's much simpler than larsremote,
-			wmiir and what not...
+			dwm reads from standard input to print arbitrary status text (like
+			the date, load, battery charge). That's much simpler than
+			larsremote, wmiir and what not...
 			
 
 			- 
-			Anselm does not want any feedback to dwm. If you ask for support,
-			feature requests, or if you report bugs, they will be ignored
-			with a high chance. dwm is only intended to fit Anselms needs.
-			However you are free to download and distribute/relicense it, with the
-			conditions of the MIT/X Consortium license.
+			dwm is only intended to fit Anselms needs. That means, Anselm
+			does not want feedback to dwm. If you ask for support,
+			feature requests, or if you report "bugs" (real bugs are welcome
+			though), they will be ignored with a high
+			chance.  However you are free to download and distribute/relicense
+			it, with the conditions of the MIT/X Consortium license.
 			
 
 		
+		Documentation
+		There is a man page.
 		Screenshot
 		
 		Click here for a screenshot (20060714)
-- 
2.20.1
From 1e7e57dad3e3ac750421795f60867f65b4ff0f67 Mon Sep 17 00:00:00 2001
From: "Anselm R. Garbe" 
Date: Mon, 17 Jul 2006 11:56:27 +0200
Subject: [PATCH 05/16] updated html
---
 dwm.html | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/dwm.html b/dwm.html
index 22f2cb3..491daeb 100644
--- a/dwm.html
+++ b/dwm.html
@@ -85,21 +85,21 @@
 			larsremote, wmiir and what not...
 			
 			
-			dwm is only intended to fit Anselms needs. That means, Anselm
-			does not want feedback to dwm. If you ask for support,
-			feature requests, or if you report "bugs" (real bugs are welcome
-			though), they will be ignored with a high
+			Anselm does not wants stupid feedback to dwm. If you ask for
+			support, feature requests, or if you report "bugs" (real bugs
+			are welcome though), they will be ignored with a high
 			chance.  However you are free to download and distribute/relicense
 			it, with the conditions of the MIT/X Consortium license.
 			
 		
 		Documentation
-		There is a man page.
-		Screenshot
-		
-		Click here for a screenshot (20060714)
-		
+		
 		Development
 		
 		dwm is actively developed in parallel to wmii. You can browse its source code repository or get a copy using Mercurial with following command:
-- 
2.20.1
From 605630c14522759a0a7521d3d74ee2340591147f Mon Sep 17 00:00:00 2001
From: "Anselm R. Garbe" 
Date: Mon, 17 Jul 2006 16:46:42 +0200
Subject: [PATCH 06/16] added new stuff
---
 dwm.html | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/dwm.html b/dwm.html
index 491daeb..609ce03 100644
--- a/dwm.html
+++ b/dwm.html
@@ -21,7 +21,7 @@
 		
 		dwm is a dynamic window manager for X11.
 		
-		Philosophy
+		Philosophy
 		
 		As founder and main developer of wmii I came to the conclusion that
 		wmii is too clunky for my needs. I don't need so many funky features
@@ -33,7 +33,7 @@
 		which was a mistake. Thus the philosophy of dwm is simply to fit my
 		needs (maybe yours as well). That's it.
 		
-		Differences to ion, larswm, and wmii
+		Differences to ion, larswm, and wmii
 		
 		In contrast to ion, larswm, and wmii, dwm is much smaller, faster and simpler.
 		
@@ -85,18 +85,15 @@
 			larsremote, wmiir and what not...
 			
 			
-			Anselm does not wants stupid feedback to dwm. If you ask for
-			support, feature requests, or if you report "bugs" (real bugs
-			are welcome though), they will be ignored with a high
-			chance.  However you are free to download and distribute/relicense
-			it, with the conditions of the MIT/X Consortium license.
+			It can be downloaded and distributed under the conditions
+			of the MIT/X Consortium license.
 			
 		
-		Documentation
+		Links
 		
-- 
2.20.1
From 789717d109016279bd541efe5b72899fbcf68335 Mon Sep 17 00:00:00 2001
From: "Anselm R. Garbe" 
Date: Mon, 17 Jul 2006 18:49:13 +0200
Subject: [PATCH 07/16] simplified Makefile
---
 Makefile  | 4 ++--
 config.mk | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 3433894..23e5fc7 100644
--- a/Makefile
+++ b/Makefile
@@ -8,10 +8,10 @@ OBJ = ${SRC:.c=.o}
 MAN1 = dwm.1 
 BIN = dwm
 
-all: config dwm
+all: options dwm
 	@echo finished
 
-config:
+options:
 	@echo dwm build options:
 	@echo "LIBS     = ${LIBS}"
 	@echo "CFLAGS   = ${CFLAGS}"
diff --git a/config.mk b/config.mk
index 36199c3..1ee6b6d 100644
--- a/config.mk
+++ b/config.mk
@@ -2,7 +2,6 @@
 
 # paths
 PREFIX = /usr/local
-CONFPREFIX = ${PREFIX}/etc
 MANPREFIX = ${PREFIX}/share/man
 
 X11INC = /usr/X11R6/include
-- 
2.20.1
From 849e631510ed6533ac930449804e477fe67a43c2 Mon Sep 17 00:00:00 2001
From: "Anselm R. Garbe" 
Date: Tue, 18 Jul 2006 08:18:54 +0200
Subject: [PATCH 08/16] using EXIT_stuff in exit() now
---
 main.c | 9 ++++-----
 util.c | 6 +++---
 2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/main.c b/main.c
index 27e2627..6035fb6 100644
--- a/main.c
+++ b/main.c
@@ -179,14 +179,13 @@ main(int argc, char *argv[])
 
 	for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
 		switch (argv[i][1]) {
-		case 'v':
-			fprintf(stdout, "%s",
-					"dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n");
-			exit(0);
-			break;
 		default:
 			eprint("usage: dwm [-v]\n");
 			break;
+		case 'v':
+			fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
+			exit(EXIT_SUCCESS);
+			break;
 		}
 	}
 
diff --git a/util.c b/util.c
index 3e5fd1e..1e36b25 100644
--- a/util.c
+++ b/util.c
@@ -17,7 +17,7 @@ bad_malloc(unsigned int size)
 {
 	fprintf(stderr, "fatal: could not malloc() %d bytes\n",
 			(int) size);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 /* extern */
@@ -37,7 +37,7 @@ eprint(const char *errstr, ...) {
 	va_start(ap, errstr);
 	vfprintf(stderr, errstr, ap);
 	va_end(ap);
-	exit(1);
+	exit(EXIT_FAILURE);
 }
 
 void
@@ -55,7 +55,7 @@ spawn(Arg *arg)
 			fprintf(stderr, "dwm: execvp %s", argv[0]);
 			perror(" failed");
 		}
-		exit (0);
+		exit(EXIT_FAILURE);
 	}
 	wait(0);
 }
-- 
2.20.1
From 4f8b08d330a6c377ab919f48b8e922d1c5ded601 Mon Sep 17 00:00:00 2001
From: "Anselm R. Garbe" 
Date: Tue, 18 Jul 2006 11:38:31 +0200
Subject: [PATCH 09/16] added heretag command which allows to tag a client of a
 foreign tag with current tag
---
 client.c |  8 ++++----
 draw.c   |  2 +-
 dwm.1    |  8 ++++++++
 dwm.h    |  3 ++-
 event.c  |  4 ++++
 tag.c    | 27 +++++++++++++++++++++++----
 6 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/client.c b/client.c
index 69189de..166e979 100644
--- a/client.c
+++ b/client.c
@@ -66,8 +66,8 @@ focusnext(Arg *arg)
 	if(!sel)
 		return;
 
-	if(!(c = getnext(sel->next)))
-		c = getnext(clients);
+	if(!(c = getnext(sel->next, tsel)))
+		c = getnext(clients, tsel);
 	if(c) {
 		higher(c);
 		c->revert = sel;
@@ -410,8 +410,8 @@ zoom(Arg *arg)
 	if(!sel)
 		return;
 
-	if(sel == getnext(clients) && sel->next)  {
-		if((c = getnext(sel->next)))
+	if(sel == getnext(clients, tsel) && sel->next)  {
+		if((c = getnext(sel->next, tsel)))
 			sel = c;
 	}
 
diff --git a/draw.c b/draw.c
index b8cfffd..de4bdb0 100644
--- a/draw.c
+++ b/draw.c
@@ -97,7 +97,7 @@ drawall()
 {
 	Client *c;
 
-	for(c = clients; c; c = getnext(c->next))
+	for(c = clients; c; c = getnext(c->next, tsel))
 		drawtitle(c);
 	drawstatus();
 }
diff --git a/dwm.1 b/dwm.1
index e1379ba..96fa760 100644
--- a/dwm.1
+++ b/dwm.1
@@ -93,6 +93,14 @@ Append
 tag to current
 .B window
 .TP
+.B Control-Shift-[0..n]
+Replace current
+.B window
+of
+.B nth
+tag with current tag.
+.B window
+.TP
 .B Control-Button1
 Zooms the clicked
 .B window
diff --git a/dwm.h b/dwm.h
index de88527..0d37e99 100644
--- a/dwm.h
+++ b/dwm.h
@@ -145,7 +145,8 @@ extern int xerror(Display *dsply, XErrorEvent *ee);
 extern void appendtag(Arg *arg);
 extern void dofloat(Arg *arg);
 extern void dotile(Arg *arg);
-extern Client *getnext(Client *c);
+extern Client *getnext(Client *c, unsigned int t);
+extern void heretag(Arg *arg);
 extern void replacetag(Arg *arg);
 extern void settags(Client *c);
 extern void view(Arg *arg);
diff --git a/event.c b/event.c
index 0fce36b..4b8c07b 100644
--- a/event.c
+++ b/event.c
@@ -35,6 +35,10 @@ Key key[] = {
 	{ Mod1Mask,				XK_m,		maximize,		{ 0 } }, 
 	{ Mod1Mask,				XK_space,	dotile,		{ 0 } }, 
 	{ Mod1Mask,				XK_Return,	zoom,		{ 0 } },
+	{ ControlMask|ShiftMask,XK_0,		heretag,	{ .i = Tscratch } }, 
+	{ ControlMask|ShiftMask,XK_1,		heretag,	{ .i = Tdev } }, 
+	{ ControlMask|ShiftMask,XK_2,		heretag,	{ .i = Twww } }, 
+	{ ControlMask|ShiftMask,XK_3,		heretag,	{ .i = Twork } }, 
 	{ Mod1Mask|ShiftMask,	XK_0,		replacetag,		{ .i = Tscratch } }, 
 	{ Mod1Mask|ShiftMask,	XK_1,		replacetag,		{ .i = Tdev } }, 
 	{ Mod1Mask|ShiftMask,	XK_2,		replacetag,		{ .i = Twww } }, 
diff --git a/tag.c b/tag.c
index 5da5711..3837fbd 100644
--- a/tag.c
+++ b/tag.c
@@ -49,7 +49,7 @@ dofloat(Arg *arg)
 			ban(c);
 	}
 	if(sel && !sel->tags[tsel]) {
-		if((sel = getnext(clients))) {
+		if((sel = getnext(clients, tsel))) {
 			higher(sel);
 			focus(sel);
 		}
@@ -106,7 +106,7 @@ dotile(Arg *arg)
 			ban(c);
 	}
 	if(!sel || (sel && !sel->tags[tsel])) {
-		if((sel = getnext(clients))) {
+		if((sel = getnext(clients, tsel))) {
 			higher(sel);
 			focus(sel);
 		}
@@ -115,12 +115,31 @@ dotile(Arg *arg)
 }
 
 Client *
-getnext(Client *c)
+getnext(Client *c, unsigned int t)
 {
-	for(; c && !c->tags[tsel]; c = c->next);
+	for(; c && !c->tags[t]; c = c->next);
 	return c;
 }
 
+void
+heretag(Arg *arg)
+{
+	int i;
+	Client *c;
+
+	if(arg->i == tsel)
+		return;
+
+	if(!(c = getnext(clients, arg->i)))
+		return;
+
+	for(i = 0; i < TLast; i++)
+		c->tags[i] = NULL;
+	c->tags[tsel] = tags[tsel];
+	arrange(NULL);
+	focus(c);
+}
+
 void
 replacetag(Arg *arg)
 {
-- 
2.20.1
From 0aaa9a21f334a5c75b7efce2712384f57bd370cd Mon Sep 17 00:00:00 2001
From: "Anselm R. Garbe" 
Date: Tue, 18 Jul 2006 11:45:32 +0200
Subject: [PATCH 10/16] pop on heretag
---
 client.c | 21 ++++++++++++++-------
 dwm.h    |  1 +
 tag.c    |  2 +-
 3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/client.c b/client.c
index 166e979..fa48644 100644
--- a/client.c
+++ b/client.c
@@ -267,6 +267,18 @@ maximize(Arg *arg)
 	resize(sel, False);
 }
 
+void
+pop(Client *c)
+{
+	Client **l;
+	for(l = &clients; *l && *l != c; l = &(*l)->next);
+	*l = c->next;
+
+	c->next = clients; /* pop */
+	clients = c;
+	arrange(NULL);
+}
+
 void
 resize(Client *c, Bool inc)
 {
@@ -405,7 +417,7 @@ unmanage(Client *c)
 void
 zoom(Arg *arg)
 {
-	Client **l, *c;
+	Client *c;
 
 	if(!sel)
 		return;
@@ -415,11 +427,6 @@ zoom(Arg *arg)
 			sel = c;
 	}
 
-	for(l = &clients; *l && *l != sel; l = &(*l)->next);
-	*l = sel->next;
-
-	sel->next = clients; /* pop */
-	clients = sel;
-	arrange(NULL);
+	pop(sel);
 	focus(sel);
 }
diff --git a/dwm.h b/dwm.h
index 0d37e99..f2356a3 100644
--- a/dwm.h
+++ b/dwm.h
@@ -118,6 +118,7 @@ extern void killclient(Arg *arg);
 extern void lower(Client *c);
 extern void manage(Window w, XWindowAttributes *wa);
 extern void maximize(Arg *arg);
+extern void pop(Client *c);
 extern void resize(Client *c, Bool inc);
 extern void setsize(Client *c);
 extern void settitle(Client *c);
diff --git a/tag.c b/tag.c
index 3837fbd..fce3c6e 100644
--- a/tag.c
+++ b/tag.c
@@ -136,7 +136,7 @@ heretag(Arg *arg)
 	for(i = 0; i < TLast; i++)
 		c->tags[i] = NULL;
 	c->tags[tsel] = tags[tsel];
-	arrange(NULL);
+	pop(c);
 	focus(c);
 }
 
-- 
2.20.1
From 58f2fe3f6af3d6f8c925125c721a2d1800d750dc Mon Sep 17 00:00:00 2001
From: "Anselm R. Garbe" 
Date: Tue, 18 Jul 2006 12:36:57 +0200
Subject: [PATCH 11/16] implemened distinguishing float/managed geometries of
 clients (works quite well)
---
 client.c | 116 ++++++++++++++++++++++++++++++++-----------------------
 dwm.h    |   7 +++-
 event.c  |  30 +++++++-------
 main.c   |   1 +
 tag.c    |  29 +++++++-------
 5 files changed, 105 insertions(+), 78 deletions(-)
diff --git a/client.c b/client.c
index fa48644..beb7e35 100644
--- a/client.c
+++ b/client.c
@@ -16,16 +16,16 @@ resizetitle(Client *c)
 {
 	int i;
 
-	c->tw = 0;
+	c->bw = 0;
 	for(i = 0; i < TLast; i++)
 		if(c->tags[i])
-			c->tw += textw(c->tags[i]);
-	c->tw += textw(c->name);
-	if(c->tw > c->w)
-		c->tw = c->w + 2;
-	c->tx = c->x + c->w - c->tw + 2;
-	c->ty = c->y;
-	XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
+			c->bw += textw(c->tags[i]);
+	c->bw += textw(c->name);
+	if(c->bw > *c->w)
+		c->bw = *c->w + 2;
+	c->bx = *c->x + *c->w - c->bw + 2;
+	c->by = *c->y;
+	XMoveResizeWindow(dpy, c->title, c->bx, c->by, c->bw, c->bh);
 }
 
 static int
@@ -39,8 +39,8 @@ xerrordummy(Display *dsply, XErrorEvent *ee)
 void
 ban(Client *c)
 {
-	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
-	XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
+	XMoveWindow(dpy, c->win, *c->x + 2 * sw, *c->y);
+	XMoveWindow(dpy, c->title, c->bx + 2 * sw, c->by);
 }
 
 void
@@ -124,12 +124,12 @@ gravitate(Client *c, Bool invert)
 	case EastGravity:
 	case CenterGravity:
 	case WestGravity:
-		dy = -(c->h / 2) + c->border;
+		dy = -(*c->h / 2) + c->border;
 		break;
 	case SouthEastGravity:
 	case SouthGravity:
 	case SouthWestGravity:
-		dy = -c->h;
+		dy = -(*c->h);
 		break;
 	default:
 		break;
@@ -145,12 +145,12 @@ gravitate(Client *c, Bool invert)
 	case NorthGravity:
 	case CenterGravity:
 	case SouthGravity:
-		dx = -(c->w / 2) + c->border;
+		dx = -(*c->w / 2) + c->border;
 		break;
 	case NorthEastGravity:
 	case EastGravity:
 	case SouthEastGravity:
-		dx = -(c->w + c->border);
+		dx = -(*c->w + c->border);
 		break;
 	default:
 		break;
@@ -160,8 +160,8 @@ gravitate(Client *c, Bool invert)
 		dx = -dx;
 		dy = -dy;
 	}
-	c->x += dx;
-	c->y += dy;
+	*c->x += dx;
+	*c->y += dy;
 }
 
 void
@@ -198,13 +198,13 @@ manage(Window w, XWindowAttributes *wa)
 
 	c = emallocz(sizeof(Client));
 	c->win = w;
-	c->tx = c->x = wa->x;
-	c->ty = c->y = wa->y;
-	if(c->y < bh)
-		c->ty = c->y += bh;
-	c->tw = c->w = wa->width;
-	c->h = wa->height;
-	c->th = bh;
+	c->bx = c->fx = c->tx = wa->x;
+	c->by = c->fy = c->ty = wa->y;
+	if(c->fy < bh)
+		c->by = c->fy = c->ty += bh;
+	c->bw = c->fw = c->tw = wa->width;
+	c->fh = c->th = wa->height;
+	c->bh = bh;
 	c->border = 1;
 	c->proto = getproto(c->win);
 	setsize(c);
@@ -215,12 +215,11 @@ manage(Window w, XWindowAttributes *wa)
 	twa.background_pixmap = ParentRelative;
 	twa.event_mask = ExposureMask;
 
-	c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
+	c->title = XCreateWindow(dpy, root, c->bx, c->by, c->bw, c->bh,
 			0, DefaultDepth(dpy, screen), CopyFromParent,
 			DefaultVisual(dpy, screen),
 			CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
 
-	settitle(c);
 	settags(c);
 
 	c->next = clients;
@@ -239,7 +238,11 @@ manage(Window w, XWindowAttributes *wa)
 		c->isfloat = trans
 			|| ((c->maxw == c->minw) && (c->maxh == c->minh));
 
+	setgeom(c);
+	settitle(c);
+
 	arrange(NULL);
+
 	/* mapping the window now prevents flicker */
 	if(c->tags[tsel]) {
 		XMapRaised(dpy, c->win);
@@ -259,10 +262,10 @@ maximize(Arg *arg)
 {
 	if(!sel)
 		return;
-	sel->x = sx;
-	sel->y = sy + bh;
-	sel->w = sw - 2 * sel->border;
-	sel->h = sh - 2 * sel->border - bh;
+	*sel->x = sx;
+	*sel->y = sy + bh;
+	*sel->w = sw - 2 * sel->border;
+	*sel->h = sh - 2 * sel->border - bh;
 	higher(sel);
 	resize(sel, False);
 }
@@ -286,32 +289,32 @@ resize(Client *c, Bool inc)
 
 	if(inc) {
 		if(c->incw)
-			c->w -= (c->w - c->basew) % c->incw;
+			*c->w -= (*c->w - c->basew) % c->incw;
 		if(c->inch)
-			c->h -= (c->h - c->baseh) % c->inch;
+			*c->h -= (*c->h - c->baseh) % c->inch;
 	}
-	if(c->x > sw) /* might happen on restart */
-		c->x = sw - c->w;
-	if(c->y > sh)
-		c->ty = c->y = sh - c->h;
-	if(c->minw && c->w < c->minw)
-		c->w = c->minw;
-	if(c->minh && c->h < c->minh)
-		c->h = c->minh;
-	if(c->maxw && c->w > c->maxw)
-		c->w = c->maxw;
-	if(c->maxh && c->h > c->maxh)
-		c->h = c->maxh;
+	if(*c->x > sw) /* might happen on restart */
+		*c->x = sw - *c->w;
+	if(*c->y > sh)
+		*c->y = sh - *c->h;
+	if(c->minw && *c->w < c->minw)
+		*c->w = c->minw;
+	if(c->minh && *c->h < c->minh)
+		*c->h = c->minh;
+	if(c->maxw && *c->w > c->maxw)
+		*c->w = c->maxw;
+	if(c->maxh && *c->h > c->maxh)
+		*c->h = c->maxh;
 	resizetitle(c);
 	XSetWindowBorderWidth(dpy, c->win, 1);
-	XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
+	XMoveResizeWindow(dpy, c->win, *c->x, *c->y, *c->w, *c->h);
 	e.type = ConfigureNotify;
 	e.event = c->win;
 	e.window = c->win;
-	e.x = c->x;
-	e.y = c->y;
-	e.width = c->w;
-	e.height = c->h;
+	e.x = *c->x;
+	e.y = *c->y;
+	e.width = *c->w;
+	e.height = *c->h;
 	e.border_width = c->border;
 	e.above = None;
 	e.override_redirect = False;
@@ -319,6 +322,23 @@ resize(Client *c, Bool inc)
 	XSync(dpy, False);
 }
 
+void
+setgeom(Client *c)
+{
+	if((arrange == dotile) && !c->isfloat) {
+		c->x = &c->tx;
+		c->y = &c->ty;
+		c->w = &c->tw;
+		c->h = &c->th;
+	}
+	else {
+		c->x = &c->fx;
+		c->y = &c->fy;
+		c->w = &c->fw;
+		c->h = &c->fh;
+	}
+}
+
 void
 setsize(Client *c)
 {
diff --git a/dwm.h b/dwm.h
index f2356a3..6b907a9 100644
--- a/dwm.h
+++ b/dwm.h
@@ -65,8 +65,10 @@ struct Client {
 	char name[256];
 	char *tags[TLast];
 	int proto;
-	int x, y, w, h;
-	int tx, ty, tw, th;
+	int *x, *y, *w, *h; /* current geom */
+	int bx, by, bw, bh; /* title bar */
+	int fx, fy, fw, fh; /* floating geom */
+	int tx, ty, tw, th; /* tiled geom */
 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
 	int grav;
 	unsigned int border;
@@ -120,6 +122,7 @@ extern void manage(Window w, XWindowAttributes *wa);
 extern void maximize(Arg *arg);
 extern void pop(Client *c);
 extern void resize(Client *c, Bool inc);
+extern void setgeom(Client *c);
 extern void setsize(Client *c);
 extern void settitle(Client *c);
 extern void unmanage(Client *c);
diff --git a/event.c b/event.c
index 4b8c07b..db95dfd 100644
--- a/event.c
+++ b/event.c
@@ -62,8 +62,8 @@ movemouse(Client *c)
 	unsigned int dui;
 	Window dummy;
 
-	ocx = c->x;
-	ocy = c->y;
+	ocx = *c->x;
+	ocy = *c->y;
 	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
 				None, cursor[CurMove], CurrentTime) != GrabSuccess)
 		return;
@@ -77,8 +77,8 @@ movemouse(Client *c)
 			break;
 		case MotionNotify:
 			XSync(dpy, False);
-			c->x = ocx + (ev.xmotion.x - x1);
-			c->y = ocy + (ev.xmotion.y - y1);
+			*c->x = ocx + (ev.xmotion.x - x1);
+			*c->y = ocy + (ev.xmotion.y - y1);
 			resize(c, False);
 			break;
 		case ButtonRelease:
@@ -94,12 +94,12 @@ resizemouse(Client *c)
 	XEvent ev;
 	int ocx, ocy;
 
-	ocx = c->x;
-	ocy = c->y;
+	ocx = *c->x;
+	ocy = *c->y;
 	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
 				None, cursor[CurResize], CurrentTime) != GrabSuccess)
 		return;
-	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
+	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, *c->w, *c->h);
 	for(;;) {
 		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
 		switch(ev.type) {
@@ -109,10 +109,10 @@ resizemouse(Client *c)
 			break;
 		case MotionNotify:
 			XSync(dpy, False);
-			c->w = abs(ocx - ev.xmotion.x);
-			c->h = abs(ocy - ev.xmotion.y);
-			c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
-			c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
+			*c->w = abs(ocx - ev.xmotion.x);
+			*c->h = abs(ocy - ev.xmotion.y);
+			*c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - *c->w;
+			*c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - *c->h;
 			resize(c, True);
 			break;
 		case ButtonRelease:
@@ -187,13 +187,13 @@ configurerequest(XEvent *e)
 	if((c = getclient(ev->window))) {
 		gravitate(c, True);
 		if(ev->value_mask & CWX)
-			c->x = ev->x;
+			*c->x = ev->x;
 		if(ev->value_mask & CWY)
-			c->y = ev->y;
+			*c->y = ev->y;
 		if(ev->value_mask & CWWidth)
-			c->w = ev->width;
+			*c->w = ev->width;
 		if(ev->value_mask & CWHeight)
-			c->h = ev->height;
+			*c->h = ev->height;
 		if(ev->value_mask & CWBorderWidth)
 			c->border = 1;
 		gravitate(c, False);
diff --git a/main.c b/main.c
index 6035fb6..e8577fe 100644
--- a/main.c
+++ b/main.c
@@ -261,6 +261,7 @@ main(int argc, char *argv[])
 	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
 
 	strcpy(stext, "dwm-"VERSION);
+
 	scan();
 
 	/* main event loop, reads status text from stdin as well */
diff --git a/tag.c b/tag.c
index fce3c6e..d29a179 100644
--- a/tag.c
+++ b/tag.c
@@ -43,8 +43,10 @@ dofloat(Arg *arg)
 
 	arrange = dofloat;
 	for(c = clients; c; c = c->next) {
-		if(c->tags[tsel])
+		setgeom(c);
+		if(c->tags[tsel]) {
 			resize(c, True);
+		}
 		else
 			ban(c);
 	}
@@ -75,6 +77,7 @@ dotile(Arg *arg)
 		h = sh - bh;
 
 	for(i = 0, c = clients; c; c = c->next) {
+		setgeom(c);
 		if(c->tags[tsel]) {
 			if(c->isfloat) {
 				higher(c);
@@ -82,22 +85,22 @@ dotile(Arg *arg)
 				continue;
 			}
 			if(n == 1) {
-				c->x = sx;
-				c->y = sy + bh;
-				c->w = sw - 2 * c->border;
-				c->h = sh - 2 * c->border - bh;
+				*c->x = sx;
+				*c->y = sy + bh;
+				*c->w = sw - 2 * c->border;
+				*c->h = sh - 2 * c->border - bh;
 			}
 			else if(i == 0) {
-				c->x = sx;
-				c->y = sy + bh;
-				c->w = mw - 2 * c->border;
-				c->h = sh - 2 * c->border - bh;
+				*c->x = sx;
+				*c->y = sy + bh;
+				*c->w = mw - 2 * c->border;
+				*c->h = sh - 2 * c->border - bh;
 			}
 			else {
-				c->x = sx + mw;
-				c->y = sy + (i - 1) * h + bh;
-				c->w = w - 2 * c->border;
-				c->h = h - 2 * c->border;
+				*c->x = sx + mw;
+				*c->y = sy + (i - 1) * h + bh;
+				*c->w = w - 2 * c->border;
+				*c->h = h - 2 * c->border;
 			}
 			resize(c, False);
 			i++;
-- 
2.20.1
From 6649dcce6d7764a2a16345fa8e41759a7fa690f4 Mon Sep 17 00:00:00 2001
From: "Anselm R. Garbe" 
Date: Tue, 18 Jul 2006 13:01:33 +0200
Subject: [PATCH 12/16] changed occurrences of wmii.de into 10kloc.org in
 dwm.html, because 10kloc.org is already working
---
 dwm.html | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/dwm.html b/dwm.html
index 609ce03..32c0eae 100644
--- a/dwm.html
+++ b/dwm.html
@@ -86,27 +86,27 @@
 			
 			
 			It can be downloaded and distributed under the conditions
-			of the MIT/X Consortium license.
+			of the MIT/X Consortium license.
 			
 		
 		Links
 		
 		Development
 		
-		dwm is actively developed in parallel to wmii. You can browse its source code repository or get a copy using Mercurial with following command:
+		dwm is actively developed in parallel to wmii. You can browse its source code repository or get a copy using Mercurial with following command:
 		
 		
-		hg clone http://wmii.de/cgi-bin/hgwebdir.cgi/dwm
+		hg clone http://10kloc.org/cgi-bin/hgwebdir.cgi/dwm
 		
 		Download
 		
 		Miscellaneous
 		
-- 
2.20.1
From f1294353f200bf646b40d85906bac4d204eea5fa Mon Sep 17 00:00:00 2001
From: "arg@mmvi" 
Date: Tue, 18 Jul 2006 15:10:57 +0200
Subject: [PATCH 13/16] firefox instance is different now
---
 tag.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tag.c b/tag.c
index d29a179..077c93c 100644
--- a/tag.c
+++ b/tag.c
@@ -12,7 +12,7 @@
 /* CUSTOMIZE */ 
 static Rule rule[] = {
 	/* class			instance	tags						isfloat */
-	{ "Firefox-bin",	"Gecko",	{ [Twww] = "www" },			False },
+	{ "Firefox-bin",	"firefox-bin",	{ [Twww] = "www" },			False },
 };
 
 /* extern */
-- 
2.20.1
From 95e56ffc0d91f55dcb138b25b6788378971485a5 Mon Sep 17 00:00:00 2001
From: "arg@mmvi" 
Date: Tue, 18 Jul 2006 17:54:55 +0200
Subject: [PATCH 14/16] changed CFLAGs
---
 config.mk | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/config.mk b/config.mk
index 1ee6b6d..7d2cb6d 100644
--- a/config.mk
+++ b/config.mk
@@ -13,12 +13,12 @@ VERSION = 0.3
 LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
 
 # Linux/BSD
-#CFLAGS = -Os -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
-#	-DVERSION=\"${VERSION}\"
-#LDFLAGS = ${LIBS}
-CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
+CFLAGS = -Os -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
 	-DVERSION=\"${VERSION}\"
-LDFLAGS = -g ${LIBS}
+LDFLAGS = ${LIBS}
+#CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
+#	-DVERSION=\"${VERSION}\"
+#LDFLAGS = -g ${LIBS}
 
 
 # Solaris
-- 
2.20.1
From c53980cddcee8afd13ea793134ed3ddf5dbef0e3 Mon Sep 17 00:00:00 2001
From: "arg@10ksloc.org" 
Date: Wed, 19 Jul 2006 11:31:04 +0200
Subject: [PATCH 15/16] applied Sanders resize patch, fixed lower bug
---
 client.c | 10 ++++++++--
 dwm.h    |  5 ++++-
 event.c  | 39 +++++++++++++++++++++++++++------------
 main.c   |  2 +-
 tag.c    |  6 +++---
 5 files changed, 43 insertions(+), 19 deletions(-)
diff --git a/client.c b/client.c
index beb7e35..af2c249 100644
--- a/client.c
+++ b/client.c
@@ -267,7 +267,7 @@ maximize(Arg *arg)
 	*sel->w = sw - 2 * sel->border;
 	*sel->h = sh - 2 * sel->border - bh;
 	higher(sel);
-	resize(sel, False);
+	resize(sel, False, TopLeft);
 }
 
 void
@@ -283,9 +283,11 @@ pop(Client *c)
 }
 
 void
-resize(Client *c, Bool inc)
+resize(Client *c, Bool inc, Corner sticky)
 {
 	XConfigureEvent e;
+	int right = *c->x + *c->w;
+	int bottom = *c->y + *c->h;
 
 	if(inc) {
 		if(c->incw)
@@ -305,6 +307,10 @@ resize(Client *c, Bool inc)
 		*c->w = c->maxw;
 	if(c->maxh && *c->h > c->maxh)
 		*c->h = c->maxh;
+	if(sticky == TopRight || sticky == BottomRight)
+		*c->x = right - *c->w;
+	if(sticky == BottomLeft || sticky == BottomRight)
+		*c->y = bottom - *c->h;
 	resizetitle(c);
 	XSetWindowBorderWidth(dpy, c->win, 1);
 	XMoveResizeWindow(dpy, c->win, *c->x, *c->y, *c->w, *c->h);
diff --git a/dwm.h b/dwm.h
index 6b907a9..d3138be 100644
--- a/dwm.h
+++ b/dwm.h
@@ -25,6 +25,7 @@ enum { Tscratch, Tdev, Twww, Twork, TLast };
 /********** CUSTOMIZE **********/
 
 typedef union Arg Arg;
+typedef enum Corner Corner;
 typedef struct DC DC;
 typedef struct Client Client;
 typedef struct Fnt Fnt;
@@ -43,6 +44,8 @@ enum { WMProtocols, WMDelete, WMLast };
 /* cursor */
 enum { CurNormal, CurResize, CurMove, CurLast };
 
+enum Corner { TopLeft, TopRight, BottomLeft, BottomRight };
+
 struct Fnt {
 	int ascent;
 	int descent;
@@ -121,7 +124,7 @@ extern void lower(Client *c);
 extern void manage(Window w, XWindowAttributes *wa);
 extern void maximize(Arg *arg);
 extern void pop(Client *c);
-extern void resize(Client *c, Bool inc);
+extern void resize(Client *c, Bool inc, Corner sticky);
 extern void setgeom(Client *c);
 extern void setsize(Client *c);
 extern void settitle(Client *c);
diff --git a/event.c b/event.c
index db95dfd..9d69373 100644
--- a/event.c
+++ b/event.c
@@ -79,7 +79,7 @@ movemouse(Client *c)
 			XSync(dpy, False);
 			*c->x = ocx + (ev.xmotion.x - x1);
 			*c->y = ocy + (ev.xmotion.y - y1);
-			resize(c, False);
+			resize(c, False, TopLeft);
 			break;
 		case ButtonRelease:
 			XUngrabPointer(dpy, CurrentTime);
@@ -93,6 +93,7 @@ resizemouse(Client *c)
 {
 	XEvent ev;
 	int ocx, ocy;
+	Corner sticky;
 
 	ocx = *c->x;
 	ocy = *c->y;
@@ -113,7 +114,18 @@ resizemouse(Client *c)
 			*c->h = abs(ocy - ev.xmotion.y);
 			*c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - *c->w;
 			*c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - *c->h;
-			resize(c, True);
+			if(ocx <= ev.xmotion.x) {
+				if(ocy <= ev.xmotion.y)
+					sticky = TopLeft;
+				else
+					sticky = BottomLeft;
+			} else {
+				if(ocy <= ev.xmotion.y)
+					sticky = TopRight;
+				else
+					sticky = BottomRight;
+			}
+			resize(c, True, sticky);
 			break;
 		case ButtonRelease:
 			XUngrabPointer(dpy, CurrentTime);
@@ -153,24 +165,27 @@ buttonpress(XEvent *e)
 		}
 	}
 	else if((c = getclient(ev->window))) {
-		if(arrange == dotile && !c->isfloat) {
-			if((ev->state & ControlMask) && (ev->button == Button1))
-				zoom(NULL);
-			return;
-		}
-		/* floating windows */
-		higher(c);
 		switch(ev->button) {
 		default:
 			break;
 		case Button1:
-			movemouse(c);
+			if(arrange == dotile && !c->isfloat) {
+				if((ev->state & ControlMask) && (ev->button == Button1))
+					zoom(NULL);
+			}
+			else {
+				higher(c);
+				movemouse(c);
+			}
 			break;
 		case Button2:
 			lower(c);
 			break;
 		case Button3:
-			resizemouse(c);
+			if(arrange == dofloat || c->isfloat) {
+				higher(c);
+				resizemouse(c);
+			}
 			break;
 		}
 	}
@@ -197,7 +212,7 @@ configurerequest(XEvent *e)
 		if(ev->value_mask & CWBorderWidth)
 			c->border = 1;
 		gravitate(c, False);
-		resize(c, True);
+		resize(c, True, TopLeft);
 	}
 
 	wc.x = ev->x;
diff --git a/main.c b/main.c
index e8577fe..de59244 100644
--- a/main.c
+++ b/main.c
@@ -24,7 +24,7 @@ static void
 cleanup()
 {
 	while(sel) {
-		resize(sel, True);
+		resize(sel, True, TopLeft);
 		unmanage(sel);
 	}
 	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
diff --git a/tag.c b/tag.c
index 077c93c..1bfedb2 100644
--- a/tag.c
+++ b/tag.c
@@ -45,7 +45,7 @@ dofloat(Arg *arg)
 	for(c = clients; c; c = c->next) {
 		setgeom(c);
 		if(c->tags[tsel]) {
-			resize(c, True);
+			resize(c, True, TopLeft);
 		}
 		else
 			ban(c);
@@ -81,7 +81,7 @@ dotile(Arg *arg)
 		if(c->tags[tsel]) {
 			if(c->isfloat) {
 				higher(c);
-				resize(c, True);
+				resize(c, True, TopLeft);
 				continue;
 			}
 			if(n == 1) {
@@ -102,7 +102,7 @@ dotile(Arg *arg)
 				*c->w = w - 2 * c->border;
 				*c->h = h - 2 * c->border;
 			}
-			resize(c, False);
+			resize(c, False, TopLeft);
 			i++;
 		}
 		else
-- 
2.20.1
From aebd745f72d3bc049d0af68aec33cf17277b20e9 Mon Sep 17 00:00:00 2001
From: "arg@10ksloc.org" 
Date: Wed, 19 Jul 2006 13:22:49 +0200
Subject: [PATCH 16/16] floating clients get random (x,y) offsets now
---
 client.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/client.c b/client.c
index af2c249..62d4afc 100644
--- a/client.c
+++ b/client.c
@@ -192,6 +192,7 @@ lower(Client *c)
 void
 manage(Window w, XWindowAttributes *wa)
 {
+	int diff;
 	Client *c;
 	XSetWindowAttributes twa;
 	Window trans;
@@ -205,6 +206,12 @@ manage(Window w, XWindowAttributes *wa)
 	c->bw = c->fw = c->tw = wa->width;
 	c->fh = c->th = wa->height;
 	c->bh = bh;
+
+	diff = sw - c->fw;
+	c->fx = sx + (random() % diff ? diff : 1);
+	diff = sh - c->fh;
+	c->fy = sx + (random() % diff ? diff : 1);
+
 	c->border = 1;
 	c->proto = getproto(c->win);
 	setsize(c);
-- 
2.20.1