experimental version which allows master clients being increased/decreased
0b80d184
6 file(s) · +45 −25
| 19 | 19 | ||
| 20 | 20 | #define MASTER 600 /* per thousand */ |
|
| 21 | 21 | #define MODKEY Mod1Mask |
|
| 22 | + | #define NMASTER 1 /* clients in master area */ |
|
| 22 | 23 | #define SNAP 40 /* pixel */ |
|
| 23 | 24 | ||
| 24 | 25 | #define KEYS \ |
|
| 30 | 31 | { .cmd = "exe=\"$(lsx `echo $PATH | sed 's/:/ /g'` | sort -u " \ |
|
| 31 | 32 | " | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' " \ |
|
| 32 | 33 | "-sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"')\" && exec $exe" } }, \ |
|
| 34 | + | { MODKEY, XK_d, incnmaster, { .i = -1 } }, \ |
|
| 33 | 35 | { MODKEY, XK_j, focusnext, { 0 } }, \ |
|
| 34 | 36 | { MODKEY, XK_k, focusprev, { 0 } }, \ |
|
| 35 | 37 | { MODKEY, XK_Return, zoom, { 0 } }, \ |
|
| 36 | 38 | { MODKEY, XK_g, resizemaster, { .i = 15 } }, \ |
|
| 39 | + | { MODKEY, XK_i, incnmaster, { .i = 1 } }, \ |
|
| 37 | 40 | { MODKEY, XK_s, resizemaster, { .i = -15 } }, \ |
|
| 38 | 41 | { MODKEY|ShiftMask, XK_0, tag, { .i = -1 } }, \ |
|
| 39 | 42 | { MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \ |
|
| 19 | 19 | ||
| 20 | 20 | #define MASTER 600 /* per thousand */ |
|
| 21 | 21 | #define MODKEY Mod1Mask |
|
| 22 | + | #define NMASTER 1 /* clients in master area */ |
|
| 22 | 23 | #define SNAP 20 /* pixel */ |
|
| 23 | 24 | ||
| 24 | 25 | #define KEYS \ |
| 17 | 17 | # flags |
|
| 18 | 18 | CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" |
|
| 19 | 19 | LDFLAGS = ${LIBS} |
|
| 20 | - | #CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" |
|
| 21 | - | #LDFLAGS = -g ${LIBS} |
|
| 20 | + | CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" |
|
| 21 | + | LDFLAGS = -g ${LIBS} |
|
| 22 | 22 | ||
| 23 | 23 | # Solaris |
|
| 24 | 24 | #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" |
| 96 | 96 | extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */ |
|
| 97 | 97 | extern int screen, sx, sy, sw, sh; /* screen geometry */ |
|
| 98 | 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 | 101 | extern void (*handler[LASTEvent])(XEvent *); /* event handler */ |
|
| 101 | 102 | extern void (*arrange)(void); /* arrange function, indicates mode */ |
|
| 102 | 103 | extern Atom wmatom[WMLast], netatom[NetLast]; |
|
| 159 | 160 | extern void dotile(void); /* arranges all windows tiled */ |
|
| 160 | 161 | extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */ |
|
| 161 | 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 | 164 | extern Bool isvisible(Client *c); /* returns True if client is visible */ |
|
| 163 | 165 | extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */ |
|
| 164 | 166 | extern void restack(void); /* restores z layers of all clients */ |
|
| 20 | 20 | char stext[1024]; |
|
| 21 | 21 | Bool *seltag; |
|
| 22 | 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 | 24 | Atom wmatom[WMLast], netatom[NetLast]; |
|
| 25 | 25 | Bool running = True; |
|
| 26 | 26 | Bool issel = True; |
|
| 133 | 133 | sw = DisplayWidth(dpy, screen); |
|
| 134 | 134 | sh = DisplayHeight(dpy, screen); |
|
| 135 | 135 | master = MASTER; |
|
| 136 | + | nmaster = NMASTER; |
|
| 136 | 137 | /* bar */ |
|
| 137 | 138 | bx = sx; |
|
| 138 | 139 | by = sy; |
|
| 69 | 69 | ||
| 70 | 70 | void |
|
| 71 | 71 | dotile(void) { |
|
| 72 | - | unsigned int i, n, mpw, th; |
|
| 72 | + | unsigned int i, n, mw, mh, tw, th; |
|
| 73 | 73 | Client *c; |
|
| 74 | 74 | ||
| 75 | 75 | for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) |
|
| 76 | 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 | 83 | for(i = 0, c = clients; c; c = c->next) |
|
| 80 | 84 | if(isvisible(c)) { |
|
| 85 | 89 | c->ismax = False; |
|
| 86 | 90 | c->x = wax; |
|
| 87 | 91 | c->y = way; |
|
| 88 | - | if(n == 1) { /* only 1 window */ |
|
| 89 | - | c->w = waw - 2 * BORDERPX; |
|
| 90 | - | c->h = wah - 2 * BORDERPX; |
|
| 91 | - | } |
|
| 92 | - | else if(i == 0) { /* master window */ |
|
| 93 | - | c->w = mpw - 2 * BORDERPX; |
|
| 94 | - | c->h = wah - 2 * BORDERPX; |
|
| 95 | - | th = wah / (n - 1); |
|
| 92 | + | if(i < nmaster) { |
|
| 93 | + | c->y += i * mh; |
|
| 94 | + | c->w = mw - 2 * BORDERPX; |
|
| 95 | + | c->h = mh - 2 * BORDERPX; |
|
| 96 | 96 | } |
|
| 97 | 97 | else { /* tile window */ |
|
| 98 | - | c->x += mpw; |
|
| 99 | - | c->w = (waw - mpw) - 2 * BORDERPX; |
|
| 98 | + | c->x += mw; |
|
| 99 | + | c->w = tw - 2 * BORDERPX; |
|
| 100 | 100 | if(th > bh) { |
|
| 101 | - | c->y += (i - 1) * th; |
|
| 101 | + | c->y += (i - nmaster) * th; |
|
| 102 | 102 | c->h = th - 2 * BORDERPX; |
|
| 103 | 103 | } |
|
| 104 | 104 | else /* fallback if th < bh */ |
|
| 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 | 158 | Bool |
|
| 151 | 159 | isvisible(Client *c) { |
|
| 152 | 160 | unsigned int i; |
|
| 240 | 248 | ||
| 241 | 249 | void |
|
| 242 | 250 | zoom(Arg *arg) { |
|
| 243 | - | unsigned int n; |
|
| 251 | + | unsigned int i, n; |
|
| 244 | 252 | Client *c; |
|
| 245 | 253 | ||
| 246 | 254 | if(!sel) |
|
| 249 | 257 | togglemax(sel); |
|
| 250 | 258 | return; |
|
| 251 | 259 | } |
|
| 252 | - | for(n = 0, c = clients; c; c = c->next) |
|
| 253 | - | if(isvisible(c) && !c->isfloat) |
|
| 254 | - | n++; |
|
| 255 | - | if(n < 2 || (arrange == dofloat)) |
|
| 260 | + | for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) |
|
| 261 | + | n++; |
|
| 262 | + | if(n <= nmaster || (arrange == dofloat)) |
|
| 263 | + | return; |
|
| 264 | + | ||
| 265 | + | for(c = nexttiled(clients), i = 0; c && (c != sel) && i < nmaster; c = nexttiled(c->next)) |
|
| 266 | + | i++; |
|
| 267 | + | if(c == sel && i < nmaster) |
|
| 268 | + | for(; c && i < nmaster; c = nexttiled(c->next)) |
|
| 269 | + | i++; |
|
| 270 | + | if(!c) |
|
| 256 | 271 | return; |
|
| 257 | - | if((c = sel) == nexttiled(clients)) |
|
| 258 | - | if(!(c = nexttiled(c->next))) |
|
| 259 | - | return; |
|
| 272 | + | ||
| 260 | 273 | detach(c); |
|
| 261 | 274 | if(clients) |
|
| 262 | 275 | clients->prev = c; |
|