Add PERMON_VANITYGAPS_PATCH (#343)

This commit is contained in:
Utkarsh Verma 2024-03-14 14:08:21 +05:30 committed by GitHub
parent 5e85bc8b5c
commit 58b58dc44e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 35 additions and 6 deletions

9
dwm.c
View File

@ -482,6 +482,9 @@ struct Monitor {
int gappiv; /* vertical gap between windows */ int gappiv; /* vertical gap between windows */
int gappoh; /* horizontal outer gaps */ int gappoh; /* horizontal outer gaps */
int gappov; /* vertical outer gaps */ int gappov; /* vertical outer gaps */
#if PERMON_VANITYGAPS_PATCH
int enablegaps; /* whether gaps are enabled */
#endif // PERMON_VANITYGAPS_PATCH
#endif // VANITYGAPS_PATCH #endif // VANITYGAPS_PATCH
#if SETBORDERPX_PATCH #if SETBORDERPX_PATCH
int borderpx; int borderpx;
@ -1769,6 +1772,10 @@ createmon(void)
} }
#endif // PERTAG_PATCH #endif // PERTAG_PATCH
#if PERMON_VANITYGAPS_PATCH
m->enablegaps = 1;
#endif // PERMON_VANITYGAPS_PATCH
#if SEAMLESS_RESTART_PATCH #if SEAMLESS_RESTART_PATCH
restoremonitorstate(m); restoremonitorstate(m);
#endif // SEAMLESS_RESTART_PATCH #endif // SEAMLESS_RESTART_PATCH
@ -4651,6 +4658,8 @@ updatebarpos(Monitor *m)
#if BAR_PADDING_VANITYGAPS_PATCH && VANITYGAPS_PATCH #if BAR_PADDING_VANITYGAPS_PATCH && VANITYGAPS_PATCH
#if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH #if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH
if (!selmon || selmon->pertag->enablegaps[selmon->pertag->curtag]) if (!selmon || selmon->pertag->enablegaps[selmon->pertag->curtag])
#elif PERMON_VANITYGAPS_PATCH
if (!selmon || selmon->enablegaps)
#else #else
if (enablegaps) if (enablegaps)
#endif // PERTAG_VANITYGAPS_PATCH #endif // PERTAG_VANITYGAPS_PATCH

View File

@ -1,5 +1,5 @@
/* Settings */ /* Settings */
#if !PERTAG_VANITYGAPS_PATCH #if !(PERTAG_VANITYGAPS_PATCH || PERMON_VANITYGAPS_PATCH)
static int enablegaps = 1; static int enablegaps = 1;
#endif // PERTAG_VANITYGAPS_PATCH #endif // PERTAG_VANITYGAPS_PATCH
@ -69,10 +69,12 @@ setgapsex(const Arg *arg)
#if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH #if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH
if (!selmon->pertag->enablegaps[selmon->pertag->curtag]) if (!selmon->pertag->enablegaps[selmon->pertag->curtag])
selmon->pertag->enablegaps[selmon->pertag->curtag] = 1; selmon->pertag->enablegaps[selmon->pertag->curtag] = 1;
#elif PERMON_VANITYGAPS_PATCH
selmon->enablegaps = 1;
#else #else
if (!enablegaps) if (!enablegaps)
enablegaps = 1; enablegaps = 1;
#endif // PERTAG_VANITYGAPS_PATCH #endif // PERTAG_VANITYGAPS_PATCH | PERMON_VANITYGAPS_PATCH
setgaps(oh, ov, ih, iv); setgaps(oh, ov, ih, iv);
} }
@ -83,24 +85,35 @@ togglegaps(const Arg *arg)
{ {
#if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH #if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH
selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag]; selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag];
#elif PERMON_VANITYGAPS_PATCH
selmon->enablegaps = !selmon->enablegaps;
#else #else
enablegaps = !enablegaps; enablegaps = !enablegaps;
#endif // PERTAG_VANITYGAPS_PATCH #endif // PERTAG_VANITYGAPS_PATCH | PERMON_VANITYGAPS_PATCH
#if BAR_PADDING_VANITYGAPS_PATCH #if BAR_PADDING_VANITYGAPS_PATCH
#if PERMON_VANITYGAPS_PATCH
updatebarpos(selmon); updatebarpos(selmon);
for (Bar *bar = selmon->bar; bar; bar = bar->next) for (Bar *bar = selmon->bar; bar; bar = bar->next)
XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh); XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
#else
for (Monitor *m = mons; m; m = m->next) {
updatebarpos(m);
for (Bar *bar = m->bar; bar; bar = bar->next)
XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
}
#endif // PERMON_VANITYGAPS_PATCH
#if BAR_SYSTRAY_PATCH #if BAR_SYSTRAY_PATCH
drawbarwin(systray->bar); drawbarwin(systray->bar);
#endif // BAR_SYSTRAY_PATCH #endif // BAR_SYSTRAY_PATCH
#endif // BAR_PADDING_VANITYGAPS_PATCH #endif // BAR_PADDING_VANITYGAPS_PATCH
#if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH
#if (PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH) || PERMON_VANITYGAPS_PATCH
arrange(selmon); arrange(selmon);
#else #else
arrange(NULL); arrange(NULL);
#endif // PERTAG_VANITYGAPS_PATCH #endif // PERTAG_VANITYGAPS_PATCH | PERMON_VANITYGAPS_PATCH
} }
static void static void
@ -193,9 +206,11 @@ getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc)
unsigned int n, oe, ie; unsigned int n, oe, ie;
#if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH #if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH
oe = ie = m->pertag->enablegaps[m->pertag->curtag]; oe = ie = m->pertag->enablegaps[m->pertag->curtag];
#elif PERMON_VANITYGAPS_PATCH
oe = ie = m->enablegaps;
#else #else
oe = ie = enablegaps; oe = ie = enablegaps;
#endif // PERTAG_VANITYGAPS_PATCH #endif // PERTAG_VANITYGAPS_PATCH | PERMON_VANITYGAPS_PATCH
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++);

View File

@ -903,6 +903,11 @@
*/ */
#define PERTAG_VANITYGAPS_PATCH 0 #define PERTAG_VANITYGAPS_PATCH 0
/* This patch allows configuring vanity gaps on a per-monitor basis rather than
* all monitors (default).
*/
#define PERMON_VANITYGAPS_PATCH 0
/* This controls whether or not to also store bar position on a per /* This controls whether or not to also store bar position on a per
* tag basis, or leave it as one bar per monitor. * tag basis, or leave it as one bar per monitor.
*/ */