all repos — dwm @ 14d05e7c725a4a07136ceb123cf760272afc1a87

my dwm build

first step to a more flexible dotile() algorithm
Anselm R. Garbe arg@10kloc.org
Fri, 29 Sep 2006 12:38:27 +0200
commit

14d05e7c725a4a07136ceb123cf760272afc1a87

parent

a118a57fe3fd13036f24ebe093a5c329608a0600

7 files changed, 52 insertions(+), 35 deletions(-)

jump to
M config.arg.hconfig.arg.h

@@ -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 SELFGCOLOR "#eeeeee"

#define STATUSBGCOLOR "#222222" #define STATUSFGCOLOR "#9999cc" -#define MASTERW 60 /* percent */ +#define MASTER 60 /* percent */ #define MODKEY Mod1Mask #define KEYS \
M config.default.hconfig.default.h

@@ -8,7 +8,9 @@ const char *tags[] = { "1", "2", "3", "4", "5", NULL };

#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 SELFGCOLOR "#eeeeee"

#define STATUSBGCOLOR "#dddddd" #define STATUSFGCOLOR "#222222" -#define MASTERW 60 /* percent */ +#define MASTER 60 /* percent */ #define MODKEY Mod1Mask #define KEYS \
M config.mkconfig.mk

@@ -1,5 +1,5 @@

# dwm version -VERSION = 1.7.1 +VERSION = 1.8 # Customize below to fit your system
M dwm.hdwm.h

@@ -48,6 +48,10 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */

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 */
M event.cevent.c

@@ -176,8 +176,11 @@ XConfigureWindow(dpy, c->win, newmask, &wc);

else configure(c); XSync(dpy, False); - if(c->isfloat) + if(c->isfloat) { resize(c, False, TopLeft); + if(!isvisible(c)) + ban(c); + } else arrange(NULL); }
M main.cmain.c

@@ -19,7 +19,7 @@ /* extern */

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 @@ bmw = textw(FLOATSYMBOL) > textw(TILESYMBOL) ? textw(FLOATSYMBOL) : textw(TILESYMBOL);

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;
M view.cview.c

@@ -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 @@ else

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 @@ if(!sel || sel->isfloat || n < 2 || (arrange == dofloat))

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); }