apply nmaster patch
This commit is contained in:
parent
f68a01cd76
commit
b1a28ae1da
@ -24,6 +24,7 @@ static const Rule rules[] = {
|
|||||||
|
|
||||||
/* layout(s) */
|
/* layout(s) */
|
||||||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||||
|
static const int nmaster = 1; /* number of clients in master area */
|
||||||
static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
|
static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
|
||||||
|
|
||||||
static const Layout layouts[] = {
|
static const Layout layouts[] = {
|
||||||
@ -55,6 +56,8 @@ static Key keys[] = {
|
|||||||
{ MODKEY, XK_b, togglebar, {0} },
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||||
|
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||||
|
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
{ MODKEY, XK_Return, zoom, {0} },
|
{ MODKEY, XK_Return, zoom, {0} },
|
||||||
|
42
dwm.c
42
dwm.c
@ -125,6 +125,7 @@ typedef struct {
|
|||||||
struct Monitor {
|
struct Monitor {
|
||||||
char ltsymbol[16];
|
char ltsymbol[16];
|
||||||
float mfact;
|
float mfact;
|
||||||
|
int nmaster;
|
||||||
int num;
|
int num;
|
||||||
int by; /* bar geometry */
|
int by; /* bar geometry */
|
||||||
int mx, my, mw, mh; /* screen size */
|
int mx, my, mw, mh; /* screen size */
|
||||||
@ -189,6 +190,7 @@ static long getstate(Window w);
|
|||||||
static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||||
static void grabbuttons(Client *c, Bool focused);
|
static void grabbuttons(Client *c, Bool focused);
|
||||||
static void grabkeys(void);
|
static void grabkeys(void);
|
||||||
|
static void incnmaster(const Arg *arg);
|
||||||
static void initfont(const char *fontstr);
|
static void initfont(const char *fontstr);
|
||||||
static void keypress(XEvent *e);
|
static void keypress(XEvent *e);
|
||||||
static void killclient(const Arg *arg);
|
static void killclient(const Arg *arg);
|
||||||
@ -664,6 +666,7 @@ createmon(void) {
|
|||||||
die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
|
die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
|
||||||
m->tagset[0] = m->tagset[1] = 1;
|
m->tagset[0] = m->tagset[1] = 1;
|
||||||
m->mfact = mfact;
|
m->mfact = mfact;
|
||||||
|
m->nmaster = nmaster;
|
||||||
m->showbar = showbar;
|
m->showbar = showbar;
|
||||||
m->topbar = topbar;
|
m->topbar = topbar;
|
||||||
m->lt[0] = &layouts[0];
|
m->lt[0] = &layouts[0];
|
||||||
@ -1023,6 +1026,12 @@ grabkeys(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
incnmaster(const Arg *arg) {
|
||||||
|
selmon->nmaster = MAX(selmon->nmaster + arg->i, 1);
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
initfont(const char *fontstr) {
|
initfont(const char *fontstr) {
|
||||||
char *def, **missing;
|
char *def, **missing;
|
||||||
@ -1650,32 +1659,23 @@ textnw(const char *text, unsigned int len) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
tile(Monitor *m) {
|
tile(Monitor *m) {
|
||||||
int x, y, h, w, mw;
|
unsigned int i, n, mw, mh, tw, th;
|
||||||
unsigned int i, n;
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
if(n == 0)
|
if(n == 0)
|
||||||
return;
|
return;
|
||||||
/* master */
|
|
||||||
c = nexttiled(m->clients);
|
mh = (n > m->nmaster) ? m->wh / m->nmaster : m->wh / n;
|
||||||
mw = m->mfact * m->ww;
|
mw = (n > m->nmaster) ? m->ww * m->mfact : m->ww;
|
||||||
resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw, False);
|
th = (n > m->nmaster) ? m->wh / (n - m->nmaster) : 0;
|
||||||
if(--n == 0)
|
tw = m->ww - mw;
|
||||||
return;
|
|
||||||
/* tile stack */
|
for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
x = (m->wx > c->x) ? c->x + mw + 2 * c->bw : m->wx + mw;
|
if(i < m->nmaster)
|
||||||
y = m->wy;
|
resize(c, m->wx, m->wy + (i*mh), mw - (2*c->bw), mh - (2*c->bw), False);
|
||||||
w = (m->wx > c->x) ? m->wx + m->ww - x : m->ww - mw;
|
else
|
||||||
h = m->wh / n;
|
resize(c, m->wx + mw, m->wy + ((i - m->nmaster)*th), tw - (2*c->bw), th - (2*c->bw), False);
|
||||||
if(h < bh)
|
|
||||||
h = m->wh;
|
|
||||||
for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
|
|
||||||
resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
|
|
||||||
? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False);
|
|
||||||
if(h != m->wh)
|
|
||||||
y = c->y + HEIGHT(c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user