summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.def.h7
-rw-r--r--dwl.c44
2 files changed, 42 insertions, 9 deletions
diff --git a/config.def.h b/config.def.h
index 82d9836..6489de3 100644
--- a/config.def.h
+++ b/config.def.h
@@ -16,6 +16,7 @@ static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0xae81ffff);
static const float urgentcolor[] = COLOR(0xff0000ff);
+static const unsigned int gappx = 5; /* default gap size */
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
@@ -202,6 +203,12 @@ static const Key keys[] = {
{ WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT, XKB_KEY_space, spawn, SHCMD("makoctl dismiss --all")},
{ WLR_MODIFIER_CTRL|MODKEY, XKB_KEY_space, spawn, SHCMD("makoctl restore")},
+ /* Adjust gaps */
+ { MODKEY, XKB_KEY_minus, setgaps, {.i = -1} },
+ { MODKEY, XKB_KEY_equal, setgaps, {.i = +1} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_plus, setgaps, {.i = 0} },
+ { MODKEY, XKB_KEY_a, togglegaps, {0} },
+
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
diff --git a/dwl.c b/dwl.c
index 0c2ff09..0e07ac4 100644
--- a/dwl.c
+++ b/dwl.c
@@ -209,6 +209,7 @@ struct Monitor {
unsigned int seltags;
unsigned int sellt;
uint32_t tagset[2];
+ int gappx;
float mfact;
int gamma_lut_changed;
int nmaster;
@@ -337,6 +338,7 @@ static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating);
static void setfullscreen(Client *c, int fullscreen);
+static void setgaps(const Arg *arg);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, uint32_t newtags);
@@ -353,6 +355,7 @@ static void tile(Monitor *m);
static void togglefloating(const Arg *arg);
static void togglesticky(const Arg *arg);
static void togglefullscreen(const Arg *arg);
+static void togglegaps(const Arg *arg);
static void togglescratch(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
@@ -1042,6 +1045,7 @@ createmon(struct wl_listener *listener, void *data)
m->m.y = r->y;
m->mfact = r->mfact;
m->nmaster = r->nmaster;
+ m->gappx = gappx;
m->lt[0] = r->lt;
m->lt[1] = &layouts[LENGTH(layouts) > 1 && r->lt != &layouts[1]];
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
@@ -2513,6 +2517,17 @@ setfullscreen(Client *c, int fullscreen)
}
void
+setgaps(const Arg *arg) {
+ if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
+ selmon->gappx = gappx;
+ else if (selmon->gappx + arg->i < 0)
+ selmon->gappx = 0;
+ else
+ selmon->gappx += arg->i;
+ arrange(selmon);
+}
+
+void
setsticky(Client *c, int sticky)
{
if(sticky && !c->issticky) {
@@ -2882,7 +2897,7 @@ void
tile(Monitor *m)
{
unsigned int mw, my, ty, draw_borders = 1;
- int i, n = 0;
+ int i, n = 0, gap = 0;
Client *c;
wl_list_for_each(c, &clients, link)
@@ -2891,25 +2906,28 @@ tile(Monitor *m)
if (n == 0)
return;
+ if (n > 1)
+ gap = m->gappx;
+
if (n == smartborders)
draw_borders = 0;
if (n > m->nmaster)
mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
else
- mw = m->w.width;
- i = my = ty = 0;
+ mw = m->w.width - gap;
+ i = 0; my = ty = gap;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
if (i < m->nmaster) {
- resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
- .height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0, draw_borders);
- my += c->geom.height;
+ resize(c, (struct wlr_box){.x = m->w.x + gap, .y = m->w.y + my,
+ .width = mw - gap, .height = (m->w.height - my - gap) / (MIN(n, m->nmaster) - i)}, 0, draw_borders);
+ my += c->geom.height + gap;
} else {
- resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
- .width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0, draw_borders);
- ty += c->geom.height;
+ resize(c, (struct wlr_box){.x = m->w.x + mw + gap, .y = m->w.y + ty,
+ .width = m->w.width - mw - 2 * gap, .height = (m->w.height - ty) / (n - i) - gap}, 0, draw_borders);
+ ty += c->geom.height + gap;
}
i++;
}
@@ -2932,6 +2950,14 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen);
}
+void togglegaps(const Arg *arg) {
+ if (selmon->gappx == 0)
+ selmon->gappx = gappx;
+ else
+ selmon->gappx = 0;
+ arrange(selmon);
+}
+
void
togglescratch(const Arg *arg)
{