about summary refs log tree commit diff stats
path: root/view.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@10kloc.org>2006-09-29 12:38:27 +0200
committerAnselm R. Garbe <arg@10kloc.org>2006-09-29 12:38:27 +0200
commit14d05e7c725a4a07136ceb123cf760272afc1a87 (patch)
tree39328e09b357c05afb8951c5aaccaeb844b2b14d /view.c
parenta118a57fe3fd13036f24ebe093a5c329608a0600 (diff)
downloaddwm-14d05e7c725a4a07136ceb123cf760272afc1a87.tar.gz
first step to a more flexible dotile() algorithm
Diffstat (limited to 'view.c')
-rw-r--r--view.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/view.c b/view.c
index d3378ff..90080fb 100644
--- a/view.c
+++ b/view.c
@@ -65,6 +65,8 @@ togglemax(Client *c)
 /* extern */
 
 void (*arrange)(Arg *) = DEFMODE;
+Bool isvertical = VERTICALSTACK;
+StackPos stackpos = STACKPOS;
 
 void
 detach(Client *c) {
@@ -97,35 +99,37 @@ dofloat(Arg *arg) {
 
 /* 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 @@ dotile(Arg *arg) {
 			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 @@ dotile(Arg *arg) {
 					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 @@ resizecol(Arg *arg) {
 		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);
 }