diff options
| author | Connor Lane Smith <cls@lubutu.com> | 2011-10-25 20:40:46 +0100 |
|---|---|---|
| committer | Connor Lane Smith <cls@lubutu.com> | 2011-10-25 20:40:46 +0100 |
| commit | b1a28ae1dab34a159e7cf17a82ecda0635e72f97 (patch) | |
| tree | 23f6aed38bb99261031a8df297ab626f9ec78806 | |
| parent | apply resize hints in floating layout (diff) | |
| download | dwm-b1a28ae1dab34a159e7cf17a82ecda0635e72f97.tar.gz dwm-b1a28ae1dab34a159e7cf17a82ecda0635e72f97.zip | |
apply nmaster patch
Diffstat (limited to '')
| -rw-r--r-- | config.def.h | 3 | ||||
| -rw-r--r-- | dwm.c | 42 |
2 files changed, 24 insertions, 21 deletions
diff --git a/config.def.h b/config.def.h index 91cf439..973ab4c 100644 --- a/config.def.h +++ b/config.def.h | |||
| @@ -24,6 +24,7 @@ static const Rule rules[] = { | |||
| 24 | 24 | ||
| 25 | /* layout(s) */ | 25 | /* layout(s) */ |
| 26 | static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ | 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 | static const Bool resizehints = True; /* True means respect size hints in tiled resizals */ | 28 | static const Bool resizehints = True; /* True means respect size hints in tiled resizals */ |
| 28 | 29 | ||
| 29 | static const Layout layouts[] = { | 30 | static const Layout layouts[] = { |
| @@ -55,6 +56,8 @@ static Key keys[] = { | |||
| 55 | { MODKEY, XK_b, togglebar, {0} }, | 56 | { MODKEY, XK_b, togglebar, {0} }, |
| 56 | { MODKEY, XK_j, focusstack, {.i = +1 } }, | 57 | { MODKEY, XK_j, focusstack, {.i = +1 } }, |
| 57 | { MODKEY, XK_k, focusstack, {.i = -1 } }, | 58 | { MODKEY, XK_k, focusstack, {.i = -1 } }, |
| 59 | { MODKEY, XK_i, incnmaster, {.i = +1 } }, | ||
| 60 | { MODKEY, XK_d, incnmaster, {.i = -1 } }, | ||
| 58 | { MODKEY, XK_h, setmfact, {.f = -0.05} }, | 61 | { MODKEY, XK_h, setmfact, {.f = -0.05} }, |
| 59 | { MODKEY, XK_l, setmfact, {.f = +0.05} }, | 62 | { MODKEY, XK_l, setmfact, {.f = +0.05} }, |
| 60 | { MODKEY, XK_Return, zoom, {0} }, | 63 | { MODKEY, XK_Return, zoom, {0} }, |
| @@ -125,6 +125,7 @@ typedef struct { | |||
| 125 | struct Monitor { | 125 | struct Monitor { |
| 126 | char ltsymbol[16]; | 126 | char ltsymbol[16]; |
| 127 | float mfact; | 127 | float mfact; |
| 128 | int nmaster; | ||
| 128 | int num; | 129 | int num; |
| 129 | int by; /* bar geometry */ | 130 | int by; /* bar geometry */ |
| 130 | int mx, my, mw, mh; /* screen size */ | 131 | int mx, my, mw, mh; /* screen size */ |
| @@ -189,6 +190,7 @@ static long getstate(Window w); | |||
| 189 | static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); | 190 | static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); |
| 190 | static void grabbuttons(Client *c, Bool focused); | 191 | static void grabbuttons(Client *c, Bool focused); |
| 191 | static void grabkeys(void); | 192 | static void grabkeys(void); |
| 193 | static void incnmaster(const Arg *arg); | ||
| 192 | static void initfont(const char *fontstr); | 194 | static void initfont(const char *fontstr); |
| 193 | static void keypress(XEvent *e); | 195 | static void keypress(XEvent *e); |
| 194 | static void killclient(const Arg *arg); | 196 | static void killclient(const Arg *arg); |
| @@ -664,6 +666,7 @@ createmon(void) { | |||
| 664 | die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); | 666 | die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); |
| 665 | m->tagset[0] = m->tagset[1] = 1; | 667 | m->tagset[0] = m->tagset[1] = 1; |
| 666 | m->mfact = mfact; | 668 | m->mfact = mfact; |
| 669 | m->nmaster = nmaster; | ||
| 667 | m->showbar = showbar; | 670 | m->showbar = showbar; |
| 668 | m->topbar = topbar; | 671 | m->topbar = topbar; |
| 669 | m->lt[0] = &layouts[0]; | 672 | m->lt[0] = &layouts[0]; |
| @@ -1024,6 +1027,12 @@ grabkeys(void) { | |||
| 1024 | } | 1027 | } |
| 1025 | 1028 | ||
| 1026 | void | 1029 | void |
| 1030 | incnmaster(const Arg *arg) { | ||
| 1031 | selmon->nmaster = MAX(selmon->nmaster + arg->i, 1); | ||
| 1032 | arrange(selmon); | ||
| 1033 | } | ||
| 1034 | |||
| 1035 | void | ||
| 1027 | initfont(const char *fontstr) { | 1036 | initfont(const char *fontstr) { |
| 1028 | char *def, **missing; | 1037 | char *def, **missing; |
| 1029 | int n; | 1038 | int n; |
| @@ -1650,32 +1659,23 @@ textnw(const char *text, unsigned int len) { | |||
| 1650 | 1659 | ||
| 1651 | void | 1660 | void |
| 1652 | tile(Monitor *m) { | 1661 | tile(Monitor *m) { |
| 1653 | int x, y, h, w, mw; | 1662 | unsigned int i, n, mw, mh, tw, th; |
| 1654 | unsigned int i, n; | ||
| 1655 | Client *c; | 1663 | Client *c; |
| 1656 | 1664 | ||
| 1657 | for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); | 1665 | for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); |
| 1658 | if(n == 0) | 1666 | if(n == 0) |
| 1659 | return; | 1667 | return; |
| 1660 | /* master */ | 1668 | |
| 1661 | c = nexttiled(m->clients); | 1669 | mh = (n > m->nmaster) ? m->wh / m->nmaster : m->wh / n; |
| 1662 | mw = m->mfact * m->ww; | 1670 | mw = (n > m->nmaster) ? m->ww * 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); | 1671 | th = (n > m->nmaster) ? m->wh / (n - m->nmaster) : 0; |
| 1664 | if(--n == 0) | 1672 | tw = m->ww - mw; |
| 1665 | return; | 1673 | |
| 1666 | /* tile stack */ | 1674 | for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) |
| 1667 | x = (m->wx > c->x) ? c->x + mw + 2 * c->bw : m->wx + mw; | 1675 | if(i < m->nmaster) |
| 1668 | y = m->wy; | 1676 | resize(c, m->wx, m->wy + (i*mh), mw - (2*c->bw), mh - (2*c->bw), False); |
| 1669 | w = (m->wx > c->x) ? m->wx + m->ww - x : m->ww - mw; | 1677 | else |
| 1670 | h = m->wh / n; | 1678 | resize(c, m->wx + mw, m->wy + ((i - m->nmaster)*th), tw - (2*c->bw), th - (2*c->bw), False); |
| 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 | } | ||
| 1679 | } | 1679 | } |
| 1680 | 1680 | ||
| 1681 | void | 1681 | void |
