commit 228af1e3d50b690a3013d24943ba3ce59f7734b6
parent 79e9e467a66f0a477bed1ea3729487ea7c889a09
Author: Jake Koroman <jakekoroman@gmail.com>
Date: Sun, 7 Apr 2024 18:35:37 -0400
added gaps patch and updated colours.
Diffstat:
2 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/dwl/config.h b/dwl/config.h
@@ -13,11 +13,14 @@
/* appearance */
static const int sloppyfocus = 1; /* focus follows mouse */
static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
+static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */
+static int gaps = 1; /* 1 means gaps between windows are added */
+static const unsigned int gappx = 10; /* gap pixel between windows */
static const unsigned int borderpx = 1; /* border pixel of windows */
static const float rootcolor[] = COLOR(0x222222ff);
-static const float bordercolor[] = COLOR(0x444444ff);
-static const float focuscolor[] = COLOR(0x005577ff);
-static const float urgentcolor[] = COLOR(0xff0000ff);
+static const float bordercolor[] = COLOR(0x181818ff);
+static const float focuscolor[] = COLOR(0x3465a4ff);
+static const float urgentcolor[] = COLOR(0xa40000ff);
/* To conform 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 */
@@ -95,6 +98,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_r, spawn, {.v = rdpmenucmd} },
{ MODKEY, XKB_KEY_Delete, spawn, {.v = swaylockcmd} },
{ MODKEY, XKB_KEY_F2, togglebar, {0} },
+ { MODKEY, XKB_KEY_g, togglegaps, {0} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_J, movestack, {.i = +1} },
diff --git a/dwl/dwl.c b/dwl/dwl.c
@@ -209,6 +209,7 @@ struct Monitor {
struct wlr_box w; /* window area, layout-relative */
struct wl_list layers[4]; /* LayerSurface.link */
const Layout *lt[2];
+ int gaps;
unsigned int seltags;
unsigned int sellt;
uint32_t tagset[2];
@@ -365,6 +366,7 @@ static void tile(Monitor *m);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
+static void togglegaps(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);
@@ -1044,6 +1046,8 @@ createmon(struct wl_listener *listener, void *data)
wlr_output_state_init(&state);
/* Initialize monitor state using configured rules */
+ m->gaps = gaps;
+
m->tagset[0] = m->tagset[1] = 1;
for (r = monrules; r < END(monrules); r++) {
if (!r->name || strstr(wlr_output->name, r->name)) {
@@ -3002,7 +3006,7 @@ tagmon(const Arg *arg)
void
tile(Monitor *m)
{
- unsigned int mw, my, ty;
+ unsigned int h, r, e = m->gaps, mw, my, ty;
int i, n = 0;
Client *c;
@@ -3011,23 +3015,30 @@ tile(Monitor *m)
n++;
if (n == 0)
return;
+ if (smartgaps == n)
+ e = 0;
if (n > m->nmaster)
- mw = m->nmaster ? ROUND(m->w.width * m->mfact) : 0;
+ mw = m->nmaster ? ROUND((m->w.width + gappx*e) * m->mfact) : 0;
else
- mw = m->w.width;
- i = my = ty = 0;
+ mw = m->w.width - 2*gappx*e + gappx*e;
+ i = 0;
+ my = ty = gappx*e;
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);
- my += c->geom.height;
+ r = MIN(n, m->nmaster) - i;
+ h = (m->w.height - my - gappx*e - gappx*e * (r - 1)) / r;
+ resize(c, (struct wlr_box){.x = m->w.x + gappx*e, .y = m->w.y + my,
+ .width = mw - gappx*e, .height = h}, 0);
+ my += c->geom.height + gappx*e;
} 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);
- ty += c->geom.height;
+ r = n - i;
+ h = (m->w.height - ty - gappx*e - gappx*e * (r - 1)) / r;
+ resize(c, (struct wlr_box){.x = m->w.x + mw + gappx*e, .y = m->w.y + ty,
+ .width = m->w.width - mw - 2*gappx*e, .height = h}, 0);
+ ty += c->geom.height + gappx*e;
}
i++;
}
@@ -3058,6 +3069,13 @@ togglefullscreen(const Arg *arg)
}
void
+togglegaps(const Arg *arg)
+{
+ selmon->gaps = !selmon->gaps;
+ arrange(selmon);
+}
+
+void
toggletag(const Arg *arg)
{
uint32_t newtags;