From 521f87af13006ae548f6e3a668a303a792255338 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sun, 4 Apr 2021 10:49:25 +0200 Subject: [PATCH] Adding proposed changes to have different gaps on a per tag basis ref. #106 --- README.md | 2 ++ patch/pertag.c | 10 ++++++++++ patch/vanitygaps.c | 18 ++++++++++++------ patches.def.h | 5 +++++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3f5ebb4..1046497 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2021-04-04 - Added option for having different gaps on a per tag basis + 2021-03-31 - Added tapresize patch (contributed by [verschmelzen](https://github.com/verschmelzen)) 2021-03-29 - Removed alwaysfullscreen patch (merged into dwm 6.2) diff --git a/patch/pertag.c b/patch/pertag.c index 3ca7ab2..f8165a6 100644 --- a/patch/pertag.c +++ b/patch/pertag.c @@ -22,6 +22,9 @@ struct Pertag { #if VANITYGAPS_PATCH int enablegaps[NUMTAGS + 1]; #endif // VANITYGAPS_PATCH + #if PERTAG_VANITYGAPS_PATCH && VANITYGAPS_PATCH + unsigned int gaps[NUMTAGS + 1]; + #endif // PERTAG_VANITYGAPS_PATCH | VANITYGAPS_PATCH }; void @@ -56,6 +59,13 @@ pertagview(const Arg *arg) selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; + #if PERTAG_VANITYGAPS_PATCH && VANITYGAPS_PATCH + selmon->gappoh = (selmon->pertag->gaps[selmon->pertag->curtag] & 0xff) >> 0; + selmon->gappov = (selmon->pertag->gaps[selmon->pertag->curtag] & 0xff00) >> 8; + selmon->gappih = (selmon->pertag->gaps[selmon->pertag->curtag] & 0xff0000) >> 16; + selmon->gappiv = (selmon->pertag->gaps[selmon->pertag->curtag] & 0xff000000) >> 24; + #endif // PERTAG_VANITYGAPS_PATCH | VANITYGAPS_PATCH + #if FLEXTILE_DELUXE_LAYOUT selmon->ltaxis[LAYOUT] = selmon->pertag->ltaxis[selmon->pertag->curtag][LAYOUT]; selmon->ltaxis[MASTER] = selmon->pertag->ltaxis[selmon->pertag->curtag][MASTER]; diff --git a/patch/vanitygaps.c b/patch/vanitygaps.c index dd579de..bf81669 100644 --- a/patch/vanitygaps.c +++ b/patch/vanitygaps.c @@ -1,7 +1,7 @@ /* Settings */ -#if !PERTAG_PATCH +#if !PERTAG_VANITYGAPS_PATCH || !PERTAG_PATCH static int enablegaps = 1; -#endif // PERTAG_PATCH +#endif // PERTAG_VANITYGAPS_PATCH | PERTAG_PATCH static void setgaps(int oh, int ov, int ih, int iv) @@ -15,6 +15,12 @@ setgaps(int oh, int ov, int ih, int iv) selmon->gappov = ov; selmon->gappih = ih; selmon->gappiv = iv; + + #if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH + selmon->pertag->gaps[selmon->pertag->curtag] = + ((oh & 0xFF) << 0) | ((ov & 0xFF) << 8) | ((ih & 0xFF) << 16) | ((iv & 0xFF) << 24); + #endif // PERTAG_VANITYGAPS_PATCH | PERTAG_PATCH + arrange(selmon); } @@ -60,13 +66,13 @@ setgapsex(const Arg *arg) iv = (arg->i & 0x7f); /* Auto enable gaps if disabled */ - #if PERTAG_PATCH + #if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH if (!selmon->pertag->enablegaps[selmon->pertag->curtag]) selmon->pertag->enablegaps[selmon->pertag->curtag] = 1; #else if (!enablegaps) enablegaps = 1; - #endif // PERTAG_PATCH + #endif // PERTAG_VANITYGAPS_PATCH | PERTAG_PATCH setgaps(oh, ov, ih, iv); } @@ -75,11 +81,11 @@ setgapsex(const Arg *arg) static void togglegaps(const Arg *arg) { - #if PERTAG_PATCH + #if PERTAG_VANITYGAPS_PATCH && PERTAG_PATCH selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag]; #else enablegaps = !enablegaps; - #endif // PERTAG_PATCH + #endif // PERTAG_VANITYGAPS_PATCH | PERTAG_PATCH arrange(NULL); } diff --git a/patches.def.h b/patches.def.h index fe2d1e0..16fb791 100644 --- a/patches.def.h +++ b/patches.def.h @@ -721,6 +721,11 @@ */ #define PERTAG_PATCH 0 +/* Option to store gaps on a per tag basis rather than on a per monitor basis. + * Depends on both pertag and vanitygaps patches being enabled. + */ +#define PERTAG_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. */