Hi,

I stumbled upon the list of Xmonad extensions[1] and saw a spiral tiling layout
there.  Attached is the resulting patch that implements something similar for
dwm.

A quick ascii-art representation:

+-----------+-----------+
|           |           |
|           |           |
|           |           |
|           +--+--+-----+
|           |  |-+|     |
|           +--+--+     |
|           |     |     |
+-----------+-----+-----+

[1]: http://www.xmonad.org/contrib.html

Regards,
-- 
Jeroen Schot

[EMAIL PROTECTED] (mail & jabber)
http://schot.a-eskwadraat.nl
diff -up dwm.orig/config.default.h dwm/config.default.h
--- dwm.orig/config.default.h	2007-07-23 21:37:29.000000000 +0200
+++ dwm/config.default.h	2007-07-24 15:43:59.000000000 +0200
@@ -30,6 +30,7 @@ static Layout layout[] = { \
 	/* symbol		function */ \
 	{ "[]=",		tile }, /* first entry is default */ \
 	{ "><>",		floating }, \
+	{ "(@)",		spiral	}, \
 };
 #define MASTERWIDTH		600		/* master width per thousand */
 #define NMASTER			1		/* clients in master area */
diff -up dwm.orig/dwm.h dwm/dwm.h
--- dwm.orig/dwm.h	2007-07-23 21:37:29.000000000 +0200
+++ dwm/dwm.h	2007-07-24 15:43:29.000000000 +0200
@@ -127,6 +127,7 @@ void initlayouts(void);			/* initialize 
 Client *nexttiled(Client *c);		/* returns tiled successor of c */
 void restack(void);			/* restores z layers of all clients */
 void setlayout(const char *arg);	/* sets layout, NULL means next layout */
+void spiral(void);			/* arranges all windows in a spiral */	
 void togglebar(const char *arg);	/* shows/hides the bar */
 void togglemax(const char *arg);	/* toggles maximization of floating client */
 void zoom(const char *arg);		/* zooms the focused client to master area, arg is ignored */
diff -up dwm.orig/layout.c dwm/layout.c
--- dwm.orig/layout.c	2007-07-23 21:37:29.000000000 +0200
+++ dwm/layout.c	2007-07-24 15:46:42.000000000 +0200
@@ -211,6 +211,50 @@ setlayout(const char *arg) {
 }
 
 void
+spiral(void) {
+	unsigned int i, n, nx, ny, nw, nh;
+	Client *c;
+
+	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+		n++;
+	nx = wax;
+	ny = way + wah;
+	nh = wah;
+	nw = waw;
+	for(i = 0, c = clients; c; c = c->next)
+		if(isvisible(c)) {
+			unban(c);
+			if(c->isfloating)
+				continue;
+			c->ismax = False;
+			if(i < n - 1) {
+				if(i % 2 == 0)
+					nw /= 2;
+				else
+					nh /= 2;
+				if(i % 4 == 2)
+					nx += nw;
+				else if(i % 4 == 3)
+					ny += nh;
+			}
+			if(i % 4 == 0)
+				ny -= nh;
+			else if(i % 4 == 1)
+				nx += nw;
+			else if(i % 4 == 2)
+				ny += nh;
+			else 
+				nx -= nw;
+			resize(c, nx, ny, nw - 2 * c->border, nh - 2 * c ->border, False);
+			i++;
+		}
+		else
+			ban(c);
+	focus(NULL);
+	restack();
+}
+
+void
 togglebar(const char *arg) {
 	if(bpos == BarOff)
 		bpos = (BARPOS == BarOff) ? BarTop : BARPOS;

Reply via email to