summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.def.h2
-rw-r--r--dwm.c43
-rw-r--r--vanitygaps.c42
3 files changed, 44 insertions, 43 deletions
diff --git a/config.def.h b/config.def.h
index b62459c..705474b 100644
--- a/config.def.h
+++ b/config.def.h
@@ -8,6 +8,7 @@ static const unsigned int gappih = 15; /* horiz inner gap between windo
static const unsigned int gappiv = 30; /* vert inner gap between windows */
static const unsigned int gappoh = 15; /* horiz outer gap between windows and screen edge */
static const unsigned int gappov = 30; /* vert outer gap between windows and screen edge */
+static int enablegaps = 1; /* 1 means enable gaps on startup */
static int smartgaps = 0; /* 1 means no outer gap when there is only one window */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 0; /* 0 means bottom bar */
@@ -43,6 +44,7 @@ static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
+#define PERTAG_GAPS 1
#include "vanitygaps.c"
static const Layout layouts[] = {
diff --git a/dwm.c b/dwm.c
index 780be02..5e2fc17 100644
--- a/dwm.c
+++ b/dwm.c
@@ -193,6 +193,7 @@ static void focusin(XEvent *e);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
static Atom getatomprop(Client *c, Atom prop);
+static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc);
static int getrootptr(int *x, int *y);
static long getstate(Window w);
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
@@ -236,6 +237,7 @@ static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
+static void togglegaps(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus);
@@ -308,6 +310,9 @@ struct Pertag {
unsigned int curtag, prevtag; /* current and previous tag */
int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
+ #if PERTAG_GAPS
+ int enablegaps[LENGTH(tags) + 1]; /* gaps per tag */
+ #endif // PERTAG_GAPS
unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
@@ -746,7 +751,9 @@ createmon(void)
for (i = 0; i <= LENGTH(tags); i++) {
m->pertag->nmasters[i] = m->nmaster;
m->pertag->mfacts[i] = m->mfact;
-
+ #if PERTAG_GAPS
+ m->pertag->enablegaps[i] = enablegaps;
+ #endif // PERTAG_GAPS
m->pertag->ltidxs[i][0] = m->lt[0];
m->pertag->ltidxs[i][1] = m->lt[1];
m->pertag->sellts[i] = m->sellt;
@@ -1085,6 +1092,29 @@ getatomprop(Client *c, Atom prop)
return atom;
}
+void
+getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc)
+{
+ unsigned int n, oe, ie;
+ #if PERTAG_GAPS
+ oe = ie = selmon->pertag->enablegaps[selmon->pertag->curtag];
+ #else
+ oe = ie = enablegaps;
+ #endif // PERTAG_GAPS
+ Client *c;
+
+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+ if (smartgaps && n == 1) {
+ oe = 0; // outer gaps disabled when only one client
+ }
+
+ *oh = m->gappoh*oe; // outer horizontal gap
+ *ov = m->gappov*oe; // outer vertical gap
+ *ih = m->gappih*ie; // inner horizontal gap
+ *iv = m->gappiv*ie; // inner vertical gap
+ *nc = n; // number of clients
+}
+
int
getrootptr(int *x, int *y)
{
@@ -1966,6 +1996,17 @@ togglefloating(const Arg *arg)
}
void
+togglegaps(const Arg *arg)
+{
+ #if PERTAG_GAPS
+ selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag];
+ #else
+ enablegaps = !enablegaps;
+ #endif // PERTAG_GAPS
+ arrange(NULL);
+}
+
+void
toggletag(const Arg *arg)
{
unsigned int newtags;
diff --git a/vanitygaps.c b/vanitygaps.c
index 7a36b9d..68d08ad 100644
--- a/vanitygaps.c
+++ b/vanitygaps.c
@@ -1,5 +1,3 @@
-/* Key binding functions */
-static void togglegaps(const Arg *arg);
/* Layouts */
static void bstack(Monitor *m);
static void centeredmaster(Monitor *m);
@@ -9,48 +7,8 @@ static void fibonacci(Monitor *m, int s);
static void spiral(Monitor *m);
static void tile(Monitor *m);
/* Internals */
-static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc);
static void getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr);
-/* Settings */
-#if !PERTAG_PATCH
-static int enablegaps = 1;
-#endif // PERTAG_PATCH
-
-void
-togglegaps(const Arg *arg)
-{
- #if PERTAG_PATCH
- selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag];
- #else
- enablegaps = !enablegaps;
- #endif // PERTAG_PATCH
- arrange(NULL);
-}
-
-void
-getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc)
-{
- unsigned int n, oe, ie;
- #if PERTAG_PATCH
- oe = ie = selmon->pertag->enablegaps[selmon->pertag->curtag];
- #else
- oe = ie = enablegaps;
- #endif // PERTAG_PATCH
- Client *c;
-
- for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
- if (smartgaps && n == 1) {
- oe = 0; // outer gaps disabled when only one client
- }
-
- *oh = m->gappoh*oe; // outer horizontal gap
- *ov = m->gappov*oe; // outer vertical gap
- *ih = m->gappih*ie; // inner horizontal gap
- *iv = m->gappiv*ie; // inner vertical gap
- *nc = n; // number of clients
-}
-
void
getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr)
{