dwm-speedie/libs/vanitygaps.c

138 lines
2.4 KiB
C
Raw Normal View History

2023-09-13 10:57:58 +02:00
/* Settings */
static void
2023-07-04 18:05:12 +02:00
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;
2023-09-13 10:57:58 +02:00
selmon->pertag->gaps[selmon->pertag->curtag] =
((oh & 0xFF) << 0) | ((ov & 0xFF) << 8) | ((ih & 0xFF) << 16) | ((iv & 0xFF) << 24);
2023-07-04 18:05:12 +02:00
arrange(selmon);
}
2023-09-13 10:57:58 +02:00
static void
togglegaps(const Arg *arg)
{
selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag];
updatebarpos(selmon);
for (Bar *bar = selmon->bar; bar; bar = bar->next)
XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
drawbarwin(systray->bar);
arrange(selmon);
}
static void
2023-07-04 18:05:12 +02:00
defaultgaps(const Arg *arg)
{
setgaps(gappoh, gappov, gappih, gappiv);
}
2023-09-13 10:57:58 +02:00
static void
2023-07-04 18:05:12 +02:00
incrgaps(const Arg *arg)
{
setgaps(
selmon->gappoh + arg->i,
selmon->gappov + arg->i,
selmon->gappih + arg->i,
selmon->gappiv + arg->i
);
}
2023-09-13 10:57:58 +02:00
static void
2023-07-04 18:05:12 +02:00
incrigaps(const Arg *arg)
{
setgaps(
selmon->gappoh,
selmon->gappov,
selmon->gappih + arg->i,
selmon->gappiv + arg->i
);
}
2023-09-13 10:57:58 +02:00
static void
2023-07-04 18:05:12 +02:00
incrogaps(const Arg *arg)
{
setgaps(
selmon->gappoh + arg->i,
selmon->gappov + arg->i,
selmon->gappih,
selmon->gappiv
);
}
2023-09-13 10:57:58 +02:00
static void
2023-07-04 18:05:12 +02:00
incrohgaps(const Arg *arg)
{
setgaps(
selmon->gappoh + arg->i,
selmon->gappov,
selmon->gappih,
selmon->gappiv
);
}
2023-09-13 10:57:58 +02:00
static void
2023-07-04 18:05:12 +02:00
incrovgaps(const Arg *arg)
{
setgaps(
selmon->gappoh,
selmon->gappov + arg->i,
selmon->gappih,
selmon->gappiv
);
}
2023-09-13 10:57:58 +02:00
static void
2023-07-04 18:05:12 +02:00
incrihgaps(const Arg *arg)
{
setgaps(
selmon->gappoh,
selmon->gappov,
selmon->gappih + arg->i,
selmon->gappiv
);
}
2023-09-13 10:57:58 +02:00
static void
2023-07-04 18:05:12 +02:00
incrivgaps(const Arg *arg)
{
setgaps(
selmon->gappoh,
selmon->gappov,
selmon->gappih,
selmon->gappiv + arg->i
);
}
2023-09-13 10:57:58 +02:00
static void
2023-07-04 18:05:12 +02:00
getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc)
{
unsigned int n, oe, ie;
2023-09-13 10:57:58 +02:00
oe = ie = m->pertag->enablegaps[m->pertag->curtag];
2023-07-04 18:05:12 +02:00
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
2023-09-13 10:57:58 +02:00
if (n == 1) {
oe *= smartgaps_fact; // outer gaps disabled or multiplied when only one client
2023-07-04 18:05:12 +02:00
}
*oh = m->gappoh*oe; // outer horizontal gap
*ov = m->gappov*oe; // outer vertical gap
*ih = m->gappih*ie; // inner horizontal gap
*iv = m->gappiv*ie; // inner vertical gap
*nc = n; // number of clients
}