Allow negative values for gaps and padding

Issue #21 resolved
wyspr created an issue

I use this code in BSPWM to make window borders overlap and appear as one, while pushing other borders off screen.

Basically provides the same look as this dwm patch https://dwm.suckless.org/patches/singularborders/

BORDER=2
bspc config border_width       $BORDER
bspc config window_gap        -$BORDER

for side in right bottom left
do
  bspc config ${side}_padding -$BORDER
done

As of now DK does not allow for negative values for these settings and I can't port this over from my bspwmrc, could this be changed?

Comments (8)

  1. Nate Maia repo owner

    Couldn't this be done by just setting the border width to 0 or am I missing something? eg.

    dkcmd set border width=0
    

    Failing that, I think there's a lot of issues that will come from a change like this and I don't think it's something I want to fully integrate at the moment. Currently I use signed input as relative offsets to the value and there would be no way to determine if you want and absolute change or relative. However I don't wanna be a prick and just tell you no so I can make a simple patch that does (close to) what you want. I set the min to be -100 but feel free to change it to whatever you like, there's likely some weird bugs and it's completely untested so let me know if you run into any issues.

    diff --git a/src/cmd.c b/src/cmd.c
    index ade8f60..21984d2 100644
    --- a/src/cmd.c
    +++ b/src/cmd.c
    @@ -339,8 +339,15 @@ int cmdgappx(char **argv)
            respond(cmdresp, "!invalid value for gap: %s", *argv);
            return -1;
        } else {
    +       int n;
    +       int max = setws->mon->wh - setws->padb - setws->padt;
    +       int min = -100;
            nparsed++;
    -       adjustisetting(i, rel, &setws->gappx, border[BORD_WIDTH], 1);
    +       n = CLAMP(i, min, (max / 6) - (int)border[BORD_WIDTH]);
    +       if (n != setws->gappx) {
    +           setws->gappx = n;
    +           needsrefresh = 1;
    +       }
        }
        return nparsed;
     }
    @@ -471,11 +478,12 @@ int cmdmvstack(char **argv)
     int cmdpad(char **argv)
     {
        int i, rel, orig, nparsed = 0;
    +   int min = -100;
    
     #define PAD(v, max)                                                                       \
        argv++, nparsed++, orig = v;                                                          \
    -   if (!argv || (i = parseintclamp(*argv, &rel, v * -1, max)) == INT_MIN) goto badvalue; \
    -   v = CLAMP(rel ? v + i : i, 0, max);                                                   \
    +   if (!argv || (i = parseintclamp(*argv, &rel, min, max)) == INT_MIN) goto badvalue; \
    +   v = CLAMP(i, min, max);                                                   \
        needsrefresh = needsrefresh || v != orig
    
        while (*argv) {
    

    Note that these will still be considered relative changes to the current value so you might have to fiddle with it to get the right amount.

  2. Edwin van Olst

    I would also love this feature. Negative padding to get an inner gap only and negative gaps to overlap the (outer) border.

  3. Nate Maia repo owner

    I love how I post a possible solution and get no response for over a month but as soon as I close the issue people chime in XD.

    I'm willing to reopen this if I actually get feedback on my responses. Has anyone tested the above patch?

  4. Edwin van Olst

    I’m sorry about that! I have tested the patch but I got unexpected results. Honestly, my knowledge of C is not great and it’s unclear to me what the patch is supposed to accomplish exactly. But I could not get overlapping borders: https://imgur.com/a/vdNfmTY

  5. Nate Maia repo owner

    After some testing and working on it this weekend it's a much bigger job than expected. I've updated the above patch so that it does do what it should (allow negative values) but the layouts and other code would also need to be updated which is a large job. I'm not sure how others like bsp are handling it but something like this was never considered in the design and there's a lot of issues.

  6. Log in to comment