| tfirst step to a more flexible dotile() algorithm - dwm - [fork] customized bui… | |
| git clone git://src.adamsgaard.dk/dwm | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| commit 14d05e7c725a4a07136ceb123cf760272afc1a87 | |
| parent a118a57fe3fd13036f24ebe093a5c329608a0600 | |
| Author: Anselm R. Garbe <[email protected]> | |
| Date: Fri, 29 Sep 2006 12:38:27 +0200 | |
| first step to a more flexible dotile() algorithm | |
| Diffstat: | |
| M config.arg.h | 6 ++++-- | |
| M config.default.h | 4 +++- | |
| M config.mk | 2 +- | |
| M dwm.h | 8 +++++++- | |
| M event.c | 5 ++++- | |
| M main.c | 4 ++-- | |
| M view.c | 58 +++++++++++++++++------------… | |
| 7 files changed, 52 insertions(+), 35 deletions(-) | |
| --- | |
| diff --git a/config.arg.h b/config.arg.h | |
| t@@ -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 == horizonta… | |
| #define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso… | |
| #define NORMBGCOLOR "#333333" | |
| t@@ -18,7 +20,7 @@ const char *tags[] = { "dev", "work", "net", "fnord", NULL }; | |
| #define STATUSBGCOLOR "#222222" | |
| #define STATUSFGCOLOR "#9999cc" | |
| -#define MASTERW 60 /* percent */ | |
| +#define MASTER 60 /* percent */ | |
| #define MODKEY Mod1Mask | |
| #define KEYS \ | |
| diff --git a/config.default.h b/config.default.h | |
| t@@ -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 == horizonta… | |
| #define FONT "fixed" | |
| #define NORMBGCOLOR "#333366" | |
| t@@ -18,7 +20,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", NULL }; | |
| #define STATUSBGCOLOR "#dddddd" | |
| #define STATUSFGCOLOR "#222222" | |
| -#define MASTERW 60 /* percent */ | |
| +#define MASTER 60 /* percent */ | |
| #define MODKEY Mod1Mask | |
| #define KEYS \ | |
| diff --git a/config.mk b/config.mk | |
| t@@ -1,5 +1,5 @@ | |
| # dwm version | |
| -VERSION = 1.7.1 | |
| +VERSION = 1.8 | |
| # Customize below to fit your system | |
| diff --git a/dwm.h b/dwm.h | |
| t@@ -48,6 +48,10 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* … | |
| enum { ColFG, ColBG, ColLast }; /* color */ | |
| typedef enum { | |
| + StackLeft, StackBottom, StackRight | |
| +} StackPos; /* stack position*/ | |
| + | |
| +typedef enum { | |
| TopLeft, TopRight, BotLeft, BotRight | |
| } Corner; /* window corners */ | |
| t@@ -97,16 +101,18 @@ struct Client { | |
| extern const char *tags[]; /* all tags */ | |
| extern char stext[1024]; /* status text */ | |
| extern int bx, by, bw, bh, bmw; /* bar geometry, bar mo… | |
| -extern int mw, screen, sx, sy, sw, sh; /* screen geometry, mast… | |
| +extern int master, screen, sx, sy, sw, sh; /* screen geometry, master w… | |
| extern unsigned int ntags, numlockmask; /* number of tags, dyna… | |
| extern void (*handler[LASTEvent])(XEvent *); /* event handler */ | |
| extern void (*arrange)(Arg *); /* arrange function, ind… | |
| 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… | |
| extern Cursor cursor[CurLast]; | |
| extern DC dc; /* global draw context */ | |
| extern Display *dpy; | |
| +extern StackPos stackpos; | |
| extern Window root, barwin; | |
| /* client.c */ | |
| diff --git a/event.c b/event.c | |
| t@@ -176,8 +176,11 @@ configurerequest(XEvent *e) { | |
| else | |
| configure(c); | |
| XSync(dpy, False); | |
| - if(c->isfloat) | |
| + if(c->isfloat) { | |
| resize(c, False, TopLeft); | |
| + if(!isvisible(c)) | |
| + ban(c); | |
| + } | |
| else | |
| arrange(NULL); | |
| } | |
| diff --git a/main.c b/main.c | |
| t@@ -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; | |
| t@@ -133,7 +133,7 @@ setup(void) { | |
| 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; | |
| diff --git a/view.c b/view.c | |
| t@@ -65,6 +65,8 @@ togglemax(Client *c) | |
| /* extern */ | |
| void (*arrange)(Arg *) = DEFMODE; | |
| +Bool isvertical = VERTICALSTACK; | |
| +StackPos stackpos = STACKPOS; | |
| void | |
| detach(Client *c) { | |
| t@@ -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)) { | |
| t@@ -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) | |
| t@@ -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; | |
| t@@ -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); | |
| } |