X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=a58eb2a4c930ef3fc2a4e0516be2be00e66b402d;hp=39b0a51097d2876e4122114ecd57b5bc030b07a0;hb=b1a28ae1dab34a159e7cf17a82ecda0635e72f97;hpb=0f1f30daca0eaf0a400fd3f8d274594c07b32a51 diff --git a/dwm.c b/dwm.c index 39b0a51..a58eb2a 100644 --- a/dwm.c +++ b/dwm.c @@ -125,6 +125,7 @@ typedef struct { struct Monitor { char ltsymbol[16]; float mfact; + int nmaster; int num; int by; /* bar geometry */ 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 void grabbuttons(Client *c, Bool focused); static void grabkeys(void); +static void incnmaster(const Arg *arg); static void initfont(const char *fontstr); static void keypress(XEvent *e); static void killclient(const Arg *arg); @@ -349,7 +351,7 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) { *h = bh; if(*w < bh) *w = bh; - if(resizehints || c->isfloating) { + if(resizehints || c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) { /* see last two sentences in ICCCM 4.1.2.3 */ baseismin = c->basew == c->minw && c->baseh == c->minh; if(!baseismin) { /* temporarily remove base dimensions */ @@ -664,6 +666,7 @@ createmon(void) { die("fatal: could not malloc() %u bytes\n", sizeof(Monitor)); m->tagset[0] = m->tagset[1] = 1; m->mfact = mfact; + m->nmaster = nmaster; m->showbar = showbar; m->topbar = topbar; m->lt[0] = &layouts[0]; @@ -1024,6 +1027,12 @@ grabkeys(void) { } void +incnmaster(const Arg *arg) { + selmon->nmaster = MAX(selmon->nmaster + arg->i, 1); + arrange(selmon); +} + +void initfont(const char *fontstr) { char *def, **missing; int n; @@ -1597,7 +1606,7 @@ showhide(Client *c) { } else { /* hide clients bottom up */ showhide(c->snext); - XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); + XMoveWindow(dpy, c->win, c->w * -2, c->y); } } @@ -1650,32 +1659,23 @@ textnw(const char *text, unsigned int len) { void tile(Monitor *m) { - int x, y, h, w, mw; - unsigned int i, n; + unsigned int i, n, mw, mh, tw, th; Client *c; for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); if(n == 0) return; - /* master */ - c = nexttiled(m->clients); - mw = m->mfact * m->ww; - resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw, False); - if(--n == 0) - return; - /* tile stack */ - x = (m->wx > c->x) ? c->x + mw + 2 * c->bw : m->wx + mw; - y = m->wy; - w = (m->wx > c->x) ? m->wx + m->ww - x : m->ww - mw; - h = m->wh / n; - 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); - } + + mh = (n > m->nmaster) ? m->wh / m->nmaster : m->wh / n; + mw = (n > m->nmaster) ? m->ww * m->mfact : m->ww; + th = (n > m->nmaster) ? m->wh / (n - m->nmaster) : 0; + tw = m->ww - mw; + + for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if(i < m->nmaster) + resize(c, m->wx, m->wy + (i*mh), mw - (2*c->bw), mh - (2*c->bw), False); + else + resize(c, m->wx + mw, m->wy + ((i - m->nmaster)*th), tw - (2*c->bw), th - (2*c->bw), False); } void