Hello,
I have modified the patch to make it work with some of the gap patches,
see attachments. In all cases one applies first the *gap patch and then
the vfact-*gap one.
I have also made a tiny change to the original patch (the behavior
remains exactly the same).
I have realized just a few days ago that the functionality that my patch
adds is already included in xtile.
I will send the "zoomstack" patch that I have mentioned in my first
email in a separate thread.
Best,
Sebastiano
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);
diff --git a/config.def.h b/config.def.h
index 38d2f6c..e748e20 100644
--- a/config.def.h
+++ b/config.def.h
@@ -34,6 +34,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 */
@@ -98,6 +100,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 d090af8..cc0c030 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 */
@@ -206,6 +208,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);
@@ -638,6 +643,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;
@@ -1624,6 +1631,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)
{
@@ -1700,12 +1728,18 @@ tile(Monitor *m)
mw = m->ww - m->gappx;
for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
- h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
+ 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;
+ h -= m->gappx;
resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
if (my + HEIGHT(c) + m->gappx < m->wh)
my += HEIGHT(c) + m->gappx;
} else {
- h = (m->wh - ty) / (n - i) - m->gappx;
+ h = (m->wh - ty) / (n - i);
+ if (i == m->nmaster && n - i > 1 && m->vfactstack > 0.01)
+ h *= (n - i) * m->vfactstack;
+ h -= m->gappx;
resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
if (ty + HEIGHT(c) + m->gappx < m->wh)
ty += HEIGHT(c) + m->gappx;
diff --git a/config.def.h b/config.def.h
index 0927c2d..f38210a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -38,6 +38,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 */
@@ -115,6 +117,12 @@ static Key keys[] = {
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
+ { MODKEY, XK_e, setvfactmaster, {.f = +0.05} },
+ { MODKEY|ShiftMask, XK_e, setvfactmaster, {.f = -0.05} },
+ { MODKEY|ControlMask, XK_e, setvfactmaster, {.f = +1.0 } },
+ { MODKEY, XK_r, setvfactstack, {.f = +0.05} },
+ { MODKEY|ShiftMask, XK_r, setvfactstack, {.f = -0.05} },
+ { MODKEY|ControlMask, XK_r, setvfactstack, {.f = +1.0 } },
};
/* button definitions */
diff --git a/dwm.c b/dwm.c
index 36025bf..db9e7f6 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 */
@@ -218,6 +220,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);
@@ -651,6 +656,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;
@@ -1735,6 +1742,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)
{
@@ -1817,12 +1845,16 @@ tile(Monitor *m)
if (i < m->nmaster) {
r = MIN(n, m->nmaster) - i;
h = (m->wh - my - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
+ if (i == 0 && MIN(n, m->nmaster) > 1 && m->vfactmaster > 0.01)
+ h *= r * m->vfactmaster;
resize(c, m->wx + m->gappov*oe, m->wy + my, mw - (2*c->bw) - m->gappiv*ie, h - (2*c->bw), 0);
if (my + HEIGHT(c) + m->gappih*ie < m->wh)
my += HEIGHT(c) + m->gappih*ie;
} else {
r = n - i;
h = (m->wh - ty - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
+ if (i == m->nmaster && n - i > 1 && m->vfactstack > 0.01)
+ h *= r * m->vfactstack;
resize(c, m->wx + mw + m->gappov*oe, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappov*oe, h - (2*c->bw), 0);
if (ty + HEIGHT(c) + m->gappih*ie < m->wh)
ty += HEIGHT(c) + m->gappih*ie;
diff --git a/config.def.h b/config.def.h
index b11471d..33c9a09 100644
--- a/config.def.h
+++ b/config.def.h
@@ -34,6 +34,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 */
@@ -95,6 +97,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 8a192a3..b624071 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;
@@ -1635,6 +1642,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)
{
@@ -1712,11 +1740,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);