diff options
| author | Anselm R. Garbe <arg@suckless.org> | 2007-01-05 12:50:39 +0100 |
|---|---|---|
| committer | Anselm R. Garbe <arg@suckless.org> | 2007-01-05 12:50:39 +0100 |
| commit | 0b80d1842d1c921a8a94c11fd9222dad9311cc97 (patch) | |
| tree | aadfdc5b88d211e21fcc1be93f2716dee4370abb | |
| parent | fixed comment of drawclient() (diff) | |
| download | dwm-0b80d1842d1c921a8a94c11fd9222dad9311cc97.tar.gz dwm-0b80d1842d1c921a8a94c11fd9222dad9311cc97.zip | |
experimental version which allows master clients being increased/decreased
Diffstat (limited to '')
| -rw-r--r-- | config.arg.h | 3 | ||||
| -rw-r--r-- | config.default.h | 1 | ||||
| -rw-r--r-- | config.mk | 4 | ||||
| -rw-r--r-- | dwm.h | 4 | ||||
| -rw-r--r-- | main.c | 3 | ||||
| -rw-r--r-- | view.c | 55 |
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 \ |
| @@ -17,8 +17,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 | |||
| 17 | # flags | 17 | # flags |
| 18 | CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" | 18 | CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" |
| 19 | LDFLAGS = ${LIBS} | 19 | LDFLAGS = ${LIBS} |
| 20 | #CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" | 20 | CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" |
| 21 | #LDFLAGS = -g ${LIBS} | 21 | LDFLAGS = -g ${LIBS} |
| 22 | 22 | ||
| 23 | # Solaris | 23 | # Solaris |
| 24 | #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" | 24 | #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" |
| @@ -96,7 +96,8 @@ extern char stext[1024]; /* status text */ | |||
| 96 | extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */ | 96 | extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */ |
| 97 | extern int screen, sx, sy, sw, sh; /* screen geometry */ | 97 | extern int screen, sx, sy, sw, sh; /* screen geometry */ |
| 98 | extern int wax, way, wah, waw; /* windowarea geometry */ | 98 | extern int wax, way, wah, waw; /* windowarea geometry */ |
| 99 | extern unsigned int master, ntags, numlockmask; /* master percent, number of tags, dynamic lock mask */ | 99 | extern unsigned int master, nmaster; /* master percent, number of master clients */ |
| 100 | extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */ | ||
| 100 | extern void (*handler[LASTEvent])(XEvent *); /* event handler */ | 101 | extern void (*handler[LASTEvent])(XEvent *); /* event handler */ |
| 101 | extern void (*arrange)(void); /* arrange function, indicates mode */ | 102 | extern void (*arrange)(void); /* arrange function, indicates mode */ |
| 102 | extern Atom wmatom[WMLast], netatom[NetLast]; | 103 | extern Atom wmatom[WMLast], netatom[NetLast]; |
| @@ -159,6 +160,7 @@ extern void dofloat(void); /* arranges all windows floating */ | |||
| 159 | extern void dotile(void); /* arranges all windows tiled */ | 160 | extern void dotile(void); /* arranges all windows tiled */ |
| 160 | extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ | 161 | extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ |
| 161 | extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ | 162 | extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */ |
| 163 | extern void incnmaster(Arg *arg); /* increments nmaster with arg's index value */ | ||
| 162 | extern Bool isvisible(Client *c); /* returns True if client is visible */ | 164 | extern Bool isvisible(Client *c); /* returns True if client is visible */ |
| 163 | extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */ | 165 | extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */ |
| 164 | extern void restack(void); /* restores z layers of all clients */ | 166 | extern void restack(void); /* restores z layers of all clients */ |
| @@ -20,7 +20,7 @@ | |||
| 20 | char stext[1024]; | 20 | char stext[1024]; |
| 21 | Bool *seltag; | 21 | Bool *seltag; |
| 22 | int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah; | 22 | int bx, by, bw, bh, bmw, masterd, screen, sx, sy, sw, sh, wax, way, waw, wah; |
| 23 | unsigned int master, ntags, numlockmask; | 23 | unsigned int master, nmaster, ntags, numlockmask; |
| 24 | Atom wmatom[WMLast], netatom[NetLast]; | 24 | Atom wmatom[WMLast], netatom[NetLast]; |
| 25 | Bool running = True; | 25 | Bool running = True; |
| 26 | Bool issel = True; | 26 | Bool 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; |
| @@ -69,12 +69,16 @@ dofloat(void) { | |||
| 69 | 69 | ||
| 70 | void | 70 | void |
| 71 | dotile(void) { | 71 | dotile(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 | ||
| 150 | void | ||
| 151 | incnmaster(Arg *arg) { | ||
| 152 | if(nmaster + arg->i < 1) | ||
| 153 | return; | ||
| 154 | nmaster += arg->i; | ||
| 155 | arrange(); | ||
| 156 | } | ||
| 157 | |||
| 150 | Bool | 158 | Bool |
| 151 | isvisible(Client *c) { | 159 | isvisible(Client *c) { |
| 152 | unsigned int i; | 160 | unsigned int i; |
| @@ -240,7 +248,7 @@ view(Arg *arg) { | |||
| 240 | 248 | ||
| 241 | void | 249 | void |
| 242 | zoom(Arg *arg) { | 250 | zoom(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; |
