summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.arg.h3
-rw-r--r--config.default.h1
-rw-r--r--config.mk4
-rw-r--r--dwm.h4
-rw-r--r--main.c3
-rw-r--r--view.c55
6 files changed, 45 insertions, 25 deletions
diff --git a/config.arg.h b/config.arg.h
index 60bdf21..d889d96 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -19,6 +19,7 @@ const char *tags[] = { "dev", "work", "net", "fnord", NULL };
19 19
20#define MASTER 600 /* per thousand */ 20#define MASTER 600 /* per thousand */
21#define MODKEY Mod1Mask 21#define MODKEY Mod1Mask
22#define NMASTER 1 /* clients in master area */
22#define SNAP 40 /* pixel */ 23#define SNAP 40 /* pixel */
23 24
24#define KEYS \ 25#define KEYS \
@@ -30,10 +31,12 @@ static Key key[] = { \
30 { .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \ 31 { .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \
31 " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \ 32 " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \
32 "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \ 33 "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \
34 { MODKEY, XK_d, incnmaster, { .i = -1 } }, \
33 { MODKEY, XK_j, focusnext, { 0 } }, \ 35 { MODKEY, XK_j, focusnext, { 0 } }, \
34 { MODKEY, XK_k, focusprev, { 0 } }, \ 36 { MODKEY, XK_k, focusprev, { 0 } }, \
35 { MODKEY, XK_Return, zoom, { 0 } }, \ 37 { MODKEY, XK_Return, zoom, { 0 } }, \
36 { MODKEY, XK_g, resizemaster, { .i = 15 } }, \ 38 { MODKEY, XK_g, resizemaster, { .i = 15 } }, \
39 { MODKEY, XK_i, incnmaster, { .i = 1 } }, \
37 { MODKEY, XK_s, resizemaster, { .i = -15 } }, \ 40 { MODKEY, XK_s, resizemaster, { .i = -15 } }, \
38 { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \ 41 { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \
39 { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ 42 { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
diff --git a/config.default.h b/config.default.h
index 3dd5aa0..5b08f93 100644
--- a/config.default.h
+++ b/config.default.h
@@ -19,6 +19,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", NULL };
19 19
20#define MASTER 600 /* per thousand */ 20#define MASTER 600 /* per thousand */
21#define MODKEY Mod1Mask 21#define MODKEY Mod1Mask
22#define NMASTER 1 /* clients in master area */
22#define SNAP 20 /* pixel */ 23#define SNAP 20 /* pixel */
23 24
24#define KEYS \ 25#define KEYS \
diff --git a/config.mk b/config.mk
index 1d73f2b..f65e6fc 100644
--- a/config.mk
+++ b/config.mk
@@ -17,8 +17,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
17# flags 17# flags
18CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" 18CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
19LDFLAGS = ${LIBS} 19LDFLAGS = ${LIBS}
20#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" 20CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
21#LDFLAGS = -g ${LIBS} 21LDFLAGS = -g ${LIBS}
22 22
23# Solaris 23# Solaris
24#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" 24#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
diff --git a/dwm.h b/dwm.h
index 2816a96..f929181 100644
--- a/dwm.h
+++ b/dwm.h
@@ -96,7 +96,8 @@ extern char stext[1024]; /* status text */
96extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */ 96extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
97extern int screen, sx, sy, sw, sh; /* screen geometry */ 97extern int screen, sx, sy, sw, sh; /* screen geometry */
98extern int wax, way, wah, waw; /* windowarea geometry */ 98extern int wax, way, wah, waw; /* windowarea geometry */
99extern unsigned int master, ntags, numlockmask; /* master percent, number of tags, dynamic lock mask */ 99extern unsigned int master, nmaster; /* master percent, number of master clients */
100extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
100extern void (*handler[LASTEvent])(XEvent *); /* event handler */ 101extern void (*handler[LASTEvent])(XEvent *); /* event handler */
101extern void (*arrange)(void); /* arrange function, indicates mode */ 102extern void (*arrange)(void); /* arrange function, indicates mode */
102extern Atom wmatom[WMLast], netatom[NetLast]; 103extern Atom wmatom[WMLast], netatom[NetLast];
@@ -159,6 +160,7 @@ extern void dofloat(void); /* arranges all windows floating */
159extern void dotile(void); /* arranges all windows tiled */ 160extern void dotile(void); /* arranges all windows tiled */
160extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ 161extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
161extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ 162extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
163extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */
162extern Bool isvisible(Client *c); /* returns True if client is visible */ 164extern Bool isvisible(Client *c); /* returns True if client is visible */
163extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */ 165extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */
164extern void restack(void); /* restores z layers of all clients */ 166extern void restack(void); /* restores z layers of all clients */
diff --git a/main.c b/main.c
index 47749fe..da209a9 100644
--- a/main.c
+++ b/main.c
@@ -20,7 +20,7 @@
20char stext[1024]; 20char stext[1024];
21Bool *seltag; 21Bool *seltag;
22int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah; 22int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah;
23unsigned int master, ntags, numlockmask; 23unsigned int master, nmaster, ntags, numlockmask;
24Atom wmatom[WMLast], netatom[NetLast]; 24Atom wmatom[WMLast], netatom[NetLast];
25Bool running = True; 25Bool running = True;
26Bool issel = True; 26Bool issel = True;
@@ -133,6 +133,7 @@ setup(void) {
133 sw = DisplayWidth(dpy, screen); 133 sw = DisplayWidth(dpy, screen);
134 sh = DisplayHeight(dpy, screen); 134 sh = DisplayHeight(dpy, screen);
135 master = MASTER; 135 master = MASTER;
136 nmaster = NMASTER;
136 /* bar */ 137 /* bar */
137 bx = sx; 138 bx = sx;
138 by = sy; 139 by = sy;
diff --git a/view.c b/view.c
index 72a4991..1ac3141 100644
--- a/view.c
+++ b/view.c
@@ -69,12 +69,16 @@ dofloat(void) {
69 69
70void 70void
71dotile(void) { 71dotile(void) {
72 unsigned int i, n, mpw, th; 72 unsigned int i, n, mw, mh, tw, th;
73 Client *c; 73 Client *c;
74 74
75 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) 75 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
76 n++; 76 n++;
77 mpw = (waw * master) / 1000; 77 /* window geoms */
78 mw = (n > nmaster) ? (waw * master) / 1000 : waw;
79 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
80 tw = waw - mw;
81 th = (n > nmaster) ? wah / (n - nmaster) : 0;
78 82
79 for(i = 0, c = clients; c; c = c->next) 83 for(i = 0, c = clients; c; c = c->next)
80 if(isvisible(c)) { 84 if(isvisible(c)) {
@@ -85,20 +89,16 @@ dotile(void) {
85 c->ismax = False; 89 c->ismax = False;
86 c->x = wax; 90 c->x = wax;
87 c->y = way; 91 c->y = way;
88 if(n == 1) { /* only 1 window */ 92 if(i < nmaster) {
89 c->w = waw - 2 * BORDERPX; 93 c->y += i * mh;
90 c->h = wah - 2 * BORDERPX; 94 c->w = mw - 2 * BORDERPX;
91 } 95 c->h = mh - 2 * BORDERPX;
92 else if(i == 0) { /* master window */
93 c->w = mpw - 2 * BORDERPX;
94 c->h = wah - 2 * BORDERPX;
95 th = wah / (n - 1);
96 } 96 }
97 else { /* tile window */ 97 else { /* tile window */
98 c->x += mpw; 98 c->x += mw;
99 c->w = (waw - mpw) - 2 * BORDERPX; 99 c->w = tw - 2 * BORDERPX;
100 if(th > bh) { 100 if(th > bh) {
101 c->y += (i - 1) * th; 101 c->y += (i - nmaster) * th;
102 c->h = th - 2 * BORDERPX; 102 c->h = th - 2 * BORDERPX;
103 } 103 }
104 else /* fallback if th < bh */ 104 else /* fallback if th < bh */
@@ -147,6 +147,14 @@ focusprev(Arg *arg) {
147 } 147 }
148} 148}
149 149
150void
151incnmaster(Arg *arg) {
152 if(nmaster + arg->i < 1)
153 return;
154 nmaster += arg->i;
155 arrange();
156}
157
150Bool 158Bool
151isvisible(Client *c) { 159isvisible(Client *c) {
152 unsigned int i; 160 unsigned int i;
@@ -240,7 +248,7 @@ view(Arg *arg) {
240 248
241void 249void
242zoom(Arg *arg) { 250zoom(Arg *arg) {
243 unsigned int n; 251 unsigned int i, n;
244 Client *c; 252 Client *c;
245 253
246 if(!sel) 254 if(!sel)
@@ -249,14 +257,19 @@ zoom(Arg *arg) {
249 togglemax(sel); 257 togglemax(sel);
250 return; 258 return;
251 } 259 }
252 for(n = 0, c = clients; c; c = c->next) 260 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
253 if(isvisible(c) && !c->isfloat) 261 n++;
254 n++; 262 if(n <= nmaster || (arrange == dofloat))
255 if(n < 2 || (arrange == dofloat))
256 return; 263 return;
257 if((c = sel) == nexttiled(clients)) 264
258 if(!(c = nexttiled(c->next))) 265 for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next))
259 return; 266 i++;
267 if(c == sel && i < nmaster)
268 for(; c && i < nmaster; c = nexttiled(c->next))
269 i++;
270 if(!c)
271 return;
272
260 detach(c); 273 detach(c);
261 if(clients) 274 if(clients)
262 clients->prev = c; 275 clients->prev = c;