apply nmaster patch
b1a28ae1
2 file(s) · +24 −21
| 24 | 24 | ||
| 25 | 25 | /* layout(s) */ |
|
| 26 | 26 | static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ |
|
| 27 | + | static const int nmaster = 1; /* number of clients in master area */ |
|
| 27 | 28 | static const Bool resizehints = True; /* True means respect size hints in tiled resizals */ |
|
| 28 | 29 | ||
| 29 | 30 | static const Layout layouts[] = { |
|
| 55 | 56 | { MODKEY, XK_b, togglebar, {0} }, |
|
| 56 | 57 | { MODKEY, XK_j, focusstack, {.i = +1 } }, |
|
| 57 | 58 | { MODKEY, XK_k, focusstack, {.i = -1 } }, |
|
| 59 | + | { MODKEY, XK_i, incnmaster, {.i = +1 } }, |
|
| 60 | + | { MODKEY, XK_d, incnmaster, {.i = -1 } }, |
|
| 58 | 61 | { MODKEY, XK_h, setmfact, {.f = -0.05} }, |
|
| 59 | 62 | { MODKEY, XK_l, setmfact, {.f = +0.05} }, |
|
| 60 | 63 | { MODKEY, XK_Return, zoom, {0} }, |
|
| 125 | 125 | struct Monitor { |
|
| 126 | 126 | char ltsymbol[16]; |
|
| 127 | 127 | float mfact; |
|
| 128 | + | int nmaster; |
|
| 128 | 129 | int num; |
|
| 129 | 130 | int by; /* bar geometry */ |
|
| 130 | 131 | int mx, my, mw, mh; /* screen size */ |
|
| 189 | 190 | static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); |
|
| 190 | 191 | static void grabbuttons(Client *c, Bool focused); |
|
| 191 | 192 | static void grabkeys(void); |
|
| 193 | + | static void incnmaster(const Arg *arg); |
|
| 192 | 194 | static void initfont(const char *fontstr); |
|
| 193 | 195 | static void keypress(XEvent *e); |
|
| 194 | 196 | static void killclient(const Arg *arg); |
|
| 664 | 666 | die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); |
|
| 665 | 667 | m->tagset[0] = m->tagset[1] = 1; |
|
| 666 | 668 | m->mfact = mfact; |
|
| 669 | + | m->nmaster = nmaster; |
|
| 667 | 670 | m->showbar = showbar; |
|
| 668 | 671 | m->topbar = topbar; |
|
| 669 | 672 | m->lt[0] = &layouts[0]; |
|
| 1024 | 1027 | } |
|
| 1025 | 1028 | ||
| 1026 | 1029 | void |
|
| 1030 | + | incnmaster(const Arg *arg) { |
|
| 1031 | + | selmon->nmaster = MAX(selmon->nmaster + arg->i, 1); |
|
| 1032 | + | arrange(selmon); |
|
| 1033 | + | } |
|
| 1034 | + | ||
| 1035 | + | void |
|
| 1027 | 1036 | initfont(const char *fontstr) { |
|
| 1028 | 1037 | char *def, **missing; |
|
| 1029 | 1038 | int n; |
|
| 1650 | 1659 | ||
| 1651 | 1660 | void |
|
| 1652 | 1661 | tile(Monitor *m) { |
|
| 1653 | - | int x, y, h, w, mw; |
|
| 1654 | - | unsigned int i, n; |
|
| 1662 | + | unsigned int i, n, mw, mh, tw, th; |
|
| 1655 | 1663 | Client *c; |
|
| 1656 | 1664 | ||
| 1657 | 1665 | for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); |
|
| 1658 | 1666 | if(n == 0) |
|
| 1659 | 1667 | return; |
|
| 1660 | - | /* master */ |
|
| 1661 | - | c = nexttiled(m->clients); |
|
| 1662 | - | mw = m->mfact * m->ww; |
|
| 1663 | - | resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw, False); |
|
| 1664 | - | if(--n == 0) |
|
| 1665 | - | return; |
|
| 1666 | - | /* tile stack */ |
|
| 1667 | - | x = (m->wx > c->x) ? c->x + mw + 2 * c->bw : m->wx + mw; |
|
| 1668 | - | y = m->wy; |
|
| 1669 | - | w = (m->wx > c->x) ? m->wx + m->ww - x : m->ww - mw; |
|
| 1670 | - | h = m->wh / n; |
|
| 1671 | - | if(h < bh) |
|
| 1672 | - | h = m->wh; |
|
| 1673 | - | for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { |
|
| 1674 | - | resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) |
|
| 1675 | - | ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False); |
|
| 1676 | - | if(h != m->wh) |
|
| 1677 | - | y = c->y + HEIGHT(c); |
|
| 1678 | - | } |
|
| 1668 | + | ||
| 1669 | + | mh = (n > m->nmaster) ? m->wh / m->nmaster : m->wh / n; |
|
| 1670 | + | mw = (n > m->nmaster) ? m->ww * m->mfact : m->ww; |
|
| 1671 | + | th = (n > m->nmaster) ? m->wh / (n - m->nmaster) : 0; |
|
| 1672 | + | tw = m->ww - mw; |
|
| 1673 | + | ||
| 1674 | + | for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) |
|
| 1675 | + | if(i < m->nmaster) |
|
| 1676 | + | resize(c, m->wx, m->wy + (i*mh), mw - (2*c->bw), mh - (2*c->bw), False); |
|
| 1677 | + | else |
|
| 1678 | + | resize(c, m->wx + mw, m->wy + ((i - m->nmaster)*th), tw - (2*c->bw), th - (2*c->bw), False); |
|
| 1679 | 1679 | } |
|
| 1680 | 1680 | ||
| 1681 | 1681 | void |
|