aboutsummaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
authordavidpkj <davidpenkow1@gmail.com>2023-03-16 12:00:35 +0100
committerdavidpkj <davidpenkow1@gmail.com>2023-03-16 12:00:35 +0100
commite640538556092fd7f660b1dd49eec2c91b2d4268 (patch)
treefd6e69c1b708906272ad4accbd137ace11d77d01 /dwm.c
parenta192172275f052a53d049fe2e224f4c3c97ef55c (diff)
Patch: fullgaps-toggle-20200830
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c63
1 files changed, 53 insertions, 10 deletions
diff --git a/dwm.c b/dwm.c
index 761f292..dc73b06 100644
--- a/dwm.c
+++ b/dwm.c
@@ -64,6 +64,9 @@
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+#define GAP_TOGGLE 100
+#define GAP_RESET 0
+
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel }; /* color schemes */
@@ -120,6 +123,12 @@ typedef struct {
void (*arrange)(Monitor *);
} Layout;
+typedef struct {
+ int isgap;
+ int realgap;
+ int gappx;
+} Gap;
+
#define MAXTABS 50
typedef struct Pertag Pertag;
@@ -132,6 +141,7 @@ struct Monitor {
int ty; /* tab bar geometry */
int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
+ Gap *gap;
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
@@ -206,6 +216,7 @@ static void focusin(XEvent *e);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
static void focuswin(const Arg *arg);
+static void gap_copy(Gap *to, const Gap *from);
static Atom getatomprop(Client *c, Atom prop);
static int getrootptr(int *x, int *y);
static long getstate(Window w);
@@ -241,6 +252,7 @@ static void setclientstate(Client *c, long state);
static void setfocus(Client *c);
static void setfullscreen(Client *c, int fullscreen);
static void setsticky(Client *c, int sticky);
+static void setgaps(const Arg *arg);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setup(void);
@@ -781,6 +793,8 @@ createmon(void)
m->showtab = showtab;
m->topbar = topbar;
m->toptab = toptab;
+ m->gap = malloc(sizeof(Gap));
+ gap_copy(m->gap, &default_gap);
m->ntabs = 0;
m->lt[0] = &layouts[def_layouts[1] % LENGTH(layouts)];
m->lt[1] = &layouts[1 % LENGTH(layouts)];
@@ -1512,6 +1526,35 @@ prevtiled(Client *c) {
}
void
+gap_copy(Gap *to, const Gap *from)
+{
+ to->isgap = from->isgap;
+ to->realgap = from->realgap;
+ to->gappx = from->gappx;
+}
+
+void
+setgaps(const Arg *arg)
+{
+ Gap *p = selmon->gap;
+ switch(arg->i)
+ {
+ case GAP_TOGGLE:
+ p->isgap = 1 - p->isgap;
+ break;
+ case GAP_RESET:
+ gap_copy(p, &default_gap);
+ break;
+ default:
+ p->realgap += arg->i;
+ p->isgap = 1;
+ }
+ p->realgap = MAX(p->realgap, 0);
+ p->gappx = p->realgap * p->isgap;
+ arrange(selmon);
+}
+
+void
propertynotify(XEvent *e)
{
Client *c;
@@ -2038,18 +2081,18 @@ tile(Monitor *m)
if (n > m->nmaster)
mw = m->nmaster ? m->ww * m->mfact : 0;
else
- mw = m->ww;
- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
+ mw = m->ww - m->gap->gappx;
+ for (i = 0, my = ty = m->gap->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
if (i < m->nmaster) {
- h = (m->wh - my) / (MIN(n, m->nmaster) - i);
- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
- if (my + HEIGHT(c) < m->wh)
- my += HEIGHT(c);
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gap->gappx;
+ resize(c, m->wx + m->gap->gappx, m->wy + my, mw - (2*c->bw) - m->gap->gappx, h - (2*c->bw), 0);
+ if (my + HEIGHT(c) + m->gap->gappx < m->wh)
+ my += HEIGHT(c) + m->gap->gappx;
} else {
- h = (m->wh - ty) / (n - i);
- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
- if (ty + HEIGHT(c) < m->wh)
- ty += HEIGHT(c);
+ h = (m->wh - ty) / (n - i) - m->gap->gappx;
+ resize(c, m->wx + mw + m->gap->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gap->gappx, h - (2*c->bw), 0);
+ if (ty + HEIGHT(c) + m->gap->gappx < m->wh)
+ ty += HEIGHT(c) + m->gap->gappx;
}
}