dwm.c
changeset 1130 b661ad410646
parent 1129 43d862bda73e
child 1132 a1c28da5bc91
--- a/dwm.c	Thu Mar 06 18:53:15 2008 +0000
+++ b/dwm.c	Thu Mar 06 19:20:14 2008 +0000
@@ -1,6 +1,3 @@
-/**
- * - allow for vstack
- */
 /* See LICENSE file for copyright and license details.
  *
  * dynamic window manager is designed like any other X client as well. It is
@@ -36,7 +33,6 @@
 #include <sys/select.h>
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <regex.h>
 #include <X11/cursorfont.h>
 #include <X11/keysym.h>
 #include <X11/Xatom.h>
@@ -170,8 +166,10 @@
 void tag(const char *arg);
 unsigned int textnw(const char *text, unsigned int len);
 unsigned int textw(const char *text);
-void tile(void);
+void tileh(void);
+void tilehstack(unsigned int n);
 unsigned int tilemaster(void);
+void tilev(void);
 void tilevstack(unsigned int n);
 void togglefloating(const char *arg);
 void toggletag(const char *arg);
@@ -1547,6 +1545,37 @@
 		resize(c, x, y, w, h, False);
 }
 
+void
+tileh(void) {
+	tilehstack(tilemaster());
+}
+
+void
+tilehstack(unsigned int n) {
+	int i, x, w;
+	Client *c;
+
+	if(n == 0)
+		return;
+
+	x = TX;
+	w = (TW) / n;
+	if(w < bh)
+		w = TW;
+
+	for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++)
+		if(i > 0) {
+			if(i > 1 && i == n) /* remainder */
+				tileresize(c, x, TY, ((TX) + (TW)) - x - 2 * c->border,
+				              TH - 2 * c->border);
+			else
+				tileresize(c, x, TY, w - 2 * c->border,
+				              TH - 2 * c->border);
+			if(w != TW)
+				x = c->x + c->w + 2 * c->border;
+		}
+}
+
 unsigned int
 tilemaster(void) {
 	unsigned int n;
@@ -1564,6 +1593,11 @@
 }
 
 void
+tilev(void) {
+	tilevstack(tilemaster());
+}
+
+void
 tilevstack(unsigned int n) {
 	int i, y, h;
 	Client *c;
@@ -1590,11 +1624,6 @@
 }
 
 void
-tile(void) {
-	tilevstack(tilemaster());
-}
-
-void
 togglefloating(const char *arg) {
 	if(!sel)
 		return;