mirror of
https://codeberg.org/frosty/dwm.git
synced 2024-09-19 03:36:55 -04:00
patch: vanitygaps
This commit is contained in:
parent
838f9f1392
commit
34edb9f650
|
@ -3,6 +3,11 @@
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
static const unsigned int snap = 32; /* snap pixel */
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
|
static const unsigned int gappih = 10; /* horiz inner gap between windows */
|
||||||
|
static const unsigned int gappiv = 10; /* vert inner gap between windows */
|
||||||
|
static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
|
||||||
|
static const unsigned int gappov = 10; /* vert outer gap between windows and screen edge */
|
||||||
|
static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */
|
||||||
static const int showbar = 1; /* 0 means no bar */
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
static const char *fonts[] = { "monospace:size=10" };
|
static const char *fonts[] = { "monospace:size=10" };
|
||||||
|
@ -75,6 +80,10 @@ static const Key keys[] = {
|
||||||
{ MODKEY, XK_d, 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|Mod4Mask, XK_h, incrgaps, {.i = +1 } },
|
||||||
|
{ MODKEY|Mod4Mask, XK_l, incrgaps, {.i = -1 } },
|
||||||
|
{ MODKEY|Mod4Mask, XK_0, togglegaps, {0} },
|
||||||
|
{ MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} },
|
||||||
{ MODKEY, XK_Return, zoom, {0} },
|
{ MODKEY, XK_Return, zoom, {0} },
|
||||||
{ MODKEY, XK_Tab, view, {0} },
|
{ MODKEY, XK_Tab, view, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||||
|
|
82
dwm.c
82
dwm.c
|
@ -120,6 +120,10 @@ struct Monitor {
|
||||||
int by; /* bar geometry */
|
int by; /* bar geometry */
|
||||||
int mx, my, mw, mh; /* screen size */
|
int mx, my, mw, mh; /* screen size */
|
||||||
int wx, wy, ww, wh; /* window area */
|
int wx, wy, ww, wh; /* window area */
|
||||||
|
int gappih; /* horizontal gap between windows */
|
||||||
|
int gappiv; /* vertical gap between windows */
|
||||||
|
int gappoh; /* horizontal outer gaps */
|
||||||
|
int gappov; /* vertical outer gaps */
|
||||||
unsigned int seltags;
|
unsigned int seltags;
|
||||||
unsigned int sellt;
|
unsigned int sellt;
|
||||||
unsigned int tagset[2];
|
unsigned int tagset[2];
|
||||||
|
@ -206,6 +210,10 @@ static void sendmon(Client *c, Monitor *m);
|
||||||
static void setclientstate(Client *c, long state);
|
static void setclientstate(Client *c, long state);
|
||||||
static void setfocus(Client *c);
|
static void setfocus(Client *c);
|
||||||
static void setfullscreen(Client *c, int fullscreen);
|
static void setfullscreen(Client *c, int fullscreen);
|
||||||
|
static void setgaps(int oh, int ov, int ih, int iv);
|
||||||
|
static void incrgaps(const Arg *arg);
|
||||||
|
static void togglegaps(const Arg *arg);
|
||||||
|
static void defaultgaps(const Arg *arg);
|
||||||
static void setsticky(Client *c, int sticky);
|
static void setsticky(Client *c, int sticky);
|
||||||
static void setlayout(const Arg *arg);
|
static void setlayout(const Arg *arg);
|
||||||
static void setmfact(const Arg *arg);
|
static void setmfact(const Arg *arg);
|
||||||
|
@ -249,6 +257,7 @@ static char stext[256];
|
||||||
static int screen;
|
static int screen;
|
||||||
static int sw, sh; /* X display screen geometry width, height */
|
static int sw, sh; /* X display screen geometry width, height */
|
||||||
static int bh; /* bar height */
|
static int bh; /* bar height */
|
||||||
|
static int enablegaps = 1; /* enables gaps, used by togglegaps */
|
||||||
static int lrpad; /* sum of left and right padding for text */
|
static int lrpad; /* sum of left and right padding for text */
|
||||||
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
static int (*xerrorxlib)(Display *, XErrorEvent *);
|
||||||
static unsigned int numlockmask = 0;
|
static unsigned int numlockmask = 0;
|
||||||
|
@ -678,6 +687,10 @@ createmon(void)
|
||||||
m->nmaster = nmaster;
|
m->nmaster = nmaster;
|
||||||
m->showbar = showbar;
|
m->showbar = showbar;
|
||||||
m->topbar = topbar;
|
m->topbar = topbar;
|
||||||
|
m->gappih = gappih;
|
||||||
|
m->gappiv = gappiv;
|
||||||
|
m->gappoh = gappoh;
|
||||||
|
m->gappov = gappov;
|
||||||
m->lt[0] = &layouts[0];
|
m->lt[0] = &layouts[0];
|
||||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||||
|
@ -1450,6 +1463,45 @@ resizemouse(const Arg *arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setgaps(int oh, int ov, int ih, int iv)
|
||||||
|
{
|
||||||
|
if (oh < 0) oh = 0;
|
||||||
|
if (ov < 0) ov = 0;
|
||||||
|
if (ih < 0) ih = 0;
|
||||||
|
if (iv < 0) iv = 0;
|
||||||
|
|
||||||
|
selmon->gappoh = oh;
|
||||||
|
selmon->gappov = ov;
|
||||||
|
selmon->gappih = ih;
|
||||||
|
selmon->gappiv = iv;
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
togglegaps(const Arg *arg)
|
||||||
|
{
|
||||||
|
enablegaps = !enablegaps;
|
||||||
|
arrange(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
defaultgaps(const Arg *arg)
|
||||||
|
{
|
||||||
|
setgaps(gappoh, gappov, gappih, gappiv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
incrgaps(const Arg *arg)
|
||||||
|
{
|
||||||
|
setgaps(
|
||||||
|
selmon->gappoh + arg->i,
|
||||||
|
selmon->gappov + arg->i,
|
||||||
|
selmon->gappih + arg->i,
|
||||||
|
selmon->gappiv + arg->i
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
restack(Monitor *m)
|
restack(Monitor *m)
|
||||||
{
|
{
|
||||||
|
@ -1804,28 +1856,34 @@ tagmon(const Arg *arg)
|
||||||
void
|
void
|
||||||
tile(Monitor *m)
|
tile(Monitor *m)
|
||||||
{
|
{
|
||||||
unsigned int i, n, h, mw, my, ty;
|
unsigned int i, n, h, r, oe = enablegaps, ie = enablegaps, mw, my, ty;
|
||||||
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;
|
||||||
|
|
||||||
|
if (smartgaps == n) {
|
||||||
|
oe = 0; // outer gaps disabled
|
||||||
|
}
|
||||||
|
|
||||||
if (n > m->nmaster)
|
if (n > m->nmaster)
|
||||||
mw = m->nmaster ? m->ww * m->mfact : 0;
|
mw = m->nmaster ? (m->ww + m->gappiv*ie) * m->mfact : 0;
|
||||||
else
|
else
|
||||||
mw = m->ww;
|
mw = m->ww - 2*m->gappov*oe + m->gappiv*ie;
|
||||||
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
for (i = 0, my = ty = m->gappoh*oe, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
if (i < m->nmaster) {
|
if (i < m->nmaster) {
|
||||||
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
r = MIN(n, m->nmaster) - i;
|
||||||
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
h = (m->wh - my - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
|
||||||
if (my + HEIGHT(c) < m->wh)
|
resize(c, m->wx + m->gappov*oe, m->wy + my, mw - (2*c->bw) - m->gappiv*ie, h - (2*c->bw), 0);
|
||||||
my += HEIGHT(c);
|
if (my + HEIGHT(c) + m->gappih*ie < m->wh)
|
||||||
|
my += HEIGHT(c) + m->gappih*ie;
|
||||||
} else {
|
} else {
|
||||||
h = (m->wh - ty) / (n - i);
|
r = n - i;
|
||||||
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
h = (m->wh - ty - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
|
||||||
if (ty + HEIGHT(c) < m->wh)
|
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);
|
||||||
ty += HEIGHT(c);
|
if (ty + HEIGHT(c) + m->gappih*ie < m->wh)
|
||||||
|
ty += HEIGHT(c) + m->gappih*ie;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue