From 58b58dc44ead403891436122725118f16197b8f2 Mon Sep 17 00:00:00 2001 From: Utkarsh Verma Date: Thu, 14 Mar 2024 14:08:21 +0530 Subject: [PATCH] Add PERMON_VANITYGAPS_PATCH (#343) --- dwm.c | 9 +++++++++ patch/vanitygaps.c | 27 +++++++++++++++++++++------ patches.def.h | 5 +++++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/dwm.c b/dwm.c index fa51816..543b721 100644 --- a/dwm.c +++ b/dwm.c @@ -482,6 +482,9 @@ struct Monitor { int gappiv; /* vertical gap between windows */ int gappoh; /* horizontal outer gaps */ int gappov; /* vertical outer gaps */ + #if PERMON_VANITYGAPS_PATCH + int enablegaps; /* whether gaps are enabled */ + #endif // PERMON_VANITYGAPS_PATCH #endif // VANITYGAPS_PATCH #if SETBORDERPX_PATCH int borderpx; @@ -1769,6 +1772,10 @@ createmon(void) } #endif // PERTAG_PATCH + #if PERMON_VANITYGAPS_PATCH + m->enablegaps = 1; + #endif // PERMON_VANITYGAPS_PATCH + #if SEAMLESS_RESTART_PATCH restoremonitorstate(m); #endif // SEAMLESS_RESTART_PATCH @@ -4651,6 +4658,8 @@ updatebarpos(Monitor *m) #if BAR_PADDING_VANITYGAPS_PATCH && VANITYGAPS_PATCH #if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH if (!selmon || selmon->pertag->enablegaps[selmon->pertag->curtag]) + #elif PERMON_VANITYGAPS_PATCH + if (!selmon || selmon->enablegaps) #else if (enablegaps) #endif // PERTAG_VANITYGAPS_PATCH diff --git a/patch/vanitygaps.c b/patch/vanitygaps.c index 303d4df..bf51660 100644 --- a/patch/vanitygaps.c +++ b/patch/vanitygaps.c @@ -1,5 +1,5 @@ /* Settings */ -#if !PERTAG_VANITYGAPS_PATCH +#if !(PERTAG_VANITYGAPS_PATCH || PERMON_VANITYGAPS_PATCH) static int enablegaps = 1; #endif // PERTAG_VANITYGAPS_PATCH @@ -69,10 +69,12 @@ setgapsex(const Arg *arg) #if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH if (!selmon->pertag->enablegaps[selmon->pertag->curtag]) selmon->pertag->enablegaps[selmon->pertag->curtag] = 1; + #elif PERMON_VANITYGAPS_PATCH + selmon->enablegaps = 1; #else if (!enablegaps) enablegaps = 1; - #endif // PERTAG_VANITYGAPS_PATCH + #endif // PERTAG_VANITYGAPS_PATCH | PERMON_VANITYGAPS_PATCH setgaps(oh, ov, ih, iv); } @@ -83,24 +85,35 @@ togglegaps(const Arg *arg) { #if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag]; + #elif PERMON_VANITYGAPS_PATCH + selmon->enablegaps = !selmon->enablegaps; #else enablegaps = !enablegaps; - #endif // PERTAG_VANITYGAPS_PATCH + #endif // PERTAG_VANITYGAPS_PATCH | PERMON_VANITYGAPS_PATCH #if BAR_PADDING_VANITYGAPS_PATCH + #if PERMON_VANITYGAPS_PATCH updatebarpos(selmon); for (Bar *bar = selmon->bar; bar; bar = bar->next) 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 drawbarwin(systray->bar); #endif // BAR_SYSTRAY_PATCH #endif // BAR_PADDING_VANITYGAPS_PATCH - #if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH + + #if (PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH) || PERMON_VANITYGAPS_PATCH arrange(selmon); #else arrange(NULL); - #endif // PERTAG_VANITYGAPS_PATCH + #endif // PERTAG_VANITYGAPS_PATCH | PERMON_VANITYGAPS_PATCH } 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; #if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH oe = ie = m->pertag->enablegaps[m->pertag->curtag]; + #elif PERMON_VANITYGAPS_PATCH + oe = ie = m->enablegaps; #else oe = ie = enablegaps; - #endif // PERTAG_VANITYGAPS_PATCH + #endif // PERTAG_VANITYGAPS_PATCH | PERMON_VANITYGAPS_PATCH Client *c; for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); diff --git a/patches.def.h b/patches.def.h index 410f9b9..968eb75 100644 --- a/patches.def.h +++ b/patches.def.h @@ -903,6 +903,11 @@ */ #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 * tag basis, or leave it as one bar per monitor. */