Merge pull request #25 from E-Almqvist/dev

Gap modes
pull/33/head
Elias Almqvist 4 years ago committed by GitHub
commit b224052fb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/config.h
  2. 13
      src/dwm.c

@ -4,7 +4,7 @@
static const unsigned int borderpx = 4; /* border pixel of windows */ static const unsigned int borderpx = 4; /* border pixel of windows */
static const unsigned int snap = 16; /* snap pixel (32)*/ static const unsigned int snap = 16; /* snap pixel (32)*/
static const unsigned int gappx = 0; static const unsigned int gappx = 0;
static const unsigned int gappx2 = 40; static const unsigned int gapmodes[] = { gappx, 40, 80 };
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 0; /* 0 means bottom bar */ static const int topbar = 0; /* 0 means bottom bar */
static const int usealtbar = 1; /* 1 means use non-dwm status bar */ static const int usealtbar = 1; /* 1 means use non-dwm status bar */
@ -126,7 +126,8 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_x, spawn, {.v = betterlockscreencmd} }, { MODKEY|ShiftMask, XK_x, spawn, {.v = betterlockscreencmd} },
{ MODKEY, XK_Print, spawn, {.v = spectaclecmd} }, { MODKEY, XK_Print, spawn, {.v = spectaclecmd} },
{ MODKEY, XK_u, spawn, {.v = cmuspausecmd} }, { MODKEY, XK_u, spawn, {.v = cmuspausecmd} },
{ MODKEY, XK_g, togglegaps, {0} }, { MODKEY, XK_g, switchgaps, {.i = +1 } },
{ MODKEY, XK_v, switchgaps, {.i = -1 } },
{ MODKEY, XK_minus, setgaps, {.i = -1 } }, { MODKEY, XK_minus, setgaps, {.i = -1 } },
{ MODKEY, XK_plus, setgaps, {.i = +1 } }, { MODKEY, XK_plus, setgaps, {.i = +1 } },
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },

@ -137,6 +137,7 @@ struct Monitor {
int mx, my, mw, mh; /* screen size */ int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */ int wx, wy, ww, wh; /* window area */
int gappx; /* gaps between windows */ int gappx; /* gaps between windows */
int gapidx; /* gap mode index */
unsigned int seltags; unsigned int seltags;
unsigned int sellt; unsigned int sellt;
unsigned int tagset[2]; unsigned int tagset[2];
@ -229,7 +230,7 @@ static void setclientstate(Client *c, long state);
static void setfocus(Client *c); static void setfocus(Client *c);
static void setfullscreen(Client *c, int fullscreen); static void setfullscreen(Client *c, int fullscreen);
static void setgaps(const Arg *arg); static void setgaps(const Arg *arg);
static void togglegaps(const Arg *arg); static void switchgaps(const Arg *arg);
static void setlayout(const Arg *arg); static void setlayout(const Arg *arg);
static void setlayoutsafe(const Arg *arg); static void setlayoutsafe(const Arg *arg);
static void setmfact(const Arg *arg); static void setmfact(const Arg *arg);
@ -696,6 +697,7 @@ createmon(void)
m->showbar = showbar; m->showbar = showbar;
m->topbar = topbar; m->topbar = topbar;
m->gappx = gappx; m->gappx = gappx;
m->gapidx = 0;
m->lt[0] = &layouts[0]; m->lt[0] = &layouts[0];
m->lt[1] = &layouts[1 % LENGTH(layouts)]; m->lt[1] = &layouts[1 % LENGTH(layouts)];
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
@ -1839,12 +1841,11 @@ setgaps(const Arg *arg)
} }
void void
togglegaps(const Arg *arg) switchgaps(const Arg *arg)
{ {
if (selmon->gappx == gappx2) selmon->gapidx = (selmon->gapidx + arg->i) % LENGTH(gapmodes);
selmon->gappx = gappx; selmon->gappx = gapmodes[selmon->gapidx];
else
selmon->gappx = gappx2;
arrange(selmon); arrange(selmon);
} }

Loading…
Cancel
Save