Hi,

a friend of mine wrote an alternative bottom stack patch for dwm
(currently included for 2.7) that differs from Ross Mohn's "Bottom Stack
Layout" patch in the way that it doesn't create pancake-like flat
windows layed on top of one another but rather a number of windows side
by side this way:

+----+
|    |
+----+
[][][]

We consider this layout far more usable, especially on widescreen
displays which are getting more and more popular.

This code is based mostly on Ross'es code, it's simplified in the way,
that there's no way to move the stack to the left side of the screen. We
don't think it's worth the extra code.

Also there's a simple feature added that make all tags (-1) visible when
leaving dwm -- a useful feature for those who quit dwm in a hurry
leaving some clients invisible and running.

Hope some of you find it useful,

cheers,

[a]

-- 
. Antoni Grzymala - antoni (at) chopin.edu.pl -------------------.
| OpenPGP KeyID EB315583 available now from a keyserver near you |
| Fingerprint A819 6D2E D5EB D9E0 D2D9  7AF6 2FAF 4A11 EB31 5583 |
`----------------------------------------------------------------'
diff -Naur dwm-2.7/config.default.h dwm-2.7-new/config.default.h
--- dwm-2.7/config.default.h    2006-12-14 08:50:46.000000000 +0100
+++ dwm-2.7-new/config.default.h        2006-12-14 15:09:43.000000000 +0100
@@ -7,7 +7,9 @@
 
 #define DEFMODE                        dotile /* dofloat */
 #define FLOATSYMBOL            "><>"
-#define TILESYMBOL             "[]="
+#define VSTACKSYMBOL           "[]="
+#define BSTACKSYMBOL           "==="
+#define STACKPOS               StackRight      /* StackLeft */
 
 #define FONT                   "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
 #define NORMBGCOLOR            "#333366"
@@ -28,6 +30,7 @@
        { MODKEY,                       XK_Tab,         focusnext,      { 0 } 
}, \
        { MODKEY|ShiftMask,             XK_Tab,         focusprev,      { 0 } 
}, \
        { MODKEY,                       XK_Return,      zoom,           { 0 } 
}, \
+       { MODKEY,                       XK_b,           togglestackpos, { 0 } 
}, \
        { MODKEY,                       XK_g,           resizemaster,   { .i = 
15 } }, \
        { MODKEY,                       XK_s,           resizemaster,   { .i = 
-15 } }, \
        { MODKEY|ShiftMask,             XK_0,           tag,            { .i = 
-1 } }, \
diff -Naur dwm-2.7/draw.c dwm-2.7-new/draw.c
--- dwm-2.7/draw.c      2006-12-14 08:50:46.000000000 +0100
+++ dwm-2.7-new/draw.c  2006-12-14 15:09:43.000000000 +0100
@@ -120,7 +120,8 @@
                dc.x += dc.w;
        }
        dc.w = bmw;
-       drawtext(arrange == dofloat ?  FLOATSYMBOL : TILESYMBOL, dc.status, 
False, False);
+       drawtext(arrange == dofloat ?  FLOATSYMBOL : stackpos == StackBottom ?
+               BSTACKSYMBOL : VSTACKSYMBOL, dc.status, False, False);
        x = dc.x + dc.w;
        dc.w = textw(stext);
        dc.x = bw - dc.w;
diff -Naur dwm-2.7/dwm.h dwm-2.7-new/dwm.h
--- dwm-2.7/dwm.h       2006-12-14 08:50:46.000000000 +0100
+++ dwm-2.7-new/dwm.h   2006-12-14 15:09:43.000000000 +0100
@@ -46,6 +46,10 @@
 enum { ColFG, ColBG, ColLast };                                /* color */
 
 typedef enum {
+       StackLeft, StackBottom, StackRight
+} StackPos; /* stack position */
+
+typedef enum {
        TopLeft, TopRight, BotLeft, BotRight
 } Corner; /* window corners */
 
@@ -105,6 +109,7 @@
 extern Cursor cursor[CurLast];
 extern DC dc;                                  /* global draw context */
 extern Display *dpy;
+extern StackPos stackpos;
 extern Window root, barwin;
 
 /* client.c */
@@ -162,6 +167,7 @@
 extern Bool isvisible(Client *c);              /* returns True if client is 
visible */
 extern void resizemaster(Arg *arg);            /* resizes the master percent 
with arg's index value */
 extern void restack(void);                     /* restores z layers of all 
clients */
+extern void togglestackpos(Arg *arg);          /* toggles stack position */
 extern void togglefloat(Arg *arg);             /* toggles focusesd client 
between floating/non-floating state */
 extern void togglemode(Arg *arg);              /* toggles global arrange 
function (dotile/dofloat) */
 extern void toggleview(Arg *arg);              /* toggles the tag with arg's 
index (in)visible */
diff -Naur dwm-2.7/event.c dwm-2.7-new/event.c
--- dwm-2.7/event.c     2006-12-14 08:50:46.000000000 +0100
+++ dwm-2.7-new/event.c 2006-12-14 15:09:43.000000000 +0100
@@ -133,6 +133,8 @@
                }
                if((ev->x < x + bmw) && (ev->button == Button1))
                        togglemode(NULL);
+               else if((ev->x < x + bmw) && (ev->button == Button3))
+                       togglestackpos(NULL);
        }
        else if((c = getclient(ev->window))) {
                focus(c);
diff -Naur dwm-2.7/main.c dwm-2.7-new/main.c
--- dwm-2.7/main.c      2006-12-14 08:50:46.000000000 +0100
+++ dwm-2.7-new/main.c  2006-12-14 15:09:43.000000000 +0100
@@ -128,7 +128,8 @@
        dc.status[ColFG] = getcolor(STATUSFGCOLOR);
        setfont(FONT);
        /* geometry */
-       bmw = textw(TILESYMBOL) > textw(FLOATSYMBOL) ?  textw(TILESYMBOL) : 
textw(FLOATSYMBOL);
+       bmw = textw(VSTACKSYMBOL) > textw(BSTACKSYMBOL) ? textw(VSTACKSYMBOL) : 
textw(BSTACKSYMBOL);
+       bmw = bmw > textw(FLOATSYMBOL) ? bmw : textw(FLOATSYMBOL);
        sx = sy = 0;
        sw = DisplayWidth(dpy, screen);
        sh = DisplayHeight(dpy, screen);
@@ -206,6 +207,9 @@
 
 void
 quit(Arg *arg) {
+        Arg a;
+        a.i = -1;
+        view(&a);
        readin = running = False;
 }
 
diff -Naur dwm-2.7/view.c dwm-2.7-new/view.c
--- dwm-2.7/view.c      2006-12-14 08:50:46.000000000 +0100
+++ dwm-2.7-new/view.c  2006-12-14 15:09:43.000000000 +0100
@@ -37,6 +37,7 @@
 /* extern */
 
 void (*arrange)(void) = DEFMODE;
+StackPos stackpos = STACKPOS;
 
 void
 detach(Client *c) {
@@ -69,7 +70,7 @@
 
 void
 dotile(void) {
-       unsigned int i, n, mpx, stackw, th;
+       unsigned int i, n, mpx, mpy, stackw, stackh, th, tw;
        Client *c;
 
        for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
@@ -77,6 +78,9 @@
        mpx = (waw * master) / 1000;
        stackw = waw - mpx;
 
+        mpy = (wah * master) / 1000;
+        stackh = wah - mpy;
+
        for(i = 0, c = clients; c; c = c->next)
                if(isvisible(c)) {
                        if(c->isfloat) {
@@ -91,19 +95,38 @@
                                c->h = wah - 2 * BORDERPX;
                        }
                        else if(i == 0) { /* master window */
-                               c->w = mpx - 2 * BORDERPX;
-                               c->h = wah - 2 * BORDERPX;
-                               th = wah / (n - 1);
+                               if (stackpos == StackRight){
+                                       c->w = mpx - 2 * BORDERPX;
+                                       c->h = wah - 2 * BORDERPX;
+                                       th = wah / (n - 1);
+                                       }
+                               else {
+                                       c->w = waw - 2 * BORDERPX;
+                                       c->h = mpy - 2 * BORDERPX;
+                                       tw = waw / (n - 1);
+                                       }
                        }
                        else {  /* tile window */
-                               c->x += mpx;
-                               c->w = stackw - 2 * BORDERPX;
-                               if(th > bh) {
-                                       c->y += (i - 1) * th;
-                                       c->h = th - 2 * BORDERPX;
+                               if (stackpos == StackRight){
+                                       c->x += mpx;            
+                                       c->w = stackw - 2 * BORDERPX;
+                                       if(th > bh) {
+                                               c->y += (i - 1) * th;
+                                               c->h = th - 2 * BORDERPX;
+                                       }
+                                       else /* fallback if th < bh */
+                                        c->h = wah - 2 * BORDERPX;
+                               }
+                               else{
+                                       c->y += mpy;
+                                       c->h = stackh - 2 * BORDERPX;
+                                       if(tw > bh) {
+                                               c->x += (i - 1) * tw;
+                                               c->w = tw - 2 * BORDERPX;
+                                       }
+                                       else /* fallback if th < bh */
+                                               c->w = waw - 2 * BORDERPX;
                                }
-                               else /* fallback if th < bh */
-                                       c->h = wah - 2 * BORDERPX;
                        }
                        resize(c, False, TopLeft);
                        i++;
@@ -229,6 +252,14 @@
 }
 
 void
+togglestackpos(Arg *arg) {
+       if(arrange == dofloat)
+               return;
+       stackpos = stackpos == StackBottom ? STACKPOS : StackBottom;
+       arrange();
+}
+
+void
 view(Arg *arg) {
        unsigned int i;
 

Attachment: pgp8tC27LlD9m.pgp
Description: PGP signature

Reply via email to