diff --git a/config.def.h b/config.def.h index 1c0b587..ff87720 100644 --- a/config.def.h +++ b/config.def.h @@ -33,6 +33,8 @@ static const Rule rules[] = { /* layout(s) */ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ +static const float vfactmaster = 0.5; /* vertical factor of first master tile */ +static const float vfactstack = 0.5; /* vertical factor of first stack tile */ static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ @@ -94,6 +96,12 @@ static Key keys[] = { TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) { MODKEY|ShiftMask, XK_q, quit, {0} }, + { MODKEY, XK_y, setvfactmaster, {.f = +0.05} }, + { MODKEY|ShiftMask, XK_y, setvfactmaster, {.f = -0.05} }, + { MODKEY|ControlMask, XK_y, setvfactmaster, {.f = +1.0 } }, + { MODKEY, XK_o, setvfactstack, {.f = +0.05} }, + { MODKEY|ShiftMask, XK_o, setvfactstack, {.f = -0.05} }, + { MODKEY|ControlMask, XK_o, setvfactstack, {.f = +1.0 } }, }; /* button definitions */ diff --git a/dwm.c b/dwm.c index 664c527..84fbdf2 100644 --- a/dwm.c +++ b/dwm.c @@ -114,6 +114,8 @@ typedef struct { struct Monitor { char ltsymbol[16]; float mfact; + float vfactmaster; + float vfactstack; int nmaster; int num; int by; /* bar geometry */ @@ -204,6 +206,9 @@ static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); +static void setvfact(float *factor, float f); +static void setvfactmaster(const Arg *arg); +static void setvfactstack(const Arg *arg); static void showhide(Client *c); static void sigchld(int unused); static void spawn(const Arg *arg); @@ -636,6 +641,8 @@ createmon(void) m = ecalloc(1, sizeof(Monitor)); m->tagset[0] = m->tagset[1] = 1; m->mfact = mfact; + m->vfactmaster = vfactmaster; + m->vfactstack = vfactstack; m->nmaster = nmaster; m->showbar = showbar; m->topbar = topbar; @@ -1611,6 +1618,27 @@ seturgent(Client *c, int urg) XFree(wmh); } +void +setvfact(float *factor, float f) { + if (!selmon->lt[selmon->sellt]->arrange) + return; + f += (*factor < 0.05 ? 0.5 : *factor); + *factor = f < 1.0 ? (f < 0.05 || f > 0.95 ? *factor : f) : 0.0; + arrange(selmon); +} + +void +setvfactmaster(const Arg *arg) +{ + setvfact(&selmon->vfactmaster, arg->f); +} + +void +setvfactstack(const Arg *arg) +{ + setvfact(&selmon->vfactstack, arg->f); +} + void showhide(Client *c) { @@ -1688,11 +1716,15 @@ tile(Monitor *m) for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) if (i < m->nmaster) { h = (m->wh - my) / (MIN(n, m->nmaster) - i); + if (i == 0 && MIN(n, m->nmaster) > 1 && m->vfactmaster > 0.01) + h *= (MIN(n, m->nmaster) - i) * m->vfactmaster; resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); if (my + HEIGHT(c) < m->wh) my += HEIGHT(c); } else { h = (m->wh - ty) / (n - i); + if (i == m->nmaster && n - i > 1 && m->vfactstack > 0.01) + h *= (n - i) * m->vfactstack; resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); if (ty + HEIGHT(c) < m->wh) ty += HEIGHT(c);