summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2025-02-11 15:41:46 -0600
committerSquibid <me@zacharyscheiman.com>2025-02-11 15:41:46 -0600
commit082aa1edac6826731c5c0159f29037a3efd91afa (patch)
treed7d54951de40fcbc7e4dda101f4554d17ead8fe1
parent398ec943214031a25e28ffddd1c0493e92373786 (diff)
downloaddwl-082aa1edac6826731c5c0159f29037a3efd91afa.tar.gz
dwl-082aa1edac6826731c5c0159f29037a3efd91afa.tar.bz2
dwl-082aa1edac6826731c5c0159f29037a3efd91afa.zip
add uselessgaps patch
-rw-r--r--config.def.h3
-rw-r--r--dwl.c52
-rw-r--r--patches/main...serenevoid:uselessgaps.patch137
3 files changed, 178 insertions, 14 deletions
diff --git a/config.def.h b/config.def.h
index 1593033..f56367f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -6,7 +6,9 @@
/* 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 const unsigned int borderpx = 1; /* border pixel of windows */
+static const unsigned int gappx = 10; /* horiz inner gap between windows */
static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
@@ -136,6 +138,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
{ MODKEY, XKB_KEY_Return, zoom, {0} },
{ MODKEY, XKB_KEY_Tab, view, {0} },
+ { MODKEY, XKB_KEY_g, togglegaps, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
diff --git a/dwl.c b/dwl.c
index 3da4c59..8c600f8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -205,6 +205,7 @@ struct Monitor {
struct wlr_box w; /* window area, layout-relative */
struct wl_list layers[4]; /* LayerSurface.link */
const Layout *lt[2];
+ int gappx; /* horizontal outer gaps */
unsigned int seltags;
unsigned int sellt;
uint32_t tagset[2];
@@ -356,6 +357,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);
@@ -426,6 +428,8 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static int enablegaps = 1; /* enables gaps, used by togglegaps */
+
/* global event handlers */
static struct wl_listener cursor_axis = {.notify = axisnotify};
static struct wl_listener cursor_button = {.notify = buttonpress};
@@ -1076,9 +1080,9 @@ createmon(struct wl_listener *listener, void *data)
for (i = 0; i < LENGTH(m->layers); i++)
wl_list_init(&m->layers[i]);
-
wlr_output_state_init(&state);
/* Initialize monitor state using configured rules */
+ m->gappx = gappx;
m->tagset[0] = m->tagset[1] = 1;
for (r = monrules; r < END(monrules); r++) {
if (!r->name || strstr(wlr_output->name, r->name)) {
@@ -2031,12 +2035,16 @@ void
monocle(Monitor *m)
{
Client *c;
- int n = 0;
+ int n = 0, e = enablegaps;
+
+ if (smartgaps == 1) {
+ e = 0; // outer gaps disabled
+ }
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
- resize(c, m->w, 0);
+ resize(c, (struct wlr_box){ .x = m->w.x + m->gappx*e, .y = m->w.y + m->gappx*e, .width = m->w.width - 2*m->gappx*e, .height = m->w.height - 2*m->gappx*e }, 0);
n++;
}
if (n)
@@ -2891,8 +2899,8 @@ tagmon(const Arg *arg)
void
tile(Monitor *m)
{
- unsigned int mw, my, ty;
- int i, n = 0;
+ unsigned int h, r, e = enablegaps, mw, my, ty;
+ int i, n = 0;
Client *c;
wl_list_for_each(c, &clients, link)
@@ -2901,22 +2909,31 @@ tile(Monitor *m)
if (n == 0)
return;
+ if (smartgaps == n) {
+ e = 0; // outer gaps disabled
+ }
+
if (n > m->nmaster)
- mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
+ mw = m->nmaster ? (int)roundf((m->w.width + m->gappx*e) * m->mfact) : 0;
else
- mw = m->w.width;
- i = my = ty = 0;
+ mw = m->w.width - 2*m->gappx*e + m->gappx*e;
+ i = 0;
+ my = ty = m->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 - m->gappx*e - m->gappx*e * (r - 1)) / r;
+ resize(c, (struct wlr_box){.x = m->w.x + m->gappx*e, .y = m->w.y + my,
+ .width = mw - m->gappx*e, .height = h}, 0);
+ my += c->geom.height + m->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 - m->gappx*e - m->gappx*e * (r - 1)) / r;
+ resize(c, (struct wlr_box){.x = m->w.x + mw + m->gappx*e, .y = m->w.y + ty,
+ .width = m->w.width - mw - 2*m->gappx*e, .height = h}, 0);
+ ty += c->geom.height + m->gappx*e;
}
i++;
}
@@ -2947,6 +2964,13 @@ togglefullscreen(const Arg *arg)
}
void
+togglegaps(const Arg *arg)
+{
+ enablegaps = !enablegaps;
+ arrange(selmon);
+}
+
+void
toggletag(const Arg *arg)
{
uint32_t newtags;
diff --git a/patches/main...serenevoid:uselessgaps.patch b/patches/main...serenevoid:uselessgaps.patch
new file mode 100644
index 0000000..4c0944f
--- /dev/null
+++ b/patches/main...serenevoid:uselessgaps.patch
@@ -0,0 +1,137 @@
+From 366a810531ce3425ea5eca4e32eba431dc26570e Mon Sep 17 00:00:00 2001
+From: serenevoid <ajuph9224@gmail.com>
+Date: Sun, 16 Jul 2023 22:07:02 +0530
+Subject: [PATCH] feat(gaps): Useless Gaps
+
+- KISS (Keep it simple and stupid)
+- Use common gap value instead of separate inner and outer gaps
+- Set gap value in config.h and toggle gaps on or off
+- minimal and efficient
+---
+ config.def.h | 3 +++
+ dwl.c | 41 +++++++++++++++++++++++++++++++----------
+ 2 files changed, 34 insertions(+), 10 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 447ba0051..16ad12ce8 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -1,7 +1,9 @@
+ /* 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 const unsigned int borderpx = 1; /* border pixel of windows */
++static const unsigned int gappx = 10; /* horiz inner gap between windows */
+ static const float bordercolor[] = {0.5, 0.5, 0.5, 1.0};
+ static const float focuscolor[] = {1.0, 0.0, 0.0, 1.0};
+ /* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */
+@@ -119,6 +121,7 @@ static const Key keys[] = {
+ { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05} },
+ { MODKEY, XKB_KEY_Return, zoom, {0} },
+ { MODKEY, XKB_KEY_Tab, view, {0} },
+++ { MODKEY, XKB_KEY_g, togglegaps, {0} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
+ { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
+diff --git a/dwl.c b/dwl.c
+index 93f66efe6..aea07d68c 100644
+--- a/dwl.c
++++ b/dwl.c
+@@ -185,6 +185,7 @@ struct Monitor {
+ struct wlr_box w; /* window area, layout-relative */
+ struct wl_list layers[4]; /* LayerSurface::link */
+ const Layout *lt[2];
++ int gappx; /* horizontal outer gaps */
+ unsigned int seltags;
+ unsigned int sellt;
+ uint32_t tagset[2];
+@@ -304,6 +305,7 @@ static void tagmon(const Arg *arg);
+ static void tile(Monitor *m);
+ 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);
+@@ -367,6 +369,8 @@ static struct wlr_box sgeom;
+ static struct wl_list mons;
+ static Monitor *selmon;
+
++static int enablegaps = 1; /* enables gaps, used by togglegaps */
++
+ /* global event handlers */
+ static struct wl_listener cursor_axis = {.notify = axisnotify};
+ static struct wl_listener cursor_button = {.notify = buttonpress};
+@@ -913,6 +917,7 @@ createmon(struct wl_listener *listener, void *data)
+ /* Initialize monitor state using configured rules */
+ for (i = 0; i < LENGTH(m->layers); i++)
+ wl_list_init(&m->layers[i]);
++ m->gappx = gappx;
+ m->tagset[0] = m->tagset[1] = 1;
+ for (r = monrules; r < END(monrules); r++) {
+ if (!r->name || strstr(wlr_output->name, r->name)) {
+@@ -2361,7 +2366,7 @@ tagmon(const Arg *arg)
+ void
+ tile(Monitor *m)
+ {
+- unsigned int i, n = 0, mw, my, ty;
++ unsigned int i, n = 0, h, r, e = enablegaps, mw, my, ty;
+ Client *c;
+
+ wl_list_for_each(c, &clients, link)
+@@ -2370,22 +2375,31 @@ tile(Monitor *m)
+ if (n == 0)
+ return;
+
++ if (smartgaps == n) {
++ e = 0; // outer gaps disabled
++ }
++
+ if (n > m->nmaster)
+- mw = m->nmaster ? m->w.width * m->mfact : 0;
++ mw = m->nmaster ? (m->w.width + m->gappx*e) * m->mfact : 0;
+ else
+- mw = m->w.width;
+- i = my = ty = 0;
++ mw = m->w.width - 2*m->gappx*e + m->gappx*e;
++ i = 0;
++ my = ty = m->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 - m->gappx*e - m->gappx*e * (r - 1)) / r;
++ resize(c, (struct wlr_box){.x = m->w.x + m->gappx*e, .y = m->w.y + my,
++ .width = mw - m->gappx*e, .height = h}, 0);
++ my += c->geom.height + m->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 - m->gappx*e - m->gappx*e * (r - 1)) / r;
++ resize(c, (struct wlr_box){.x = m->w.x + mw + m->gappx*e, .y = m->w.y + ty,
++ .width = m->w.width - mw - 2*m->gappx*e, .height = h}, 0);
++ ty += c->geom.height + m->gappx*e;
+ }
+ i++;
+ }
+@@ -2408,6 +2422,13 @@ togglefullscreen(const Arg *arg)
+ setfullscreen(sel, !sel->isfullscreen);
+ }
+
++void
++togglegaps(const Arg *arg)
++{
++ enablegaps = !enablegaps;
++ arrange(selmon);
++}
++
+ void
+ toggletag(const Arg *arg)
+ {