diff -Naur dwmbase/config.def.h dwmfork/config.def.h --- dwmbase/config.def.h 2015-11-08 23:39:37.000000000 +0100 +++ dwmfork/config.def.h 2018-02-15 21:01:40.755130451 +0100 @@ -11,6 +11,7 @@ static const char selbordercolor[] = "#005577"; static const char selbgcolor[] = "#005577"; static const char selfgcolor[] = "#eeeeee"; +static unsigned int gappx = 5; static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ @@ -64,6 +65,8 @@ { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY|ShiftMask, XK_j, movegap, {.i = +1 }}, + { MODKEY|ShiftMask, XK_k, movegap, {.i = -1 }}, { MODKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, diff -Naur dwmbase/dwm.c dwmfork/dwm.c --- dwmbase/dwm.c 2015-11-08 23:39:37.000000000 +0100 +++ dwmfork/dwm.c 2018-02-15 21:04:21.631786581 +0100 @@ -52,8 +52,8 @@ #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) #define LENGTH(X) (sizeof X / sizeof X[0]) #define MOUSEMASK (BUTTONMASK|PointerMotionMask) -#define WIDTH(X) ((X)->w + 2 * (X)->bw) -#define HEIGHT(X) ((X)->h + 2 * (X)->bw) +#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx) +#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx) #define TAGMASK ((1 << LENGTH(tags)) - 1) #define TEXTW(X) (drw_text(drw, 0, 0, 0, 0, (X), 0) + drw->fonts[0]->h) @@ -183,6 +183,7 @@ static void maprequest(XEvent *e); static void monocle(Monitor *m); static void motionnotify(XEvent *e); +static void movegap(const Arg *arg); static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); static void pop(Client *); @@ -1146,6 +1147,16 @@ mon = m; } +void +movegap(const Arg *arg) +{ + if(arg->i < 0 && gappx > 0) + gappx--; + else if(arg->i > 0) + gappx++; + arrange(selmon); +} + void movemouse(const Arg *arg) { @@ -1293,12 +1304,36 @@ resizeclient(Client *c, int x, int y, int w, int h) { XWindowChanges wc; + unsigned int n; + unsigned int gapoffset; + unsigned int gapincr; + Client *nbc; - c->oldx = c->x; c->x = wc.x = x; - c->oldy = c->y; c->y = wc.y = y; - c->oldw = c->w; c->w = wc.width = w; - c->oldh = c->h; c->h = wc.height = h; wc.border_width = c->bw; + + /* Get number of clients for the selected monitor */ + for (n = 0, nbc = nexttiled(selmon->clients); nbc; nbc = nexttiled(nbc->next), n++); + + /* Do nothing if layout is floating */ + if (c->isfloating || selmon->lt[selmon->sellt]->arrange == NULL) { + gapincr = gapoffset = 0; + } else { + /* Remove border and gap if layout is monocle or only one client */ + if (selmon->lt[selmon->sellt]->arrange == monocle || n == 1) { + gapoffset = 0; + gapincr = -2 * borderpx; + wc.border_width = 0; + } else { + gapoffset = gappx; + gapincr = 2 * gappx; + } + } + + c->oldx = c->x; c->x = wc.x = x + gapoffset; + c->oldy = c->y; c->y = wc.y = y + gapoffset; + c->oldw = c->w; c->w = wc.width = w - gapincr; + c->oldh = c->h; c->h = wc.height = h - gapincr; + XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); configure(c); XSync(dpy, False);