texperimental version which allows master clients being increased/decreased - d… | |
git clone git://src.adamsgaard.dk/dwm | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 0b80d1842d1c921a8a94c11fd9222dad9311cc97 | |
parent d7ec23a5db32eb00ee90e60bef35010639498cab | |
Author: Anselm R. Garbe <[email protected]> | |
Date: Fri, 5 Jan 2007 12:50:39 +0100 | |
experimental version which allows master clients being increased/decreased | |
Diffstat: | |
M config.arg.h | 3 +++ | |
M config.default.h | 1 + | |
M config.mk | 4 ++-- | |
M dwm.h | 4 +++- | |
M main.c | 3 ++- | |
M view.c | 55 +++++++++++++++++++----------… | |
6 files changed, 45 insertions(+), 25 deletions(-) | |
--- | |
diff --git a/config.arg.h b/config.arg.h | |
t@@ -19,6 +19,7 @@ const char *tags[] = { "dev", "work", "net", "fnord", NULL }; | |
#define MASTER 600 /* per thousand */ | |
#define MODKEY Mod1Mask | |
+#define NMASTER 1 /* clients in master a… | |
#define SNAP 40 /* pixel */ | |
#define KEYS \ | |
t@@ -30,10 +31,12 @@ static Key key[] = { \ | |
{ .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u "… | |
" | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMF… | |
"-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe… | |
+ { MODKEY, XK_d, incnmaster, … | |
{ MODKEY, XK_j, focusnext, … | |
{ MODKEY, XK_k, focusprev, … | |
{ MODKEY, XK_Return, zoom, … | |
{ MODKEY, XK_g, resizemaster, … | |
+ { MODKEY, XK_i, incnmaster, … | |
{ MODKEY, XK_s, resizemaster, … | |
{ MODKEY|ShiftMask, XK_0, tag, … | |
{ MODKEY|ShiftMask, XK_1, tag, … | |
diff --git a/config.default.h b/config.default.h | |
t@@ -19,6 +19,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", NULL }; | |
#define MASTER 600 /* per thousand */ | |
#define MODKEY Mod1Mask | |
+#define NMASTER 1 /* clients in master a… | |
#define SNAP 20 /* pixel */ | |
#define KEYS \ | |
diff --git a/config.mk b/config.mk | |
t@@ -17,8 +17,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 | |
# flags | |
CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" | |
LDFLAGS = ${LIBS} | |
-#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" | |
-#LDFLAGS = -g ${LIBS} | |
+CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" | |
+LDFLAGS = -g ${LIBS} | |
# Solaris | |
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" | |
diff --git a/dwm.h b/dwm.h | |
t@@ -96,7 +96,8 @@ extern char stext[1024]; /* status te… | |
extern int bx, by, bw, bh, bmw; /* bar geometry, bar mo… | |
extern int screen, sx, sy, sw, sh; /* screen geometry */ | |
extern int wax, way, wah, waw; /* windowarea geometry */ | |
-extern unsigned int master, ntags, numlockmask; /* master percent, numb… | |
+extern unsigned int master, nmaster; /* master percent, number … | |
+extern unsigned int ntags, numlockmask; /* number of tags, dyna… | |
extern void (*handler[LASTEvent])(XEvent *); /* event handler */ | |
extern void (*arrange)(void); /* arrange function, indi… | |
extern Atom wmatom[WMLast], netatom[NetLast]; | |
t@@ -159,6 +160,7 @@ extern void dofloat(void); /* arran… | |
extern void dotile(void); /* arranges all windows tiled… | |
extern void focusnext(Arg *arg); /* focuses next visible client… | |
extern void focusprev(Arg *arg); /* focuses previous visible cl… | |
+extern void incnmaster(Arg *arg); /* increments nmaster with ar… | |
extern Bool isvisible(Client *c); /* returns True if client is … | |
extern void resizemaster(Arg *arg); /* resizes the master perce… | |
extern void restack(void); /* restores z layers of all … | |
diff --git a/main.c b/main.c | |
t@@ -20,7 +20,7 @@ | |
char stext[1024]; | |
Bool *seltag; | |
int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah; | |
-unsigned int master, ntags, numlockmask; | |
+unsigned int master, nmaster, ntags, numlockmask; | |
Atom wmatom[WMLast], netatom[NetLast]; | |
Bool running = True; | |
Bool issel = True; | |
t@@ -133,6 +133,7 @@ setup(void) { | |
sw = DisplayWidth(dpy, screen); | |
sh = DisplayHeight(dpy, screen); | |
master = MASTER; | |
+ nmaster = NMASTER; | |
/* bar */ | |
bx = sx; | |
by = sy; | |
diff --git a/view.c b/view.c | |
t@@ -69,12 +69,16 @@ dofloat(void) { | |
void | |
dotile(void) { | |
- unsigned int i, n, mpw, th; | |
+ unsigned int i, n, mw, mh, tw, th; | |
Client *c; | |
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) | |
n++; | |
- mpw = (waw * master) / 1000; | |
+ /* window geoms */ | |
+ mw = (n > nmaster) ? (waw * master) / 1000 : waw; | |
+ mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1); | |
+ tw = waw - mw; | |
+ th = (n > nmaster) ? wah / (n - nmaster) : 0; | |
for(i = 0, c = clients; c; c = c->next) | |
if(isvisible(c)) { | |
t@@ -85,20 +89,16 @@ dotile(void) { | |
c->ismax = False; | |
c->x = wax; | |
c->y = way; | |
- if(n == 1) { /* only 1 window */ | |
- c->w = waw - 2 * BORDERPX; | |
- c->h = wah - 2 * BORDERPX; | |
- } | |
- else if(i == 0) { /* master window */ | |
- c->w = mpw - 2 * BORDERPX; | |
- c->h = wah - 2 * BORDERPX; | |
- th = wah / (n - 1); | |
+ if(i < nmaster) { | |
+ c->y += i * mh; | |
+ c->w = mw - 2 * BORDERPX; | |
+ c->h = mh - 2 * BORDERPX; | |
} | |
else { /* tile window */ | |
- c->x += mpw; | |
- c->w = (waw - mpw) - 2 * BORDERPX; | |
+ c->x += mw; | |
+ c->w = tw - 2 * BORDERPX; | |
if(th > bh) { | |
- c->y += (i - 1) * th; | |
+ c->y += (i - nmaster) * th; | |
c->h = th - 2 * BORDERPX; | |
} | |
else /* fallback if th < bh */ | |
t@@ -147,6 +147,14 @@ focusprev(Arg *arg) { | |
} | |
} | |
+void | |
+incnmaster(Arg *arg) { | |
+ if(nmaster + arg->i < 1) | |
+ return; | |
+ nmaster += arg->i; | |
+ arrange(); | |
+} | |
+ | |
Bool | |
isvisible(Client *c) { | |
unsigned int i; | |
t@@ -240,7 +248,7 @@ view(Arg *arg) { | |
void | |
zoom(Arg *arg) { | |
- unsigned int n; | |
+ unsigned int i, n; | |
Client *c; | |
if(!sel) | |
t@@ -249,14 +257,19 @@ zoom(Arg *arg) { | |
togglemax(sel); | |
return; | |
} | |
- for(n = 0, c = clients; c; c = c->next) | |
- if(isvisible(c) && !c->isfloat) | |
- n++; | |
- if(n < 2 || (arrange == dofloat)) | |
+ for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) | |
+ n++; | |
+ if(n <= nmaster || (arrange == dofloat)) | |
return; | |
- if((c = sel) == nexttiled(clients)) | |
- if(!(c = nexttiled(c->next))) | |
- return; | |
+ | |
+ for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c =… | |
+ i++; | |
+ if(c == sel && i < nmaster) | |
+ for(; c && i < nmaster; c = nexttiled(c->next)) | |
+ i++; | |
+ if(!c) | |
+ return; | |
+ | |
detach(c); | |
if(clients) | |
clients->prev = c; |