first step to a more flexible dotile() algorithm
authorAnselm R. Garbe <arg@10kloc.org>
Fri, 29 Sep 2006 12:38:27 +0200
changeset 505 2c29d74b11dc
parent 504 0cefc169ff67
child 506 b467b5a749db
first step to a more flexible dotile() algorithm
config.arg.h
config.default.h
config.mk
dwm.h
event.c
main.c
view.c
--- a/config.arg.h	Thu Sep 28 21:29:20 2006 +0200
+++ b/config.arg.h	Fri Sep 29 12:38:27 2006 +0200
@@ -6,9 +6,11 @@
 #define TAGS \
 const char *tags[] = { "dev", "work", "net", "fnord", NULL };
 
-#define DEFMODE			dotile /* dofloat */
+#define DEFMODE			dotile		/* dofloat */
 #define FLOATSYMBOL		"><>"
+#define STACKPOS		StackRight	/* StackLeft, StackBottom */
 #define TILESYMBOL		"[]="
+#define VERTICALSTACK		True		/* False == horizontal stack  */
 
 #define FONT			"-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
 #define NORMBGCOLOR		"#333333"
@@ -18,7 +20,7 @@
 #define STATUSBGCOLOR		"#222222"
 #define STATUSFGCOLOR		"#9999cc"
 
-#define MASTERW			60 /* percent */
+#define MASTER			60 /* percent */
 #define MODKEY			Mod1Mask
 
 #define KEYS \
--- a/config.default.h	Thu Sep 28 21:29:20 2006 +0200
+++ b/config.default.h	Fri Sep 29 12:38:27 2006 +0200
@@ -8,7 +8,9 @@
 
 #define DEFMODE			dotile /* dofloat */
 #define FLOATSYMBOL		"><>"
+#define STACKPOS		StackRight	/* StackLeft, StackBottom */
 #define TILESYMBOL		"[]="
+#define VERTICALSTACK		True		/* False == horizontal stack  */
 
 #define FONT			"fixed"
 #define NORMBGCOLOR		"#333366"
@@ -18,7 +20,7 @@
 #define STATUSBGCOLOR		"#dddddd"
 #define STATUSFGCOLOR		"#222222"
 
-#define MASTERW			60 /* percent */
+#define MASTER			60 /* percent */
 #define MODKEY			Mod1Mask
 
 #define KEYS \
--- a/config.mk	Thu Sep 28 21:29:20 2006 +0200
+++ b/config.mk	Fri Sep 29 12:38:27 2006 +0200
@@ -1,5 +1,5 @@
 # dwm version
-VERSION = 1.7.1
+VERSION = 1.8
 
 # Customize below to fit your system
 
--- a/dwm.h	Thu Sep 28 21:29:20 2006 +0200
+++ b/dwm.h	Fri Sep 29 12:38:27 2006 +0200
@@ -48,6 +48,10 @@
 enum { ColFG, ColBG, ColLast };				/* color */
 
 typedef enum {
+	StackLeft, StackBottom, StackRight
+} StackPos; /* stack position*/
+
+typedef enum {
 	TopLeft, TopRight, BotLeft, BotRight
 } Corner; /* window corners */
 
@@ -97,16 +101,18 @@
 extern const char *tags[];			/* all tags */
 extern char stext[1024];			/* status text */
 extern int bx, by, bw, bh, bmw;			/* bar geometry, bar mode label width */
-extern int mw, screen, sx, sy, sw, sh;		/* screen geometry, master width */
+extern int master, screen, sx, sy, sw, sh;	/* screen geometry, master width */
 extern unsigned int ntags, numlockmask;		/* number of tags, dynamic lock mask */
 extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
 extern void (*arrange)(Arg *);			/* arrange function, indicates mode  */
 extern Atom wmatom[WMLast], netatom[NetLast];
 extern Bool running, issel, *seltag;		/* seltag is array of Bool */
+extern Bool isvertical;				/* stack direction */
 extern Client *clients, *sel, *stack;		/* global client list and stack */
 extern Cursor cursor[CurLast];
 extern DC dc;					/* global draw context */
 extern Display *dpy;
+extern StackPos stackpos;
 extern Window root, barwin;
 
 /* client.c */
--- a/event.c	Thu Sep 28 21:29:20 2006 +0200
+++ b/event.c	Fri Sep 29 12:38:27 2006 +0200
@@ -176,8 +176,11 @@
 		else
 			configure(c);
 		XSync(dpy, False);
-		if(c->isfloat)
+		if(c->isfloat) {
 			resize(c, False, TopLeft);
+			if(!isvisible(c))
+				ban(c);
+		}
 		else
 			arrange(NULL);
 	}
--- a/main.c	Thu Sep 28 21:29:20 2006 +0200
+++ b/main.c	Fri Sep 29 12:38:27 2006 +0200
@@ -19,7 +19,7 @@
 
 char stext[1024];
 Bool *seltag;
-int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh;
+int bx, by, bw, bh, bmw, master, screen, sx, sy, sw, sh;
 unsigned int ntags, numlockmask;
 Atom wmatom[WMLast], netatom[NetLast];
 Bool running = True;
@@ -133,7 +133,7 @@
 	sx = sy = 0;
 	sw = DisplayWidth(dpy, screen);
 	sh = DisplayHeight(dpy, screen);
-	mw = (sw * MASTERW) / 100;
+	master = ((stackpos == StackBottom ? sh - bh : sw) * MASTER) / 100;
 
 	bx = by = 0;
 	bw = sw;
--- a/view.c	Thu Sep 28 21:29:20 2006 +0200
+++ b/view.c	Fri Sep 29 12:38:27 2006 +0200
@@ -65,6 +65,8 @@
 /* extern */
 
 void (*arrange)(Arg *) = DEFMODE;
+Bool isvertical = VERTICALSTACK;
+StackPos stackpos = STACKPOS;
 
 void
 detach(Client *c) {
@@ -97,35 +99,37 @@
 
 /* This algorithm is based on a (M)aster area and a (S)tacking area.
  * It supports following arrangements:
- *
- * 	MMMS		MMMM
- * 	MMMS		MMMM
- * 	MMMS		SSSS
- *
- * The stacking area can be set to arrange clients vertically or horizontally.
- * Through inverting the algorithm it can be used to achieve following setup in
- * a dual head environment (due to running two dwm instances concurrently on
- * the specific screen):
- *
- * 	SMM MMS		MMM MMM
- * 	SMM MMS		MMM MMM
- * 	SMM MMS		SSS SSS
- *
- * This uses the center of the two screens for master areas.
+ * 	MMMS		MMMM		SMMM
+ * 	MMMS		MMMM		SMMM
+ * 	MMMS		SSSS		SMMM
  */
 void
 dotile(Arg *arg) {
 	int h, i, n, w;
 	Client *c;
 
-	w = sw - mw;
 	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
 		n++;
 
-	if(n > 1)
-		h = (sh - bh) / (n - 1);
-	else
-		h = sh - bh;
+	if(isvertical) {
+		if(stackpos == StackBottom) {
+			w = sw;
+			if(n > 1)
+				h = (sh - bh) / (n - 1);
+			else
+				h = sh - bh;
+		}
+		else {
+			w = sw - master;
+			if(n > 1)
+				h = (sh - bh) / (n - 1);
+			else
+				h = sh - bh;
+		}
+	}
+	else { /* horizontal stack */
+
+	}
 
 	for(i = 0, c = clients; c; c = c->next) {
 		if(isvisible(c)) {
@@ -143,11 +147,11 @@
 			else if(i == 0) {
 				c->x = sx;
 				c->y = sy + bh;
-				c->w = mw - 2 * BORDERPX;
+				c->w = master - 2 * BORDERPX;
 				c->h = sh - 2 * BORDERPX - bh;
 			}
 			else if(h > bh) {
-				c->x = sx + mw;
+				c->x = sx + master;
 				c->y = sy + (i - 1) * h + bh;
 				c->w = w - 2 * BORDERPX;
 				if(i + 1 == n)
@@ -156,7 +160,7 @@
 					c->h = h - 2 * BORDERPX;
 			}
 			else { /* fallback if h < bh */
-				c->x = sx + mw;
+				c->x = sx + master;
 				c->y = sy + bh;
 				c->w = w - 2 * BORDERPX;
 				c->h = sh - 2 * BORDERPX - bh;
@@ -228,14 +232,14 @@
 		return;
 
 	if(sel == getnext(clients)) {
-		if(mw + arg->i > sw - 100 || mw + arg->i < 100)
+		if(master + arg->i > sw - 100 || master + arg->i < 100)
 			return;
-		mw += arg->i;
+		master += arg->i;
 	}
 	else {
-		if(mw - arg->i > sw - 100 || mw - arg->i < 100)
+		if(master - arg->i > sw - 100 || master - arg->i < 100)
 			return;
-		mw -= arg->i;
+		master -= arg->i;
 	}
 	arrange(NULL);
 }