Skip to content

Commit f645088

Browse files
committed
Toggle gaps pertag
1 parent 512bc80 commit f645088

4 files changed

Lines changed: 33 additions & 43 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dwm: ${OBJ}
2626
${CC} -o $@ ${OBJ} ${LDFLAGS}
2727

2828
clean:
29-
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
29+
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz *.rej *.orig *.diff
3030

3131
dist: clean
3232
mkdir -p dwm-${VERSION}

config.def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
static const unsigned int borderpx = 3; /* border pixel of windows */
55
static const unsigned int snap = 5; /* snap pixel */
66
static const int swallowfloating = 1; /* 1 means swallow floating windows by default */
7+
static int enablegaps = 1; /* 1 means gaps are enabled by default */
78
static const unsigned int gappih = 5; /* horiz inner gap between windows */
89
static const unsigned int gappiv = 5; /* vert inner gap between windows */
910
static const unsigned int gappoh = 5; /* horiz outer gap between windows and screen edge */

dwm.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ static void focusin(XEvent *e);
210210
static void focusmon(const Arg *arg);
211211
static void focusstack(const Arg *arg);
212212
static Atom getatomprop(Client *c, Atom prop);
213+
static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc);
213214
static int getrootptr(int *x, int *y);
214215
static long getstate(Window w);
215216
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
@@ -259,8 +260,9 @@ static void spawn(const Arg *arg);
259260
static void tag(const Arg *arg);
260261
static void tagmon(const Arg *arg);
261262
static void togglebar(const Arg *arg);
262-
static void togglefloating(const Arg *arg);
263263
static void togglecanfocusfloating(const Arg *arg);
264+
static void togglefloating(const Arg *arg);
265+
static void togglegaps(const Arg *arg);
264266
static void togglescratch(const Arg *arg);
265267
static void togglesticky(const Arg *arg);
266268
static void toggletag(const Arg *arg);
@@ -340,6 +342,7 @@ struct Pertag {
340342
unsigned int curtag, prevtag; /* current and previous tag */
341343
int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
342344
float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
345+
int enablegaps[LENGTH(tags) + 1]; /* vanitygaps per tag */
343346
unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
344347
const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
345348
int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */
@@ -825,6 +828,7 @@ createmon(void)
825828
m->pertag->nmasters[i] = m->nmaster;
826829
m->pertag->mfacts[i] = m->mfact;
827830

831+
m->pertag->enablegaps[i] = enablegaps;
828832
m->pertag->ltidxs[i][0] = m->lt[0];
829833
m->pertag->ltidxs[i][1] = m->lt[1];
830834
m->pertag->sellts[i] = m->sellt;
@@ -2791,6 +2795,13 @@ togglecanfocusfloating(const Arg *arg)
27912795
arrange(selmon);
27922796
}
27932797

2798+
void
2799+
togglegaps(const Arg *arg)
2800+
{
2801+
selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag];
2802+
arrange(NULL);
2803+
}
2804+
27942805
void
27952806
togglescratch(const Arg *arg)
27962807
{
@@ -3303,6 +3314,25 @@ winpid(Window w)
33033314
return result;
33043315
}
33053316

3317+
void
3318+
getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc)
3319+
{
3320+
unsigned int n, oe, ie;
3321+
oe = ie = selmon->pertag->enablegaps[selmon->pertag->curtag];
3322+
Client *c;
3323+
3324+
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
3325+
if (smartgaps && n == 1) {
3326+
oe = 0; // outer gaps disabled when only one client
3327+
}
3328+
3329+
*oh = m->gappoh*oe; // outer horizontal gap
3330+
*ov = m->gappov*oe; // outer vertical gap
3331+
*ih = m->gappih*ie; // inner horizontal gap
3332+
*iv = m->gappiv*ie; // inner vertical gap
3333+
*nc = n; // number of clients
3334+
}
3335+
33063336
pid_t
33073337
getparentprocess(pid_t p)
33083338
{

vanitygaps.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* Key binding functions */
22
static void defaultgaps(const Arg *arg);
33
static void incrgaps(const Arg *arg);
4-
static void togglegaps(const Arg *arg);
54
/* Layouts (delete the ones you do not need) */
65
static void bstack(Monitor *m);
76
static void bstackhoriz(Monitor *m);
@@ -15,15 +14,9 @@ static void nrowgrid(Monitor *m);
1514
static void spiral(Monitor *m);
1615
static void tile(Monitor *m);
1716
/* Internals */
18-
static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc);
1917
static void getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr);
2018
static void setgaps(int oh, int ov, int ih, int iv);
2119

22-
/* Settings */
23-
#if !PERTAG_PATCH
24-
static int enablegaps = 1;
25-
#endif // PERTAG_PATCH
26-
2720
void
2821
setgaps(int oh, int ov, int ih, int iv)
2922
{
@@ -39,17 +32,6 @@ setgaps(int oh, int ov, int ih, int iv)
3932
arrange(selmon);
4033
}
4134

42-
void
43-
togglegaps(const Arg *arg)
44-
{
45-
#if PERTAG_PATCH
46-
selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag];
47-
#else
48-
enablegaps = !enablegaps;
49-
#endif // PERTAG_PATCH
50-
arrange(NULL);
51-
}
52-
5335
void
5436
defaultgaps(const Arg *arg)
5537
{
@@ -67,29 +49,6 @@ incrgaps(const Arg *arg)
6749
);
6850
}
6951

70-
void
71-
getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc)
72-
{
73-
unsigned int n, oe, ie;
74-
#if PERTAG_PATCH
75-
oe = ie = selmon->pertag->enablegaps[selmon->pertag->curtag];
76-
#else
77-
oe = ie = enablegaps;
78-
#endif // PERTAG_PATCH
79-
Client *c;
80-
81-
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
82-
if (smartgaps && n == 1) {
83-
oe = 0; // outer gaps disabled when only one client
84-
}
85-
86-
*oh = m->gappoh*oe; // outer horizontal gap
87-
*ov = m->gappov*oe; // outer vertical gap
88-
*ih = m->gappih*ie; // inner horizontal gap
89-
*iv = m->gappiv*ie; // inner vertical gap
90-
*nc = n; // number of clients
91-
}
92-
9352
void
9453
getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr)
9554
{

0 commit comments

Comments
 (0)