Compare commits

..
3 Commits
Author SHA1 Message Date
André Desgualdo Pereira 237670da97 fix white spaces at the end of some lines 2025-10-19 08:49:13 -03:00
fauxmight f82f83cd57 Update patches/gridall/winview+gaplessgrid+gridall.diff
Fix minor trailing whitespace issue at multiple lines.
2025-10-19 13:44:20 +02:00
André Desgualdo Pereira f8e4399bba add gridall patch 2025-10-19 13:44:20 +02:00
217 changed files with 2206 additions and 15471 deletions
+2 -2
View File
@@ -47,9 +47,9 @@ If you target the unstable `main` branch, specify that in the `Download` link on
You may choose to include screenshots (hosted in your patch's subdirectory) in your `README.md`. The process is described [here](https://docs.codeberg.org/markdown/using-images/).
8. Use the Codeberg web interface to send a pull request to [dwl-patches] (NOT to [dwl])
9. WHEN YOUR PULL REQUEST IS APPROVED, your Codeberg account will also be granted commit access to [dwl-patches]. Once you have write access, you can make direct modifications/updates to your patches and you are free to create new patches rather than creating pull requests.
9. WHEN YOUR PULL REQUEST IS APPROVED, your Codeberg account will also be granted commit access to [dwl-patches]. Once you have write access, you can make direct modifications/upates to your patches and you are free to create new patches rather than creating pull requests.
Individuals who have made known that they no longer intend to maintain their patches will have commit access to the [dwl-patches] repository removed.
Individuals who have made known that they no longer intend to maintain their patches will have commit access to the [dwl-pathces] repository removed.
A returning user who formerly had commit access is welcome to open an issue on [dwl-patches] requesting commit access be reinstated. When doing so, please link to the original issue opened that granted commit access.
+1 -1
View File
@@ -3,7 +3,7 @@ Automatically center floating windows.
### Download
- [git branch](https://codeberg.org/guidocella/dwl/src/branch/alwayscenter)
- [2026-01-15](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/alwayscenter/alwayscenter.patch)
- [2024-06-05](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/alwayscenter/alwayscenter.patch)
### Authors
- [Guido Cella](https://codeberg.org/guidocella)
+28 -14
View File
@@ -1,25 +1,39 @@
From 48110f0443c8e1ddcd56b6fed5da46535024919c Mon Sep 17 00:00:00 2001
From f43a49324c2ddd21100d6308d1adde9d894746e2 Mon Sep 17 00:00:00 2001
From: Guido Cella <guido@guidocella.xyz>
Date: Tue, 13 Jan 2026 21:17:22 +0100
Date: Wed, 5 Jun 2024 12:05:16 +0200
Subject: [PATCH] center floating windows
---
dwl.c | 2 ++
1 file changed, 2 insertions(+)
dwl.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/dwl.c b/dwl.c
index 44f3ad9..72714f8 100644
index 12f441e..c377c67 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2414,6 +2414,8 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
/* Make sure window actually overlaps with the monitor */
resize(c, c->geom, 0);
c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */
+ c->prev.x = (m->w.width - c->prev.width) / 2 + m->m.x;
+ c->prev.y = (m->w.height - c->prev.height) / 2 + m->m.y;
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
setfloating(c, c->isfloating);
@@ -499,6 +499,11 @@ applyrules(Client *c)
}
}
+ if (mon) {
+ c->geom.x = (mon->w.width - c->geom.width) / 2 + mon->m.x;
+ c->geom.y = (mon->w.height - c->geom.height) / 2 + mon->m.y;
+ }
+
c->isfloating |= client_is_float_type(c);
setmon(c, mon, newtags);
}
@@ -1787,6 +1792,10 @@ mapnotify(struct wl_listener *listener, void *data)
* If there is no parent, apply rules */
if ((p = client_get_parent(c))) {
c->isfloating = 1;
+ if (p->mon) {
+ c->geom.x = (p->mon->w.width - c->geom.width) / 2 + p->mon->m.x;
+ c->geom.y = (p->mon->w.height - c->geom.height) / 2 + p->mon->m.y;
+ }
setmon(c, p->mon, p->tags);
} else {
applyrules(c);
--
2.52.0
2.49.0
+2 -4
View File
@@ -5,12 +5,10 @@ Note: Commands from array are executed using execvp(). So if you need to execute
### Download
- [git branch](https://codeberg.org/sevz/dwl/src/branch/autostart)
- [autostart_main-5fd19fe](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/autostart/autostart_main-5fd19fe.patch)
- [autostart_wlroots-next-f4249db.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/autostart/autostart_wlroots-next-f4249db.patch)
- [autostart_0.8.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/autostart/autostart_0.8.patch)
- [2025-01-20](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/autostart/autostart.patch)
- [0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/autostart/autostart-0.7.patch)
### Authors
- [fauxmight](https://codeberg.org/fauxmight)
- [sevz](https://codeberg.org/sevz)
- [Rayan Nakib](https://nakibrayan2.pages.dev/)
- [NFVblog](https://github.com/nf02)
@@ -1,18 +1,24 @@
From e8932f159793012a54047c48b3710703a63c07fb Mon Sep 17 00:00:00 2001
From: A Frederick Christensen <dwl@ivories.org>
Date: Fri, 27 Feb 2026 12:29:02 -0600
Subject: [PATCH] Applied autostart patch
From 787f7252d63945996f009828aff3c44afd0f7781 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?=
<leohdz172@proton.me>
Date: Sat, 8 Jul 2023 17:11:36 -0600
Subject: [PATCH] port autostart patch from dwm
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
https://dwm.suckless.org/patches/cool_autostart/
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
---
config.def.h | 6 ++++++
dwl.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 61 insertions(+), 3 deletions(-)
config.def.h | 7 +++++++
dwl.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..6eb0db4 100644
index 22d2171..8dc6502 100644
--- a/config.def.h
+++ b/config.def.h
@@ -20,6 +20,12 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
@@ -20,6 +20,13 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
/* logging */
static int log_level = WLR_ERROR;
@@ -22,14 +28,15 @@ index 8a6eda0..6eb0db4 100644
+ NULL /* terminate */
+};
+
+
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */
{ "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
diff --git a/dwl.c b/dwl.c
index 8a9715d..3450817 100644
index 5bf995e..e8b8727 100644
--- a/dwl.c
+++ b/dwl.c
@@ -248,6 +248,7 @@ static void arrange(Monitor *m);
@@ -249,6 +249,7 @@ static void arrange(Monitor *m);
static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m);
@@ -37,17 +44,17 @@ index 8a9715d..3450817 100644
static void axisnotify(struct wl_listener *listener, void *data);
static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
@@ -451,6 +452,9 @@ static struct wl_listener xwayland_ready = {.notify = xwaylandready};
static struct wlr_xwayland *xwayland;
#endif
@@ -432,6 +433,9 @@ static xcb_atom_t netatom[NetLast];
/* attempt to encapsulate suck into one file */
#include "client.h"
+static pid_t *autostart_pids;
+static size_t autostart_len;
+
/* configuration, allows nested code to access above variables */
#include "config.h"
@@ -605,6 +609,27 @@ arrangelayers(Monitor *m)
/* function implementations */
void
applybounds(Client *c, struct wlr_box *bbox)
@@ -580,6 +584,27 @@ arrangelayers(Monitor *m)
}
}
@@ -75,13 +82,11 @@ index 8a9715d..3450817 100644
void
axisnotify(struct wl_listener *listener, void *data)
{
@@ -701,12 +726,23 @@ checkidleinhibitor(struct wlr_surface *exclude)
@@ -676,11 +701,21 @@ checkidleinhibitor(struct wlr_surface *exclude)
void
cleanup(void)
{
+ size_t i;
+
cleanuplisteners();
#ifdef XWAYLAND
wlr_xwayland_destroy(xwayland);
xwayland = NULL;
@@ -99,36 +104,44 @@ index 8a9715d..3450817 100644
if (child_pid > 0) {
kill(-child_pid, SIGTERM);
waitpid(child_pid, NULL, 0);
@@ -1562,10 +1598,25 @@ gpureset(struct wl_listener *listener, void *data)
void
@@ -1497,18 +1532,31 @@ void
handlesig(int signo)
{
- if (signo == SIGCHLD)
if (signo == SIGCHLD) {
-#ifdef XWAYLAND
siginfo_t in;
/* wlroots expects to reap the XWayland process itself, so we
* use WNOWAIT to keep the child waitable until we know it's not
* XWayland.
*/
while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid
- && (!xwayland || in.si_pid != xwayland->server->pid))
- waitpid(in.si_pid, NULL, 0);
-#else
- while (waitpid(-1, NULL, WNOHANG) > 0);
- else if (signo == SIGINT || signo == SIGTERM)
+ if (signo == SIGCHLD) {
+ pid_t pid, *p, *lim;
+ while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) {
+ if (pid == child_pid)
+#ifdef XWAYLAND
+ && (!xwayland || in.si_pid != xwayland->server->pid)
#endif
+ ) {
+ pid_t *p, *lim;
+ waitpid(in.si_pid, NULL, 0);
+ if (in.si_pid == child_pid)
+ child_pid = -1;
+ if (!(p = autostart_pids))
+ continue;
+ lim = &p[autostart_len];
+
+ for (; p < lim; p++) {
+ if (*p == pid) {
+ if (*p == in.si_pid) {
+ *p = -1;
+ break;
+ }
+ }
+ }
+ } else if (signo == SIGINT || signo == SIGTERM) {
} else if (signo == SIGINT || signo == SIGTERM) {
quit(NULL);
+ }
}
void
@@ -2252,6 +2303,7 @@ run(char *startup_cmd)
}
@@ -2224,6 +2272,7 @@ run(char *startup_cmd)
die("startup: backend_start");
/* Now that the socket exists and the backend is started, run the startup command */
@@ -137,5 +150,5 @@ index 8a9715d..3450817 100644
int piperw[2];
if (pipe(piperw) < 0)
--
2.52.0
2.45.2
@@ -1,18 +1,24 @@
From d2e2e61aeb25ad71c2c559994968ba64e0974503 Mon Sep 17 00:00:00 2001
From: A Frederick Christensen <dwl@ivories.org>
Date: Fri, 27 Feb 2026 12:23:04 -0600
Subject: [PATCH] Applied autostart patch
From 3b0b0249d900121a90528616f4d11f733c7a5ca2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?=
<leohdz172@proton.me>
Date: Sat, 8 Jul 2023 17:11:36 -0600
Subject: [PATCH] port autostart patch from dwm
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
https://dwm.suckless.org/patches/cool_autostart/
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
---
config.def.h | 6 ++++++
config.def.h | 7 +++++++
dwl.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 61 insertions(+), 3 deletions(-)
2 files changed, 62 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..6eb0db4 100644
index 22d2171d..8dc6502c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -20,6 +20,12 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
@@ -20,6 +20,13 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
/* logging */
static int log_level = WLR_ERROR;
@@ -22,11 +28,12 @@ index 8a6eda0..6eb0db4 100644
+ NULL /* terminate */
+};
+
+
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */
{ "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
diff --git a/dwl.c b/dwl.c
index 44f3ad9..e7b6199 100644
index ad21e1ba..3118e07f 100644
--- a/dwl.c
+++ b/dwl.c
@@ -246,6 +246,7 @@ static void arrange(Monitor *m);
@@ -37,17 +44,17 @@ index 44f3ad9..e7b6199 100644
static void axisnotify(struct wl_listener *listener, void *data);
static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
@@ -449,6 +450,9 @@ static struct wl_listener xwayland_ready = {.notify = xwaylandready};
static struct wlr_xwayland *xwayland;
#endif
@@ -455,6 +456,9 @@ static struct wlr_xwayland *xwayland;
/* attempt to encapsulate suck into one file */
#include "client.h"
+static pid_t *autostart_pids;
+static size_t autostart_len;
+
/* configuration, allows nested code to access above variables */
#include "config.h"
@@ -603,6 +607,27 @@ arrangelayers(Monitor *m)
/* function implementations */
void
applybounds(Client *c, struct wlr_box *bbox)
@@ -599,6 +603,27 @@ arrangelayers(Monitor *m)
}
}
@@ -75,7 +82,7 @@ index 44f3ad9..e7b6199 100644
void
axisnotify(struct wl_listener *listener, void *data)
{
@@ -699,12 +724,23 @@ checkidleinhibitor(struct wlr_surface *exclude)
@@ -695,12 +720,23 @@ checkidleinhibitor(struct wlr_surface *exclude)
void
cleanup(void)
{
@@ -99,7 +106,7 @@ index 44f3ad9..e7b6199 100644
if (child_pid > 0) {
kill(-child_pid, SIGTERM);
waitpid(child_pid, NULL, 0);
@@ -1560,10 +1596,25 @@ gpureset(struct wl_listener *listener, void *data)
@@ -1551,10 +1587,25 @@ gpureset(struct wl_listener *listener, void *data)
void
handlesig(int signo)
{
@@ -128,7 +135,7 @@ index 44f3ad9..e7b6199 100644
}
void
@@ -2250,6 +2301,7 @@ run(char *startup_cmd)
@@ -2241,6 +2292,7 @@ run(char *startup_cmd)
die("startup: backend_start");
/* Now that the socket exists and the backend is started, run the startup command */
@@ -137,5 +144,5 @@ index 44f3ad9..e7b6199 100644
int piperw[2];
if (pipe(piperw) < 0)
--
2.52.0
2.48.0
@@ -1,128 +0,0 @@
diff --git a/config.def.h b/config.def.h
index 572984b..0697b66 100644
--- a/config.def.h
+++ b/config.def.h
@@ -20,6 +20,12 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
/* logging */
static int log_level = WLR_ERROR;
+/* Autostart */
+static const char *const autostart[] = {
+ "wbg", "/path/to/your/image", NULL,
+ NULL /* terminate */
+};
+
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */
{ "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
diff --git a/dwl.c b/dwl.c
index f902ace..36496b3 100644
--- a/dwl.c
+++ b/dwl.c
@@ -263,6 +263,7 @@ static void arrange(Monitor *m);
static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m);
+static void autostartexec(void);
static void axisnotify(struct wl_listener *listener, void *data);
static void buttonpress(struct wl_listener *listener, void *data);
static void capturerequest(struct wl_listener *listener, void *data);
@@ -471,6 +472,9 @@ static struct wl_listener xwayland_ready = {.notify = xwaylandready};
static struct wlr_xwayland *xwayland;
#endif
+static pid_t *autostart_pids;
+static size_t autostart_len;
+
/* configuration, allows nested code to access above variables */
#include "config.h"
@@ -630,6 +634,27 @@ arrangelayers(Monitor *m)
}
}
+void
+autostartexec(void) {
+ const char *const *p;
+ size_t i = 0;
+
+ /* count entries */
+ for (p = autostart; *p; autostart_len++, p++)
+ while (*++p);
+
+ autostart_pids = calloc(autostart_len, sizeof(pid_t));
+ for (p = autostart; *p; i++, p++) {
+ if ((autostart_pids[i] = fork()) == 0) {
+ setsid();
+ execvp(*p, (char *const *)p);
+ die("dwl: execvp %s:", *p);
+ }
+ /* skip arguments */
+ while (*++p);
+ }
+}
+
void
axisnotify(struct wl_listener *listener, void *data)
{
@@ -767,12 +792,23 @@ checkidleinhibitor(struct wlr_surface *exclude)
void
cleanup(void)
{
+ size_t i;
+
cleanuplisteners();
#ifdef XWAYLAND
wlr_xwayland_destroy(xwayland);
xwayland = NULL;
#endif
wl_display_destroy_clients(dpy);
+
+ /* kill child processes */
+ for (i = 0; i < autostart_len; i++) {
+ if (0 < autostart_pids[i]) {
+ kill(autostart_pids[i], SIGTERM);
+ waitpid(autostart_pids[i], NULL, 0);
+ }
+ }
+
if (child_pid > 0) {
kill(-child_pid, SIGTERM);
waitpid(child_pid, NULL, 0);
@@ -1646,10 +1682,25 @@ gpureset(struct wl_listener *listener, void *data)
void
handlesig(int signo)
{
- if (signo == SIGCHLD)
- while (waitpid(-1, NULL, WNOHANG) > 0);
- else if (signo == SIGINT || signo == SIGTERM)
+ if (signo == SIGCHLD) {
+ pid_t pid, *p, *lim;
+ while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) {
+ if (pid == child_pid)
+ child_pid = -1;
+ if (!(p = autostart_pids))
+ continue;
+ lim = &p[autostart_len];
+
+ for (; p < lim; p++) {
+ if (*p == pid) {
+ *p = -1;
+ break;
+ }
+ }
+ }
+ } else if (signo == SIGINT || signo == SIGTERM) {
quit(NULL);
+ }
}
void
@@ -2365,6 +2416,7 @@ run(char *startup_cmd)
die("startup: backend_start");
/* Now that the socket exists and the backend is started, run the startup command */
+ autostartexec();
if (startup_cmd) {
int piperw[2];
if (pipe(piperw) < 0)
-25
View File
@@ -1,25 +0,0 @@
![dwl bar-appicons patch example](example.png)
### Description
Adds support for app icons that can replace the tag indicator and tag name.
This feature is configurable through an additional option in `rules`.
Icons should work out of the box. Emojis require a special font like
[Noto Color Emoji](https://fonts.google.com/noto/specimen/Noto+Color+Emoji).
When one or more app icons are present in a tag, the tag name will be enclosed
by the outer separators (`outer_separator_beg` and `outer_separator_end`).
Additionally, the icons within the tag will be separated by `inner_separator`.
Each tag can display a maximum of `truncate_icons_after` icons, after which the
`truncate_symbol` will be shown.
**Inspiration:** [XMonad's DynamicIcons](https://hackage.haskell.org/package/xmonad-contrib-0.18.1/docs/XMonad-Hooks-DynamicIcons.html)
### Prerequisites
Make sure you have the [bar](/dwl/dwl-patches/raw/branch/main/patches/bar) patch.
### Download
- [main_2025-10-24](/dwl/dwl-patches/raw/branch/main/patches/bar-appicons/appicons.patch)
### Authors
- [rumenmitov](https://codeberg.org/rumenmitov)
-282
View File
@@ -1,282 +0,0 @@
From f5d1206f7f467cafd5a0217a46c31928316ba2fe Mon Sep 17 00:00:00 2001
From: Rumen <rumenmitov@protonmail.com>
Date: Mon, 1 Dec 2025 20:29:49 +0100
Subject: [PATCH] fix(bar-appicons): fixed various compiler warnings
---
config.def.h | 14 +++--
dwl.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 150 insertions(+), 7 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1b7472d..a48b78d 100644
--- a/config.def.h
+++ b/config.def.h
@@ -26,12 +26,20 @@ static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
/* logging */
static int log_level = WLR_ERROR;
+/* appicons */
+/* NOTE: set to 0 to set to default (whitespace) */
+static char outer_separator_beg = '[';
+static char outer_separator_end = ']';
+static char inner_separator = ' ';
+static unsigned truncate_icons_after = 2; /* will default to 1, that is the min */
+static char truncate_symbol[] = "...";
+
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
+ /* app_id title tags mask isfloating monitor appicon*/
/* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ { "Gimp_EXAMPLE", NULL, 0, 1, -1, NULL }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1, "" }, /* Start on ONLY tag "9" */
};
/* layout(s) */
diff --git a/dwl.c b/dwl.c
index bf340d8..e2baf66 100644
--- a/dwl.c
+++ b/dwl.c
@@ -143,6 +143,7 @@ typedef struct {
struct wl_listener set_hints;
#endif
unsigned int bw;
+ char *appicon;
uint32_t tags;
int isfloating, isurgent, isfullscreen;
uint32_t resize; /* configure serial of a pending resize */
@@ -221,6 +222,7 @@ struct Monitor {
unsigned int seltags;
unsigned int sellt;
uint32_t tagset[2];
+ char **tag_icons;
float mfact;
int gamma_lut_changed;
int nmaster;
@@ -252,6 +254,7 @@ typedef struct {
uint32_t tags;
int isfloating;
int monitor;
+ const char *appicon;
} Rule;
typedef struct {
@@ -313,6 +316,9 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data);
static void destroysessionlock(struct wl_listener *listener, void *data);
static void destroykeyboardgroup(struct wl_listener *listener, void *data);
static Monitor *dirtomon(enum wlr_direction dir);
+static void remove_outer_separators(char **str);
+static void appiconsappend(char **str, const char *appicon, size_t new_size);
+static void applyappicon(char *tag_icons[], unsigned int *icons_per_tag, const Client *c);
static void drawbar(Monitor *m);
static void drawbars(void);
static void focusclient(Client *c, int lift);
@@ -527,12 +533,19 @@ applyrules(Client *c)
const Rule *r;
Monitor *mon = selmon, *m;
+ outer_separator_beg = outer_separator_beg ? outer_separator_beg : ' ';
+ outer_separator_end = outer_separator_end ? outer_separator_end : ' ';
+ inner_separator = inner_separator ? inner_separator : ' ';
+ truncate_icons_after = truncate_icons_after > 0 ? truncate_icons_after : 1;
+
appid = client_get_appid(c);
title = client_get_title(c);
for (r = rules; r < END(rules); r++) {
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
+ /* r->appicon is static, so lifetime is sufficient */
+ c->appicon = (char*) r->appicon;
c->isfloating = r->isfloating;
newtags |= r->tags;
i = 0;
@@ -775,7 +788,7 @@ buttonpress(struct wl_listener *listener, void *data)
(buffer = wlr_scene_buffer_from_node(node)) && buffer == selmon->scene_buffer) {
cx = (cursor->x - selmon->m.x) * selmon->wlr_output->scale;
do
- x += TEXTW(selmon, tags[i]);
+ x += TEXTW(selmon, selmon->tag_icons[i]);
while (cx >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
@@ -905,6 +918,16 @@ cleanupmon(struct wl_listener *listener, void *data)
wlr_output_layout_remove(output_layout, m->wlr_output);
wlr_scene_output_destroy(m->scene_output);
+ for (long unsigned int tag_idx = 0; tag_idx < LENGTH(tags); tag_idx++) {
+ if (m->tag_icons[tag_idx]) free(m->tag_icons[tag_idx]);
+ m->tag_icons[tag_idx] = NULL;
+ }
+
+ if (m->tag_icons) {
+ free(m->tag_icons);
+ m->tag_icons = NULL;
+ }
+
closemon(m);
wlr_scene_node_destroy(&m->fullscreen_bg->node);
wlr_scene_node_destroy(&m->scene_buffer->node);
@@ -1227,6 +1250,13 @@ createmon(struct wl_listener *listener, void *data)
m->lt[0] = r->lt;
m->lt[1] = &layouts[LENGTH(layouts) > 1 && r->lt != &layouts[1]];
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof(m->ltsymbol));
+
+ m->tag_icons = (char**) malloc(LENGTH(tags) * sizeof(char*));
+ if (m->tag_icons == NULL) perror("dwm: malloc()");
+ for (long unsigned int tag_idx = 0; tag_idx < LENGTH(tags); tag_idx++) {
+ m->tag_icons[tag_idx] = NULL;
+ }
+
wlr_output_state_set_scale(&state, r->scale);
wlr_output_state_set_transform(&state, r->rr);
break;
@@ -1566,6 +1596,98 @@ dirtomon(enum wlr_direction dir)
return selmon;
}
+void
+remove_outer_separators(char **str)
+{
+ const char *clean_tag_name_beg = *str + 1;
+ const size_t clean_tag_name_len = strlen(*str) - 2;
+
+ char *temp_tag_name = (char*)
+ malloc(clean_tag_name_len + 1);
+
+ if (temp_tag_name == NULL) perror("dwm: malloc()");
+
+ memset(temp_tag_name, 0, clean_tag_name_len + 1);
+
+ strncpy(temp_tag_name,
+ clean_tag_name_beg,
+ clean_tag_name_len);
+
+ if (*str) free(*str);
+ *str = temp_tag_name;
+}
+
+void
+appiconsappend(char **str, const char *appicon, size_t new_size)
+{
+ char *temp_tag_name = (char*) malloc(new_size);
+ if (temp_tag_name == NULL) perror("dwm: malloc()");
+
+ /* NOTE: Example format of temp_tag_name (with two appicons):
+ * <outer_sep_beg><appicon><inner_sep><appicon><outer_sep_end>
+ */
+ temp_tag_name = memset(temp_tag_name, 0, new_size);
+
+ temp_tag_name[0] = outer_separator_beg;
+ temp_tag_name[new_size - 2] = outer_separator_end;
+
+ strncpy(temp_tag_name + 1, *str, strlen(*str));
+ temp_tag_name[strlen(temp_tag_name)] = inner_separator;
+
+ strncpy(temp_tag_name + strlen(temp_tag_name),
+ appicon, strlen(appicon));
+
+ if (*str) free(*str);
+ *str = temp_tag_name;
+}
+
+void
+applyappicon(char *tag_icons[], unsigned int *icons_per_tag, const Client *c)
+{
+ const size_t outer_separators_size = 2;
+ const size_t inner_separator_size = 1;
+ size_t new_size = 0;
+
+ for (unsigned t = 1, i = 0;
+ i < LENGTH(tags);
+ t <<= 1, i++)
+ {
+ if (c->tags & t) {
+ if (icons_per_tag[i] == 0) {
+ if (tag_icons[i]) free(tag_icons[i]);
+ tag_icons[i] = strndup(c->appicon, strlen(c->appicon));
+ } else {
+ char *icon = NULL;
+ if (icons_per_tag[i] < truncate_icons_after)
+ icon = c->appicon;
+ else if (icons_per_tag[i] == truncate_icons_after)
+ icon = truncate_symbol;
+ else {
+ icons_per_tag[i]++;
+ continue;
+ }
+
+ /* remove outer separators from previous iterations
+ * otherwise they get applied recursively */
+ if (icons_per_tag[i] > 1) {
+ remove_outer_separators(&tag_icons[i]);
+ }
+
+ new_size = strlen(tag_icons[i])
+ + outer_separators_size
+ + inner_separator_size
+ + strlen(icon)
+ + 1;
+
+ appiconsappend(&tag_icons[i], icon, new_size);
+ }
+
+ icons_per_tag[i]++;
+ }
+ }
+}
+
+
void
drawbar(Monitor *m)
{
@@ -1575,6 +1697,7 @@ drawbar(Monitor *m)
uint32_t i, occ = 0, urg = 0;
Client *c;
Buffer *buf;
+ unsigned int icons_per_tag[LENGTH(tags)];
if (!m->scene_buffer->node.enabled)
return;
@@ -1588,9 +1711,21 @@ drawbar(Monitor *m)
drwl_text(m->drw, m->b.width - tw, 0, tw, m->b.height, 0, stext, 0);
}
+ memset(icons_per_tag, 0, LENGTH(tags) * sizeof(int));
+
+ for (long unsigned int tag_idx = 0; tag_idx < LENGTH(tags); tag_idx++) {
+ /* set each tag to default value */
+ m->tag_icons[tag_idx] = strndup(tags[tag_idx], strlen(tags[tag_idx]));
+ }
+
wl_list_for_each(c, &clients, link) {
if (c->mon != m)
continue;
+
+ if (c->appicon && strlen(c->appicon) > 0) {
+ applyappicon(m->tag_icons, icons_per_tag, c);
+ }
+
occ |= c->tags;
if (c->isurgent)
urg |= c->tags;
@@ -1598,10 +1733,10 @@ drawbar(Monitor *m)
x = 0;
c = focustop(m);
for (i = 0; i < LENGTH(tags); i++) {
- w = TEXTW(m, tags[i]);
+ w = TEXTW(m, m->tag_icons[i]);
drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
- drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, tags[i], urg & 1 << i);
- if (occ & 1 << i)
+ drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->tag_icons[i], urg & 1 << i);
+ if (occ & 1 << i && icons_per_tag[i] ==0)
drwl_rect(m->drw, x + boxs, boxs, boxw, boxw,
m == selmon && c && c->tags & 1 << i,
urg & 1 << i);
--
2.52.0
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

-42
View File
@@ -1,42 +0,0 @@
### Description
Based on the corresponding `dwm` patch, this patch implements the AwesomeWM-style bar for `dwl`.
Clients are hidden using the logic already present in the `arrange` function.
#### Default key bindings
* `Mod + s` — Unhide the selected client.
* `Mod + Shift + s` — Unhide all hidden clients on the current tag.
* `Mod + Shift + h` — Hide the focused client.
* `Mod + Shift + j` / `Mod + Shift + k` — Cycle through both visible and hidden clients.
#### Bar buttons
* Clicking the focused client hides it.
* Clicking an unfocused visible client focuses it.
* Clicking a hidden client unhides and focuses it.
### Dependencies
* [bar](/dwl/dwl-patches/raw/branch/main/patches/bar/bar.patch)
### Download
* [main 2026-08-03](/dwl/dwl-patches/raw/branch/main/patches/bar-awesomebar/bar-awesomebar.patch)
### Authors
* [DanD](https://codeberg.org/DanD)
### Credits
This patch is based on the original `dwm` implementation by:
* ornx <ornx[at]protonmail.com>
* Yegor Bayev [kodxpub@gmail.com](mailto:kodxpub@gmail.com)
* Xac [jiangfengxi.c@gmail.com](mailto:jiangfengxi.c@gmail.com)
* G-OD
* mpetco https://codeberg.org/mpetco
-405
View File
@@ -1,405 +0,0 @@
From c712e2f23e9dbe28ee1e9ba461056f1533aabbaa Mon Sep 17 00:00:00 2001
From: Ricardo <dandgg.ftw@gmail.com>
Date: Mon, 3 Aug 2026 00:31:37 +0100
Subject: [PATCH] awesomebar
---
config.def.h | 12 +++-
dwl.c | 195 ++++++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 186 insertions(+), 21 deletions(-)
diff --git a/config.def.h b/config.def.h
index 7da50d2..1dca4a2 100644
--- a/config.def.h
+++ b/config.def.h
@@ -17,6 +17,7 @@ static uint32_t colors[][3] = {
/* fg bg border */
[SchemeNorm] = { 0xbbbbbbff, 0x222222ff, 0x444444ff },
[SchemeSel] = { 0xeeeeeeff, 0x005577ff, 0x005577ff },
+ [SchemeHid] = { 0x005577ff, 0x222222ff, 0x005577ff },
[SchemeUrg] = { 0, 0, 0x770000ff },
};
@@ -130,8 +131,13 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
{ MODKEY, XKB_KEY_b, togglebar, {0} },
- { MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
- { MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
+ { MODKEY, XKB_KEY_j, focusstackvis, {.i = +1} },
+ { MODKEY, XKB_KEY_k, focusstackvis, {.i = -1} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_j, focusstackhid, {.i = +1} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_k, focusstackhid, {.i = -1} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_h, hide, {0} },
+ { MODKEY, XKB_KEY_s, show, {0} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_s, showall, {0} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
@@ -175,7 +181,7 @@ static const Key keys[] = {
static const Button buttons[] = {
{ ClkLtSymbol, 0, BTN_LEFT, setlayout, {.v = &layouts[0]} },
{ ClkLtSymbol, 0, BTN_RIGHT, setlayout, {.v = &layouts[2]} },
- { ClkTitle, 0, BTN_MIDDLE, zoom, {0} },
+ { ClkTitle, 0, BTN_LEFT, togglewin, {0} },
{ ClkStatus, 0, BTN_MIDDLE, spawn, {.v = termcmd} },
{ ClkClient, MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
{ ClkClient, MODKEY, BTN_MIDDLE, togglefloating, {0} },
diff --git a/dwl.c b/dwl.c
index 7fe9468..0d325b3 100644
--- a/dwl.c
+++ b/dwl.c
@@ -79,7 +79,8 @@
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#define MIN(A, B) ((A) < (B) ? (A) : (B))
#define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS)
-#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
+#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]) && !(C)->ishidden)
+#define VISIBLE(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define END(A) ((A) + LENGTH(A))
#define TAGMASK ((1u << LENGTH(tags)) - 1)
@@ -88,7 +89,7 @@
#define TEXTW(mon, text) (drwl_font_getwidth(mon->drw, text) + mon->lrpad)
/* enums */
-enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */
+enum { SchemeNorm, SchemeSel, SchemeHid, SchemeUrg }; /* color schemes */
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
enum { XDGShell, LayerShell, X11 }; /* client types */
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
@@ -148,6 +149,7 @@ typedef struct {
uint32_t tags;
int isfloating, isurgent, isfullscreen;
uint32_t resize; /* configure serial of a pending resize */
+ int ishidden, tempshow;
} Client;
typedef struct {
@@ -216,6 +218,7 @@ struct Monitor {
int width, height;
int real_width, real_height; /* non-scaled */
float scale;
+ int bt, btw; /* awesome bar */
} b; /* bar area */
struct wlr_box w; /* window area, layout-relative */
struct wl_list layers[4]; /* LayerSurface.link */
@@ -319,11 +322,14 @@ static void drawbar(Monitor *m);
static void drawbars(void);
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
-static void focusstack(const Arg *arg);
+static void focusstack(const Arg *arg, int hid);
+static void focusstackhid(const Arg *arg);
+static void focusstackvis(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
static void handlesig(int signo);
+static void hide(const Arg *arg);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
static int keybinding(uint32_t mods, xkb_keysym_t sym);
@@ -363,6 +369,8 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
+static void show(const Arg *arg);
+static void showall(const Arg *arg);
static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
static int statusin(int fd, unsigned int mask, void *data);
@@ -374,6 +382,7 @@ static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
+static void togglewin(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);
static void unmaplayersurfacenotify(struct wl_listener *listener, void *data);
static void unmapnotify(struct wl_listener *listener, void *data);
@@ -786,8 +795,28 @@ buttonpress(struct wl_listener *listener, void *data)
click = ClkLtSymbol;
else if (cx > selmon->b.width - (TEXTW(selmon, stext) - selmon->lrpad + 2)) {
click = ClkStatus;
- } else
- click = ClkTitle;
+ } else {
+ int nvis = selmon->b.bt;
+ int base = nvis ? selmon->b.btw / nvis : 0;
+ int remainder = nvis ? selmon->b.btw % nvis : 0;
+ int idx = 0;
+ int tabw = 0;
+
+ x += TEXTW(selmon, selmon->ltsymbol);
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLE(c, selmon))
+ continue;
+ tabw = base + (idx < remainder ? 1 : 0);
+ idx++;
+ x += tabw;
+ if (cx < x) {
+ arg.v = c;
+ break;
+ }
+ }
+ if (arg.v)
+ click = ClkTitle;
+ }
}
/* Change focus if the button was _pressed_ over a client */
@@ -799,7 +828,10 @@ buttonpress(struct wl_listener *listener, void *data)
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
for (b = buttons; b < END(buttons); b++) {
if (CLEANMASK(mods) == CLEANMASK(b->mod) && event->button == b->button && click == b->click && b->func) {
- b->func(click == ClkTagBar && b->arg.i == 0 ? &arg : &b->arg);
+ if (click == ClkTitle && b->arg.i == 0)
+ b->func(&arg);
+ else
+ b->func(click == ClkTagBar && b->arg.i == 0 ? &arg : &b->arg);
return;
}
}
@@ -1571,7 +1603,7 @@ dirtomon(enum wlr_direction dir)
void
drawbar(Monitor *m)
{
- int x, w, tw = 0;
+ int x, w, tw = 0, n = 0;
int boxs = m->drw->font->height / 9;
int boxw = m->drw->font->height / 6 + 2;
uint32_t i, occ = 0, urg = 0;
@@ -1593,6 +1625,8 @@ drawbar(Monitor *m)
wl_list_for_each(c, &clients, link) {
if (c->mon != m)
continue;
+ if (VISIBLE(c, m))
+ n++;
occ |= c->tags;
if (c->isurgent)
urg |= c->tags;
@@ -1614,17 +1648,35 @@ drawbar(Monitor *m)
x = drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
if ((w = m->b.width - tw - x) > m->b.height) {
- if (c) {
- drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]);
- drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, client_get_title(c), 0);
- if (c && c->isfloating)
- drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0);
+ if (n > 0) {
+ int base = w / n;
+ int remainder = w % n;
+ int tabw;
+ int idx = 0;
+
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLE(c, m))
+ continue;
+ if (c == focustop(m))
+ drwl_setscheme(m->drw, colors[SchemeSel]);
+ else if (c->ishidden)
+ drwl_setscheme(m->drw, colors[SchemeHid]);
+ else
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ tabw = base + (idx < remainder ? 1 : 0);
+ idx++;
+ drwl_text(m->drw, x, 0, tabw, m->b.height, m->lrpad / 2, client_get_title(c), 0);
+ x += tabw;
+ }
} else {
drwl_setscheme(m->drw, colors[SchemeNorm]);
drwl_rect(m->drw, x, 0, w, m->b.height, 1, 1);
}
}
+ m->b.bt = n;
+ m->b.btw = w;
+
wlr_scene_buffer_set_dest_size(m->scene_buffer,
m->b.real_width, m->b.real_height);
wlr_scene_node_set_position(&m->scene_buffer->node, m->m.x,
@@ -1677,7 +1729,12 @@ focusclient(Client *c, int lift)
* handling a drag operation */
if (!exclusive_focus && !seat->drag)
client_set_border_color(c, (float[])COLOR(colors[SchemeSel][ColBorder]));
- }
+ if (c->ishidden) {
+ c->tempshow = 1;
+ c->ishidden = 0;
+ arrange(c->mon);
+ }
+ }
/* Deactivate old client if focus is changing */
if (old && (!c || client_surface(c) != old)) {
@@ -1695,6 +1752,11 @@ focusclient(Client *c, int lift)
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
client_set_border_color(old_c, (float[])COLOR(colors[SchemeNorm][ColBorder]));
client_activate_surface(old, 0);
+ if (old_c->tempshow) {
+ old_c->tempshow = 0;
+ old_c->ishidden = 1;
+ arrange(old_c->mon);
+ }
}
}
drawbars();
@@ -1728,24 +1790,37 @@ focusmon(const Arg *arg)
}
void
-focusstack(const Arg *arg)
+focusstack(const Arg *arg, int hid)
{
/* Focus the next or previous client (in tiling order) on selmon */
- Client *c, *sel = focustop(selmon);
- if (!sel || (sel->isfullscreen && !client_has_children(sel)))
+ Client *c, *sel;
+
+ if (hid) {
+ wl_list_for_each(sel, &fstack, flink)
+ if (VISIBLE(sel, selmon))
+ break;
+ } else {
+ sel = focustop(selmon);
+ }
+
+ if (!sel || (sel->isfullscreen && !client_has_children(sel)))
return;
if (arg->i > 0) {
wl_list_for_each(c, &sel->link, link) {
if (&c->link == &clients)
continue; /* wrap past the sentinel node */
- if (VISIBLEON(c, selmon))
+ if (!hid && VISIBLEON(c, selmon))
+ break; /* found it */
+ if (hid && VISIBLE(c, selmon))
break; /* found it */
}
} else {
wl_list_for_each_reverse(c, &sel->link, link) {
if (&c->link == &clients)
continue; /* wrap past the sentinel node */
- if (VISIBLEON(c, selmon))
+ if (!hid && VISIBLEON(c, selmon))
+ break; /* found it */
+ if (hid && VISIBLE(c, selmon))
break; /* found it */
}
}
@@ -1753,6 +1828,18 @@ focusstack(const Arg *arg)
focusclient(c, 1);
}
+void
+focusstackhid(const Arg *arg)
+{
+ focusstack(arg, 1);
+}
+
+void
+focusstackvis(const Arg *arg)
+{
+ focusstack(arg, 0);
+}
+
/* We probably should change the name of this: it sounds like it
* will focus the topmost client of this mon, when actually will
* only return that client */
@@ -1808,6 +1895,21 @@ handlesig(int signo)
quit(NULL);
}
+void
+hide(const Arg *arg)
+{
+ Client *c = focustop(selmon);
+
+ if (!c || client_is_unmanaged(c) || c->isfullscreen)
+ return;
+
+ if (!c->ishidden && !c->tempshow) {
+ c->ishidden = 1;
+ arrange(c->mon);
+ focusclient(focustop(c->mon), 1);
+ }
+}
+
void
incnmaster(const Arg *arg)
{
@@ -2869,6 +2971,38 @@ setup(void)
#endif
}
+void
+show(const Arg *arg)
+{
+ Client *c = focustop(selmon);
+
+ if (!c)
+ return;
+
+ if (c->tempshow) {
+ c->ishidden = 0;
+ c->tempshow = 0;
+ arrange(c->mon);
+ }
+}
+
+void
+showall(const Arg *arg)
+{
+ Client *c;
+
+ wl_list_for_each(c, &clients, link)
+ if (VISIBLE(c, selmon))
+ if (c->ishidden) {
+ c->ishidden = 0;
+ if (c->tempshow)
+ c->tempshow = 0;
+ }
+
+ arrange(selmon);
+ focusclient(focustop(selmon), 1);
+}
+
void
spawn(const Arg *arg)
{
@@ -3025,6 +3159,31 @@ toggleview(const Arg *arg)
drawbars();
}
+void
+togglewin(const Arg *arg)
+{
+ Client *c = (Client *)arg->v;
+
+ if (!c)
+ return;
+
+ if (c == focustop(selmon)) {
+ if (!c->ishidden && !client_is_unmanaged(c) && !c->isfullscreen) {
+ c->ishidden = 1;
+ c->tempshow = 0;
+ arrange(c->mon);
+ focusclient(focustop(c->mon), 1);
+ }
+ } else {
+ if (c->ishidden) {
+ c->ishidden = 0;
+ c->tempshow = 0;
+ arrange(c->mon);
+ }
+ focusclient(c, 1);
+ }
+}
+
void
unlocksession(struct wl_listener *listener, void *data)
{
--
2.55.0
-31
View File
@@ -1,31 +0,0 @@
![dwl bar-modes patch example](./example.png)
### Description
Add a mode indicator to bar that tells which mode you are in, just like
river-classic's [dam](https://codeberg.org/sewn/dam) bar.
The string from `modes_labels` defined in `config.h` is used, while normal mode
is ignored.
Another usage is to serve as a hint for each modes keybindings:
```c
enum {
BROWSER,
};
const char *modes_labels[] = {
"[f]irefox [b]rave [c]hromium [q]utebrowser",
};
```
### Dependencies
this patch depends on:
- [bar](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/bar/) patch
- [modes](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/modes/) patch
### Download
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/bar-modes/bar-modes.patch)
### Authors
- [unixchad](https://codeberg.org/unixchad/)
-144
View File
@@ -1,144 +0,0 @@
From 04b37902e0098fb69250fd25b5afbc610a284529 Mon Sep 17 00:00:00 2001
From: nate zhou <gnuunixchad@outlook.com>
Date: Mon, 2 Mar 2026 21:54:03 +0800
Subject: [PATCH] Patch: bar-modes for 0.8
Add modes_labels indicator to bar, which behaves like river-classic's
dam bar. This patch has to be applied after the bar and modes patch.
---
dwl.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 72 insertions(+), 15 deletions(-)
diff --git a/dwl.c b/dwl.c
index ae290ad..7229034 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1585,19 +1585,29 @@ drawbar(Monitor *m)
uint32_t i, occ = 0, urg = 0;
Client *c;
Buffer *buf;
+ char mode_text[256] = "";
+ int mode_width = 0;
+ int title_width;
+ int remaining;
+ int status_shown = 0;
if (!m->scene_buffer->node.enabled)
return;
if (!(buf = bufmon(m)))
return;
- /* draw status first so it can be overdrawn by tags later */
- if (m == selmon) { /* status is only drawn on selected monitor */
- drwl_setscheme(m->drw, colors[SchemeNorm]);
- tw = TEXTW(m, stext) - m->lrpad + 2; /* 2px right padding */
- drwl_text(m->drw, m->b.width - tw, 0, tw, m->b.height, 0, stext, 0);
+ /* get current mode text if in a mode (not normal) */
+ if (active_mode_index >= 0 && active_mode_index < LENGTH(modes_labels) &&
+ modes_labels[active_mode_index]) {
+ strncpy(mode_text, modes_labels[active_mode_index], sizeof(mode_text) - 1);
+ mode_text[sizeof(mode_text) - 1] = '\0';
+ mode_width = TEXTW(m, mode_text);
}
+ /* calculate status text width */
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ tw = TEXTW(m, stext) - m->lrpad + 2;
+
wl_list_for_each(c, &clients, link) {
if (c->mon != m)
continue;
@@ -1607,6 +1617,8 @@ drawbar(Monitor *m)
}
x = 0;
c = focustop(m);
+
+ /* draw tags (always shown) */
for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(m, tags[i]);
drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
@@ -1617,19 +1629,63 @@ drawbar(Monitor *m)
urg & 1 << i);
x += w;
}
+
+ /* draw mode indicator after tags if in a mode */
+ if (mode_text[0]) {
+ drwl_setscheme(m->drw, colors[SchemeSel]);
+ drwl_text(m->drw, x, 0, mode_width, m->b.height, m->lrpad / 2, mode_text, 0);
+ x += mode_width;
+ }
+
+ /* draw layout symbol after mode */
w = TEXTW(m, m->ltsymbol);
drwl_setscheme(m->drw, colors[SchemeNorm]);
- x = drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
-
- if ((w = m->b.width - tw - x) > m->b.height) {
- if (c) {
- drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]);
- drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, client_get_title(c), 0);
- if (c && c->isfloating)
- drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0);
- } else {
+ drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
+ x += w;
+
+ remaining = m->b.width - x;
+
+ if (mode_text[0] && remaining >= tw) {
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ drwl_text(m->drw, m->b.width - tw, 0, tw, m->b.height, 0, stext, 0);
+ remaining -= tw;
+ status_shown = 1;
+ }
+
+ title_width = remaining;
+
+ if (c && title_width > m->b.height) {
+ drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]);
+ drwl_text(m->drw, x, 0, title_width, m->b.height, m->lrpad / 2,
+ client_get_title(c), 0);
+ if (c && c->isfloating)
+ drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0);
+ } else if (title_width > 0) {
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ drwl_rect(m->drw, x, 0, title_width, m->b.height, 1, 1);
+ }
+
+ if (!mode_text[0]) {
+ /* not in a mode - normal behavior with status */
+ if (remaining >= tw) {
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ drwl_text(m->drw, m->b.width - tw, 0, tw, m->b.height, 0, stext, 0);
+
+ int title_space = remaining - tw;
+ if (title_space > m->b.height && c) {
+ drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]);
+ drwl_text(m->drw, x, 0, title_space, m->b.height, m->lrpad / 2,
+ client_get_title(c), 0);
+ if (c && c->isfloating)
+ drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0);
+ } else if (title_space > 0) {
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ drwl_rect(m->drw, x, 0, title_space, m->b.height, 1, 1);
+ }
+ } else if (remaining > 0) {
drwl_setscheme(m->drw, colors[SchemeNorm]);
- drwl_rect(m->drw, x, 0, w, m->b.height, 1, 1);
+ drwl_text(m->drw, m->b.width - remaining, 0, remaining, m->b.height, 0,
+ stext, 0);
}
}
@@ -3437,6 +3493,7 @@ entermode(const Arg *arg)
{
active_mode_index = arg->i;
printstatus();
+ drawbars();
}
#ifdef XWAYLAND
--
2.53.0
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

-14
View File
@@ -1,14 +0,0 @@
### Description
Add a `window_title` option to toggle showing window titles in the bar, similar to the DWM `notitle` patch.
### Dependencies
this patch depends on [bar](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/bar/) patch
### Download
- [git branch](/pi66/dwl-patches/src/branch/bar-notitle)
- [0.7](/dwl/dwl-patches/raw/branch/main/patches/bar-notitle/bar-notitle.patch)
- [main 2026-02-28](/dwl/dwl-patches/raw/branch/main/patches/bar-notitle/bar-notitle.patch)
### Authors
- [Pi66](https://codeberg.org/pi66)
[website](https://pi66.xyz)
-38
View File
@@ -1,38 +0,0 @@
From 5dc83d75ff1b7dadf1fd1f96fe2303848e35d382 Mon Sep 17 00:00:00 2001
From: pi66 <pixel2176@proton.me>
Date: Sat, 28 Feb 2026 20:26:28 +0100
Subject: [PATCH] add window_title option (like dwm notitle patch)
---
config.def.h | 1 +
dwl.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/config.def.h b/config.def.h
index 7da50d2..3d3dfe8 100644
--- a/config.def.h
+++ b/config.def.h
@@ -7,6 +7,7 @@
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 unsigned int borderpx = 1; /* border pixel of windows */
+static const int window_title = 0; /* 1 means showing window titles on the bar */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = {"monospace:size=10"};
diff --git a/dwl.c b/dwl.c
index 7fe9468..0c7262a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1614,7 +1614,7 @@ drawbar(Monitor *m)
x = drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
if ((w = m->b.width - tw - x) > m->b.height) {
- if (c) {
+ if (c && window_title) {
drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]);
drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, client_get_title(c), 0);
if (c && c->isfloating)
--
2.52.0
-16
View File
@@ -1,16 +0,0 @@
# Description
Reload colorscheme on the fly without restart or recompile DWL.
> NOTE:
The patch works on (main 2025-11-01) and v0.7
# Dependencies
this patch depends on [bar](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/bar/) patch
# Download
- [git branch](https://codeberg.org/pi66/dwl-patches/raw/branch/main/patches/bar-recolr/bar-recolr.patch)
- [main 2025-11-01](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/bar-recolr/bar-recolr.patch)
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/bar-recolr/bar-recolr.patch)
# Authors
- [pi66](https://pi66.xyz)
-80
View File
@@ -1,80 +0,0 @@
From 89029325be300f03bbc3ca3b2d77f107d0cb5ca2 Mon Sep 17 00:00:00 2001
From: pi66 <pixel2176@proton.me>
Date: Tue, 25 Nov 2025 12:53:36 +0100
Subject: [PATCH] Add: load colors from an external file
---
config.def.h | 3 +++
dwl.c | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/config.def.h b/config.def.h
index 1b7472d..3c04759 100644
--- a/config.def.h
+++ b/config.def.h
@@ -9,6 +9,8 @@ static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will
static const unsigned int borderpx = 1; /* border pixel of windows */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
+static const int refresh_colors = 0; /* 1 means reloading colors when the session starts*/
+static const char *colors_file = "/home/pixel/.cache/wal/dwl-colors"; /* change the username */
static const char *fonts[] = {"monospace:size=10"};
static const float rootcolor[] = COLOR(0x000000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
@@ -135,6 +137,7 @@ static const Key keys[] = {
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
{ MODKEY, XKB_KEY_b, togglebar, {0} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
+ { MODKEY, XKB_KEY_n, reload_colors, {0} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
diff --git a/dwl.c b/dwl.c
index bf340d8..fc81d89 100644
--- a/dwl.c
+++ b/dwl.c
@@ -345,6 +345,7 @@ static void pointerfocus(Client *c, struct wlr_surface *surface,
double sx, double sy, uint32_t time);
static void powermgrsetmode(struct wl_listener *listener, void *data);
static void quit(const Arg *arg);
+static void reload_colors(const Arg *arg);
static void rendermon(struct wl_listener *listener, void *data);
static void requestdecorationmode(struct wl_listener *listener, void *data);
static void requeststartdrag(struct wl_listener *listener, void *data);
@@ -2348,6 +2349,25 @@ quit(const Arg *arg)
wl_display_terminate(dpy);
}
+void
+reload_colors(const Arg *arg)
+{
+ FILE *f = fopen(colors_file, "r");
+ if (!f) return;
+
+ for (int i = 0; i < (int)LENGTH(colors); i++) {
+ unsigned int fg, bg, border;
+ if (fscanf(f, "%x %x %x", &fg, &bg, &border) != 3)
+ break;
+
+ colors[i][ColFg] = fg;
+ colors[i][ColBg] = bg;
+ colors[i][ColBorder] = border;
+ }
+ fclose(f);
+ drawbars();
+}
+
void
rendermon(struct wl_listener *listener, void *data)
{
@@ -3482,6 +3502,7 @@ main(int argc, char *argv[])
if (!getenv("XDG_RUNTIME_DIR"))
die("XDG_RUNTIME_DIR must be set");
setup();
+ if (refresh_colors) reload_colors(0);
run(startup_cmd);
cleanup();
return EXIT_SUCCESS;
--
2.51.2
+1 -1
View File
@@ -301,7 +301,7 @@ index 0000000..125312c
+ pipefd = ecalloc(2, sizeof(int));
+
+ /*
+ * Libdbus forbids calling dbus_connection_dispatch from the
+ * Libdbus forbids calling dbus_connection_dipatch from the
+ * DBusDispatchStatusFunction directly. Notify the event loop of
+ * updates via a self-pipe.
+ */
+1 -1
View File
@@ -13,7 +13,7 @@ slstatus -s | dwl
* pixman
### Download
- [main 2026-01-05](/dwl/dwl-patches/raw/branch/main/patches/bar/bar.patch)
- [main 2025-07-29](/dwl/dwl-patches/raw/branch/main/patches/bar/bar.patch)
- [0.7](/dwl/dwl-patches/raw/branch/main/patches/bar/bar-0.7.patch)
- [0.6](/dwl/dwl-patches/raw/branch/main/patches/bar/bar-0.6.patch)
+72 -77
View File
@@ -1,14 +1,15 @@
From d6a2c4e7f0d3108c7a8a1ad6e76a62e854b2f8e1 Mon Sep 17 00:00:00 2001
From 8906a73dbc8996dd1bfff15f5b26aaee6d45fd61 Mon Sep 17 00:00:00 2001
From: sewn <sewn@disroot.org>
Date: Mon, 5 Jan 2026 16:51:14 +0300
Date: Tue, 29 Jul 2025 15:21:19 +0300
Subject: [PATCH] Implement dwm bar clone
Signed-off-by: sewn <sewn@disroot.org>
---
Makefile | 2 +-
config.def.h | 33 ++--
drwl.h | 310 +++++++++++++++++++++++++++++++++++
dwl.c | 444 +++++++++++++++++++++++++++++++++++++++++----------
4 files changed, 697 insertions(+), 92 deletions(-)
drwl.h | 311 ++++++++++++++++++++++++++++++++++++
dwl.c | 441 +++++++++++++++++++++++++++++++++++++++++----------
4 files changed, 695 insertions(+), 92 deletions(-)
create mode 100644 drwl.h
diff --git a/Makefile b/Makefile
@@ -25,7 +26,7 @@ index 578194f..279b1c0 100644
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..7da50d2 100644
index 95c2afa..1b7472d 100644
--- a/config.def.h
+++ b/config.def.h
@@ -7,15 +7,21 @@
@@ -56,15 +57,15 @@ index 8a6eda0..7da50d2 100644
/* logging */
static int log_level = WLR_ERROR;
@@ -123,6 +129,7 @@ static const Key keys[] = {
/* modifier key function argument */
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
+ { MODKEY, XKB_KEY_b, togglebar, {0} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
@@ -166,7 +173,15 @@ static const Key keys[] = {
@@ -127,6 +133,7 @@ static const Key keys[] = {
/* modifier key function argument */
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
+ { MODKEY, XKB_KEY_b, togglebar, {0} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
@@ -170,7 +177,15 @@ static const Key keys[] = {
};
static const Button buttons[] = {
@@ -85,10 +86,10 @@ index 8a6eda0..7da50d2 100644
};
diff --git a/drwl.h b/drwl.h
new file mode 100644
index 0000000..21afd21
index 0000000..90cc35b
--- /dev/null
+++ b/drwl.h
@@ -0,0 +1,310 @@
@@ -0,0 +1,311 @@
+/*
+ * drwl - https://codeberg.org/sewn/drwl
+ *
@@ -172,6 +173,7 @@ index 0000000..21afd21
+static int
+drwl_init(void)
+{
+ fcft_set_scaling_filter(FCFT_SCALING_FILTER_LANCZOS3);
+ return fcft_init(FCFT_LOG_COLORIZE_AUTO, 0, FCFT_LOG_CLASS_ERROR);
+}
+
@@ -400,15 +402,10 @@ index 0000000..21afd21
+ fcft_fini();
+}
diff --git a/dwl.c b/dwl.c
index 44f3ad9..7b2abf5 100644
index 12f441e..bf340d8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1,10 +1,12 @@
/*
* See LICENSE file for copyright and license details.
*/
+#include <fcntl.h>
#include <getopt.h>
@@ -5,6 +5,7 @@
#include <libinput.h>
#include <linux/input-event-codes.h>
#include <math.h>
@@ -416,7 +413,7 @@ index 44f3ad9..7b2abf5 100644
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -59,6 +61,7 @@
@@ -59,6 +60,7 @@
#include <wlr/types/wlr_xdg_decoration_v1.h>
#include <wlr/types/wlr_xdg_output_v1.h>
#include <wlr/types/wlr_xdg_shell.h>
@@ -424,7 +421,7 @@ index 44f3ad9..7b2abf5 100644
#include <wlr/util/log.h>
#include <wlr/util/region.h>
#include <xkbcommon/xkbcommon.h>
@@ -69,6 +72,7 @@
@@ -69,6 +71,7 @@
#endif
#include "util.h"
@@ -432,7 +429,7 @@ index 44f3ad9..7b2abf5 100644
/* macros */
#define MAX(A, B) ((A) > (B) ? (A) : (B))
@@ -77,14 +81,17 @@
@@ -77,14 +80,17 @@
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define END(A) ((A) + LENGTH(A))
@@ -451,7 +448,7 @@ index 44f3ad9..7b2abf5 100644
typedef union {
int i;
@@ -94,6 +101,7 @@ typedef union {
@@ -94,6 +100,7 @@ typedef union {
} Arg;
typedef struct {
@@ -459,7 +456,7 @@ index 44f3ad9..7b2abf5 100644
unsigned int mod;
unsigned int button;
void (*func)(const Arg *);
@@ -183,10 +191,19 @@ typedef struct {
@@ -183,10 +190,19 @@ typedef struct {
void (*arrange)(Monitor *);
} Layout;
@@ -479,7 +476,7 @@ index 44f3ad9..7b2abf5 100644
struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
struct wl_listener frame;
struct wl_listener destroy;
@@ -194,6 +211,11 @@ struct Monitor {
@@ -194,6 +210,11 @@ struct Monitor {
struct wl_listener destroy_lock_surface;
struct wlr_session_lock_surface_v1 *lock_surface;
struct wlr_box m; /* monitor area, layout-relative */
@@ -491,7 +488,7 @@ index 44f3ad9..7b2abf5 100644
struct wlr_box w; /* window area, layout-relative */
struct wl_list layers[4]; /* LayerSurface.link */
const Layout *lt[2];
@@ -205,6 +227,9 @@ struct Monitor {
@@ -205,6 +226,9 @@ struct Monitor {
int nmaster;
char ltsymbol[16];
int asleep;
@@ -501,7 +498,7 @@ index 44f3ad9..7b2abf5 100644
};
typedef struct {
@@ -247,6 +272,13 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
@@ -247,6 +271,13 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m);
static void axisnotify(struct wl_listener *listener, void *data);
@@ -515,7 +512,7 @@ index 44f3ad9..7b2abf5 100644
static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
static void checkidleinhibitor(struct wlr_surface *exclude);
@@ -282,6 +314,8 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data);
@@ -282,6 +313,8 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data);
static void destroysessionlock(struct wl_listener *listener, void *data);
static void destroykeyboardgroup(struct wl_listener *listener, void *data);
static Monitor *dirtomon(enum wlr_direction dir);
@@ -524,7 +521,7 @@ index 44f3ad9..7b2abf5 100644
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
@@ -310,7 +344,6 @@ static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int
@@ -310,7 +343,6 @@ static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int
static void outputmgrtest(struct wl_listener *listener, void *data);
static void pointerfocus(Client *c, struct wlr_surface *surface,
double sx, double sy, uint32_t time);
@@ -532,7 +529,7 @@ index 44f3ad9..7b2abf5 100644
static void powermgrsetmode(struct wl_listener *listener, void *data);
static void quit(const Arg *arg);
static void rendermon(struct wl_listener *listener, void *data);
@@ -331,9 +364,11 @@ static void setsel(struct wl_listener *listener, void *data);
@@ -331,9 +363,11 @@ static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
@@ -544,7 +541,7 @@ index 44f3ad9..7b2abf5 100644
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -342,6 +377,7 @@ static void unlocksession(struct wl_listener *listener, void *data);
@@ -342,6 +376,7 @@ static void unlocksession(struct wl_listener *listener, void *data);
static void unmaplayersurfacenotify(struct wl_listener *listener, void *data);
static void unmapnotify(struct wl_listener *listener, void *data);
static void updatemons(struct wl_listener *listener, void *data);
@@ -552,7 +549,7 @@ index 44f3ad9..7b2abf5 100644
static void updatetitle(struct wl_listener *listener, void *data);
static void urgent(struct wl_listener *listener, void *data);
static void view(const Arg *arg);
@@ -406,6 +442,15 @@ static struct wlr_box sgeom;
@@ -406,6 +441,15 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
@@ -568,7 +565,7 @@ index 44f3ad9..7b2abf5 100644
/* global event handlers */
static struct wl_listener cursor_axis = {.notify = axisnotify};
static struct wl_listener cursor_button = {.notify = buttonpress};
@@ -521,7 +566,7 @@ arrange(Monitor *m)
@@ -521,7 +565,7 @@ arrange(Monitor *m)
wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
(c = focustop(m)) && c->isfullscreen);
@@ -577,7 +574,7 @@ index 44f3ad9..7b2abf5 100644
/* We move all clients (except fullscreen and unmanaged) to LyrTile while
* in floating layout to avoid "real" floating clients be always on top */
@@ -576,6 +621,11 @@ arrangelayers(Monitor *m)
@@ -576,6 +620,11 @@ arrangelayers(Monitor *m)
if (!m->wlr_output->enabled)
return;
@@ -589,7 +586,7 @@ index 44f3ad9..7b2abf5 100644
/* Arrange exclusive surfaces from top->bottom */
for (i = 3; i >= 0; i--)
arrangelayer(m, &m->layers[i], &usable_area, 1);
@@ -618,17 +668,102 @@ axisnotify(struct wl_listener *listener, void *data)
@@ -618,17 +667,102 @@ axisnotify(struct wl_listener *listener, void *data)
event->delta_discrete, event->source, event->relative_direction);
}
@@ -692,7 +689,7 @@ index 44f3ad9..7b2abf5 100644
switch (event->state) {
case WL_POINTER_BUTTON_STATE_PRESSED:
cursor_mode = CurPressed;
@@ -636,17 +771,34 @@ buttonpress(struct wl_listener *listener, void *data)
@@ -636,17 +770,34 @@ buttonpress(struct wl_listener *listener, void *data)
if (locked)
break;
@@ -731,7 +728,7 @@ index 44f3ad9..7b2abf5 100644
return;
}
}
@@ -721,6 +873,8 @@ cleanup(void)
@@ -721,6 +872,8 @@ cleanup(void)
/* Destroy after the wayland display (when the monitors are already destroyed)
to avoid destroying them with an invalid scene output. */
wlr_scene_node_destroy(&scene->tree.node);
@@ -740,7 +737,7 @@ index 44f3ad9..7b2abf5 100644
}
void
@@ -736,6 +890,12 @@ cleanupmon(struct wl_listener *listener, void *data)
@@ -736,6 +889,12 @@ cleanupmon(struct wl_listener *listener, void *data)
wlr_layer_surface_v1_destroy(l->layer_surface);
}
@@ -753,7 +750,7 @@ index 44f3ad9..7b2abf5 100644
wl_list_remove(&m->destroy.link);
wl_list_remove(&m->frame.link);
wl_list_remove(&m->link);
@@ -748,6 +908,7 @@ cleanupmon(struct wl_listener *listener, void *data)
@@ -748,6 +907,7 @@ cleanupmon(struct wl_listener *listener, void *data)
closemon(m);
wlr_scene_node_destroy(&m->fullscreen_bg->node);
@@ -761,7 +758,7 @@ index 44f3ad9..7b2abf5 100644
free(m);
}
@@ -814,7 +975,7 @@ closemon(Monitor *m)
@@ -814,7 +974,7 @@ closemon(Monitor *m)
setmon(c, selmon, c->tags);
}
focusclient(focustop(selmon), 1);
@@ -770,7 +767,7 @@ index 44f3ad9..7b2abf5 100644
}
void
@@ -1066,7 +1227,7 @@ createmon(struct wl_listener *listener, void *data)
@@ -1066,7 +1226,7 @@ createmon(struct wl_listener *listener, void *data)
m->nmaster = r->nmaster;
m->lt[0] = r->lt;
m->lt[1] = &layouts[LENGTH(layouts) > 1 && r->lt != &layouts[1]];
@@ -779,7 +776,7 @@ index 44f3ad9..7b2abf5 100644
wlr_output_state_set_scale(&state, r->scale);
wlr_output_state_set_transform(&state, r->rr);
break;
@@ -1088,8 +1249,15 @@ createmon(struct wl_listener *listener, void *data)
@@ -1088,8 +1248,15 @@ createmon(struct wl_listener *listener, void *data)
wlr_output_commit_state(wlr_output, &state);
wlr_output_state_finish(&state);
@@ -796,7 +793,7 @@ index 44f3ad9..7b2abf5 100644
/* The xdg-protocol specifies:
*
@@ -1399,6 +1567,80 @@ dirtomon(enum wlr_direction dir)
@@ -1399,6 +1566,80 @@ dirtomon(enum wlr_direction dir)
return selmon;
}
@@ -877,7 +874,7 @@ index 44f3ad9..7b2abf5 100644
void
focusclient(Client *c, int lift)
{
@@ -1433,13 +1675,13 @@ focusclient(Client *c, int lift)
@@ -1433,13 +1674,13 @@ focusclient(Client *c, int lift)
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
if (!exclusive_focus && !seat->drag)
@@ -893,7 +890,7 @@ index 44f3ad9..7b2abf5 100644
* and focus it after the overlay is closed. */
if (old_client_type == LayerShell && wlr_scene_node_coords(
&old_l->scene->node, &unused_lx, &unused_ly)
@@ -1450,12 +1692,11 @@ focusclient(Client *c, int lift)
@@ -1450,12 +1691,11 @@ focusclient(Client *c, int lift)
/* Don't deactivate old client if the new one wants focus, as this causes issues with winecfg
* and probably other clients */
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
@@ -908,7 +905,7 @@ index 44f3ad9..7b2abf5 100644
if (!c) {
/* With no client, all we have left is to clear focus */
@@ -1769,7 +2010,7 @@ mapnotify(struct wl_listener *listener, void *data)
@@ -1768,7 +2008,7 @@ mapnotify(struct wl_listener *listener, void *data)
for (i = 0; i < 4; i++) {
c->border[i] = wlr_scene_rect_create(c->scene, 0, 0,
@@ -917,7 +914,7 @@ index 44f3ad9..7b2abf5 100644
c->border[i]->node.data = c;
}
@@ -1792,7 +2033,7 @@ mapnotify(struct wl_listener *listener, void *data)
@@ -1791,7 +2031,7 @@ mapnotify(struct wl_listener *listener, void *data)
} else {
applyrules(c);
}
@@ -926,7 +923,7 @@ index 44f3ad9..7b2abf5 100644
unset_fullscreen:
m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
@@ -2085,44 +2326,6 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
@@ -2084,44 +2324,6 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
wlr_seat_pointer_notify_motion(seat, time, sx, sy);
}
@@ -971,7 +968,7 @@ index 44f3ad9..7b2abf5 100644
void
powermgrsetmode(struct wl_listener *listener, void *data)
{
@@ -2251,22 +2454,14 @@ run(char *startup_cmd)
@@ -2250,22 +2452,14 @@ run(char *startup_cmd)
/* Now that the socket exists and the backend is started, run the startup command */
if (startup_cmd) {
@@ -995,7 +992,7 @@ index 44f3ad9..7b2abf5 100644
}
/* Mark stdout as non-blocking to avoid the startup script
@@ -2276,7 +2471,7 @@ run(char *startup_cmd)
@@ -2275,7 +2469,7 @@ run(char *startup_cmd)
if (fd_set_nonblock(STDOUT_FILENO) < 0)
close(STDOUT_FILENO);
@@ -1004,7 +1001,7 @@ index 44f3ad9..7b2abf5 100644
/* At this point the outputs are initialized, choose initial selmon based on
* cursor position, and set default cursor image */
@@ -2342,7 +2537,7 @@ setfloating(Client *c, int floating)
@@ -2341,7 +2535,7 @@ setfloating(Client *c, int floating)
(p && p->isfullscreen) ? LyrFS
: c->isfloating ? LyrFloat : LyrTile]);
arrange(c->mon);
@@ -1013,7 +1010,7 @@ index 44f3ad9..7b2abf5 100644
}
void
@@ -2365,7 +2560,7 @@ setfullscreen(Client *c, int fullscreen)
@@ -2364,7 +2558,7 @@ setfullscreen(Client *c, int fullscreen)
resize(c, c->prev, 0);
}
arrange(c->mon);
@@ -1022,7 +1019,7 @@ index 44f3ad9..7b2abf5 100644
}
void
@@ -2377,9 +2572,9 @@ setlayout(const Arg *arg)
@@ -2376,9 +2570,9 @@ setlayout(const Arg *arg)
selmon->sellt ^= 1;
if (arg && arg->v)
selmon->lt[selmon->sellt] = (Layout *)arg->v;
@@ -1034,7 +1031,7 @@ index 44f3ad9..7b2abf5 100644
}
/* arg > 1.0 will set mfact absolutely */
@@ -2452,6 +2647,7 @@ setup(void)
@@ -2451,6 +2645,7 @@ setup(void)
for (i = 0; i < (int)LENGTH(sig); i++)
sigaction(sig[i], &sa, NULL);
@@ -1042,7 +1039,7 @@ index 44f3ad9..7b2abf5 100644
wlr_log_init(log_level, NULL);
/* The Wayland display is managed by libwayland. It handles accepting
@@ -2646,6 +2842,11 @@ setup(void)
@@ -2645,6 +2840,11 @@ setup(void)
wl_signal_add(&output_mgr->events.apply, &output_mgr_apply);
wl_signal_add(&output_mgr->events.test, &output_mgr_test);
@@ -1054,16 +1051,15 @@ index 44f3ad9..7b2abf5 100644
/* Make sure XWayland clients don't connect to the parent X server,
* e.g when running in the x11 backend or the wayland backend and the
* compositor has Xwayland support */
@@ -2670,6 +2871,8 @@ void
@@ -2669,6 +2869,7 @@ void
spawn(const Arg *arg)
{
if (fork() == 0) {
+ close(STDIN_FILENO);
+ open("/dev/null", O_RDWR);
dup2(STDERR_FILENO, STDOUT_FILENO);
setsid();
execvp(((char **)arg->v)[0], (char **)arg->v);
@@ -2688,6 +2891,30 @@ startdrag(struct wl_listener *listener, void *data)
@@ -2687,6 +2888,30 @@ startdrag(struct wl_listener *listener, void *data)
LISTEN_STATIC(&drag->icon->events.destroy, destroydragicon);
}
@@ -1094,7 +1090,7 @@ index 44f3ad9..7b2abf5 100644
void
tag(const Arg *arg)
{
@@ -2698,7 +2925,7 @@ tag(const Arg *arg)
@@ -2697,7 +2922,7 @@ tag(const Arg *arg)
sel->tags = arg->ui & TAGMASK;
focusclient(focustop(selmon), 1);
arrange(selmon);
@@ -1103,7 +1099,7 @@ index 44f3ad9..7b2abf5 100644
}
void
@@ -2743,6 +2970,15 @@ tile(Monitor *m)
@@ -2742,6 +2967,14 @@ tile(Monitor *m)
}
}
@@ -1113,13 +1109,12 @@ index 44f3ad9..7b2abf5 100644
+ wlr_scene_node_set_enabled(&selmon->scene_buffer->node,
+ !selmon->scene_buffer->node.enabled);
+ arrangelayers(selmon);
+ drawbars();
+}
+
void
togglefloating(const Arg *arg)
{
@@ -2771,7 +3007,7 @@ toggletag(const Arg *arg)
@@ -2770,7 +3003,7 @@ toggletag(const Arg *arg)
sel->tags = newtags;
focusclient(focustop(selmon), 1);
arrange(selmon);
@@ -1128,7 +1123,7 @@ index 44f3ad9..7b2abf5 100644
}
void
@@ -2784,7 +3020,7 @@ toggleview(const Arg *arg)
@@ -2783,7 +3016,7 @@ toggleview(const Arg *arg)
selmon->tagset[selmon->seltags] = newtagset;
focusclient(focustop(selmon), 1);
arrange(selmon);
@@ -1137,7 +1132,7 @@ index 44f3ad9..7b2abf5 100644
}
void
@@ -2832,7 +3068,7 @@ unmapnotify(struct wl_listener *listener, void *data)
@@ -2831,7 +3064,7 @@ unmapnotify(struct wl_listener *listener, void *data)
}
wlr_scene_node_destroy(&c->scene->node);
@@ -1146,7 +1141,7 @@ index 44f3ad9..7b2abf5 100644
motionnotify(0, NULL, 0, 0, 0, 0);
}
@@ -2932,6 +3168,13 @@ updatemons(struct wl_listener *listener, void *data)
@@ -2931,6 +3164,13 @@ updatemons(struct wl_listener *listener, void *data)
}
}
@@ -1160,7 +1155,7 @@ index 44f3ad9..7b2abf5 100644
/* FIXME: figure out why the cursor image is at 0,0 after turning all
* the monitors on.
* Move the cursor image where it used to be. It does not generate a
@@ -2942,12 +3185,45 @@ updatemons(struct wl_listener *listener, void *data)
@@ -2941,12 +3181,45 @@ updatemons(struct wl_listener *listener, void *data)
wlr_output_manager_v1_set_configuration(output_mgr, config);
}
@@ -1207,7 +1202,7 @@ index 44f3ad9..7b2abf5 100644
}
void
@@ -2960,10 +3236,10 @@ urgent(struct wl_listener *listener, void *data)
@@ -2959,10 +3232,10 @@ urgent(struct wl_listener *listener, void *data)
return;
c->isurgent = 1;
@@ -1220,7 +1215,7 @@ index 44f3ad9..7b2abf5 100644
}
void
@@ -2976,7 +3252,7 @@ view(const Arg *arg)
@@ -2975,7 +3248,7 @@ view(const Arg *arg)
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
focusclient(focustop(selmon), 1);
arrange(selmon);
@@ -1229,7 +1224,7 @@ index 44f3ad9..7b2abf5 100644
}
void
@@ -3017,6 +3293,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
@@ -3016,6 +3289,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
{
struct wlr_scene_node *node, *pnode;
struct wlr_surface *surface = NULL;
@@ -1237,7 +1232,7 @@ index 44f3ad9..7b2abf5 100644
Client *c = NULL;
LayerSurface *l = NULL;
int layer;
@@ -3025,9 +3302,12 @@ xytonode(double x, double y, struct wlr_surface **psurface,
@@ -3024,9 +3298,12 @@ xytonode(double x, double y, struct wlr_surface **psurface,
if (!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny)))
continue;
@@ -1253,7 +1248,7 @@ index 44f3ad9..7b2abf5 100644
/* Walk the tree to find a node that knows the client */
for (pnode = node; pnode && !c; pnode = &pnode->parent->node)
c = pnode->data;
@@ -3160,10 +3440,10 @@ sethints(struct wl_listener *listener, void *data)
@@ -3159,10 +3436,10 @@ sethints(struct wl_listener *listener, void *data)
return;
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
@@ -1267,5 +1262,5 @@ index 44f3ad9..7b2abf5 100644
void
--
2.52.0
2.50.0
-25
View File
@@ -1,25 +0,0 @@
### Description
This patch **requires** the dwl [barconfig](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/bar) patch be applied first! The barconfig patch provides configuration for the dwl bar via the variable
`barlayout`. This determines which of the elements listed below to
display on the bar and in which order:
- 't' -> the tags
- 'l' -> the current layout symbol
- 'n' -> the window name
- 's' -> the status message
- '|' -> elements on the right of this separator will be displayed from
the right
**NOTE**: This patch is a dwl port of the [original](https://dwm.suckless.org/patches/barconfig/) barconfig patch for dwm.
### Known Issues With Patch
Changing the location of the tags breaks the tag button presses (the buttons expect the click in the usual location of the tags). I do not have any plans to look into this, as I ported this patch for the sole purpose of having the option to omit the layout symbol from the bar.
### Download
- [main 2025-10-24](/dwl/dwl-patches/raw/branch/main/patches/barconfig/barconfig.patch)
### Authors - latest at top
- Rumen Mitov
Codeberg: [rumenmitov](https://codeberg.org/rumenmitov)
Email: rumenmitov@protonmail.com
-194
View File
@@ -1,194 +0,0 @@
From e733fda4e498c998a104d0d5bb42b9c7373f2c9d Mon Sep 17 00:00:00 2001
From: Rumen <rumenmitov@protonmail.com>
Date: Fri, 24 Oct 2025 09:33:24 +0200
Subject: [PATCH] Barconfig: Configure the dwl bar!
NOTE: This is a port of the original barconfig patch for dwm!
This patch provides configuration for the dwl bar via the variable
`barlayout`. This determines which of the elements listed below to
display on the bar and in which order:
- 't' -> the tags
- 'l' -> the current layout symbol
- 'n' -> the window name
- 's' -> the status message
- '|' -> elements on the right of this separator will be displayed from
the right
---
config.def.h | 1 +
dwl.c | 134 +++++++++++++++++++++++++++++++++++----------------
2 files changed, 93 insertions(+), 42 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1b7472d..c7a33d6 100644
--- a/config.def.h
+++ b/config.def.h
@@ -9,6 +9,7 @@ static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will
static const unsigned int borderpx = 1; /* border pixel of windows */
static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */
+static const char *barlayout = "tln|s";
static const char *fonts[] = {"monospace:size=10"};
static const float rootcolor[] = COLOR(0x000000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
diff --git a/dwl.c b/dwl.c
index bf340d8..f0d72cf 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1569,10 +1569,10 @@ dirtomon(enum wlr_direction dir)
void
drawbar(Monitor *m)
{
- int x, w, tw = 0;
+ int x = 0, w, tw = 0, moveright = 0;
int boxs = m->drw->font->height / 9;
int boxw = m->drw->font->height / 6 + 2;
- uint32_t i, occ = 0, urg = 0;
+ uint32_t i, j, occ = 0, urg = 0;
Client *c;
Buffer *buf;
@@ -1581,48 +1581,99 @@ drawbar(Monitor *m)
if (!(buf = bufmon(m)))
return;
- /* draw status first so it can be overdrawn by tags later */
- if (m == selmon) { /* status is only drawn on selected monitor */
- drwl_setscheme(m->drw, colors[SchemeNorm]);
- tw = TEXTW(m, stext) - m->lrpad + 2; /* 2px right padding */
- drwl_text(m->drw, m->b.width - tw, 0, tw, m->b.height, 0, stext, 0);
- }
+ if (barlayout[0] == '\0')
+ barlayout = "tln|s";
+
+ drwl_text(m->drw, 0, 0, m->w.width, m->b.height, 0, "", 0); /* draw background */
+
+ for (i = 0; i < strlen(barlayout); i++) {
+ switch (barlayout[i]) {
+ case 'l':
+ w = TEXTW(m, m->ltsymbol);
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ if (moveright) {
+ x -= w;
+ drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
+ } else
+ x = drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
+ break;
- wl_list_for_each(c, &clients, link) {
- if (c->mon != m)
- continue;
- occ |= c->tags;
- if (c->isurgent)
- urg |= c->tags;
- }
- x = 0;
- c = focustop(m);
- for (i = 0; i < LENGTH(tags); i++) {
- w = TEXTW(m, tags[i]);
- drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
- drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, tags[i], urg & 1 << i);
- if (occ & 1 << i)
- drwl_rect(m->drw, x + boxs, boxs, boxw, boxw,
- m == selmon && c && c->tags & 1 << i,
- urg & 1 << i);
- x += w;
- }
- w = TEXTW(m, m->ltsymbol);
- drwl_setscheme(m->drw, colors[SchemeNorm]);
- x = drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
-
- if ((w = m->b.width - tw - x) > m->b.height) {
- if (c) {
- drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]);
- drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, client_get_title(c), 0);
- if (c && c->isfloating)
- drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0);
- } else {
- drwl_setscheme(m->drw, colors[SchemeNorm]);
- drwl_rect(m->drw, x, 0, w, m->b.height, 1, 1);
- }
- }
+ case 'n':
+ c = focustop(m);
+
+ if (c) {
+ tw = TEXTW(m, client_get_title(c));
+ if (moveright)
+ x -= tw;
+
+ drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]);
+ drwl_text(m->drw, x, 0, moveright ? tw : m->w.width, m->b.height, m->lrpad / 2, client_get_title(c), 0);
+
+ if (c && c->isfloating)
+ drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0);
+
+ } else {
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ drwl_rect(m->drw, x, 0, tw, m->b.height, 1, 1);
+ }
+
+ if (!moveright)
+ x += tw;
+ break;
+
+ case 's':
+ if (m == selmon) { /* status is only drawn on selected monitor */
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ tw = TEXTW(m, stext) - m->lrpad + 2; /* 2px right padding */
+ if (moveright) {
+ x -= tw;
+ drwl_text(m->drw, x, 0, tw, m->b.height, 0, stext, 0);
+ } else
+ x = drwl_text(m->drw, x, 0, tw, m->b.height, 0, stext, 0);
+ }
+ break;
+
+ case 't':
+ wl_list_for_each(c, &clients, link) {
+ if (c->mon != m)
+ continue;
+ occ |= c->tags;
+ if (c->isurgent)
+ urg |= c->tags;
+ }
+
+ c = focustop(m);
+
+ /* tags */
+ if (moveright) {
+ tw = 0;
+ for (j = 0; j < LENGTH(tags); j++) {
+ tw += TEXTW(m, tags[j]);
+ }
+ x -= tw;
+ }
+ for (j = 0; j < LENGTH(tags); j++) {
+ w = TEXTW(m, tags[j]);
+ drwl_setscheme(m->drw, colors[m->tagset[m->seltags] & 1 << j ? SchemeSel : SchemeNorm]);
+ drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, tags[j], urg & 1 << j);
+ if (occ & 1 << j)
+ drwl_rect(m->drw, x + boxs, boxs, boxw, boxw,
+ m == selmon && c && c->tags & 1 << j,
+ urg & 1 << i);
+ x += w;
+ }
+ if (moveright)
+ x -= tw;
+ break;
+
+ case '|':
+ moveright = 1;
+ x = m->w.width;
+ break;
+ }
+ }
+
wlr_scene_buffer_set_dest_size(m->scene_buffer,
m->b.real_width, m->b.real_height);
wlr_scene_node_set_position(&m->scene_buffer->node, m->m.x,
--
2.51.1
-8
View File
@@ -1,8 +0,0 @@
### Description
Borderless client if rule set to borderless
### Download
[main 2025-11-29](/dwl/dwl-patches/raw/branch/main/patches/borderlessrule/borderlessrule.patch)
### Author
- [freezboltz](https://codeberg.org/freezboltz)
@@ -1,71 +0,0 @@
From 2a81a809a648046f8361056af06dadf3397fecaa Mon Sep 17 00:00:00 2001
From: Anant Murmu <freezboltz@gmail.com>
Date: Tue, 2 Dec 2025 08:02:16 +0530
Subject: [PATCH] fix: missing field in struct Rule isborderless
---
config.def.h | 7 ++++---
dwl.c | 7 ++++++-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/config.def.h b/config.def.h
index 95c2afa..9eee6ca 100644
--- a/config.def.h
+++ b/config.def.h
@@ -22,10 +22,11 @@ static int log_level = WLR_ERROR;
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
+ /* app_id title tags mask isfloating monitor isborderless */
/* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ { "Gimp_EXAMPLE", NULL, 0, 1, -1, 0 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1, 0 }, /* Start on ONLY tag "9" */
+ { "foo_EXAMPLE", NULL, 0, 0, -1, 1 }, /* Start on currently visible tags with no border around it */
};
/* layout(s) */
diff --git a/dwl.c b/dwl.c
index 12f441e..572f754 100644
--- a/dwl.c
+++ b/dwl.c
@@ -137,7 +137,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isborderless, isfullscreen;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -228,6 +228,7 @@ typedef struct {
uint32_t tags;
int isfloating;
int monitor;
+ int isborderless;
} Rule;
typedef struct {
@@ -490,6 +491,7 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
+ c->isborderless = r->isborderless;
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -2210,6 +2212,9 @@ resize(Client *c, struct wlr_box geo, int interact)
if (!c->mon || !client_surface(c)->mapped)
return;
+ if (c->isborderless)
+ c->bw = 0;
+
bbox = interact ? &sgeom : &c->mon->w;
client_set_bounds(c, geo.width, geo.height);
--
2.52.0
+1 -1
View File
@@ -3,7 +3,7 @@ From: wochap <gean.marroquin@gmail.com>
Date: Tue, 4 Jun 2024 16:02:25 -0500
Subject: [PATCH] implement borders patch
this patch adds 2 extra borders relative to the client, they don't
tihs patch adds 2 extra borders relative to the client, they don't
change the size of the client
---
client.h | 16 +++++++++++++---
-2
View File
@@ -15,14 +15,12 @@ bstack (TTT) bstackhoriz (===)
### Download
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/bottomstack/bottomstack.patch)
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.6-b/bottomstack)
- [2024-07-09](https://codeberg.org/dwl/dwl-patches/raw/commit/20de07dc8759200c8a4c9651475acb331d245890/patches/bottomstack/bottomstack.patch)
- [2024-04-11](https://codeberg.org/dwl/dwl-patches/raw/commit/0f4e40fee49d1b8b430778e241b29496ae3b3b70/bottomstack/bottomstack.patch)
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/5368aa392c7ebf8d7d24c232b80cfae1be457d41/bottomstack/bottomstack.patch)
### Authors
- [unixchad](https://codeberg.org/unixchad)
- [wochap](https://codeberg.org/wochap)
- [DanielMowitz](https://github.com/DanielMowitz)
- [Abanoub8](https://github.com/Abanoub8)
+20 -21
View File
@@ -1,7 +1,7 @@
From 86e379b187bcc9f8f5896a87309474fcf3736de9 Mon Sep 17 00:00:00 2001
From: nate zhou <gnuunixchad@outlook.com>
Date: Sat, 28 Feb 2026 21:29:53 +0800
Subject: [PATCH] Patch: bottomstack-0.8.patch
From b352fb08f40b1ee2d8c4748be4922df711e3aaa9 Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com>
Date: Fri, 5 Jul 2024 10:44:29 -0500
Subject: [PATCH] implement bottomstack
---
config.def.h | 4 +++
@@ -9,10 +9,10 @@ Subject: [PATCH] Patch: bottomstack-0.8.patch
2 files changed, 88 insertions(+)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..ae87518 100644
index 22d2171..5aac3e9 100644
--- a/config.def.h
+++ b/config.def.h
@@ -33,6 +33,8 @@ static const Layout layouts[] = {
@@ -34,6 +34,8 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
@@ -21,20 +21,20 @@ index 8a6eda0..ae87518 100644
};
/* monitors */
@@ -135,6 +137,8 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XKB_KEY_u, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XKB_KEY_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
@@ -139,6 +141,8 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XKB_KEY_u, setlayout, {.v = &layouts[3]} },
+ { MODKEY, XKB_KEY_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index 44f3ad9..68c25a5 100644
index dc0437e..5648d5f 100644
--- a/dwl.c
+++ b/dwl.c
@@ -59,6 +59,7 @@
@@ -57,6 +57,7 @@
#include <wlr/types/wlr_xdg_decoration_v1.h>
#include <wlr/types/wlr_xdg_output_v1.h>
#include <wlr/types/wlr_xdg_shell.h>
@@ -50,8 +50,8 @@ index 44f3ad9..68c25a5 100644
+static void bstackhoriz(Monitor *m);
/* variables */
static pid_t child_pid = -1;
@@ -3213,3 +3216,84 @@ main(int argc, char *argv[])
static const char broken[] = "broken";
@@ -3160,3 +3163,84 @@ main(int argc, char *argv[])
usage:
die("Usage: %s [-v] [-d] [-s startup command]", argv[0]);
}
@@ -137,5 +137,4 @@ index 44f3ad9..68c25a5 100644
+ }
+}
--
2.53.0
2.45.1
+54 -35
View File
@@ -1,10 +1,10 @@
### Description
# btrtile - A Focus-Driven Tiling Layout
# btrtile A Focus-Driven Tiling Layout
It provides a focus-driven, mouse- and keyboard-friendly tiling layout that grants you granular control over how clients are placed and resized.
![btrtile in action](https://codeberg.org/julmajustus/my-dwl-patches/raw/branch/main/demos/btrtiledemo.gif?raw=true)
![btrtile in action](https://github.com/julmajustus/dwl-patches/blob/main/demos/btrtiledemo.gif?raw=true)
---
@@ -14,35 +14,39 @@ While dwls patches folder is full of different layouts, I couldn't find suita
---
# How it works
Clients live in a binary tree, every split has a ratio (50/50 by default).
When a new client opens, it splits the client you last focused. The pointer decides which side it lands on: left half of the client puts it on the left, and so on. If the area is wider than it is tall the split is vertical, otherwise horizontal. When several clients open at once, each one splits the previous one, so you get a nice spiral instead of a pile in one corner.
- **Mouse**
Drag a tiled client with `MODKEY` + left button to float it, drop it on another tiled client to place it next to it.
`MODKEY` + right button resizes the divider next to the client you grabbed, it follows the pointer 1:1.
- **Keyboard**
`setratio_h` / `setratio_v` move a divider, `swapclients` swaps a client with its neighbour in a direction,
`togglesplit` flips the direction of the split you're in (and keeps it that way),
`swapsplit` mirrors the split.
# Features
- **Combined Tiling and Management**
Combines tiling layout and management of clients under one patchset.
- **Focus-Driven Splits**
When you add a new client, btrtile checks where your pointer is relative to the focused clients geometry.
- If the pointer is on the left half (for a horizontally large client), the new client spawns on the left side, and vice versa.
- By default, new splits are 50/50.
- **Adaptive Splitting**
- If the area to be split is wider than its height, btrtile does a vertical split.
- Otherwise, it does a horizontal split.
- **Keyboard and Mouse Driven**
- Supports keyboard-based commands for quick ratio adjustments and client swapping.
- Mouse-based resizing and moving are integrated for more intuitive manipulation.
---
# How It Works
btrtile organizes clients using a binary tree data structure that represents splits either vertically or horizontally.
When a new client appears:
1. **Focused Client Detection**
btrtile checks your pointer location to find which client (if any) youre interacting with.
2. **Split Creation**
- If theres a focused client, btrtile creates a split node around it, placing the new client on the side where your pointer is.
3. **Ratio Management**
Each split node has a `split_ratio` (defaulting to 0.5). This ratio defines how much space is allocated to each child node. You can adjust this ratio using keyboard or mouse actions.
**config.h:**
```c
use_active_for_splits = 1; /* 1: split the last focused client, 0: the one under the pointer */
force_split = 0; /* 0: new client on the pointer's side, 1: always left/top, 2: always right/bottom */
preserve_split = 0; /* 1: splits keep their direction, 0: direction follows the shape of the area */
split_width_multiplier = 1.0f; /* split side by side when width >= height * this */
resize_interval_ms = 16; /* limits mouse resize updates, 16ms is ~60 per second */
```
`force_split = 2` gives you a predictable spiral if you don't want the pointer to matter.
`split_width_multiplier` is handy on wide monitors, where windows tend to stay wider than tall for a long time.
Smoother mouse resizing costs some cpu, so tune `resize_interval_ms` to your refresh rate.
If resizing feels sluggish, try compiling dwl with -O2/-O3.
---
# What It Doesnt Handle
@@ -52,6 +56,23 @@ If resizing feels sluggish, try compiling dwl with -O2/-O3.
---
# Configuring btrtile
btrtile adds couple variables to config.h to fine tune the mouse resizing of tiled clients.
1. **resize_factor**
- A multiplier to transfer pointer movement to client weight ratio. Depends heavily on mouse sensivity.
Defaults to 0.0002f.
2. **resize_interval_ms**
- A time based resize call limiter. Depends on framerate and screen refresh rate.
Defaults to 16ms. (~60 resize updates per second)
Fine tune these values to find the best values for your setup, smoother resizing can significally increase cpu overhead.
If mouse resizing feels sluggish, you can try compiling dwl with more aggressive optimization flags like -O2/-O3.
---
# Patch recommendations
1. **Patches that I use with my btrtile**
@@ -74,11 +95,9 @@ If resizing feels sluggish, try compiling dwl with -O2/-O3.
---
### Download
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/btrtile-0.9)
- [0.8](./btrtile-v0.8.patch)
- [0.8 WITH gaps](./btrtile-v0.8-gaps.patch)
- [main-d16036e](./btrtile-d16036e.patch)
- [main-d16036e WITH gaps](./btrtile-gaps-d16036e.patch)
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/btrtile-dev)
- [0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-v0.7.patch)
- [0.7 WITH gaps](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-v0.7-gaps.patch)
### Authors
- [julmajustus](https://codeberg.org/julmajustus)
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,35 +1,30 @@
From 42e35a6a8a93f0e6d886ad69686c85c1d58536d6 Mon Sep 17 00:00:00 2001
From 858ef20d36c2d5e6a23a69b3b5909a80fab05f97 Mon Sep 17 00:00:00 2001
From: julmajustus <julmajustus@tutanota.com>
Date: Mon, 22 Jun 2026 22:54:11 +0300
Subject: [PATCH] btrtile: bug fixes and readability improvement
Date: Thu, 13 Feb 2025 23:25:20 +0200
Subject: [PATCH] btrtile-gaps with multi-tag support
- Removed client old_geom caching for simplicity fixes: https://codeberg.org/dwl/dwl-patches/issues/647
- Improved readability of the client sanitization loop inside btrtile function
- Removed fullscreened client's from the sanitization loop to retain their geometry
---
btrtile.c | 575 +++++++++++++++++++++++++++++++++++++++++++++++++++
btrtile.c | 582 +++++++++++++++++++++++++++++++++++++++++++++++++++
config.def.h | 12 ++
dwl.c | 151 +++++++++++---
3 files changed, 711 insertions(+), 27 deletions(-)
dwl.c | 152 +++++++++++---
3 files changed, 717 insertions(+), 29 deletions(-)
create mode 100644 btrtile.c
diff --git a/btrtile.c b/btrtile.c
new file mode 100644
index 0000000..24bf4d9
index 0000000..650cab5
--- /dev/null
+++ b/btrtile.c
@@ -0,0 +1,575 @@
@@ -0,0 +1,582 @@
+/* ************************************************************************** */
+/* @@@ @@@@@@@@ */
+/* @@@ @@@@@@@@@@ */
+/* @@! @@! @@@@ */
+/* !@! !@! @!@!@ */
+/* btrtile.c @!! @!@ @! !@! */
+/* !!! !@!!! !!! */
+/* By: julmajustus <julmajustus@tutanota.com> !!: !!:! !!! */
+/* ::! :!: !:! */
+/* Created: 2024/12/15 00:26:07 by julmajustus :: ::::::: :: */
+/* Updated: 2026/06/22 22:54:06 by julmajustus : : : : : : */
+/* */
+/* ::: :::::::: */
+/* btrtile.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: jmakkone <jmakkone@student.hive.fi> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/12/15 00:26:07 by jmakkone #+# #+# */
+/* Updated: 2025/02/13 23:25:03 by jmakkone ### ########.fr */
+/* */
+/* ************************************************************************** */
+
@@ -52,8 +47,7 @@ index 0000000..24bf4d9
+static void destroy_node(LayoutNode *node);
+static void destroy_tree(Monitor *m);
+static LayoutNode *find_client_node(LayoutNode *node, Client *c);
+static LayoutNode *find_suitable_split(Monitor *m, LayoutNode *start,
+ unsigned int need_vertical, int focused_on_left);
+static LayoutNode *find_suitable_split(LayoutNode *start, unsigned int need_vert);
+static void init_tree(Monitor *m);
+static void insert_client(Monitor *m, Client *focused_client, Client *new_client);
+static LayoutNode *remove_client_node(LayoutNode *node, Client *c);
@@ -64,6 +58,7 @@ index 0000000..24bf4d9
+static unsigned int visible_count(LayoutNode *node, Monitor *m);
+static Client *xytoclient(double x, double y);
+
+static int resizing_from_mouse = 0;
+static double resize_last_update_x, resize_last_update_y;
+static uint32_t last_resize_time = 0;
+
@@ -92,6 +87,7 @@ index 0000000..24bf4d9
+ if (!c || !VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ return;
+ resize(c, area, 0);
+ c->old_geom = area;
+ return;
+ }
+
@@ -168,13 +164,15 @@ index 0000000..24bf4d9
+ LayoutNode *found;
+ struct wlr_box full_area;
+
+ if (!m)
+ if (!m || !m->root)
+ return;
+
+ /* Remove floating and moved clients */
+ /* Remove non tiled clients from tree. */
+ wl_list_for_each(c, &clients, link) {
+ if (c->mon != m || c->isfloating)
+ if (c->mon == m && !c->isfloating && !c->isfullscreen) {
+ } else {
+ remove_client(m, c);
+ }
+ }
+
+ /* If no client is found under cursor, fallback to focustop(m) */
@@ -268,37 +266,30 @@ index 0000000..24bf4d9
+}
+
+LayoutNode *
+find_suitable_split(Monitor *m, LayoutNode *start_node,
+ unsigned int need_vertical, int focused_on_left)
+find_suitable_split(LayoutNode *start_node, unsigned int need_vertical)
+{
+ LayoutNode *n = start_node, *child = NULL;
+
+ if (!m)
+ return NULL;
+
+ if (n && n->is_client_node) {
+ child = n;
+ LayoutNode *n = start_node;
+ /* if we started from a client node, jump to its parent: */
+ if (n && n->is_client_node)
+ n = n->split_node;
+ }
+
+ while (n) {
+ if (!n->is_client_node && n->is_split_vertically == need_vertical
+ && visible_count(n->left, m) > 0
+ && visible_count(n->right, m) > 0) {
+ if ((focused_on_left && n->left == child) ||
+ (!focused_on_left && n->right == child))
+ return n;
+ }
+ child = n;
+ if (!n->is_client_node && n->is_split_vertically == need_vertical &&
+ visible_count(n->left, selmon) > 0 && visible_count(n->right, selmon) > 0)
+ return n;
+ n = n->split_node;
+ }
+ return NULL;
+}
+
+void
+init_tree(Monitor *m)
+{
+ if (m)
+ m->root = NULL;
+ if (!m)
+ return;
+ m->root = calloc(1, sizeof(LayoutNode));
+ if (!m->root)
+ m->root = NULL;
+}
+
+void
@@ -422,31 +413,21 @@ index 0000000..24bf4d9
+ m->root = remove_client_node(m->root, c);
+}
+
+static void
+setratio(unsigned int need_vertical, const Arg *arg)
+void
+setratio_h(const Arg *arg)
+{
+ Client *sel;
+ Client *sel = focustop(selmon);
+ LayoutNode *client_node, *split_node;
+ float new_ratio;
+ int focused_on_left;
+
+ if (!selmon || !selmon->lt[selmon->sellt]->arrange)
+ return;
+
+ sel = focustop(selmon);
+ if (!sel)
+ if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange)
+ return;
+
+ client_node = find_client_node(selmon->root, sel);
+ if (!client_node)
+ return;
+
+ focused_on_left = (arg->f >= 0.0f);
+
+ split_node = find_suitable_split(selmon, client_node, need_vertical, focused_on_left);
+
+ if (!split_node)
+ split_node = find_suitable_split(selmon, client_node, need_vertical, !focused_on_left);
+ split_node = find_suitable_split(client_node, 1);
+ if (!split_node)
+ return;
+
@@ -457,85 +438,109 @@ index 0000000..24bf4d9
+ new_ratio = 0.95f;
+ split_node->split_ratio = new_ratio;
+
+ apply_layout(selmon, selmon->root, selmon->w, 1);
+}
+
+void
+setratio_h(const Arg *arg)
+{
+ setratio(1, arg);
+ /* Skip the arrange if done resizing by mouse,
+ * we call arrange from motionotify */
+ if (!resizing_from_mouse) {
+ arrange(selmon);
+ }
+}
+
+void
+setratio_v(const Arg *arg)
+{
+ setratio(0, arg);
+ Client *sel = focustop(selmon);
+ LayoutNode *client_node, *split_node;
+ float new_ratio;
+
+ if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange)
+ return;
+
+ client_node = find_client_node(selmon->root, sel);
+ if (!client_node)
+ return;
+
+ split_node = find_suitable_split(client_node, 0);
+ if (!split_node)
+ return;
+
+ new_ratio = (arg->f != 0.0f) ? (split_node->split_ratio + arg->f) : 0.5f;
+ if (new_ratio < 0.05f)
+ new_ratio = 0.05f;
+ if (new_ratio > 0.95f)
+ new_ratio = 0.95f;
+ split_node->split_ratio = new_ratio;
+
+ /* Skip the arrange if done resizing by mouse,
+ * we call arrange from motionotify */
+ if (!resizing_from_mouse) {
+ arrange(selmon);
+ }
+}
+
+void swapclients(const Arg *arg) {
+ Client *c, *tmp, *target = NULL, *sel = focustop(selmon);
+ Client *c, *tmp, *target = NULL, *sel = focustop(selmon);
+ LayoutNode *sel_node, *target_node;
+ int closest_dist = INT_MAX, dist, sel_center_x, sel_center_y,
+ int closest_dist = INT_MAX, dist, sel_center_x, sel_center_y,
+ cand_center_x, cand_center_y;
+
+ if (!sel || sel->isfullscreen ||
+ !selmon->root || !selmon->lt[selmon->sellt]->arrange)
+ return;
+ if (!sel || sel->isfullscreen ||
+ !selmon->root || !selmon->lt[selmon->sellt]->arrange)
+ return;
+
+
+ /* Get the center coordinates of the selected client */
+ sel_center_x = sel->geom.x + sel->geom.width / 2;
+ sel_center_y = sel->geom.y + sel->geom.height / 2;
+ /* Get the center coordinates of the selected client */
+ sel_center_x = sel->geom.x + sel->geom.width / 2;
+ sel_center_y = sel->geom.y + sel->geom.height / 2;
+
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen || c == sel)
+ continue;
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen || c == sel)
+ continue;
+
+ /* Get the center of candidate client */
+ cand_center_x = c->geom.x + c->geom.width / 2;
+ cand_center_y = c->geom.y + c->geom.height / 2;
+ /* Get the center of candidate client */
+ cand_center_x = c->geom.x + c->geom.width / 2;
+ cand_center_y = c->geom.y + c->geom.height / 2;
+
+ /* Check that the candidate lies in the requested direction. */
+ switch (arg->ui) {
+ case 0:
+ if (cand_center_x >= sel_center_x)
+ continue;
+ break;
+ case 1:
+ if (cand_center_x <= sel_center_x)
+ continue;
+ break;
+ case 2:
+ if (cand_center_y >= sel_center_y)
+ continue;
+ break;
+ case 3:
+ if (cand_center_y <= sel_center_y)
+ continue;
+ break;
+ default:
+ continue;
+ }
+ /* Check that the candidate lies in the requested direction. */
+ switch (arg->ui) {
+ case 0:
+ if (cand_center_x >= sel_center_x)
+ continue;
+ break;
+ case 1:
+ if (cand_center_x <= sel_center_x)
+ continue;
+ break;
+ case 2:
+ if (cand_center_y >= sel_center_y)
+ continue;
+ break;
+ case 3:
+ if (cand_center_y <= sel_center_y)
+ continue;
+ break;
+ default:
+ continue;
+ }
+
+ /* Get distance between the centers */
+ dist = abs(sel_center_x - cand_center_x) + abs(sel_center_y - cand_center_y);
+ if (dist < closest_dist) {
+ closest_dist = dist;
+ target = c;
+ }
+ }
+ /* Get distance between the centers */
+ dist = abs(sel_center_x - cand_center_x) + abs(sel_center_y - cand_center_y);
+ if (dist < closest_dist) {
+ closest_dist = dist;
+ target = c;
+ }
+ }
+
+ /* If target is found, swap the two clients positions in the layout tree */
+ if (target) {
+ sel_node = find_client_node(selmon->root, sel);
+ target_node = find_client_node(selmon->root, target);
+ if (sel_node && target_node) {
+ tmp = sel_node->client;
+ sel_node->client = target_node->client;
+ target_node->client = tmp;
+ arrange(selmon);
+ }
+ }
+ /* If target is found, swap the two clients positions in the layout tree */
+ if (target) {
+ sel_node = find_client_node(selmon->root, sel);
+ target_node = find_client_node(selmon->root, target);
+ if (sel_node && target_node) {
+ tmp = sel_node->client;
+ sel_node->client = target_node->client;
+ target_node->client = tmp;
+ arrange(selmon);
+ }
+ }
+}
+
+unsigned int
@@ -558,12 +563,11 @@ index 0000000..24bf4d9
+
+Client *
+xytoclient(double x, double y) {
+ Monitor *m = xytomon(x, y);
+ Client *c, *closest = NULL;
+ double dist, mindist = INT_MAX, dx, dy;
+
+ wl_list_for_each_reverse(c, &clients, link) {
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen &&
+ if (VISIBLEON(c, selmon) && !c->isfloating && !c->isfullscreen &&
+ x >= c->geom.x && x <= (c->geom.x + c->geom.width) &&
+ y >= c->geom.y && y <= (c->geom.y + c->geom.height)){
+ return c;
@@ -572,7 +576,7 @@ index 0000000..24bf4d9
+
+ /* If no client was found at cursor position fallback to closest. */
+ wl_list_for_each_reverse(c, &clients, link) {
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) {
+ if (VISIBLEON(c, selmon) && !c->isfloating && !c->isfullscreen) {
+ dx = 0, dy = 0;
+
+ if (x < c->geom.x)
@@ -585,7 +589,7 @@ index 0000000..24bf4d9
+ else if (y > (c->geom.y + c->geom.height))
+ dy = y - (c->geom.y + c->geom.height);
+
+ dist = dx * dx + dy * dy;
+ dist = sqrt(dx * dx + dy * dy);
+ if (dist < mindist) {
+ mindist = dist;
+ closest = c;
@@ -595,13 +599,13 @@ index 0000000..24bf4d9
+ return closest;
+}
diff --git a/config.def.h b/config.def.h
index 8a6eda0..bc04e3f 100644
index 22d2171..92f3ad6 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,7 +13,10 @@ static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
+static const float resize_factor = 0.0002f; /* Resize multiplier for mouse resizing, depends on mouse sensivity. */
+static const uint32_t resize_interval_ms = 16; /* Resize interval depends on framerate and screen refresh rate. */
@@ -609,7 +613,7 @@ index 8a6eda0..bc04e3f 100644
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
@@ -30,6 +33,7 @@ static const Rule rules[] = {
@@ -31,6 +34,7 @@ static const Rule rules[] = {
/* layout(s) */
static const Layout layouts[] = {
/* symbol arrange function */
@@ -617,23 +621,23 @@ index 8a6eda0..bc04e3f 100644
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
@@ -144,6 +148,14 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up, swapclients, {.i = DIR_UP} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, swapclients, {.i = DIR_DOWN} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, swapclients, {.i = DIR_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, swapclients, {.i = DIR_LEFT} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Right, setratio_h, {.f = +0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Left, setratio_h, {.f = -0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Up, setratio_v, {.f = -0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Down, setratio_v, {.f = +0.025f} },
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
@@ -148,6 +152,14 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up, swapclients, {.i = DIR_UP} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, swapclients, {.i = DIR_DOWN} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, swapclients, {.i = DIR_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, swapclients, {.i = DIR_LEFT} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Right, setratio_h, {.f = +0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Left, setratio_h, {.f = -0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Up, setratio_v, {.f = -0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Down, setratio_v, {.f = +0.025f} },
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 44f3ad9..2529e1f 100644
index a2711f6..e49a061 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1,6 +1,7 @@
@@ -644,24 +648,26 @@ index 44f3ad9..2529e1f 100644
#include <getopt.h>
#include <libinput.h>
#include <linux/input-event-codes.h>
@@ -100,6 +101,7 @@ typedef struct {
@@ -103,6 +104,7 @@ typedef struct {
const Arg arg;
} Button;
+typedef struct LayoutNode LayoutNode;
typedef struct Monitor Monitor;
typedef struct {
/* Must keep this field first */
@@ -137,7 +139,7 @@ typedef struct {
/* Must keep these three elements in this order */
@@ -139,8 +141,9 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, was_tiled;
uint32_t resize; /* configure serial of a pending resize */
+ struct wlr_box old_geom;
} Client;
@@ -205,6 +207,7 @@ struct Monitor {
typedef struct {
@@ -208,6 +211,7 @@ struct Monitor {
int nmaster;
char ltsymbol[16];
int asleep;
@@ -669,7 +675,7 @@ index 44f3ad9..2529e1f 100644
};
typedef struct {
@@ -247,6 +250,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
@@ -250,6 +254,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m);
static void axisnotify(struct wl_listener *listener, void *data);
@@ -677,7 +683,7 @@ index 44f3ad9..2529e1f 100644
static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
static void checkidleinhibitor(struct wlr_surface *exclude);
@@ -329,6 +333,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
@@ -333,6 +338,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
@@ -687,7 +693,7 @@ index 44f3ad9..2529e1f 100644
static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
@@ -454,6 +461,7 @@ static struct wlr_xwayland *xwayland;
@@ -431,6 +439,7 @@ static xcb_atom_t netatom[NetLast];
/* attempt to encapsulate suck into one file */
#include "client.h"
@@ -695,7 +701,7 @@ index 44f3ad9..2529e1f 100644
/* function implementations */
void
@@ -624,7 +632,7 @@ buttonpress(struct wl_listener *listener, void *data)
@@ -601,7 +610,7 @@ buttonpress(struct wl_listener *listener, void *data)
struct wlr_pointer_button_event *event = data;
struct wlr_keyboard *keyboard;
uint32_t mods;
@@ -704,7 +710,7 @@ index 44f3ad9..2529e1f 100644
const Button *b;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@@ -645,7 +653,7 @@ buttonpress(struct wl_listener *listener, void *data)
@@ -622,7 +631,7 @@ buttonpress(struct wl_listener *listener, void *data)
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
for (b = buttons; b < END(buttons); b++) {
if (CLEANMASK(mods) == CLEANMASK(b->mod) &&
@@ -713,9 +719,9 @@ index 44f3ad9..2529e1f 100644
b->func(&b->arg);
return;
}
@@ -655,6 +663,21 @@ buttonpress(struct wl_listener *listener, void *data)
@@ -632,15 +641,36 @@ buttonpress(struct wl_listener *listener, void *data)
/* If you released any buttons, we exit interactive move/resize mode. */
/* TODO: should reset to the pointer focus's current setcursor */
/* TODO should reset to the pointer focus's current setcursor */
if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) {
+ c = grabc;
+ if (c && c->was_tiled && !strcmp(selmon->ltsymbol, "|w|")) {
@@ -728,14 +734,31 @@ index 44f3ad9..2529e1f 100644
+ selmon->root = create_client_node(c);
+
+ setfloating(c, 0);
+ apply_layout(selmon, selmon->root, selmon->w, 1);
+ arrange(selmon);
+
+ } else if (cursor_mode == CurResize && !c->isfloating) {
+ resizing_from_mouse = 0;
+ }
+ } else {
+ if (cursor_mode == CurResize && resizing_from_mouse)
+ resizing_from_mouse = 0;
+ }
+ /* Default behaviour */
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
cursor_mode = CurNormal;
/* Drop the window off on its new monitor */
@@ -746,6 +769,7 @@ cleanupmon(struct wl_listener *listener, void *data)
selmon = xytomon(cursor->x, cursor->y);
setmon(grabc, selmon, 0);
+ grabc = NULL;
return;
- } else {
- cursor_mode = CurNormal;
}
+ cursor_mode = CurNormal;
break;
}
/* If the event wasn't handled by the compositor, notify the client with
@@ -720,6 +750,7 @@ cleanupmon(struct wl_listener *listener, void *data)
wlr_output_layout_remove(output_layout, m->wlr_output);
wlr_scene_output_destroy(m->scene_output);
@@ -743,7 +766,7 @@ index 44f3ad9..2529e1f 100644
closemon(m);
wlr_scene_node_destroy(&m->fullscreen_bg->node);
free(m);
@@ -1090,6 +1114,7 @@ createmon(struct wl_listener *listener, void *data)
@@ -1024,6 +1055,7 @@ createmon(struct wl_listener *listener, void *data)
wl_list_insert(&mons, &m->link);
printstatus();
@@ -751,25 +774,18 @@ index 44f3ad9..2529e1f 100644
/* The xdg-protocol specifies:
*
@@ -1329,9 +1354,17 @@ destroynotify(struct wl_listener *listener, void *data)
{
/* Called when the xdg_toplevel is destroyed. */
Client *c = wl_container_of(listener, c, destroy);
+ Monitor *mon;
@@ -1263,6 +1295,10 @@ destroynotify(struct wl_listener *listener, void *data)
wl_list_remove(&c->destroy.link);
wl_list_remove(&c->set_title.link);
wl_list_remove(&c->fullscreen.link);
+ /* We check if the destroyed client was part of any tiled_list, to catch
+ * client removals even if they would not be currently managed by btrtile */
+ wl_list_for_each(mon, &mons, link) {
+ if (mon->root) {
+ remove_client(mon, c);
+ }
+ }
+ if (selmon && selmon->root)
+ remove_client(selmon, c);
#ifdef XWAYLAND
if (c->type != XDGShell) {
wl_list_remove(&c->activate.link);
@@ -1862,7 +1895,8 @@ void
@@ -1809,7 +1845,8 @@ void
motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
double dx_unaccel, double dy_unaccel)
{
@@ -779,13 +795,13 @@ index 44f3ad9..2529e1f 100644
Client *c = NULL, *w = NULL;
LayerSurface *l = NULL;
struct wlr_surface *surface = NULL;
@@ -1916,18 +1950,55 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
@@ -1863,18 +1900,56 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
/* Update drag icon's position */
wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x), (int)round(cursor->y));
- /* If we are currently grabbing the mouse, handle and return */
+ /* Skip if internal call */
+ if (time == 0)
+ /* Skip if internal call or already resizing */
+ if (time == 0 && resizing_from_mouse)
+ goto focus;
+
+ tiled = grabc && !grabc->isfloating && !grabc->isfullscreen;
@@ -807,7 +823,7 @@ index 44f3ad9..2529e1f 100644
- resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
- .width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
- return;
+ if (tiled) {
+ if (tiled && resizing_from_mouse) {
+ dx_total = cursor->x - resize_last_update_x;
+ dy_total = cursor->y - resize_last_update_y;
+
@@ -820,6 +836,7 @@ index 44f3ad9..2529e1f 100644
+ a.f = (float)(dy_total * resize_factor);
+ setratio_v(&a);
+ }
+ arrange(selmon);
+
+ last_resize_time = time;
+ resize_last_update_x = cursor->x;
@@ -842,7 +859,7 @@ index 44f3ad9..2529e1f 100644
/* If there's no client surface under the cursor, set the cursor image to a
* default. This is what makes the cursor image appear when you move it
* off of a client or over its border. */
@@ -1961,22 +2032,40 @@ moveresize(const Arg *arg)
@@ -1908,22 +1983,41 @@ moveresize(const Arg *arg)
if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen)
return;
@@ -852,7 +869,7 @@ index 44f3ad9..2529e1f 100644
- case CurMove:
- grabcx = (int)round(cursor->x) - grabc->geom.x;
- grabcy = (int)round(cursor->y) - grabc->geom.y;
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "all-scroll");
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur");
- break;
- case CurResize:
- /* Doesn't work for X11 output - the next absolute motion event
@@ -877,6 +894,7 @@ index 44f3ad9..2529e1f 100644
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
+ resize_last_update_x = cursor->x;
+ resize_last_update_y = cursor->y;
+ resizing_from_mouse = 1;
+ break;
+ }
+ } else {
@@ -899,21 +917,6 @@ index 44f3ad9..2529e1f 100644
}
}
@@ -2826,6 +2915,14 @@ unmapnotify(struct wl_listener *listener, void *data)
focusclient(focustop(selmon), 1);
}
} else {
+ /* btrtile remove clients for each monitor */
+ Monitor *mon;
+ wl_list_for_each(mon, &mons, link) {
+ if (mon->root) {
+ remove_client(mon, c);
+ }
+ }
+
wl_list_remove(&c->link);
setmon(c, NULL, 0);
wl_list_remove(&c->flink);
--
2.53.0
2.45.3
@@ -1,35 +1,30 @@
From 04d7c04a0a88e381df788e1ec60398d956543f8b Mon Sep 17 00:00:00 2001
From b9789420f166c20579f29ecd171a8956c681848d Mon Sep 17 00:00:00 2001
From: julmajustus <julmajustus@tutanota.com>
Date: Mon, 22 Jun 2026 22:52:57 +0300
Subject: [PATCH] btrtile: bug fixes and readability improvement
Date: Thu, 13 Feb 2025 23:23:40 +0200
Subject: [PATCH] btrtile with multi-tag support
- Removed client old_geom caching for simplicity fixes: https://codeberg.org/dwl/dwl-patches/issues/647
- Improved readability of the client sanitization loop inside btrtile function
- Removed fullscreened client's from the sanitization loop to retain their geometry
---
btrtile.c | 556 +++++++++++++++++++++++++++++++++++++++++++++++++++
btrtile.c | 563 +++++++++++++++++++++++++++++++++++++++++++++++++++
config.def.h | 12 ++
dwl.c | 151 +++++++++++---
3 files changed, 692 insertions(+), 27 deletions(-)
dwl.c | 152 +++++++++++---
3 files changed, 698 insertions(+), 29 deletions(-)
create mode 100644 btrtile.c
diff --git a/btrtile.c b/btrtile.c
new file mode 100644
index 0000000..6055871
index 0000000..03f4680
--- /dev/null
+++ b/btrtile.c
@@ -0,0 +1,556 @@
@@ -0,0 +1,563 @@
+/* ************************************************************************** */
+/* @@@ @@@@@@@@ */
+/* @@@ @@@@@@@@@@ */
+/* @@! @@! @@@@ */
+/* !@! !@! @!@!@ */
+/* btrtile.c @!! @!@ @! !@! */
+/* !!! !@!!! !!! */
+/* By: julmajustus <julmajustus@tutanota.com> !!: !!:! !!! */
+/* ::! :!: !:! */
+/* Created: 2024/12/15 00:26:07 by julmajustus :: ::::::: :: */
+/* Updated: 2026/06/22 22:52:52 by julmajustus : : : : : : */
+/* */
+/* ::: :::::::: */
+/* btrtile.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: jmakkone <jmakkone@student.hive.fi> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/12/15 00:26:07 by jmakkone #+# #+# */
+/* Updated: 2025/02/13 23:22:33 by jmakkone ### ########.fr */
+/* */
+/* ************************************************************************** */
+
@@ -52,8 +47,7 @@ index 0000000..6055871
+static void destroy_node(LayoutNode *node);
+static void destroy_tree(Monitor *m);
+static LayoutNode *find_client_node(LayoutNode *node, Client *c);
+static LayoutNode *find_suitable_split(Monitor *m, LayoutNode *start,
+ unsigned int need_vertical, int focused_on_left);
+static LayoutNode *find_suitable_split(LayoutNode *start, unsigned int need_vert);
+static void init_tree(Monitor *m);
+static void insert_client(Monitor *m, Client *focused_client, Client *new_client);
+static LayoutNode *remove_client_node(LayoutNode *node, Client *c);
@@ -64,6 +58,7 @@ index 0000000..6055871
+static unsigned int visible_count(LayoutNode *node, Monitor *m);
+static Client *xytoclient(double x, double y);
+
+static int resizing_from_mouse = 0;
+static double resize_last_update_x, resize_last_update_y;
+static uint32_t last_resize_time = 0;
+
@@ -85,6 +80,7 @@ index 0000000..6055871
+ if (!c || !VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ return;
+ resize(c, area, 0);
+ c->old_geom = area;
+ return;
+ }
+
@@ -149,13 +145,15 @@ index 0000000..6055871
+ LayoutNode *found;
+ struct wlr_box full_area;
+
+ if (!m)
+ if (!m || !m->root)
+ return;
+
+ /* Remove floating and moved clients */
+ /* Remove non tiled clients from tree. */
+ wl_list_for_each(c, &clients, link) {
+ if (c->mon != m || c->isfloating)
+ if (c->mon == m && !c->isfloating && !c->isfullscreen) {
+ } else {
+ remove_client(m, c);
+ }
+ }
+
+ /* If no client is found under cursor, fallback to focustop(m) */
@@ -249,37 +247,30 @@ index 0000000..6055871
+}
+
+LayoutNode *
+find_suitable_split(Monitor *m, LayoutNode *start_node,
+ unsigned int need_vertical, int focused_on_left)
+find_suitable_split(LayoutNode *start_node, unsigned int need_vertical)
+{
+ LayoutNode *n = start_node, *child = NULL;
+
+ if (!m)
+ return NULL;
+
+ if (n && n->is_client_node) {
+ child = n;
+ LayoutNode *n = start_node;
+ /* if we started from a client node, jump to its parent: */
+ if (n && n->is_client_node)
+ n = n->split_node;
+ }
+
+ while (n) {
+ if (!n->is_client_node && n->is_split_vertically == need_vertical
+ && visible_count(n->left, m) > 0
+ && visible_count(n->right, m) > 0) {
+ if ((focused_on_left && n->left == child) ||
+ (!focused_on_left && n->right == child))
+ return n;
+ }
+ child = n;
+ if (!n->is_client_node && n->is_split_vertically == need_vertical &&
+ visible_count(n->left, selmon) > 0 && visible_count(n->right, selmon) > 0)
+ return n;
+ n = n->split_node;
+ }
+ return NULL;
+}
+
+void
+init_tree(Monitor *m)
+{
+ if (m)
+ m->root = NULL;
+ if (!m)
+ return;
+ m->root = calloc(1, sizeof(LayoutNode));
+ if (!m->root)
+ m->root = NULL;
+}
+
+void
@@ -403,31 +394,21 @@ index 0000000..6055871
+ m->root = remove_client_node(m->root, c);
+}
+
+static void
+setratio(unsigned int need_vertical, const Arg *arg)
+void
+setratio_h(const Arg *arg)
+{
+ Client *sel;
+ Client *sel = focustop(selmon);
+ LayoutNode *client_node, *split_node;
+ float new_ratio;
+ int focused_on_left;
+
+ if (!selmon || !selmon->lt[selmon->sellt]->arrange)
+ return;
+
+ sel = focustop(selmon);
+ if (!sel)
+ if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange)
+ return;
+
+ client_node = find_client_node(selmon->root, sel);
+ if (!client_node)
+ return;
+
+ focused_on_left = (arg->f >= 0.0f);
+
+ split_node = find_suitable_split(selmon, client_node, need_vertical, focused_on_left);
+
+ if (!split_node)
+ split_node = find_suitable_split(selmon, client_node, need_vertical, !focused_on_left);
+ split_node = find_suitable_split(client_node, 1);
+ if (!split_node)
+ return;
+
@@ -438,85 +419,109 @@ index 0000000..6055871
+ new_ratio = 0.95f;
+ split_node->split_ratio = new_ratio;
+
+ apply_layout(selmon, selmon->root, selmon->w, 1);
+}
+
+void
+setratio_h(const Arg *arg)
+{
+ setratio(1, arg);
+ /* Skip the arrange if done resizing by mouse,
+ * we call arrange from motionotify */
+ if (!resizing_from_mouse) {
+ arrange(selmon);
+ }
+}
+
+void
+setratio_v(const Arg *arg)
+{
+ setratio(0, arg);
+ Client *sel = focustop(selmon);
+ LayoutNode *client_node, *split_node;
+ float new_ratio;
+
+ if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange)
+ return;
+
+ client_node = find_client_node(selmon->root, sel);
+ if (!client_node)
+ return;
+
+ split_node = find_suitable_split(client_node, 0);
+ if (!split_node)
+ return;
+
+ new_ratio = (arg->f != 0.0f) ? (split_node->split_ratio + arg->f) : 0.5f;
+ if (new_ratio < 0.05f)
+ new_ratio = 0.05f;
+ if (new_ratio > 0.95f)
+ new_ratio = 0.95f;
+ split_node->split_ratio = new_ratio;
+
+ /* Skip the arrange if done resizing by mouse,
+ * we call arrange from motionotify */
+ if (!resizing_from_mouse) {
+ arrange(selmon);
+ }
+}
+
+void swapclients(const Arg *arg) {
+ Client *c, *tmp, *target = NULL, *sel = focustop(selmon);
+ Client *c, *tmp, *target = NULL, *sel = focustop(selmon);
+ LayoutNode *sel_node, *target_node;
+ int closest_dist = INT_MAX, dist, sel_center_x, sel_center_y,
+ int closest_dist = INT_MAX, dist, sel_center_x, sel_center_y,
+ cand_center_x, cand_center_y;
+
+ if (!sel || sel->isfullscreen ||
+ !selmon->root || !selmon->lt[selmon->sellt]->arrange)
+ return;
+ if (!sel || sel->isfullscreen ||
+ !selmon->root || !selmon->lt[selmon->sellt]->arrange)
+ return;
+
+
+ /* Get the center coordinates of the selected client */
+ sel_center_x = sel->geom.x + sel->geom.width / 2;
+ sel_center_y = sel->geom.y + sel->geom.height / 2;
+ /* Get the center coordinates of the selected client */
+ sel_center_x = sel->geom.x + sel->geom.width / 2;
+ sel_center_y = sel->geom.y + sel->geom.height / 2;
+
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen || c == sel)
+ continue;
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen || c == sel)
+ continue;
+
+ /* Get the center of candidate client */
+ cand_center_x = c->geom.x + c->geom.width / 2;
+ cand_center_y = c->geom.y + c->geom.height / 2;
+ /* Get the center of candidate client */
+ cand_center_x = c->geom.x + c->geom.width / 2;
+ cand_center_y = c->geom.y + c->geom.height / 2;
+
+ /* Check that the candidate lies in the requested direction. */
+ switch (arg->ui) {
+ case 0:
+ if (cand_center_x >= sel_center_x)
+ continue;
+ break;
+ case 1:
+ if (cand_center_x <= sel_center_x)
+ continue;
+ break;
+ case 2:
+ if (cand_center_y >= sel_center_y)
+ continue;
+ break;
+ case 3:
+ if (cand_center_y <= sel_center_y)
+ continue;
+ break;
+ default:
+ continue;
+ }
+ /* Check that the candidate lies in the requested direction. */
+ switch (arg->ui) {
+ case 0:
+ if (cand_center_x >= sel_center_x)
+ continue;
+ break;
+ case 1:
+ if (cand_center_x <= sel_center_x)
+ continue;
+ break;
+ case 2:
+ if (cand_center_y >= sel_center_y)
+ continue;
+ break;
+ case 3:
+ if (cand_center_y <= sel_center_y)
+ continue;
+ break;
+ default:
+ continue;
+ }
+
+ /* Get distance between the centers */
+ dist = abs(sel_center_x - cand_center_x) + abs(sel_center_y - cand_center_y);
+ if (dist < closest_dist) {
+ closest_dist = dist;
+ target = c;
+ }
+ }
+ /* Get distance between the centers */
+ dist = abs(sel_center_x - cand_center_x) + abs(sel_center_y - cand_center_y);
+ if (dist < closest_dist) {
+ closest_dist = dist;
+ target = c;
+ }
+ }
+
+ /* If target is found, swap the two clients positions in the layout tree */
+ if (target) {
+ sel_node = find_client_node(selmon->root, sel);
+ target_node = find_client_node(selmon->root, target);
+ if (sel_node && target_node) {
+ tmp = sel_node->client;
+ sel_node->client = target_node->client;
+ target_node->client = tmp;
+ arrange(selmon);
+ }
+ }
+ /* If target is found, swap the two clients positions in the layout tree */
+ if (target) {
+ sel_node = find_client_node(selmon->root, sel);
+ target_node = find_client_node(selmon->root, target);
+ if (sel_node && target_node) {
+ tmp = sel_node->client;
+ sel_node->client = target_node->client;
+ target_node->client = tmp;
+ arrange(selmon);
+ }
+ }
+}
+
+unsigned int
@@ -539,12 +544,11 @@ index 0000000..6055871
+
+Client *
+xytoclient(double x, double y) {
+ Monitor *m = xytomon(x, y);
+ Client *c, *closest = NULL;
+ double dist, mindist = INT_MAX, dx, dy;
+
+ wl_list_for_each_reverse(c, &clients, link) {
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen &&
+ if (VISIBLEON(c, selmon) && !c->isfloating && !c->isfullscreen &&
+ x >= c->geom.x && x <= (c->geom.x + c->geom.width) &&
+ y >= c->geom.y && y <= (c->geom.y + c->geom.height)){
+ return c;
@@ -553,7 +557,7 @@ index 0000000..6055871
+
+ /* If no client was found at cursor position fallback to closest. */
+ wl_list_for_each_reverse(c, &clients, link) {
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) {
+ if (VISIBLEON(c, selmon) && !c->isfloating && !c->isfullscreen) {
+ dx = 0, dy = 0;
+
+ if (x < c->geom.x)
@@ -566,7 +570,7 @@ index 0000000..6055871
+ else if (y > (c->geom.y + c->geom.height))
+ dy = y - (c->geom.y + c->geom.height);
+
+ dist = dx * dx + dy * dy;
+ dist = sqrt(dx * dx + dy * dy);
+ if (dist < mindist) {
+ mindist = dist;
+ closest = c;
@@ -576,13 +580,13 @@ index 0000000..6055871
+ return closest;
+}
diff --git a/config.def.h b/config.def.h
index 8a6eda0..bc04e3f 100644
index 22d2171..92f3ad6 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,7 +13,10 @@ static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
+static const float resize_factor = 0.0002f; /* Resize multiplier for mouse resizing, depends on mouse sensivity. */
+static const uint32_t resize_interval_ms = 16; /* Resize interval depends on framerate and screen refresh rate. */
@@ -590,7 +594,7 @@ index 8a6eda0..bc04e3f 100644
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
@@ -30,6 +33,7 @@ static const Rule rules[] = {
@@ -31,6 +34,7 @@ static const Rule rules[] = {
/* layout(s) */
static const Layout layouts[] = {
/* symbol arrange function */
@@ -598,23 +602,23 @@ index 8a6eda0..bc04e3f 100644
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
@@ -144,6 +148,14 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up, swapclients, {.i = DIR_UP} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, swapclients, {.i = DIR_DOWN} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, swapclients, {.i = DIR_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, swapclients, {.i = DIR_LEFT} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Right, setratio_h, {.f = +0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Left, setratio_h, {.f = -0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Up, setratio_v, {.f = -0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Down, setratio_v, {.f = +0.025f} },
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
@@ -148,6 +152,14 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up, swapclients, {.i = DIR_UP} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, swapclients, {.i = DIR_DOWN} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, swapclients, {.i = DIR_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, swapclients, {.i = DIR_LEFT} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Right, setratio_h, {.f = +0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Left, setratio_h, {.f = -0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Up, setratio_v, {.f = -0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Down, setratio_v, {.f = +0.025f} },
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 44f3ad9..2529e1f 100644
index a2711f6..e49a061 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1,6 +1,7 @@
@@ -625,24 +629,26 @@ index 44f3ad9..2529e1f 100644
#include <getopt.h>
#include <libinput.h>
#include <linux/input-event-codes.h>
@@ -100,6 +101,7 @@ typedef struct {
@@ -103,6 +104,7 @@ typedef struct {
const Arg arg;
} Button;
+typedef struct LayoutNode LayoutNode;
typedef struct Monitor Monitor;
typedef struct {
/* Must keep this field first */
@@ -137,7 +139,7 @@ typedef struct {
/* Must keep these three elements in this order */
@@ -139,8 +141,9 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, was_tiled;
uint32_t resize; /* configure serial of a pending resize */
+ struct wlr_box old_geom;
} Client;
@@ -205,6 +207,7 @@ struct Monitor {
typedef struct {
@@ -208,6 +211,7 @@ struct Monitor {
int nmaster;
char ltsymbol[16];
int asleep;
@@ -650,7 +656,7 @@ index 44f3ad9..2529e1f 100644
};
typedef struct {
@@ -247,6 +250,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
@@ -250,6 +254,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m);
static void axisnotify(struct wl_listener *listener, void *data);
@@ -658,7 +664,7 @@ index 44f3ad9..2529e1f 100644
static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
static void checkidleinhibitor(struct wlr_surface *exclude);
@@ -329,6 +333,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
@@ -333,6 +338,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
@@ -668,7 +674,7 @@ index 44f3ad9..2529e1f 100644
static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
@@ -454,6 +461,7 @@ static struct wlr_xwayland *xwayland;
@@ -431,6 +439,7 @@ static xcb_atom_t netatom[NetLast];
/* attempt to encapsulate suck into one file */
#include "client.h"
@@ -676,7 +682,7 @@ index 44f3ad9..2529e1f 100644
/* function implementations */
void
@@ -624,7 +632,7 @@ buttonpress(struct wl_listener *listener, void *data)
@@ -601,7 +610,7 @@ buttonpress(struct wl_listener *listener, void *data)
struct wlr_pointer_button_event *event = data;
struct wlr_keyboard *keyboard;
uint32_t mods;
@@ -685,7 +691,7 @@ index 44f3ad9..2529e1f 100644
const Button *b;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@@ -645,7 +653,7 @@ buttonpress(struct wl_listener *listener, void *data)
@@ -622,7 +631,7 @@ buttonpress(struct wl_listener *listener, void *data)
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
for (b = buttons; b < END(buttons); b++) {
if (CLEANMASK(mods) == CLEANMASK(b->mod) &&
@@ -694,9 +700,9 @@ index 44f3ad9..2529e1f 100644
b->func(&b->arg);
return;
}
@@ -655,6 +663,21 @@ buttonpress(struct wl_listener *listener, void *data)
@@ -632,15 +641,36 @@ buttonpress(struct wl_listener *listener, void *data)
/* If you released any buttons, we exit interactive move/resize mode. */
/* TODO: should reset to the pointer focus's current setcursor */
/* TODO should reset to the pointer focus's current setcursor */
if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) {
+ c = grabc;
+ if (c && c->was_tiled && !strcmp(selmon->ltsymbol, "|w|")) {
@@ -709,14 +715,31 @@ index 44f3ad9..2529e1f 100644
+ selmon->root = create_client_node(c);
+
+ setfloating(c, 0);
+ apply_layout(selmon, selmon->root, selmon->w, 1);
+ arrange(selmon);
+
+ } else if (cursor_mode == CurResize && !c->isfloating) {
+ resizing_from_mouse = 0;
+ }
+ } else {
+ if (cursor_mode == CurResize && resizing_from_mouse)
+ resizing_from_mouse = 0;
+ }
+ /* Default behaviour */
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
cursor_mode = CurNormal;
/* Drop the window off on its new monitor */
@@ -746,6 +769,7 @@ cleanupmon(struct wl_listener *listener, void *data)
selmon = xytomon(cursor->x, cursor->y);
setmon(grabc, selmon, 0);
+ grabc = NULL;
return;
- } else {
- cursor_mode = CurNormal;
}
+ cursor_mode = CurNormal;
break;
}
/* If the event wasn't handled by the compositor, notify the client with
@@ -720,6 +750,7 @@ cleanupmon(struct wl_listener *listener, void *data)
wlr_output_layout_remove(output_layout, m->wlr_output);
wlr_scene_output_destroy(m->scene_output);
@@ -724,7 +747,7 @@ index 44f3ad9..2529e1f 100644
closemon(m);
wlr_scene_node_destroy(&m->fullscreen_bg->node);
free(m);
@@ -1090,6 +1114,7 @@ createmon(struct wl_listener *listener, void *data)
@@ -1024,6 +1055,7 @@ createmon(struct wl_listener *listener, void *data)
wl_list_insert(&mons, &m->link);
printstatus();
@@ -732,25 +755,18 @@ index 44f3ad9..2529e1f 100644
/* The xdg-protocol specifies:
*
@@ -1329,9 +1354,17 @@ destroynotify(struct wl_listener *listener, void *data)
{
/* Called when the xdg_toplevel is destroyed. */
Client *c = wl_container_of(listener, c, destroy);
+ Monitor *mon;
@@ -1263,6 +1295,10 @@ destroynotify(struct wl_listener *listener, void *data)
wl_list_remove(&c->destroy.link);
wl_list_remove(&c->set_title.link);
wl_list_remove(&c->fullscreen.link);
+ /* We check if the destroyed client was part of any tiled_list, to catch
+ * client removals even if they would not be currently managed by btrtile */
+ wl_list_for_each(mon, &mons, link) {
+ if (mon->root) {
+ remove_client(mon, c);
+ }
+ }
+ if (selmon && selmon->root)
+ remove_client(selmon, c);
#ifdef XWAYLAND
if (c->type != XDGShell) {
wl_list_remove(&c->activate.link);
@@ -1862,7 +1895,8 @@ void
@@ -1809,7 +1845,8 @@ void
motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
double dx_unaccel, double dy_unaccel)
{
@@ -760,13 +776,13 @@ index 44f3ad9..2529e1f 100644
Client *c = NULL, *w = NULL;
LayerSurface *l = NULL;
struct wlr_surface *surface = NULL;
@@ -1916,18 +1950,55 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
@@ -1863,18 +1900,56 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
/* Update drag icon's position */
wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x), (int)round(cursor->y));
- /* If we are currently grabbing the mouse, handle and return */
+ /* Skip if internal call */
+ if (time == 0)
+ /* Skip if internal call or already resizing */
+ if (time == 0 && resizing_from_mouse)
+ goto focus;
+
+ tiled = grabc && !grabc->isfloating && !grabc->isfullscreen;
@@ -788,7 +804,7 @@ index 44f3ad9..2529e1f 100644
- resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
- .width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
- return;
+ if (tiled) {
+ if (tiled && resizing_from_mouse) {
+ dx_total = cursor->x - resize_last_update_x;
+ dy_total = cursor->y - resize_last_update_y;
+
@@ -801,6 +817,7 @@ index 44f3ad9..2529e1f 100644
+ a.f = (float)(dy_total * resize_factor);
+ setratio_v(&a);
+ }
+ arrange(selmon);
+
+ last_resize_time = time;
+ resize_last_update_x = cursor->x;
@@ -823,7 +840,7 @@ index 44f3ad9..2529e1f 100644
/* If there's no client surface under the cursor, set the cursor image to a
* default. This is what makes the cursor image appear when you move it
* off of a client or over its border. */
@@ -1961,22 +2032,40 @@ moveresize(const Arg *arg)
@@ -1908,22 +1983,41 @@ moveresize(const Arg *arg)
if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen)
return;
@@ -833,7 +850,7 @@ index 44f3ad9..2529e1f 100644
- case CurMove:
- grabcx = (int)round(cursor->x) - grabc->geom.x;
- grabcy = (int)round(cursor->y) - grabc->geom.y;
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "all-scroll");
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur");
- break;
- case CurResize:
- /* Doesn't work for X11 output - the next absolute motion event
@@ -858,6 +875,7 @@ index 44f3ad9..2529e1f 100644
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
+ resize_last_update_x = cursor->x;
+ resize_last_update_y = cursor->y;
+ resizing_from_mouse = 1;
+ break;
+ }
+ } else {
@@ -880,21 +898,6 @@ index 44f3ad9..2529e1f 100644
}
}
@@ -2826,6 +2915,14 @@ unmapnotify(struct wl_listener *listener, void *data)
focusclient(focustop(selmon), 1);
}
} else {
+ /* btrtile remove clients for each monitor */
+ Monitor *mon;
+ wl_list_for_each(mon, &mons, link) {
+ if (mon->root) {
+ remove_client(mon, c);
+ }
+ }
+
wl_list_remove(&c->link);
setmon(c, NULL, 0);
wl_list_remove(&c->flink);
--
2.53.0
2.45.3
+1 -1
View File
@@ -7,7 +7,7 @@ covering the wallpaper more than necessary.
### Download
- [git branch](https://codeberg.org/guidocella/dwl/src/branch/center-terminal)
- [2026-09-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/center-terminal/center-terminal.patch)
- [2024-02-06](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/center-terminal/center-terminal.patch)
### Authors
- [Guido Cella](https://codeberg.org/guidocella)
+22 -22
View File
@@ -1,6 +1,6 @@
From 974db1c4a01a38e2c2af9460e4d9c5f48e7974f7 Mon Sep 17 00:00:00 2001
From 340cc5ef90dfcc495bdad045f3f76ae07405cffd Mon Sep 17 00:00:00 2001
From: Guido Cella <guido@guidocella.xyz>
Date: Mon, 9 Feb 2026 10:21:33 +0100
Date: Tue, 6 Feb 2024 09:20:48 +0100
Subject: [PATCH] add a keybinding to center the terminal
Add a keybinding that toggles centering the terminally horizontally when
@@ -14,22 +14,22 @@ covering the wallpaper more than necessary.
2 files changed, 21 insertions(+)
diff --git a/config.def.h b/config.def.h
index 13c5322..aef03cb 100644
index 22d2171..8229fcc 100644
--- a/config.def.h
+++ b/config.def.h
@@ -138,6 +138,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_v, togglecenter, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_0, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
@@ -142,6 +142,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_v, togglecenter, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
diff --git a/dwl.c b/dwl.c
index f7bda0b..cfdd4d1 100644
index 12f441e..3b15748 100644
--- a/dwl.c
+++ b/dwl.c
@@ -9,6 +9,7 @@
@@ -8,6 +8,7 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -37,15 +37,15 @@ index f7bda0b..cfdd4d1 100644
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
@@ -158,6 +159,7 @@ typedef struct {
@@ -138,6 +139,7 @@ typedef struct {
unsigned int bw;
uint32_t tags;
int isfloating, isurgent, isfullscreen;
+ bool centered;
uint32_t resize; /* configure serial of a pending resize */
} Client;
typedef struct {
@@ -354,6 +356,7 @@ static void startdrag(struct wl_listener *listener, void *data);
@@ -334,6 +336,7 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
@@ -53,16 +53,16 @@ index f7bda0b..cfdd4d1 100644
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -460,6 +463,8 @@ static struct wl_listener start_drag = {.notify = startdrag};
@@ -436,6 +439,8 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener new_session_lock = {.notify = locksession};
static struct wl_listener new_foreign_toplevel_capture_request = {.notify = capturerequest};
+static bool center;
+
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -534,6 +539,9 @@ applyrules(Client *c)
@@ -499,6 +504,9 @@ applyrules(Client *c)
}
}
@@ -72,7 +72,7 @@ index f7bda0b..cfdd4d1 100644
c->isfloating |= client_is_float_type(c);
setmon(c, mon, newtags);
}
@@ -2886,6 +2894,11 @@ tile(Monitor *m)
@@ -2730,6 +2738,11 @@ tile(Monitor *m)
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
if (i < m->nmaster) {
@@ -84,7 +84,7 @@ index f7bda0b..cfdd4d1 100644
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;
@@ -2898,6 +2911,13 @@ tile(Monitor *m)
@@ -2742,6 +2755,13 @@ tile(Monitor *m)
}
}
@@ -99,5 +99,5 @@ index f7bda0b..cfdd4d1 100644
togglefloating(const Arg *arg)
{
--
2.55.0
2.49.0
+1 -5
View File
@@ -22,16 +22,12 @@ With one and two clients in master respectively this results in:
+------------------------------+ +------------------------------+
```
Version 0.8 includes `centeredmaster_always` setting to always center a window
even if only 1 window is visible on a tag.
### Download
- [0.8](/dwl/dwl-patches/raw/branch/main/patches/centeredmaster/centeredmaster-0.8.patch)
- [0.7](/dwl/dwl-patches/raw/branch/main/patches/centeredmaster/centeredmaster-0.7.patch)
- [0.7](/dwl/dwl-patches/raw/branch/main/patches/centeredmaster/centeredmaster.patch)
- [2024-04-11](https://codeberg.org/dwl/dwl-patches/raw/commit/b104a580a80ebaf9f7e8917fe574e3e97ddd019a/centeredmaster/centeredmaster.patch)
- [0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/0f4e40fee49d1b8b430778e241b29496ae3b3b70/centeredmaster/centeredmaster.patch)
### Authors
- [Nikita Ivanov](https://codeberg.org/nikitaivanov) ([GitHub](https://github.com/NikitaIvanovV))
- [wochap](https://codeberg.org/wochap)
- [metalcranium](https://codeberg.org/metalcranium)
@@ -1,132 +0,0 @@
From d3d0000c3e2baa8c2a4633581186f768c909667a Mon Sep 17 00:00:00 2001
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
Date: Mon, 13 Apr 2026 18:24:17 +0200
Subject: [PATCH] Add centeredmaster layout
---
config.def.h | 3 +++
dwl.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..15cbe32 100644
--- a/config.def.h
+++ b/config.def.h
@@ -7,6 +7,7 @@
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 unsigned int borderpx = 1; /* border pixel of windows */
+static const int centeredmaster_always = 0; /* always center even if only 1 window */
static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
@@ -33,6 +34,7 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "|M|", centeredmaster },
};
/* monitors */
@@ -135,6 +137,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XKB_KEY_c, setlayout, {.v = &layouts[3]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index 44f3ad9..98ba318 100644
--- a/dwl.c
+++ b/dwl.c
@@ -248,6 +248,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
static void arrangelayers(Monitor *m);
static void axisnotify(struct wl_listener *listener, void *data);
static void buttonpress(struct wl_listener *listener, void *data);
+static void centeredmaster(Monitor *m);
static void chvt(const Arg *arg);
static void checkidleinhibitor(struct wlr_surface *exclude);
static void cleanup(void);
@@ -672,6 +673,78 @@ buttonpress(struct wl_listener *listener, void *data)
event->time_msec, event->button, event->state);
}
+void
+centeredmaster(Monitor *m)
+{
+ int i, n, h, mw, mx, my, oty, ety, tw;
+ Client *c;
+
+ n = 0;
+ wl_list_for_each(c, &clients, link)
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
+ n++;
+ if (n == 0)
+ return;
+
+ /* initialize areas */
+ if (centeredmaster_always) {
+ mw = m->w.width / 2;
+ mx = m->w.width / 4;
+ } else {
+ mw = m->w.width;
+ mx = 0;
+ }
+ my = 0;
+ tw = mw;
+
+ if (n > m->nmaster) {
+ /* go mfact box in the center if more than nmaster clients */
+ if (centeredmaster_always) {
+ mw = m->nmaster ? (int)roundf(m->w.width / 2) : 0;
+ tw = mw / 2;
+ } else {
+ mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
+ tw = m->w.width - mw;
+ }
+
+ if (n - m->nmaster > 1) {
+ /* only one client */
+ mx = (m->w.width - mw) / 2;
+ tw = (m->w.width - mw) / 2;
+ }
+ }
+
+ i = 0;
+ oty = 0;
+ ety = 0;
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+ if (i < m->nmaster) {
+ /* nmaster clients are stacked vertically, in the center
+ * of the screen */
+ h = (m->w.height - my) / (MIN(n, m->nmaster) - i);
+ resize(c, (struct wlr_box){.x = m->w.x + mx, .y = m->w.y + my, .width = mw,
+ .height = h}, 0);
+ my += c->geom.height;
+ } else {
+ /* stack clients are stacked vertically */
+ if ((i - m->nmaster) % 2) {
+ h = (m->w.height - ety) / ( (1 + n - i) / 2);
+ resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + ety, .width = tw,
+ .height = h}, 0);
+ ety += c->geom.height;
+ } else {
+ h = (m->w.height - oty) / ((1 + n - i) / 2);
+ resize(c, (struct wlr_box){.x = m->w.x + mx + mw, .y = m->w.y + oty, .width = tw,
+ .height = h}, 0);
+ oty += c->geom.height;
+ }
+ }
+ i++;
+ }
+}
+
void
chvt(const Arg *arg)
{
--
2.53.0
-20
View File
@@ -1,20 +0,0 @@
### Description
This patch is based on the
[client-opacity](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/client-opacity/client-opacity.patch)
patch. This patch adds differing opacity levels depending upon whether the client is focused or not.
The opacity levels can be change by short cuts.
```
[MODKEY]+[Ctrl]+[k] -> increase focus opacity unfocused client
[MODKEY]+[Ctrl]+[j] -> decrease focus opacity unfocused client
[MODKEY]+[Ctrl]+[Shift]+[k] -> increase focus opacity focused client
[MODKEY]+[Ctrl]+[Shift]+[j] -> decrease focus opacity focused client
```
### Download
- [git branch](https://codeberg.org/Hansvon/dwl/src/branch/client-opacity-focus)
- [2026-04-27](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/client-opacity-focus/client-opacity-focus.patch)
### Authors
- [Hansvon](https://codeberg.org/Hansvon)
@@ -1,204 +0,0 @@
From 57c5475d7f715b77ec05d69a2bda808b224cf0b4 Mon Sep 17 00:00:00 2001
From: Hans von Hohenstaufen <Hans.von.Hohenstaufen@protonmail.com>
Date: Mon, 22 Dec 2025 01:43:50 +0000
Subject: [PATCH] Add client opacity focus
---
config.def.h | 12 +++++++---
dwl.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 95c2afa..55abf84 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,6 +13,8 @@ static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
+static const float default_opacity_unfocus = 0.70f;
+static const float default_opacity_focus = 1.00f;
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
@@ -22,10 +24,10 @@ static int log_level = WLR_ERROR;
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
+ /* app_id title tags mask isfloating alpha focus alpha unfocus monitor */
/* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ { "Gimp_EXAMPLE", NULL, 0, 1, 1.00, 0.20, -1 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, 1.00, 1.00, -1 }, /* Start on ONLY tag "9" */
};
/* layout(s) */
@@ -139,6 +141,10 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_k, setopacityunfocus, {.f = +0.1f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_j, setopacityunfocus, {.f = -0.1f} },
+ { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT, XKB_KEY_K, setopacityfocus, {.f = +0.1f} },
+ { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT, XKB_KEY_J, setopacityfocus, {.f = -0.1f} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index 12f441e..e45e420 100644
--- a/dwl.c
+++ b/dwl.c
@@ -138,6 +138,9 @@ typedef struct {
unsigned int bw;
uint32_t tags;
int isfloating, isurgent, isfullscreen;
+ float opacity;
+ float opacity_focus;
+ float opacity_unfocus;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -227,6 +230,8 @@ typedef struct {
const char *title;
uint32_t tags;
int isfloating;
+ float opacity_focus;
+ float opacity_unfocus;
int monitor;
} Rule;
@@ -319,6 +324,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
static void requestmonstate(struct wl_listener *listener, void *data);
static void resize(Client *c, struct wlr_box geo, int interact);
static void run(char *startup_cmd);
+static void scenebuffersetopacity(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data);
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);
@@ -326,6 +332,8 @@ static void setfullscreen(Client *c, int fullscreen);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, uint32_t newtags);
+static void setopacityunfocus(const Arg *arg);
+static void setopacityfocus(const Arg *arg);
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
@@ -490,6 +498,8 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
+ c->opacity_unfocus = r->opacity_unfocus;
+ c->opacity_focus = r->opacity_focus;
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -1127,6 +1137,10 @@ createnotify(struct wl_listener *listener, void *data)
c = toplevel->base->data = ecalloc(1, sizeof(*c));
c->surface.xdg = toplevel->base;
c->bw = borderpx;
+ /* Set default opacity*/
+ c->opacity_unfocus = default_opacity_unfocus;
+ c->opacity_focus = default_opacity_focus;
+ c->opacity = default_opacity_unfocus;
LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify);
LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify);
@@ -1429,6 +1443,7 @@ focusclient(Client *c, int lift)
wl_list_insert(&fstack, &c->flink);
selmon = c->mon;
c->isurgent = 0;
+ c->opacity = c->opacity_focus;
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
@@ -1453,6 +1468,7 @@ focusclient(Client *c, int lift)
client_set_border_color(old_c, bordercolor);
client_activate_surface(old, 0);
+ old_c->opacity = old_c->opacity_unfocus;
}
}
printstatus();
@@ -2159,6 +2175,7 @@ rendermon(struct wl_listener *listener, void *data)
/* Render if no XDG clients have an outstanding resize and are visible on
* this monitor. */
wl_list_for_each(c, &clients, link) {
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, scenebuffersetopacity, c);
if (c->resize && !c->isfloating && client_is_rendered_on_mon(c, m) && !client_is_stopped(c))
goto skip;
}
@@ -2295,6 +2312,15 @@ run(char *startup_cmd)
wl_display_run(dpy);
}
+void
+scenebuffersetopacity(struct wlr_scene_buffer *buffer, int sx, int sy, void *data)
+{
+ Client *c = data;
+ /* xdg-popups are children of Client.scene, we do not have to worry about
+ * messing with them. */
+ wlr_scene_buffer_set_opacity(buffer, c->isfullscreen ? 1 : c->opacity);
+}
+
void
setcursor(struct wl_listener *listener, void *data)
{
@@ -2363,6 +2389,7 @@ setfullscreen(Client *c, int fullscreen)
* client positions are set by the user and cannot be recalculated */
resize(c, c->prev, 0);
}
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, scenebuffersetopacity, c);
arrange(c->mon);
printstatus();
}
@@ -2419,6 +2446,44 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
focusclient(focustop(selmon), 1);
}
+
+void
+setopacityunfocus(const Arg *arg)
+{
+ Client *sel = focustop(selmon);
+ if (!sel)
+ return;
+
+ sel->opacity_unfocus += arg->f;
+ if (sel->opacity_unfocus > 1.0)
+ sel->opacity_unfocus = 1.0f;
+
+ if (sel->opacity_unfocus < 0.1)
+ sel->opacity_unfocus = 0.1f;
+
+ wlr_scene_node_for_each_buffer(&sel->scene_surface->node, scenebuffersetopacity, sel);
+}
+
+void
+setopacityfocus(const Arg *arg)
+{
+ Client *sel = focustop(selmon);
+ if (!sel)
+ return;
+
+ sel->opacity_focus += arg->f;
+ if (sel->opacity_focus > 1.0)
+ sel->opacity_focus = 1.0f;
+
+ if (sel->opacity_focus < 0.1)
+ sel->opacity_focus = 0.1f;
+
+ /* Change opacity from current client */
+ sel->opacity = sel->opacity_focus;
+
+ wlr_scene_node_for_each_buffer(&sel->scene_surface->node, scenebuffersetopacity, sel);
+}
+
void
setpsel(struct wl_listener *listener, void *data)
{
--
2.53.0
+32 -23
View File
@@ -7,22 +7,21 @@ Subject: [PATCH] add default transparency for windows and rules for override
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
Modified-by: Yuki <yukii.senp@gmail.com>
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
---
config.def.h | 9 ++++++---
dwl.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 3 deletions(-)
dwl.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 95c2afa..808242a 100644
index 22d2171d..0eb86874 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,6 +13,7 @@ static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
+static const float default_opacity = 0.75;
/* tagging - TAGCOUNT must be no greater than 31 */
@@ -51,7 +50,7 @@ index 95c2afa..808242a 100644
{ MODKEY, XKB_KEY_Tab, view, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
diff --git a/dwl.c b/dwl.c
index 12f441e..f547148 100644
index ad21e1ba..0554fcdf 100644
--- a/dwl.c
+++ b/dwl.c
@@ -138,6 +138,7 @@ typedef struct {
@@ -86,7 +85,7 @@ index 12f441e..f547148 100644
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
@@ -490,6 +494,7 @@ applyrules(Client *c)
@@ -491,6 +495,7 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
@@ -94,7 +93,26 @@ index 12f441e..f547148 100644
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -1127,6 +1132,7 @@ createnotify(struct wl_listener *listener, void *data)
@@ -499,6 +504,8 @@ applyrules(Client *c)
}
}
}
+ if (c->scene_surface)
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, scenebuffersetopacity, c);
setmon(c, mon, newtags);
}
@@ -874,6 +881,9 @@ commitnotify(struct wl_listener *listener, void *data)
resize(c, c->geom, (c->isfloating && !c->isfullscreen));
+ if (c->scene_surface)
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, scenebuffersetopacity, c);
+
/* mark a pending resize as completed */
if (c->resize && c->resize <= c->surface.xdg->current.configure_serial)
c->resize = 0;
@@ -1120,6 +1130,7 @@ createnotify(struct wl_listener *listener, void *data)
c = toplevel->base->data = ecalloc(1, sizeof(*c));
c->surface.xdg = toplevel->base;
c->bw = borderpx;
@@ -102,16 +120,7 @@ index 12f441e..f547148 100644
LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify);
LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify);
@@ -2159,6 +2165,8 @@ rendermon(struct wl_listener *listener, void *data)
/* Render if no XDG clients have an outstanding resize and are visible on
* this monitor. */
wl_list_for_each(c, &clients, link) {
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, scenebuffersetopacity, c);
+
if (c->resize && !c->isfloating && client_is_rendered_on_mon(c, m) && !client_is_stopped(c))
goto skip;
}
@@ -2295,6 +2303,15 @@ run(char *startup_cmd)
@@ -2285,6 +2296,15 @@ run(char *startup_cmd)
wl_display_run(dpy);
}
@@ -127,7 +136,7 @@ index 12f441e..f547148 100644
void
setcursor(struct wl_listener *listener, void *data)
{
@@ -2363,6 +2380,7 @@ setfullscreen(Client *c, int fullscreen)
@@ -2353,6 +2373,7 @@ setfullscreen(Client *c, int fullscreen)
* client positions are set by the user and cannot be recalculated */
resize(c, c->prev, 0);
}
@@ -135,7 +144,7 @@ index 12f441e..f547148 100644
arrange(c->mon);
printstatus();
}
@@ -2419,6 +2437,23 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
@@ -2409,6 +2430,23 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
focusclient(focustop(selmon), 1);
}
@@ -159,7 +168,7 @@ index 12f441e..f547148 100644
void
setpsel(struct wl_listener *listener, void *data)
{
@@ -3130,6 +3165,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
@@ -3120,6 +3158,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
c->surface.xwayland = xsurface;
c->type = X11;
c->bw = client_is_unmanaged(c) ? 0 : borderpx;
@@ -168,5 +177,5 @@ index 12f441e..f547148 100644
/* Listen to the various events it can emit */
LISTEN(&xsurface->events.associate, &c->associate, associatex11);
--
2.51.0
2.48.0
+69 -75
View File
@@ -1,83 +1,78 @@
From 54ad3a9005a127a957bf081b0be765dcaff18c5d Mon Sep 17 00:00:00 2001
From 4d55356e918fd75a07d05db3ea28798a016405a4 Mon Sep 17 00:00:00 2001
From: Alex Denes <caskd@redxen.eu>
Date: Thu, 10 Jul 2025 12:01:29 +0000
Subject: [PATCH] Implement color manager
---
Makefile | 9 ++++++++-
config.def.h | 24 ++++++++++++++++++++----
dwl.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 79 insertions(+), 5 deletions(-)
Makefile | 6 +++++-
config.def.h | 8 +++++---
config.mk | 4 ++--
dwl.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 62 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index 3981fbb..190f29c 100644
index 578194f..570d5f5 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,8 @@ dwl: dwl.o util.o
@@ -21,7 +21,8 @@ dwl: dwl.o util.o
$(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \
ext-image-copy-capture-v1-protocol.h \
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
- wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
+ wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h \
+ color-management-v1-protocol.h color-representation-v1-protocol.h
+ color-management-v1-protocol.h
util.o: util.c util.h
# wayland-scanner is a tool which generates C headers and rigging for Wayland
@@ -43,6 +44,12 @@ pointer-constraints-unstable-v1-protocol.h:
@@ -39,6 +40,9 @@ pointer-constraints-unstable-v1-protocol.h:
wlr-layer-shell-unstable-v1-protocol.h:
$(WAYLAND_SCANNER) enum-header \
protocols/wlr-layer-shell-unstable-v1.xml $@
+color-management-v1-protocol.h:
+ $(WAYLAND_SCANNER) enum-header \
+ $(WAYLAND_PROTOCOLS)/staging/color-management/color-management-v1.xml $@
+color-representation-v1-protocol.h:
+ $(WAYLAND_SCANNER) enum-header \
+ $(WAYLAND_PROTOCOLS)/staging/color-representation/color-representation-v1.xml $@
wlr-output-power-management-unstable-v1-protocol.h:
$(WAYLAND_SCANNER) server-header \
protocols/wlr-output-power-management-unstable-v1.xml $@
diff --git a/config.def.h b/config.def.h
index 8a6eda0..d203edc 100644
index 95c2afa..43af85b 100644
--- a/config.def.h
+++ b/config.def.h
@@ -35,15 +35,31 @@ static const Layout layouts[] = {
{ "[M]", monocle },
};
+
+/*
+static struct wlr_output_image_description generic_bt2020_pq = {
+ .primaries = WLR_COLOR_NAMED_PRIMARIES_BT2020,
+ .transfer_function = WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ,
+ .max_cll = 10000,
+ .max_fall = 400,
+ .mastering_luminance = {
+ .min = 0,
+ .max = 10000,
+ },
+};
+*/
+
/* monitors */
/* (x=-1, y=-1) is reserved as an "autoconfigure" monitor position indicator
* WARNING: negative values other than (-1, -1) cause problems with Xwayland clients due to
* https://gitlab.freedesktop.org/xorg/xserver/-/issues/899 */
@@ -43,12 +43,14 @@ static const Layout layouts[] = {
*/
/* NOTE: ALWAYS add a fallback rule, even if you are completely sure it won't be used */
static const MonitorRule monrules[] = {
- /* name mfact nmaster scale layout rotate/reflect x y
- * example of a HiDPI laptop monitor:
- { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, */
- /* name mfact nmaster scale layout rotate/reflect x y */
+ /* name mfact nmaster scale layout rotate/reflect x y hdr render_format */
/* example of a HiDPI laptop monitor:
- { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
+ { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, 0, DRM_FORMAT_XRGB8888 },
+ * HDR Example
+ { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, 1, DRM_FORMAT_XRGB2101010 },
*/
/* defaults */
- { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
+ /* name mfact nmaster scale layout rotate/reflect x y image_desc pixel_format
+ * example of a HiDPI laptop monitor:
+ { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, NULL, DRM_FORMAT_XRGB8888 },
+ * HDR Example
+ { NULL, 0.5f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, &generic_bt2020_pq, DRM_FORMAT_XRGB2101010 }, */
+ { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, NULL, DRM_FORMAT_XRGB8888 },
/* default monitor rule: can be changed but cannot be eliminated; at least one monitor rule must exist */
+ { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, 0, DRM_FORMAT_XRGB8888 },
};
/* keyboard */
diff --git a/config.mk b/config.mk
index eb08a05..f641d04 100644
--- a/config.mk
+++ b/config.mk
@@ -8,8 +8,8 @@ PREFIX = /usr/local
MANDIR = $(PREFIX)/share/man
DATADIR = $(PREFIX)/share
-WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.19`
-WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.19`
+WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.20`
+WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.20`
# Allow using an alternative wlroots installation
# This has to have all the includes required by wlroots, e.g:
diff --git a/dwl.c b/dwl.c
index 8101ffa..4c3f12a 100644
index 12f441e..39812ce 100644
--- a/dwl.c
+++ b/dwl.c
@@ -4,6 +4,7 @@
@@ -88,26 +83,25 @@ index 8101ffa..4c3f12a 100644
#include <math.h>
#include <signal.h>
#include <stdio.h>
@@ -18,6 +19,8 @@
@@ -18,6 +19,7 @@
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_alpha_modifier_v1.h>
#include <wlr/types/wlr_compositor.h>
+#include <wlr/types/wlr_color_management_v1.h>
+#include <wlr/types/wlr_color_representation_v1.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_cursor_shape_v1.h>
#include <wlr/types/wlr_data_control_v1.h>
@@ -219,6 +222,9 @@ typedef struct {
@@ -215,6 +217,9 @@ typedef struct {
const Layout *lt;
enum wl_output_transform rr;
int x, y;
+
+ struct wlr_output_image_description *image_desc;
+ int hdr;
+ uint32_t render_format;
} MonitorRule;
typedef struct {
@@ -386,6 +392,7 @@ static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
@@ -382,6 +387,7 @@ static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr;
static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr;
static struct wlr_output_power_manager_v1 *power_mgr;
@@ -115,28 +109,27 @@ index 8101ffa..4c3f12a 100644
static struct wlr_pointer_constraints_v1 *pointer_constraints;
static struct wlr_relative_pointer_manager_v1 *relative_pointer_mgr;
@@ -1088,6 +1095,20 @@ createmon(struct wl_listener *listener, void *data)
@@ -1084,6 +1090,19 @@ createmon(struct wl_listener *listener, void *data)
LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon);
LISTEN(&wlr_output->events.request_state, &m->request_state, requestmonstate);
+ /* Enable HDR if supported and desired */
+ if ((r->image_desc) && (drw->features.output_color_transform) &&
+ (wlr_output->supported_primaries & r->image_desc->primaries) &&
+ (wlr_output->supported_transfer_functions & r->image_desc->transfer_function)) {
+ // Set framebuffer pixel format to one requested
+ if ((r->hdr) &&
+ (wlr_output->supported_primaries & WLR_COLOR_NAMED_PRIMARIES_BT2020) &&
+ (wlr_output->supported_transfer_functions & WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ) &&
+ (drw->features.output_color_transform)) {
+ const struct wlr_output_image_description image_desc = {
+ .primaries = WLR_COLOR_NAMED_PRIMARIES_BT2020,
+ .transfer_function = WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ,
+ };
+ wlr_output_state_set_render_format(&state, r->render_format);
+ // Check if unset and use default well-known primaries (white point will never be 0.0 if set)
+ struct wlr_color_primaries *prim = &r->image_desc->mastering_display_primaries;
+ if (prim->white.x == 0.0 && prim->white.y == 0.0) {
+ wlr_color_primaries_from_named (&r->image_desc->mastering_display_primaries, r->image_desc->primaries);
+ }
+ wlr_output_state_set_image_description(&state, r->image_desc);
+ wlr_output_state_set_image_description(&state, &image_desc);
+ }
+
wlr_output_state_set_enabled(&state, 1);
wlr_output_commit_state(wlr_output, &state);
wlr_output_state_finish(&state);
@@ -2653,6 +2674,36 @@ setup(void)
@@ -2645,6 +2664,37 @@ setup(void)
wl_signal_add(&output_mgr->events.apply, &output_mgr_apply);
wl_signal_add(&output_mgr->events.test, &output_mgr_test);
@@ -150,29 +143,30 @@ index 8101ffa..4c3f12a 100644
+ .set_mastering_display_primaries = true,
+ };
+
+ color_mgr_options->render_intents_len = 1;
+ color_mgr_options->render_intents_len = 2;
+ enum wp_color_manager_v1_render_intent *render_intents = ecalloc(color_mgr_options->render_intents_len, sizeof(*render_intents));
+ render_intents[0] = WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL;
+ render_intents[1] = WP_COLOR_MANAGER_V1_RENDER_INTENT_ABSOLUTE;
+ color_mgr_options->render_intents = render_intents;
+
+ enum wp_color_manager_v1_primaries *primaries = wlr_color_manager_v1_primaries_list_from_renderer(drw, &color_mgr_options->primaries_len);
+ enum wp_color_manager_v1_primaries *primaries = ecalloc(color_mgr_options->primaries_len, sizeof(*primaries));
+ primaries[0] = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB;
+ primaries[1] = WP_COLOR_MANAGER_V1_PRIMARIES_BT2020;
+ color_mgr_options->primaries = primaries;
+
+ enum wp_color_manager_v1_transfer_function *transfer_functions = wlr_color_manager_v1_transfer_function_list_from_renderer(drw, &color_mgr_options->transfer_functions_len);
+ color_mgr_options->transfer_functions_len = 3;
+ enum wp_color_manager_v1_transfer_function *transfer_functions = ecalloc(color_mgr_options->transfer_functions_len, sizeof(*transfer_functions));
+ transfer_functions[0] = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB;
+ transfer_functions[1] = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ;
+ transfer_functions[2] = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR;
+ color_mgr_options->transfer_functions = transfer_functions;
+
+ color_mgr = wlr_color_manager_v1_create(dpy, 2, color_mgr_options);
+ wlr_scene_set_color_manager_v1(scene, color_mgr);
+
+ wlr_color_representation_manager_v1_create_with_renderer(dpy, 1, drw);
+
+ free(transfer_functions);
+ free(primaries);
+ color_mgr = wlr_color_manager_v1_create(dpy, 1, color_mgr_options);
+ }
+
/* Make sure XWayland clients don't connect to the parent X server,
* e.g when running in the x11 backend or the wayland backend and the
* compositor has Xwayland support */
--
2.54.0
2.51.0
-11
View File
@@ -1,11 +0,0 @@
### Description
This patch allows a window to adjust its layout as if it was fullscreen, but it won't change its size and position, and it will stays under the control of dwl. For example a video on a browser can occupy the whole space reserved to the window, but we can still resize it and move it and see the status bar.
### Download
- [dwl 0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/controlled_fullscreen/controlled_fullscreen.patch)
- [2025-11-13](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/controlled_fullscreen/controlled_fullscreen_2025_11_13.patch)
- [2025-10-08](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/controlled_fullscreen/controlled_fullscreen_2025_10_08.patch)
### Authors
- [André Desgualdo Pereira](https://codeberg.org/Kana)
@@ -1,132 +0,0 @@
From 9d34e55528ef3e558dcaba7759567707d44ed82d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= <desgua@gmail.com>
Date: Mon, 4 May 2026 10:49:48 -0300
Subject: [PATCH] update controlled_fullscreen to dwl 0.8
---
dwl.c | 32 ++++++++++++--------------------
1 file changed, 12 insertions(+), 20 deletions(-)
diff --git a/dwl.c b/dwl.c
index 101a45f..0ec8db6 100644
--- a/dwl.c
+++ b/dwl.c
@@ -519,9 +519,6 @@ arrange(Monitor *m)
}
}
- wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
- (c = focustop(m)) && c->isfullscreen);
-
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
/* We move all clients (except fullscreen and unmanaged) to LyrTile while
@@ -879,7 +876,7 @@ commitnotify(struct wl_listener *listener, void *data)
return;
}
- resize(c, c->geom, (c->isfloating && !c->isfullscreen));
+ resize(c, c->geom, (c->isfloating));
/* mark a pending resize as completed */
if (c->resize && c->resize <= c->surface.xdg->current.configure_serial)
@@ -1491,7 +1488,7 @@ focusstack(const Arg *arg)
{
/* Focus the next or previous client (in tiling order) on selmon */
Client *c, *sel = focustop(selmon);
- if (!sel || (sel->isfullscreen && !client_has_children(sel)))
+ if (!sel)
return;
if (arg->i > 0) {
wl_list_for_each(c, &sel->link, link) {
@@ -1828,7 +1825,7 @@ monocle(Monitor *m)
int n = 0;
wl_list_for_each(c, &clients, link) {
- if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ if (!VISIBLEON(c, m) || c->isfloating)
continue;
resize(c, m->w, 0);
n++;
@@ -1959,7 +1956,7 @@ moveresize(const Arg *arg)
if (cursor_mode != CurNormal && cursor_mode != CurPressed)
return;
xytonode(cursor->x, cursor->y, NULL, &grabc, NULL, NULL, NULL);
- if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen)
+ if (!grabc || client_is_unmanaged(grabc))
return;
/* Float the window and tell motionnotify to grab it */
@@ -2334,14 +2331,12 @@ setcursorshape(struct wl_listener *listener, void *data)
void
setfloating(Client *c, int floating)
{
- Client *p = client_get_parent(c);
c->isfloating = floating;
/* If in floating layout do not change the client's layer */
if (!c->mon || !client_surface(c)->mapped || !c->mon->lt[c->mon->sellt]->arrange)
return;
- wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ||
- (p && p->isfullscreen) ? LyrFS
- : c->isfloating ? LyrFloat : LyrTile]);
+ wlr_scene_node_reparent(&c->scene->node,
+ layers[c->isfloating ? LyrFloat : LyrTile]);
arrange(c->mon);
printstatus();
}
@@ -2354,12 +2349,12 @@ setfullscreen(Client *c, int fullscreen)
return;
c->bw = fullscreen ? 0 : borderpx;
client_set_fullscreen(c, fullscreen);
- wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
- ? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
+ wlr_scene_node_reparent(&c->scene->node,
+ layers[c->isfloating ? LyrFloat : LyrTile]);
if (fullscreen) {
c->prev = c->geom;
- resize(c, c->mon->m, 0);
+ resize(c, c->mon->w, 0);
} else {
/* restore previous size instead of arrange for floating windows since
* client positions are set by the user and cannot be recalculated */
@@ -2719,7 +2714,7 @@ tile(Monitor *m)
Client *c;
wl_list_for_each(c, &clients, link)
- if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
+ if (VISIBLEON(c, m) && !c->isfloating)
n++;
if (n == 0)
return;
@@ -2730,7 +2725,7 @@ tile(Monitor *m)
mw = m->w.width;
i = my = ty = 0;
wl_list_for_each(c, &clients, link) {
- if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ if (!VISIBLEON(c, m) || c->isfloating)
continue;
if (i < m->nmaster) {
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
@@ -2750,7 +2745,7 @@ togglefloating(const Arg *arg)
{
Client *sel = focustop(selmon);
/* return if fullscreen */
- if (sel && !sel->isfullscreen)
+ if (sel)
setfloating(sel, !sel->isfloating);
}
@@ -2905,9 +2900,6 @@ updatemons(struct wl_listener *listener, void *data)
arrangelayers(m);
/* Don't move clients to the left output when plugging monitors */
arrange(m);
- /* make sure fullscreen clients have the right size */
- if ((c = focustop(m)) && c->isfullscreen)
- resize(c, m->m, 0);
/* Try to re-set the gamma LUT when updating monitors,
* it's only really needed when enabling a disabled output, but meh. */
--
2.53.0
@@ -1,140 +0,0 @@
From 33e9b8a227b63e344407c1e4d137b574483cbd1e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= <desgua@gmail.com>
Date: Wed, 8 Oct 2025 17:38:00 -0300
Subject: [PATCH] controlled fullscreen
---
dwl.c | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/dwl.c b/dwl.c
index 12f441e..c74380d 100644
--- a/dwl.c
+++ b/dwl.c
@@ -518,9 +518,6 @@ arrange(Monitor *m)
}
}
- wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
- (c = focustop(m)) && c->isfullscreen);
-
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
/* We move all clients (except fullscreen and unmanaged) to LyrTile while
@@ -878,7 +875,7 @@ commitnotify(struct wl_listener *listener, void *data)
return;
}
- resize(c, c->geom, (c->isfloating && !c->isfullscreen));
+ resize(c, c->geom, (c->isfloating));
/* mark a pending resize as completed */
if (c->resize && c->resize <= c->surface.xdg->current.configure_serial)
@@ -1490,7 +1487,7 @@ focusstack(const Arg *arg)
{
/* Focus the next or previous client (in tiling order) on selmon */
Client *c, *sel = focustop(selmon);
- if (!sel || (sel->isfullscreen && !client_has_children(sel)))
+ if (!sel)
return;
if (arg->i > 0) {
wl_list_for_each(c, &sel->link, link) {
@@ -1826,7 +1823,7 @@ monocle(Monitor *m)
int n = 0;
wl_list_for_each(c, &clients, link) {
- if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ if (!VISIBLEON(c, m) || c->isfloating)
continue;
resize(c, m->w, 0);
n++;
@@ -1957,7 +1954,7 @@ moveresize(const Arg *arg)
if (cursor_mode != CurNormal && cursor_mode != CurPressed)
return;
xytonode(cursor->x, cursor->y, NULL, &grabc, NULL, NULL, NULL);
- if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen)
+ if (!grabc || client_is_unmanaged(grabc))
return;
/* Float the window and tell motionnotify to grab it */
@@ -2332,14 +2329,12 @@ setcursorshape(struct wl_listener *listener, void *data)
void
setfloating(Client *c, int floating)
{
- Client *p = client_get_parent(c);
c->isfloating = floating;
/* If in floating layout do not change the client's layer */
if (!c->mon || !client_surface(c)->mapped || !c->mon->lt[c->mon->sellt]->arrange)
return;
- wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ||
- (p && p->isfullscreen) ? LyrFS
- : c->isfloating ? LyrFloat : LyrTile]);
+ wlr_scene_node_reparent(&c->scene->node,
+ layers[c->isfloating ? LyrFloat : LyrTile]);
arrange(c->mon);
printstatus();
}
@@ -2352,12 +2347,12 @@ setfullscreen(Client *c, int fullscreen)
return;
c->bw = fullscreen ? 0 : borderpx;
client_set_fullscreen(c, fullscreen);
- wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
- ? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
+ wlr_scene_node_reparent(&c->scene->node,
+ layers[c->isfloating ? LyrFloat : LyrTile]);
if (fullscreen) {
c->prev = c->geom;
- resize(c, c->mon->m, 0);
+ resize(c, c->mon->w, 0);
} else {
/* restore previous size instead of arrange for floating windows since
* client positions are set by the user and cannot be recalculated */
@@ -2413,7 +2408,6 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
/* Make sure window actually overlaps with the monitor */
resize(c, c->geom, 0);
c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */
- setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
setfloating(c, c->isfloating);
}
focusclient(focustop(selmon), 1);
@@ -2716,7 +2710,7 @@ tile(Monitor *m)
Client *c;
wl_list_for_each(c, &clients, link)
- if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
+ if (VISIBLEON(c, m) && !c->isfloating)
n++;
if (n == 0)
return;
@@ -2727,7 +2721,7 @@ tile(Monitor *m)
mw = m->w.width;
i = my = ty = 0;
wl_list_for_each(c, &clients, link) {
- if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ if (!VISIBLEON(c, m) || c->isfloating)
continue;
if (i < m->nmaster) {
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
@@ -2747,7 +2741,7 @@ togglefloating(const Arg *arg)
{
Client *sel = focustop(selmon);
/* return if fullscreen */
- if (sel && !sel->isfullscreen)
+ if (sel)
setfloating(sel, !sel->isfloating);
}
@@ -2902,9 +2896,6 @@ updatemons(struct wl_listener *listener, void *data)
arrangelayers(m);
/* Don't move clients to the left output when plugging monitors */
arrange(m);
- /* make sure fullscreen clients have the right size */
- if ((c = focustop(m)) && c->isfullscreen)
- resize(c, m->m, 0);
/* Try to re-set the gamma LUT when updating monitors,
* it's only really needed when enabling a disabled output, but meh. */
--
2.51.0
@@ -1,132 +0,0 @@
From e0cecc228d436425c0d921a1eec5e0370d24613d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= <desgua@gmail.com>
Date: Thu, 13 Nov 2025 09:09:22 -0300
Subject: [PATCH] controlled fullscreen fix
---
dwl.c | 32 ++++++++++++--------------------
1 file changed, 12 insertions(+), 20 deletions(-)
diff --git a/dwl.c b/dwl.c
index 12f441e..4f124eb 100644
--- a/dwl.c
+++ b/dwl.c
@@ -518,9 +518,6 @@ arrange(Monitor *m)
}
}
- wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
- (c = focustop(m)) && c->isfullscreen);
-
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
/* We move all clients (except fullscreen and unmanaged) to LyrTile while
@@ -878,7 +875,7 @@ commitnotify(struct wl_listener *listener, void *data)
return;
}
- resize(c, c->geom, (c->isfloating && !c->isfullscreen));
+ resize(c, c->geom, (c->isfloating));
/* mark a pending resize as completed */
if (c->resize && c->resize <= c->surface.xdg->current.configure_serial)
@@ -1490,7 +1487,7 @@ focusstack(const Arg *arg)
{
/* Focus the next or previous client (in tiling order) on selmon */
Client *c, *sel = focustop(selmon);
- if (!sel || (sel->isfullscreen && !client_has_children(sel)))
+ if (!sel)
return;
if (arg->i > 0) {
wl_list_for_each(c, &sel->link, link) {
@@ -1826,7 +1823,7 @@ monocle(Monitor *m)
int n = 0;
wl_list_for_each(c, &clients, link) {
- if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ if (!VISIBLEON(c, m) || c->isfloating)
continue;
resize(c, m->w, 0);
n++;
@@ -1957,7 +1954,7 @@ moveresize(const Arg *arg)
if (cursor_mode != CurNormal && cursor_mode != CurPressed)
return;
xytonode(cursor->x, cursor->y, NULL, &grabc, NULL, NULL, NULL);
- if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen)
+ if (!grabc || client_is_unmanaged(grabc))
return;
/* Float the window and tell motionnotify to grab it */
@@ -2332,14 +2329,12 @@ setcursorshape(struct wl_listener *listener, void *data)
void
setfloating(Client *c, int floating)
{
- Client *p = client_get_parent(c);
c->isfloating = floating;
/* If in floating layout do not change the client's layer */
if (!c->mon || !client_surface(c)->mapped || !c->mon->lt[c->mon->sellt]->arrange)
return;
- wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ||
- (p && p->isfullscreen) ? LyrFS
- : c->isfloating ? LyrFloat : LyrTile]);
+ wlr_scene_node_reparent(&c->scene->node,
+ layers[c->isfloating ? LyrFloat : LyrTile]);
arrange(c->mon);
printstatus();
}
@@ -2352,12 +2347,12 @@ setfullscreen(Client *c, int fullscreen)
return;
c->bw = fullscreen ? 0 : borderpx;
client_set_fullscreen(c, fullscreen);
- wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
- ? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
+ wlr_scene_node_reparent(&c->scene->node,
+ layers[c->isfloating ? LyrFloat : LyrTile]);
if (fullscreen) {
c->prev = c->geom;
- resize(c, c->mon->m, 0);
+ resize(c, c->mon->w, 0);
} else {
/* restore previous size instead of arrange for floating windows since
* client positions are set by the user and cannot be recalculated */
@@ -2716,7 +2711,7 @@ tile(Monitor *m)
Client *c;
wl_list_for_each(c, &clients, link)
- if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
+ if (VISIBLEON(c, m) && !c->isfloating)
n++;
if (n == 0)
return;
@@ -2727,7 +2722,7 @@ tile(Monitor *m)
mw = m->w.width;
i = my = ty = 0;
wl_list_for_each(c, &clients, link) {
- if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ if (!VISIBLEON(c, m) || c->isfloating)
continue;
if (i < m->nmaster) {
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
@@ -2747,7 +2742,7 @@ togglefloating(const Arg *arg)
{
Client *sel = focustop(selmon);
/* return if fullscreen */
- if (sel && !sel->isfullscreen)
+ if (sel)
setfloating(sel, !sel->isfloating);
}
@@ -2902,9 +2897,6 @@ updatemons(struct wl_listener *listener, void *data)
arrangelayers(m);
/* Don't move clients to the left output when plugging monitors */
arrange(m);
- /* make sure fullscreen clients have the right size */
- if ((c = focustop(m)) && c->isfullscreen)
- resize(c, m->m, 0);
/* Try to re-set the gamma LUT when updating monitors,
* it's only really needed when enabling a disabled output, but meh. */
--
2.51.0
+1 -1
View File
@@ -1,5 +1,5 @@
### Description
Generate a coredump if dwl exited abnormally (to be more useful you need to
Generate a coredump if dwl exited abnormally (to be more usefull you need to
compile dwl and wlroots with debug symbols)
### Download
+24 -24
View File
@@ -1,24 +1,24 @@
### Description
Rules for floating windows support default x, y, width, height. Defaults to the center of the screen and the client size.
If the width or height is less than or equal to 1, then the value will be interpreted as a percentage. For example, 0.5 represents 50%, 0.25 represents 25%, and 1 represents 100%. **NOTE**: Some clients, like Thunar, have minimum width/height
The variable `center_relative_to_monitor` allows the user to choose whether to center relative to the monitor or relative to the window area.
<details>
<summary>Explanation of center_relative_to_monitor:</summary>
<pre>
The "Monitor area" refers to the space enclosed by the green rectangle, while the "Window area" refers to the space enclosed by the red rectangle.
<img src="customfloat-monitor-vs-window.png"/>
</pre>
</details>
### Download
- [customfloat_main-5fd19fe](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/customfloat/customfloat_main-5fd19fe.patch)
- [customfloat_wlroots-next-f4249db](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/customfloat/customfloat_wlroots-next-f4249db.patch)
- [customfloat_0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/customfloat/customfloat_0.8.patch)
### Authors
- [fauxmight](https://codeberg.org/fauxmight)
- [wochap](https://codeberg.org/wochap)
- [Stivvo](https://github.com/Stivvo)
### Description
Rules for floating windows support default x, y, width, height. Defaults to the center of the screen and the client size.
If the width or height is less than or equal to 1, then the value will be interpreted as a percentage. For example, 0.5 represents 50%, 0.25 represents 25%, and 1 represents 100%. **NOTE**: Some clients, like Thunar, have minimum width/height
The variable `center_relative_to_monitor` allows the user to choose whether to center relative to the monitor or relative to the window area.
<details>
<summary>Explanation of center_relative_to_monitor:</summary>
<pre>
The "Monitor area" refers to the space enclosed by the green rectangle, while the "Window area" refers to the space enclosed by the red rectangle.
<img src="https://i.imgur.com/xhejzPh.png"/>
</pre>
</details>
### Download
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.5/customfloat)
- [2024-07-09](https://codeberg.org/dwl/dwl-patches/raw/commit/13d96b51b54500dd24544cf3a73c61b7a1414bc6/patches/customfloat/customfloat.patch)
- [2024-04-11](https://codeberg.org/dwl/dwl-patches/raw/commit/98cba933c9f4099202e54f39acbf17e05bde828a/customfloat/customfloat.patch)
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/bf098459219e7a473d8edb4c0435aeb6a4b82e38/customfloat/customfloat.patch)
### Authors
- [wochap](https://codeberg.org/wochap)
- [Stivvo](https://github.com/Stivvo)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 KiB

+93
View File
@@ -0,0 +1,93 @@
From 4f19f5499610d56f2616da5d44039403ac9d4c06 Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com>
Date: Tue, 9 Jul 2024 10:52:37 -0500
Subject: [PATCH] implement customfloat and generate patches
---
config.def.h | 7 ++++---
dwl.c | 27 +++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 22d2171..dee53f4 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,6 +13,7 @@ static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* 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 */
+static const int respect_monitor_reserved_area = 0; /* 1 to monitor center while respecting the monitor's reserved area, 0 to monitor center */
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
@@ -22,10 +23,10 @@ static int log_level = WLR_ERROR;
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
+ /* app_id title tags mask isfloating monitor x y width height */
/* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ { "Gimp_EXAMPLE", NULL, 0, 1, -1, 0, 0, 1000, 0.75 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1, 0, 0, 0, 0 },/* Start on ONLY tag "9" */
};
/* layout(s) */
diff --git a/dwl.c b/dwl.c
index dc0437e..be0340f 100644
--- a/dwl.c
+++ b/dwl.c
@@ -230,6 +230,10 @@ typedef struct {
uint32_t tags;
int isfloating;
int monitor;
+ int x;
+ int y;
+ float w;
+ float h;
} Rule;
typedef struct {
@@ -454,6 +458,11 @@ applyrules(Client *c)
int i;
const Rule *r;
Monitor *mon = selmon, *m;
+ int newwidth;
+ int newheight;
+ int newx;
+ int newy;
+ int apply_resize = 0;
c->isfloating = client_is_float_type(c);
if (!(appid = client_get_appid(c)))
@@ -471,9 +480,27 @@ applyrules(Client *c)
if (r->monitor == i++)
mon = m;
}
+ if (c->isfloating || !mon->lt[mon->sellt]->arrange) {
+ /* client is floating or in floating layout */
+ struct wlr_box b = respect_monitor_reserved_area ? mon->w : mon->m;
+ newwidth = (int)round(r->w ? (r->w <= 1 ? b.width * r->w : r->w) : c->geom.width);
+ newheight = (int)round(r->h ? (r->h <= 1 ? b.height * r->h : r->h) : c->geom.height);
+ newx = (int)round(r->x ? (r->x <= 1 ? b.width * r->x + b.x : r->x + b.x) : c->geom.x);
+ newy = (int)round(r->y ? (r->y <= 1 ? b.height * r->y + b.y : r->y + b.y) : c->geom.y);
+ apply_resize = 1;
+
+ }
}
}
setmon(c, mon, newtags);
+ if (apply_resize) {
+ resize(c, (struct wlr_box){
+ .x = newx,
+ .y = newy,
+ .width = newwidth,
+ .height = newheight,
+ }, 1);
+ }
}
void
--
2.45.1
-95
View File
@@ -1,95 +0,0 @@
From 96125a70b7525740a42803f1faa666ca37b9433f Mon Sep 17 00:00:00 2001
From: A Frederick Christensen <dwl@ivories.org>
Date: Mon, 23 Feb 2026 09:06:33 -0600
Subject: [PATCH] Apply customfloat patch
---
config.def.h | 7 ++++---
dwl.c | 26 ++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..16afbb3 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,6 +13,7 @@ static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
+static const int respect_monitor_reserved_area = 0; /* 1 to monitor center while respecting the monitor's reserved area, 0 to monitor center */
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
@@ -21,9 +22,9 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
static int log_level = WLR_ERROR;
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ /* app_id title tags mask isfloating monitor x y width height */
+ { "Gimp_EXAMPLE", NULL, 0, 1, -1, -1, -1, 1000, 0.75 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1, -1, -1, -1, -1 }, /* Start on ONLY tag "9" */
/* default/example rule: can be changed but cannot be eliminated; at least one rule must exist */
};
diff --git a/dwl.c b/dwl.c
index 44f3ad9..801696a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -228,6 +228,10 @@ typedef struct {
uint32_t tags;
int isfloating;
int monitor;
+ int x;
+ int y;
+ float w;
+ float h;
} Rule;
typedef struct {
@@ -482,6 +486,11 @@ applyrules(Client *c)
int i;
const Rule *r;
Monitor *mon = selmon, *m;
+ int newwidth;
+ int newheight;
+ int newx;
+ int newy;
+ int apply_resize = 0;
appid = client_get_appid(c);
title = client_get_title(c);
@@ -495,12 +504,29 @@ applyrules(Client *c)
wl_list_for_each(m, &mons, link) {
if (r->monitor == i++)
mon = m;
+ if (c->isfloating || !mon->lt[mon->sellt]->arrange) {
+ /* client is floating or in floating layout */
+ struct wlr_box b = respect_monitor_reserved_area ? mon->w : mon->m;
+ newwidth = (int)round((r->w >= 0) ? (r->w <= 1 ? b.width * r->w : r->w) : c->geom.width);
+ newheight = (int)round((r->h >= 0) ? (r->h <= 1 ? b.height * r->h : r->h) : c->geom.height);
+ newx = (int)round((r->x >= 0) ? (r->x <= 1 ? b.width * r->x + b.x : r->x + b.x) : c->geom.x);
+ newy = (int)round((r->y >= 0) ? (r->y <= 1 ? b.height * r->y + b.y : r->y + b.y) : c->geom.y);
+ apply_resize = 1;
+ }
}
}
}
c->isfloating |= client_is_float_type(c);
setmon(c, mon, newtags);
+ if (apply_resize) {
+ resize(c, (struct wlr_box){
+ .x = newx,
+ .y = newy,
+ .width = newwidth,
+ .height = newheight,
+ }, 1);
+ }
}
void
--
2.52.0
@@ -1,82 +0,0 @@
diff --git a/config.def.h b/config.def.h
index 572984b..708d87a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,6 +13,7 @@ static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
+static const int respect_monitor_reserved_area = 0; /* 1 to monitor center while respecting the monitor's reserved area, 0 to monitor center */
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
@@ -21,9 +22,9 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
static int log_level = WLR_ERROR;
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ /* app_id title tags mask isfloating monitor x y width height */
+ { "Gimp_EXAMPLE", NULL, 0, 1, -1, -1, -1, 1000, 0.75 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1, -1, -1, -1, -1 }, /* Start on ONLY tag "9" */
/* default/example rule: can be changed but cannot be eliminated; at least one rule must exist */
};
diff --git a/dwl.c b/dwl.c
index f902ace..97e09e6 100644
--- a/dwl.c
+++ b/dwl.c
@@ -245,6 +245,10 @@ typedef struct {
uint32_t tags;
int isfloating;
int monitor;
+ int x;
+ int y;
+ float w;
+ float h;
} Rule;
typedef struct {
@@ -506,6 +510,11 @@ applyrules(Client *c)
int i;
const Rule *r;
Monitor *mon = selmon, *m;
+ int newwidth;
+ int newheight;
+ int newx;
+ int newy;
+ int apply_resize = 0;
appid = client_get_appid(c);
title = client_get_title(c);
@@ -519,12 +528,29 @@ applyrules(Client *c)
wl_list_for_each(m, &mons, link) {
if (r->monitor == i++)
mon = m;
+ if (c->isfloating || !mon->lt[mon->sellt]->arrange) {
+ /* client is floating or in floating layout */
+ struct wlr_box b = respect_monitor_reserved_area ? mon->w : mon->m;
+ newwidth = (int)round((r->w >= 0) ? (r->w <= 1 ? b.width * r->w : r->w) : c->geom.width);
+ newheight = (int)round((r->h >= 0) ? (r->h <= 1 ? b.height * r->h : r->h) : c->geom.height);
+ newx = (int)round((r->x >= 0) ? (r->x <= 1 ? b.width * r->x + b.x : r->x + b.x) : c->geom.x);
+ newy = (int)round((r->y >= 0) ? (r->y <= 1 ? b.height * r->y + b.y : r->y + b.y) : c->geom.y);
+ apply_resize = 1;
+ }
}
}
}
c->isfloating |= client_is_float_type(c);
setmon(c, mon, newtags);
+ if (apply_resize) {
+ resize(c, (struct wlr_box){
+ .x = newx,
+ .y = newy,
+ .width = newwidth,
+ .height = newheight,
+ }, 1);
+ }
}
void
@@ -1,95 +0,0 @@
From d8a861b30bf93554633ff0517d5bbdcb9b9614f0 Mon Sep 17 00:00:00 2001
From: A Frederick Christensen <dwl@ivories.org>
Date: Mon, 23 Feb 2026 09:18:07 -0600
Subject: [PATCH] Apply customfloat patch
---
config.def.h | 7 ++++---
dwl.c | 26 ++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..16afbb3 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,6 +13,7 @@ static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
+static const int respect_monitor_reserved_area = 0; /* 1 to monitor center while respecting the monitor's reserved area, 0 to monitor center */
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
@@ -21,9 +22,9 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
static int log_level = WLR_ERROR;
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ /* app_id title tags mask isfloating monitor x y width height */
+ { "Gimp_EXAMPLE", NULL, 0, 1, -1, -1, -1, 1000, 0.75 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1, -1, -1, -1, -1 }, /* Start on ONLY tag "9" */
/* default/example rule: can be changed but cannot be eliminated; at least one rule must exist */
};
diff --git a/dwl.c b/dwl.c
index 8a9715d..7de0655 100644
--- a/dwl.c
+++ b/dwl.c
@@ -230,6 +230,10 @@ typedef struct {
uint32_t tags;
int isfloating;
int monitor;
+ int x;
+ int y;
+ float w;
+ float h;
} Rule;
typedef struct {
@@ -484,6 +488,11 @@ applyrules(Client *c)
int i;
const Rule *r;
Monitor *mon = selmon, *m;
+ int newwidth;
+ int newheight;
+ int newx;
+ int newy;
+ int apply_resize = 0;
appid = client_get_appid(c);
title = client_get_title(c);
@@ -497,12 +506,29 @@ applyrules(Client *c)
wl_list_for_each(m, &mons, link) {
if (r->monitor == i++)
mon = m;
+ if (c->isfloating || !mon->lt[mon->sellt]->arrange) {
+ /* client is floating or in floating layout */
+ struct wlr_box b = respect_monitor_reserved_area ? mon->w : mon->m;
+ newwidth = (int)round((r->w >= 0) ? (r->w <= 1 ? b.width * r->w : r->w) : c->geom.width);
+ newheight = (int)round((r->h >= 0) ? (r->h <= 1 ? b.height * r->h : r->h) : c->geom.height);
+ newx = (int)round((r->x >= 0) ? (r->x <= 1 ? b.width * r->x + b.x : r->x + b.x) : c->geom.x);
+ newy = (int)round((r->y >= 0) ? (r->y <= 1 ? b.height * r->y + b.y : r->y + b.y) : c->geom.y);
+ apply_resize = 1;
+ }
}
}
}
c->isfloating |= client_is_float_type(c);
setmon(c, mon, newtags);
+ if (apply_resize) {
+ resize(c, (struct wlr_box){
+ .x = newx,
+ .y = newy,
+ .width = newwidth,
+ .height = newheight,
+ }, 1);
+ }
}
void
--
2.52.0
-10
View File
@@ -1,10 +0,0 @@
### Description
Deck is a dwl-layout which is inspired by the dwm Deck layout (which is inspired by TTWM window manager). It applies the monocle-layout to the clients in the stack. The master-client is still visible. The stacked clients are like a deck of cards, hence the name.
### Download
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/decklayout/decklayout.patch)
- [git branch](https://codeberg.org/Kana/dwl/src/branch/decklayout)
- [main 2025-10-08](https://codeberg.org/dwl/dwl-patches/raw/commit/f8d1cfad116c19c01593f7436468ec0cb7a3297b/patches/decklayout/decklayout.patch)
### Authors
- [André Desgualdo Pereira](https://codeberg.org/Kana)
-112
View File
@@ -1,112 +0,0 @@
From c488515313e20f51ab961691002f9d483682ab16 Mon Sep 17 00:00:00 2001
From: nate zhou <gnuunixchad@outlook.com>
Date: Sat, 28 Feb 2026 21:32:46 +0800
Subject: [PATCH] Patch: decklayout-0.8.patch
---
config.def.h | 2 ++
dwl.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..3ec9ceb 100644
--- a/config.def.h
+++ b/config.def.h
@@ -33,6 +33,7 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "[E]", deck },
};
/* monitors */
@@ -135,6 +136,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XKB_KEY_a, setlayout, {.v = &layouts[3]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index 44f3ad9..f13f48b 100644
--- a/dwl.c
+++ b/dwl.c
@@ -278,6 +278,7 @@ static void destroylayersurfacenotify(struct wl_listener *listener, void *data);
static void destroylock(SessionLock *lock, int unlocked);
static void destroylocksurface(struct wl_listener *listener, void *data);
static void destroynotify(struct wl_listener *listener, void *data);
+static void deck(Monitor *m);
static void destroypointerconstraint(struct wl_listener *listener, void *data);
static void destroysessionlock(struct wl_listener *listener, void *data);
static void destroykeyboardgroup(struct wl_listener *listener, void *data);
@@ -1838,6 +1839,66 @@ monocle(Monitor *m)
wlr_scene_node_raise_to_top(&c->scene->node);
}
+void
+deck(Monitor *m)
+{
+ unsigned int mw, my;
+ int i, n = 0;
+ Client *c;
+
+ /* count tiled clients */
+ wl_list_for_each(c, &clients, link)
+
+ /* if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) */
+ if (VISIBLEON(c, m) && !c->isfloating)
+ n++;
+ if (n == 0)
+ return;
+
+ /* set master width */
+ if (n > m->nmaster)
+ mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
+ else
+ mw = m->w.width;
+
+ /* update layout symbol with number of stack windows */
+ /* use the following rules to count only the windows on the deck
+ if (n > m->nmaster)
+ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n - m->nmaster);
+ else
+ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); */
+
+ /* or this one to count all windows on the tag */
+ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
+
+ i = my = 0;
+ wl_list_for_each(c, &clients, link) {
+ /* if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) */
+ if (!VISIBLEON(c, m) || c->isfloating)
+ continue;
+
+ if (i < m->nmaster) {
+ /* master clients */
+ 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;
+ } else {
+ /* deck clients: overlap in stack area */
+ resize(c, (struct wlr_box){
+ .x = m->w.x + mw,
+ .y = m->w.y,
+ .width = m->w.width - mw,
+ .height = m->w.height
+ }, 0);
+ }
+ i++;
+ }
+}
+
void
motionabsolute(struct wl_listener *listener, void *data)
{
--
2.53.0
+1 -2
View File
@@ -8,8 +8,7 @@ There are also two functions that can be bound to a `Key` or `Button`,
2. `toggledimmingclient`: Which toggles dimming for the focused window, as if the client had `neverdim` applied to it. This overwrites an applied `Rule`.
### Download
- [2026-03-10](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240918.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused.patch)
- [2024-09-03](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240903.patch)
- [2024-07-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240714.patch)
- [2024-05-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240516.patch)
@@ -1,216 +0,0 @@
diff --git a/client.h b/client.h
index dabea35..3a31c25 100644
--- a/client.h
+++ b/client.h
@@ -319,6 +319,12 @@ client_set_border_color(Client *c, const float color[static 4])
wlr_scene_rect_set_color(c->border[i], color);
}
+static inline void
+client_set_dimmer_state(Client *c, const int dim)
+{
+ wlr_scene_node_set_enabled(&c->dimmer->node, DIMOPT && !c->neverdim && dim);
+}
+
static inline void
client_set_fullscreen(Client *c, int fullscreen)
{
diff --git a/config.def.h b/config.def.h
index 22d2171..4ca21c9 100644
--- a/config.def.h
+++ b/config.def.h
@@ -10,6 +10,7 @@ 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 unfocuseddim[] = COLOR(0x00000088);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* 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 */
@@ -22,10 +23,11 @@ static int log_level = WLR_ERROR;
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
- /* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ /* app_id title tags mask isfloating neverdim monitor */
+ /* examples:
+ { "Gimp_example", NULL, 0, 1, 0, -1 },
+ */
+ { "firefox_example", NULL, 1 << 8, 0, 1, -1 },
};
/* layout(s) */
@@ -140,8 +142,9 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
+ { MODKEY, XKB_KEY_apostrophe, toggledimming, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
- { MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_e, togglefullscreen, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
@@ -172,5 +175,6 @@ static const Key keys[] = {
static const Button buttons[] = {
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
+ { MODKEY|ShiftMask, BTN_MIDDLE, toggledimmingclient, {0} },
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
};
diff --git a/dwl.c b/dwl.c
index dc0c861..dcc3ece 100644
--- a/dwl.c
+++ b/dwl.c
@@ -112,6 +112,7 @@ typedef struct {
Monitor *mon;
struct wlr_scene_tree *scene;
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
+ struct wlr_scene_rect *dimmer;
struct wlr_scene_tree *scene_surface;
struct wl_list link;
struct wl_list flink;
@@ -141,7 +142,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, neverdim;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -231,6 +232,7 @@ typedef struct {
const char *title;
uint32_t tags;
int isfloating;
+ int neverdim;
int monitor;
} Rule;
@@ -338,6 +340,8 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
+static void toggledimming(const Arg *arg);
+static void toggledimmingclient(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -410,6 +414,7 @@ static struct wlr_output_layout *output_layout;
static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static int DIMOPT = 1;
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
@@ -466,6 +471,7 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
+ c->neverdim = r-> neverdim;
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -1365,8 +1371,10 @@ focusclient(Client *c, int lift)
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
- if (!exclusive_focus && !seat->drag)
+ if (!exclusive_focus && !seat->drag) {
client_set_border_color(c, focuscolor);
+ client_set_dimmer_state(c, 0);
+ }
}
/* Deactivate old client if focus is changing */
@@ -1384,7 +1392,7 @@ focusclient(Client *c, int lift)
* and probably other clients */
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
client_set_border_color(old_c, bordercolor);
-
+ client_set_dimmer_state(old_c, 1);
client_activate_surface(old, 0);
}
}
@@ -1681,8 +1689,7 @@ void
mapnotify(struct wl_listener *listener, void *data)
{
/* Called when the surface is mapped, or ready to display on-screen. */
- Client *p = NULL;
- Client *w, *c = wl_container_of(listener, c, map);
+ Client *p, *w, *d, *c = wl_container_of(listener, c, map);
Monitor *m;
int i;
@@ -1716,6 +1723,10 @@ mapnotify(struct wl_listener *listener, void *data)
c->border[i]->node.data = c;
}
+ c->dimmer = wlr_scene_rect_create(c->scene, 0, 0, unfocuseddim);
+ c->dimmer->node.data = c;
+ client_set_dimmer_state(c, 1);
+
/* Initialize client geometry with room for border */
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT);
c->geom.width += 2 * c->bw;
@@ -1734,6 +1745,10 @@ mapnotify(struct wl_listener *listener, void *data)
setmon(c, p->mon, p->tags);
} else {
applyrules(c);
+ d = focustop(selmon);
+ if (d) {
+ client_set_dimmer_state(d, 0);
+ }
}
printstatus();
@@ -2160,7 +2175,7 @@ resize(Client *c, struct wlr_box geo, int interact)
c->geom = geo;
applybounds(c, bbox);
- /* Update scene-graph, including borders */
+ /* Update scene-graph, including borders and dimmer*/
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
@@ -2170,6 +2185,8 @@ resize(Client *c, struct wlr_box geo, int interact)
wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw);
wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
+ wlr_scene_rect_set_size(c->dimmer, c->geom.width - 2*c->bw, c-> geom.height - 2*c->bw);
+ wlr_scene_node_set_position(&c->dimmer->node, c->bw, c->bw);
/* this is a no-op if size hasn't changed */
c->resize = client_set_size(c, c->geom.width - 2 * c->bw,
@@ -2681,6 +2698,27 @@ tile(Monitor *m)
}
}
+void toggledimming(const Arg *arg)
+{
+ Client *c;
+ DIMOPT ^= 1;
+ wl_list_for_each(c, &clients, link)
+ {
+ client_set_dimmer_state(c, 1);
+ }
+ c = focustop(selmon);
+ if (c)
+ client_set_dimmer_state(c, 0);
+}
+
+void
+toggledimmingclient(const Arg *arg)
+{
+ Client *sel = focustop(selmon);
+ if (sel)
+ sel -> neverdim ^= 1;
+}
+
void
togglefloating(const Arg *arg)
{
+216 -1
View File
@@ -1 +1,216 @@
09
diff --git a/client.h b/client.h
index dabea35..3a31c25 100644
--- a/client.h
+++ b/client.h
@@ -319,6 +319,12 @@ client_set_border_color(Client *c, const float color[static 4])
wlr_scene_rect_set_color(c->border[i], color);
}
+static inline void
+client_set_dimmer_state(Client *c, const int dim)
+{
+ wlr_scene_node_set_enabled(&c->dimmer->node, DIMOPT && !c->neverdim && dim);
+}
+
static inline void
client_set_fullscreen(Client *c, int fullscreen)
{
diff --git a/config.def.h b/config.def.h
index 22d2171..4ca21c9 100644
--- a/config.def.h
+++ b/config.def.h
@@ -10,6 +10,7 @@ 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 unfocuseddim[] = COLOR(0x00000088);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* 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 */
@@ -22,10 +23,11 @@ static int log_level = WLR_ERROR;
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
- /* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ /* app_id title tags mask isfloating neverdim monitor */
+ /* examples:
+ { "Gimp_example", NULL, 0, 1, 0, -1 },
+ */
+ { "firefox_example", NULL, 1 << 8, 0, 1, -1 },
};
/* layout(s) */
@@ -140,8 +142,9 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
+ { MODKEY, XKB_KEY_apostrophe, toggledimming, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
- { MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_e, togglefullscreen, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
@@ -172,5 +175,6 @@ static const Key keys[] = {
static const Button buttons[] = {
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
+ { MODKEY|ShiftMask, BTN_MIDDLE, toggledimmingclient, {0} },
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
};
diff --git a/dwl.c b/dwl.c
index dc0c861..dcc3ece 100644
--- a/dwl.c
+++ b/dwl.c
@@ -112,6 +112,7 @@ typedef struct {
Monitor *mon;
struct wlr_scene_tree *scene;
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
+ struct wlr_scene_rect *dimmer;
struct wlr_scene_tree *scene_surface;
struct wl_list link;
struct wl_list flink;
@@ -141,7 +142,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, neverdim;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -231,6 +232,7 @@ typedef struct {
const char *title;
uint32_t tags;
int isfloating;
+ int neverdim;
int monitor;
} Rule;
@@ -338,6 +340,8 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
+static void toggledimming(const Arg *arg);
+static void toggledimmingclient(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -410,6 +414,7 @@ static struct wlr_output_layout *output_layout;
static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static int DIMOPT = 1;
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
@@ -466,6 +471,7 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
+ c->neverdim = r-> neverdim;
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -1365,8 +1371,10 @@ focusclient(Client *c, int lift)
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
- if (!exclusive_focus && !seat->drag)
+ if (!exclusive_focus && !seat->drag) {
client_set_border_color(c, focuscolor);
+ client_set_dimmer_state(c, 0);
+ }
}
/* Deactivate old client if focus is changing */
@@ -1384,7 +1392,7 @@ focusclient(Client *c, int lift)
* and probably other clients */
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
client_set_border_color(old_c, bordercolor);
-
+ client_set_dimmer_state(old_c, 1);
client_activate_surface(old, 0);
}
}
@@ -1681,8 +1689,7 @@ void
mapnotify(struct wl_listener *listener, void *data)
{
/* Called when the surface is mapped, or ready to display on-screen. */
- Client *p = NULL;
- Client *w, *c = wl_container_of(listener, c, map);
+ Client *p, *w, *d, *c = wl_container_of(listener, c, map);
Monitor *m;
int i;
@@ -1716,6 +1723,10 @@ mapnotify(struct wl_listener *listener, void *data)
c->border[i]->node.data = c;
}
+ c->dimmer = wlr_scene_rect_create(c->scene, 0, 0, unfocuseddim);
+ c->dimmer->node.data = c;
+ client_set_dimmer_state(c, 1);
+
/* Initialize client geometry with room for border */
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT);
c->geom.width += 2 * c->bw;
@@ -1734,6 +1745,10 @@ mapnotify(struct wl_listener *listener, void *data)
setmon(c, p->mon, p->tags);
} else {
applyrules(c);
+ d = focustop(selmon);
+ if (d) {
+ client_set_dimmer_state(d, 0);
+ }
}
printstatus();
@@ -2160,7 +2175,7 @@ resize(Client *c, struct wlr_box geo, int interact)
c->geom = geo;
applybounds(c, bbox);
- /* Update scene-graph, including borders */
+ /* Update scene-graph, including borders and dimmer*/
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
@@ -2170,6 +2185,8 @@ resize(Client *c, struct wlr_box geo, int interact)
wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw);
wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
+ wlr_scene_rect_set_size(c->dimmer, c->geom.width - 2*c->bw, c-> geom.height - 2*c->bw);
+ wlr_scene_node_set_position(&c->dimmer->node, c->bw, c->bw);
/* this is a no-op if size hasn't changed */
c->resize = client_set_size(c, c->geom.width - 2 * c->bw,
@@ -2681,6 +2698,27 @@ tile(Monitor *m)
}
}
+void toggledimming(const Arg *arg)
+{
+ Client *c;
+ DIMOPT ^= 1;
+ wl_list_for_each(c, &clients, link)
+ {
+ client_set_dimmer_state(c, 1);
+ }
+ c = focustop(selmon);
+ if (c)
+ client_set_dimmer_state(c, 0);
+}
+
+void
+toggledimmingclient(const Arg *arg)
+{
+ Client *sel = focustop(selmon);
+ if (sel)
+ sel -> neverdim ^= 1;
+}
+
void
togglefloating(const Arg *arg)
{
-12
View File
@@ -1,12 +0,0 @@
### Description
Adds support for drm-lease-v1 for embedded displays such as VR headsets
### Download
- [git branch](/caskd/dwl/src/branch/patches/drm_lease)
- [main 2026-02-25](/dwl/dwl-patches/raw/branch/main/patches/drm_lease/drm_lease.patch)
### Authors
- [caskd](https://codeberg.org/caskd)
caskd@redxen.eu
caskd at [Libera IRC dwl channel](https://web.libera.chat/?channels=#dwl)
- Micah Gorrell
micah.gorrell@venafi.com
-124
View File
@@ -1,124 +0,0 @@
From 155578f30dc91363e7580c3020ad464ab561acd3 Mon Sep 17 00:00:00 2001
From: Micah Gorrell <micah.gorrell@venafi.com>
Date: Fri, 26 May 2023 08:17:20 -0600
Subject: [PATCH] Implemented support for the DRM lease protocol, as needed to
use devices such as VR headsets
---
dwl.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/dwl.c b/dwl.c
index 101a45f..4740dfe 100644
--- a/dwl.c
+++ b/dwl.c
@@ -23,6 +23,7 @@
#include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_drm.h>
+#include <wlr/types/wlr_drm_lease_v1.h>
#include <wlr/types/wlr_export_dmabuf_v1.h>
#include <wlr/types/wlr_ext_data_control_v1.h>
#include <wlr/types/wlr_fractional_scale_v1.h>
@@ -316,6 +317,7 @@ static void powermgrsetmode(struct wl_listener *listener, void *data);
static void quit(const Arg *arg);
static void rendermon(struct wl_listener *listener, void *data);
static void requestdecorationmode(struct wl_listener *listener, void *data);
+static void requestdrmlease(struct wl_listener *listener, void *data);
static void requeststartdrag(struct wl_listener *listener, void *data);
static void requestmonstate(struct wl_listener *listener, void *data);
static void resize(Client *c, struct wlr_box geo, int interact);
@@ -377,6 +379,7 @@ static struct wl_list clients; /* tiling order */
static struct wl_list fstack; /* focus order */
static struct wlr_idle_notifier_v1 *idle_notifier;
static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
+static struct wlr_drm_lease_v1_manager *drm_lease_manager;
static struct wlr_layer_shell_v1 *layer_shell;
static struct wlr_output_manager_v1 *output_mgr;
static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
@@ -436,6 +439,7 @@ static struct wl_listener request_set_cursor_shape = {.notify = setcursorshape};
static struct wl_listener request_start_drag = {.notify = requeststartdrag};
static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener new_session_lock = {.notify = locksession};
+static struct wl_listener drm_lease_request = {.notify = requestdrmlease};
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
@@ -727,10 +731,16 @@ cleanup(void)
void
cleanupmon(struct wl_listener *listener, void *data)
{
+ struct wlr_output *wlr_output = data;
Monitor *m = wl_container_of(listener, m, destroy);
LayerSurface *l, *tmp;
size_t i;
+ if (drm_lease_manager && wlr_output->non_desktop) {
+ wlr_drm_lease_v1_manager_withdraw_output (drm_lease_manager, wlr_output);
+ return;
+ }
+
/* m->layers[i] are intentionally not unlinked */
for (i = 0; i < LENGTH(m->layers); i++) {
wl_list_for_each_safe(l, tmp, &m->layers[i], link)
@@ -783,6 +793,9 @@ cleanuplisteners(void)
wl_list_remove(&request_start_drag.link);
wl_list_remove(&start_drag.link);
wl_list_remove(&new_session_lock.link);
+ if (drm_lease_manager) {
+ wl_list_remove(&drm_lease_request.link);
+ }
#ifdef XWAYLAND
wl_list_remove(&new_xwayland_surface.link);
wl_list_remove(&xwayland_ready.link);
@@ -1047,6 +1060,11 @@ createmon(struct wl_listener *listener, void *data)
struct wlr_output_state state;
Monitor *m;
+ if (drm_lease_manager && wlr_output->non_desktop) {
+ wlr_drm_lease_v1_manager_offer_output(drm_lease_manager, wlr_output);
+ return;
+ }
+
if (!wlr_output_init_render(wlr_output, alloc, drw))
return;
@@ -2183,6 +2201,16 @@ requestdecorationmode(struct wl_listener *listener, void *data)
WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
}
+static void requestdrmlease(struct wl_listener *listener, void *data) {
+ struct wlr_drm_lease_request_v1 *req = data;
+ struct wlr_drm_lease_v1 *lease = wlr_drm_lease_request_v1_grant(req);
+
+ if (!lease) {
+ fprintf(stderr, "Failed to grant lease request");
+ wlr_drm_lease_request_v1_reject(req);
+ }
+}
+
void
requeststartdrag(struct wl_listener *listener, void *data)
{
@@ -2648,10 +2676,18 @@ setup(void)
wl_signal_add(&output_mgr->events.apply, &output_mgr_apply);
wl_signal_add(&output_mgr->events.test, &output_mgr_test);
+ drm_lease_manager = wlr_drm_lease_v1_manager_create(dpy, backend);
+ if (drm_lease_manager) {
+ wl_signal_add(&drm_lease_manager->events.request, &drm_lease_request);
+ } else {
+ fprintf(stderr, "Failed to create wlr_drm_lease_device_v1; VR will not be available\n");
+ }
+
/* Make sure XWayland clients don't connect to the parent X server,
* e.g when running in the x11 backend or the wayland backend and the
* compositor has Xwayland support */
unsetenv("DISPLAY");
+
#ifdef XWAYLAND
/*
* Initialise the XWayland X server.
--
2.54.0
-55
View File
@@ -1,55 +0,0 @@
### Description
Adds a dwindle (fibonacci-style) layout to dwl.
Windows are arranged by recursively splitting the remaining space,
alternating between horizontal and vertical splits
With two windows:
```
┌───────────────┬────────────────┐
│ │ │
│ │ │
│ │ │
│ │ │
│ │ │
│ │ │
│ │ │
│ │ │
│ │ │
└───────────────┴────────────────┘
```
With three windows:
```
┌───────────────┬────────────────┐
│ │ │
│ │ │
│ │ │
│ │ │
│ ├────────────────┤
│ │ │
│ │ │
│ │ │
│ │ │
└───────────────┴────────────────┘
```
With four windows:
```
┌───────────────┬────────────────┐
│ │ │
│ │ │
│ │ │
│ │ │
│ ├───────┬────────┤
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
└───────────────┴───────┴────────┘
```
### Download
- [0.8](/dwl/dwl-patches/raw/branch/main/patches/dwindle/dwindle.patch)
### Authors
[cana cronica](https://codeberg.org/cana)
-105
View File
@@ -1,105 +0,0 @@
From 9be9c310cd546c22bd486f11c21e7ffcc09b1e8a Mon Sep 17 00:00:00 2001
From: C4FE1 <heitorcdesousa13@gmail.com>
Date: Fri, 20 Mar 2026 21:30:41 -0300
Subject: [PATCH] dwl: add dwindle layout
dwl: add dwindle layout
---
config.def.h | 2 ++
dwl.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..96bb1c0 100644
--- a/config.def.h
+++ b/config.def.h
@@ -33,6 +33,7 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "[\\]", dwindle },
};
/* monitors */
@@ -135,6 +136,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XKB_KEY_r, setlayout, {.v = &layouts[3]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index 101a45f..5f1b762 100644
--- a/dwl.c
+++ b/dwl.c
@@ -335,6 +335,7 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
+static void dwindle(Monitor *m);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -2745,6 +2746,58 @@ tile(Monitor *m)
}
}
+void
+dwindle(Monitor *m)
+{
+ unsigned int i, n = 0;
+ int nx, ny, nw, nh;
+ int horizontal;
+ Client *c;
+
+ /* count clients */
+ wl_list_for_each(c, &clients, link)
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
+ n++;
+
+ if (n == 0)
+ return;
+
+ nx = m->w.x;
+ ny = m->w.y;
+ nw = m->w.width;
+ nh = m->w.height;
+
+ horizontal = 1; // toggle split direction
+ i = 0;
+
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+
+ if (i == n - 1) {
+ /* last window gets remaining space */
+ resize(c, (struct wlr_box){nx, ny, nw, nh}, 0);
+ } else if (horizontal) {
+ int w = nw / 2;
+
+ resize(c, (struct wlr_box){nx, ny, w, nh}, 0);
+
+ nx += w;
+ nw -= w;
+ } else {
+ int h = nh / 2;
+
+ resize(c, (struct wlr_box){nx, ny, nw, h}, 0);
+
+ ny += h;
+ nh -= h;
+ }
+
+ horizontal = !horizontal;
+ i++;
+ }
+}
+
void
togglefloating(const Arg *arg)
{
--
2.53.0
+3 -3
View File
@@ -2,10 +2,10 @@
Always use the English keymap to get keycodes, so key bindings work even when using a non-English keyboard layout.
### Download
- [0.8](/dwl/dwl-patches/raw/branch/main/patches/en-keycodes/en-keycodes-0.8.patch)
- [0.7](/dwl/dwl-patches/raw/branch/main/patches/en-keycodes/en-keycodes-0.7.patch)
- [git branch](https://codeberg.org/ForzCross/dwl/src/branch/en-keycodes.patch)
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/en-keycodes/en-keycodes.patch)
### Authors
- [Nikita Ivanov](https://codeberg.org/nikitaivanov) ([GitHub](https://github.com/NikitaIvanovV))
- [ForzCross](https://codeberg.org/ForzCross)
- [Nikita Ivanov](https://codeberg.org/nikitaivanov) ([GitHub](https://github.com/NikitaIvanovV))
- [dimkr](https://codeberg.org/dimkr) (<dima@dimakrasner.com>)
-75
View File
@@ -1,75 +0,0 @@
From cde0921304c11c2e1341539a5ada4f7b9715b178 Mon Sep 17 00:00:00 2001
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
Date: Sun, 30 Nov 2025 23:22:42 +0100
Subject: [PATCH] Always use the English keymap to get keycodes
---
dwl.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/dwl.c b/dwl.c
index 44f3ad9..97ba897 100644
--- a/dwl.c
+++ b/dwl.c
@@ -436,6 +436,11 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener new_session_lock = {.notify = locksession};
+static struct xkb_rule_names en_rules;
+static struct xkb_context *en_context;
+static struct xkb_keymap *en_keymap;
+static struct xkb_state *en_state;
+
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -718,6 +723,9 @@ cleanup(void)
wlr_backend_destroy(backend);
wl_display_destroy(dpy);
+ xkb_state_unref(en_state);
+ xkb_keymap_unref(en_keymap);
+ xkb_context_unref(en_context);
/* Destroy after the wayland display (when the monitors are already destroyed)
to avoid destroying them with an invalid scene output. */
wlr_scene_node_destroy(&scene->tree.node);
@@ -1632,16 +1640,19 @@ keypress(struct wl_listener *listener, void *data)
/* This event is raised when a key is pressed or released. */
KeyboardGroup *group = wl_container_of(listener, group, key);
struct wlr_keyboard_key_event *event = data;
+ int nsyms, handled;
/* Translate libinput keycode -> xkbcommon */
uint32_t keycode = event->keycode + 8;
/* Get a list of keysyms based on the keymap for this keyboard */
const xkb_keysym_t *syms;
- int nsyms = xkb_state_key_get_syms(
- group->wlr_group->keyboard.xkb_state, keycode, &syms);
-
- int handled = 0;
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
+ xkb_state_update_key(en_state, keycode,
+ (event->state == WL_KEYBOARD_KEY_STATE_PRESSED)
+ ? XKB_KEY_DOWN : XKB_KEY_UP);
+ nsyms = xkb_state_key_get_syms(en_state, keycode, &syms);
+
+ handled = 0;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@@ -2624,6 +2635,12 @@ setup(void)
* pointer, touch, and drawing tablet device. We also rig up a listener to
* let us know when new input devices are available on the backend.
*/
+ en_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
+ en_rules = xkb_rules;
+ en_rules.layout = "us";
+ en_keymap = xkb_keymap_new_from_names(en_context, &en_rules,
+ XKB_KEYMAP_COMPILE_NO_FLAGS);
+ en_state = xkb_state_new(en_keymap);
wl_signal_add(&backend->events.new_input, &new_input_device);
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
--
2.53.0
@@ -1,21 +1,21 @@
From 556e47f7ce7f729ecc1b285ece0c82744741c81c Mon Sep 17 00:00:00 2001
From cd61fac9cb6e9d0172e2f7a01e6a514d676ba5f0 Mon Sep 17 00:00:00 2001
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
Date: Sun, 30 Nov 2025 23:16:53 +0100
Date: Tue, 4 Feb 2025 23:53:11 +0100
Subject: [PATCH] Always use the English keymap to get keycodes
---
dwl.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
dwl.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/dwl.c b/dwl.c
index def2562..31e98ca 100644
index def2562..c299365 100644
--- a/dwl.c
+++ b/dwl.c
@@ -413,6 +413,11 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static struct xkb_rule_names en_rules;
+static const struct xkb_rule_names en_rules = {.layout = "us"};
+static struct xkb_context *en_context;
+static struct xkb_keymap *en_keymap;
+static struct xkb_state *en_state;
@@ -57,13 +57,11 @@ index def2562..31e98ca 100644
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@@ -2607,6 +2618,12 @@ setup(void)
@@ -2607,6 +2618,10 @@ setup(void)
* pointer, touch, and drawing tablet device. We also rig up a listener to
* let us know when new input devices are available on the backend.
*/
+ en_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
+ en_rules = xkb_rules;
+ en_rules.layout = "us";
+ en_keymap = xkb_keymap_new_from_names(en_context, &en_rules,
+ XKB_KEYMAP_COMPILE_NO_FLAGS);
+ en_state = xkb_state_new(en_keymap);
@@ -71,5 +69,5 @@ index def2562..31e98ca 100644
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
LISTEN_STATIC(&virtual_keyboard_mgr->events.new_virtual_keyboard, virtualkeyboard);
--
2.51.2
2.48.1
-17
View File
@@ -1,17 +0,0 @@
### extrabar
Add an extra bar on the other side of the primary bar, shows additional status sections.
_Requires_ `bar` patch to be applied first. Heavily inspired by `dwm`'s extrabar patch.
### Status
The status text on the extra bar is set using the stdin as usual, with the text being split by `;`
For example, if `status1;status2;status3` was set,
then `status1` is set as the status of the primary bar,
`status2` is set as the left status of extrabar,
`status3` is set as the right status of extrabar.
### Author
[dhruva_sambrani](/dhruva_sambrani)
-188
View File
@@ -1,188 +0,0 @@
diff --git a/dwl.c b/dwl.c
index 7fe9468..2614a25 100644
--- a/dwl.c
+++ b/dwl.c
@@ -205,6 +205,7 @@ struct Monitor {
struct wlr_output *wlr_output;
struct wlr_scene_output *scene_output;
struct wlr_scene_buffer *scene_buffer; /* bar buffer */
+ struct wlr_scene_buffer *extra_scene_buffer; /* bar buffer */
struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
struct wl_listener frame;
struct wl_listener destroy;
@@ -230,6 +231,7 @@ struct Monitor {
int asleep;
Drwl *drw;
Buffer *pool[2];
+ Buffer *extra_pool[2];
int lrpad;
};
@@ -278,7 +280,7 @@ static void bufdestroy(struct wlr_buffer *buffer);
static bool bufdatabegin(struct wlr_buffer *buffer, uint32_t flags,
void **data, uint32_t *format, size_t *stride);
static void bufdataend(struct wlr_buffer *buffer);
-static Buffer *bufmon(Monitor *m);
+static Buffer *bufmon(Monitor *m, Buffer **pool);
static void bufrelease(struct wl_listener *listener, void *data);
static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
@@ -444,6 +446,8 @@ static struct wl_list mons;
static Monitor *selmon;
static char stext[256];
+static char stext2[256];
+static char stext3[256];
static struct wl_event_source *status_event_source;
static const struct wlr_buffer_impl buffer_impl = {
@@ -627,6 +631,11 @@ arrangelayers(Monitor *m)
usable_area.y += topbar ? m->b.real_height : 0;
}
+ if (m->extra_scene_buffer->node.enabled) {
+ usable_area.height -= m->b.real_height;
+ usable_area.y += topbar ? 0 : m->b.real_height;
+ }
+
/* Arrange exclusive surfaces from top->bottom */
for (i = 3; i >= 0; i--)
arrangelayer(m, &m->layers[i], &usable_area, 1);
@@ -706,23 +715,23 @@ bufdataend(struct wlr_buffer *wlr_buffer)
}
Buffer *
-bufmon(Monitor *m)
+bufmon(Monitor *m, Buffer **pool)
{
size_t i;
Buffer *buf = NULL;
for (i = 0; i < LENGTH(m->pool); i++) {
- if (m->pool[i]) {
- if (m->pool[i]->busy)
+ if (pool[i]) {
+ if (pool[i]->busy)
continue;
- buf = m->pool[i];
+ buf = pool[i];
break;
}
buf = ecalloc(1, sizeof(Buffer) + (m->b.width * 4 * m->b.height));
buf->image = drwl_image_create(NULL, m->b.width, m->b.height, buf->data);
wlr_buffer_init(&buf->base, &buffer_impl, m->b.width, m->b.height);
- m->pool[i] = buf;
+ pool[i] = buf;
break;
}
if (!buf)
@@ -1255,6 +1264,8 @@ createmon(struct wl_listener *listener, void *data)
m->scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL);
m->scene_buffer->point_accepts_input = baracceptsinput;
+ m->extra_scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL);
+ m->extra_scene_buffer->point_accepts_input = baracceptsinput;
updatebar(m);
wl_list_insert(&mons, &m->link);
@@ -1580,7 +1591,7 @@ drawbar(Monitor *m)
if (!m->scene_buffer->node.enabled)
return;
- if (!(buf = bufmon(m)))
+ if (!(buf = bufmon(m, m->pool)))
return;
/* draw status first so it can be overdrawn by tags later */
@@ -1633,13 +1644,47 @@ drawbar(Monitor *m)
wlr_buffer_unlock(&buf->base);
}
+void
+extrabar(Monitor *m)
+{
+ int tw = 0;
+ Buffer *buf = NULL;
+
+ /* Skip if the extra bar scene buffer is not initialized/enabled */
+ if (!m->extra_scene_buffer || !m->extra_scene_buffer->node.enabled)
+ return;
+
+ /* Inline bufmon logic for the extra pool to keep changes contained */
+ if (!(buf = bufmon(m, m->extra_pool)))
+ return;
+
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ drwl_rect(m->drw, 0, 0, m->b.width, m->b.height, 1, 1);
+
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ tw = TEXTW(m, stext2) - m->lrpad + 2; /* 2px right padding */
+ drwl_text(m->drw, 2, 0, tw, m->b.height, 0, stext2, 0);
+
+ tw = TEXTW(m, stext3) - m->lrpad + 2; /* 2px right padding */
+ drwl_text(m->drw, m->b.width - tw - 4, 0, tw, m->b.height, 0, stext3, 0);
+
+ wlr_scene_buffer_set_dest_size(m->extra_scene_buffer, m->b.real_width, m->b.real_height);
+ wlr_scene_node_set_position(&m->extra_scene_buffer->node, m->m.x,
+ m->m.y + (topbar ? m->m.height - m->b.real_height : 0));
+
+ wlr_scene_buffer_set_buffer(m->extra_scene_buffer, &buf->base);
+ wlr_buffer_unlock(&buf->base);
+}
+
void
drawbars(void)
{
Monitor *m = NULL;
- wl_list_for_each(m, &mons, link)
+ wl_list_for_each(m, &mons, link) {
drawbar(m);
+ extrabar(m);
+ }
}
void
@@ -2896,7 +2941,7 @@ startdrag(struct wl_listener *listener, void *data)
int
statusin(int fd, unsigned int mask, void *data)
{
- char status[256];
+ char status[3*256];
ssize_t n;
if (mask & WL_EVENT_ERROR)
@@ -2911,7 +2956,18 @@ statusin(int fd, unsigned int mask, void *data)
status[n] = '\0';
status[strcspn(status, "\n")] = '\0';
- strncpy(stext, status, sizeof(stext));
+ char *l1 = strchr(status, ';');
+ if (l1) {
+ *l1 = '\0';
+ char *l2 = strchr(++l1, ';');
+ if (l2) {
+ *l2 = '\0';
+ strncpy(stext3, ++l2, sizeof(stext3));
+ }
+ strncpy(stext2, l1, sizeof(stext2));
+ }
+ strncpy(stext, status, sizeof(stext));
+
drawbars();
return 0;
@@ -3206,6 +3262,12 @@ updatebar(Monitor *m)
m->pool[i] = NULL;
}
+ for (i = 0; i < LENGTH(m->extra_pool); i++)
+ if (m->extra_pool[i]) {
+ wlr_buffer_drop(&m->extra_pool[i]->base);
+ m->extra_pool[i] = NULL;
+ }
+
if (m->b.scale == m->wlr_output->scale && m->drw)
return;
-13
View File
@@ -1,13 +0,0 @@
### Description
By default, dwl responds to client requests to client messages by setting the urgency bit on the named window.
This patch changes the focus to the window instead.
Both behaviours are legitimate according to the cursed spec.
This is the approximately the equivalent of the focusonactive patch of dwm.
If you want a more controlled behavior, for example setting which clients can focus, check [activation-rule patch](https://codeberg.org/sevz/dwl-patches/src/branch/activation-rules).
### Download
- [main dwl 0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusonurgent/focusonurgent.patch)
### Authors
- [André Desgualdo Pereira](https://codeberg.org/Kana)
-29
View File
@@ -1,29 +0,0 @@
From 7cdba8df596d59a3ad2883521a65962dcd4fe644 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= <desgua@gmail.com>
Date: Sat, 14 Mar 2026 17:52:25 -0300
Subject: [PATCH] update
---
dwl.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dwl.c b/dwl.c
index 101a45f..6cd2f82 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2099,8 +2099,10 @@ printstatus(void)
if (c->mon != m)
continue;
occ |= c->tags;
- if (c->isurgent)
- urg |= c->tags;
+ if (c->isurgent) {
+ view(&((Arg){ .ui = c->tags }));
+ focusclient(c, 1);
+ }
}
if ((c = focustop(m))) {
printf("%s title %s\n", m->wlr_output->name, client_get_title(c));
--
2.51.0
+5 -6
View File
@@ -1,9 +1,9 @@
### Description
# fullscreenadaptivesync - Enables adaptive sync/VRR when a client is fullscreen.
# fullscreenadaptivesync Enables adaptive sync/VRR when a client is fullscreen.
Adds a function that automatically enables adaptive sync/VRR when a fullscreen client is detected, and disables it once the client exits fullscreen.
---
1. **Why**
@@ -18,13 +18,12 @@ Adds a function that automatically enables adaptive sync/VRR when a fullscreen c
- When the client exits fullscreen, adaptive sync is disabled again.
4. **togglefullscreenadaptivesync**
- Adds a switch to enable or disable the fullscreenadaptivesync behavior.
- Adds a switch to enable or disable the fullscreenadaptivesync behavior.
- Enabled by default.
### Download
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/fullscreenadaptivesync-0.9)
- [0.8](./fullscreenadaptivesync-v0.8.patch)
- [main-d16036e](./fullscreenadaptivesync-d16036e.patch)
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/fullscreenadaptivesync)
- [0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/fullscreenadaptivesync/fullscreenadaptivesync-v0.7.patch)
### Authors
- [julmajustus](https://codeberg.org/julmajustus)
@@ -1,162 +0,0 @@
From 860793b4ff7b03c0fe4be03f2086ae5f25876293 Mon Sep 17 00:00:00 2001
From: julmajustus <julmajustus@tutanota.com>
Date: Sun, 20 Sep 2026 02:32:01 +0300
Subject: [PATCH] fullscreenadaptivesync refactor for d16036e
---
config.def.h | 1 +
dwl.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 13c5322..262e3f3 100644
--- a/config.def.h
+++ b/config.def.h
@@ -138,6 +138,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_F5, togglefullscreenadaptivesync, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_0, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
diff --git a/dwl.c b/dwl.c
index 4cfd0fd..c3ab2ba 100644
--- a/dwl.c
+++ b/dwl.c
@@ -340,6 +340,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
static void requestmonstate(struct wl_listener *listener, void *data);
static void resize(Client *c, struct wlr_box geo, int interact);
static void run(char *startup_cmd);
+static void set_adaptive_sync(Monitor *m, int enabled);
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);
@@ -357,6 +358,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 togglefullscreenadaptivesync(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);
@@ -462,6 +464,8 @@ static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener new_session_lock = {.notify = locksession};
static struct wl_listener new_foreign_toplevel_capture_request = {.notify = capturerequest};
+static int fullscreen_adaptive_sync_enabled = 1;
+
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -2453,6 +2457,43 @@ run(char *startup_cmd)
wl_display_run(dpy);
}
+void
+set_adaptive_sync(Monitor *m, int enable)
+{
+ struct wlr_output_state state;
+ struct wlr_output_configuration_v1 *config;
+ struct wlr_output_configuration_head_v1 *config_head;
+
+ if (!m || !m->wlr_output || !m->wlr_output->enabled
+ || !fullscreen_adaptive_sync_enabled)
+ return;
+
+ if (enable && m->wlr_output->adaptive_sync_status
+ == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED)
+ return;
+
+ if (!enable && m->wlr_output->adaptive_sync_status
+ == WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED)
+ return;
+
+ config = wlr_output_configuration_v1_create();
+ config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
+
+ /* Set and commit the adaptive sync state change */
+ wlr_output_state_init(&state);
+ wlr_output_state_set_adaptive_sync_enabled(&state, enable);
+ if (!wlr_output_commit_state(m->wlr_output, &state)) {
+ wlr_output_state_finish(&state);
+ wlr_output_configuration_v1_destroy(config);
+ return;
+ }
+ wlr_output_state_finish(&state);
+
+ /* Broadcast the adaptive sync state change to output_mgr */
+ config_head->state.adaptive_sync_enabled = enable;
+ wlr_output_manager_v1_set_configuration(output_mgr, config);
+}
+
void
setcursor(struct wl_listener *listener, void *data)
{
@@ -2516,10 +2557,12 @@ setfullscreen(Client *c, int fullscreen)
if (fullscreen) {
c->prev = c->geom;
resize(c, c->mon->m, 0);
+ set_adaptive_sync(c->mon, 1);
} else {
/* restore previous size instead of arrange for floating windows since
* client positions are set by the user and cannot be recalculated */
resize(c, c->prev, 0);
+ set_adaptive_sync(c->mon, 0);
}
arrange(c->mon);
printstatus();
@@ -2699,7 +2742,7 @@ setup(void)
output_layout = wlr_output_layout_create(dpy);
wl_signal_add(&output_layout->events.change, &layout_change);
- wlr_xdg_output_manager_v1_create(dpy, output_layout);
+ wlr_xdg_output_manager_v1_create(dpy, output_layout);
/* Configure a listener to be notified when new outputs are available on the
* backend. */
@@ -2795,8 +2838,8 @@ setup(void)
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
&new_virtual_keyboard);
virtual_pointer_mgr = wlr_virtual_pointer_manager_v1_create(dpy);
- wl_signal_add(&virtual_pointer_mgr->events.new_virtual_pointer,
- &new_virtual_pointer);
+ wl_signal_add(&virtual_pointer_mgr->events.new_virtual_pointer,
+ &new_virtual_pointer);
seat = wlr_seat_create(dpy, "seat0");
wl_signal_add(&seat->events.request_set_cursor, &request_cursor);
@@ -2930,6 +2973,12 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen);
}
+void
+togglefullscreenadaptivesync(const Arg *arg)
+{
+ fullscreen_adaptive_sync_enabled = !fullscreen_adaptive_sync_enabled;
+}
+
void
toggletag(const Arg *arg)
{
@@ -2985,6 +3034,7 @@ unmapnotify(struct wl_listener *listener, void *data)
{
/* Called when the surface is unmapped, and should no longer be shown. */
Client *c = wl_container_of(listener, c, unmap);
+ Monitor *lastmon = c->mon; // fullscreen_adaptive_sync
if (c == grabc) {
cursor_mode = CurNormal;
grabc = NULL;
@@ -3002,6 +3052,9 @@ unmapnotify(struct wl_listener *listener, void *data)
setmon(c, NULL, 0);
wl_list_remove(&c->flink);
}
+ /* Toggle adaptive sync off when fullscreen client is unmapped */
+ if (c->isfullscreen)
+ set_adaptive_sync(lastmon, 0);
if (c->foreign_toplevel_handle) {
wlr_ext_foreign_toplevel_handle_v1_destroy(c->foreign_toplevel_handle);
--
2.55.0
@@ -1,33 +1,30 @@
From b9bb8d48e1be3008d72da414f6f418d77f3ca16b Mon Sep 17 00:00:00 2001
From c003f450c197a0c960bbb355511f8dca7a35e3c3 Mon Sep 17 00:00:00 2001
From: julmajustus <julmajustus@tutanota.com>
Date: Mon, 22 Jun 2026 23:01:00 +0300
Subject: [PATCH] fullscreen_adaptive_sync: Minor bug fixes
Date: Sat, 4 Jan 2025 14:24:59 +0200
Subject: [PATCH] add fullscreenadaptivesync
- Fixed logic error inside unmapnotify
- Added no-op guards inside set_adaptive_sync
- Added extra check for the config commit success
---
config.def.h | 1 +
dwl.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
dwl.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..06b3153 100644
index 22d2171..886f1ab 100644
--- a/config.def.h
+++ b/config.def.h
@@ -138,6 +138,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_F5, togglefullscreenadaptivesync, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
@@ -142,6 +142,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_F5, togglefullscreenadaptivesync, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
diff --git a/dwl.c b/dwl.c
index 44f3ad9..e4f6a9d 100644
index a2711f6..7be05ef 100644
--- a/dwl.c
+++ b/dwl.c
@@ -319,6 +319,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
@@ -322,6 +322,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
static void requestmonstate(struct wl_listener *listener, void *data);
static void resize(Client *c, struct wlr_box geo, int interact);
static void run(char *startup_cmd);
@@ -35,7 +32,7 @@ index 44f3ad9..e4f6a9d 100644
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);
@@ -336,6 +337,7 @@ static void tagmon(const Arg *arg);
@@ -340,6 +341,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
@@ -43,16 +40,16 @@ index 44f3ad9..e4f6a9d 100644
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);
@@ -436,6 +438,8 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener new_session_lock = {.notify = locksession};
@@ -413,6 +415,8 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static int fullscreen_adaptive_sync_enabled = 1;
+
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -2296,6 +2300,43 @@ run(char *startup_cmd)
@@ -2269,6 +2273,31 @@ run(char *startup_cmd)
wl_display_run(dpy);
}
@@ -67,25 +64,13 @@ index 44f3ad9..e4f6a9d 100644
+ || !fullscreen_adaptive_sync_enabled)
+ return;
+
+ if (enable && m->wlr_output->adaptive_sync_status
+ == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED)
+ return;
+
+ if (!enable && m->wlr_output->adaptive_sync_status
+ == WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED)
+ return;
+
+ config = wlr_output_configuration_v1_create();
+ config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
+
+ /* Set and commit the adaptive sync state change */
+ wlr_output_state_init(&state);
+ wlr_output_state_set_adaptive_sync_enabled(&state, enable);
+ if (!wlr_output_commit_state(m->wlr_output, &state)) {
+ wlr_output_state_finish(&state);
+ wlr_output_configuration_v1_destroy(config);
+ return;
+ }
+ wlr_output_commit_state(m->wlr_output, &state);
+ wlr_output_state_finish(&state);
+
+ /* Broadcast the adaptive sync state change to output_mgr */
@@ -96,7 +81,7 @@ index 44f3ad9..e4f6a9d 100644
void
setcursor(struct wl_listener *listener, void *data)
{
@@ -2359,10 +2400,12 @@ setfullscreen(Client *c, int fullscreen)
@@ -2332,10 +2361,12 @@ setfullscreen(Client *c, int fullscreen)
if (fullscreen) {
c->prev = c->geom;
resize(c, c->mon->m, 0);
@@ -109,7 +94,7 @@ index 44f3ad9..e4f6a9d 100644
}
arrange(c->mon);
printstatus();
@@ -2760,6 +2803,12 @@ togglefullscreen(const Arg *arg)
@@ -2739,6 +2770,12 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen);
}
@@ -122,24 +107,16 @@ index 44f3ad9..e4f6a9d 100644
void
toggletag(const Arg *arg)
{
@@ -2815,6 +2864,7 @@ unmapnotify(struct wl_listener *listener, void *data)
{
/* Called when the surface is unmapped, and should no longer be shown. */
Client *c = wl_container_of(listener, c, unmap);
+ Monitor *lastmon = c->mon; // fullscreen_adaptive_sync
if (c == grabc) {
cursor_mode = CurNormal;
grabc = NULL;
@@ -2830,6 +2880,9 @@ unmapnotify(struct wl_listener *listener, void *data)
@@ -2809,6 +2846,9 @@ unmapnotify(struct wl_listener *listener, void *data)
setmon(c, NULL, 0);
wl_list_remove(&c->flink);
}
+ /* Toggle adaptive sync off when fullscreen client is unmapped */
+ if (c->isfullscreen)
+ set_adaptive_sync(lastmon, 0);
+ set_adaptive_sync(selmon, 0);
wlr_scene_node_destroy(&c->scene->node);
printstatus();
--
2.53.0
2.45.2
-8
View File
@@ -1,8 +0,0 @@
### Description
Gamepad bindings to dwl. Press `LB + RB` toggle gamepad bindings.
### Download
- [2026-07-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gamepad-bindings/gamepad-bindings.patch)
### Authors
- [dhruva_sambrani](https://codeberg.org/dhruva_sambrani)
@@ -1,423 +0,0 @@
diff --git a/Makefile b/Makefile
index 578194f..601c70e 100644
--- a/Makefile
+++ b/Makefile
@@ -12,16 +12,17 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
-Wfloat-conversion
# CFLAGS / LDFLAGS
-PKGS = wayland-server xkbcommon libinput $(XLIBS)
+PKGS = wayland-server xkbcommon libinput libevdev libudev $(XLIBS)
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
all: dwl
-dwl: dwl.o util.o
- $(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
-dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \
+dwl: dwl.o gamepad.o util.o
+ $(CC) dwl.o gamepad.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
+dwl.o: dwl.c client.h gamepad.h config.h config.mk cursor-shape-v1-protocol.h \
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
+gamepad.o: gamepad.c gamepad.h
util.o: util.c util.h
# wayland-scanner is a tool which generates C headers and rigging for Wayland
@@ -54,7 +55,7 @@ clean:
dist: clean
mkdir -p dwl-$(VERSION)
cp -R LICENSE* Makefile CHANGELOG.md README.md client.h config.def.h \
- config.mk protocols dwl.1 dwl.c util.c util.h dwl.desktop \
+ config.mk protocols dwl.1 dwl.c gamepad.c gamepad.h util.c util.h dwl.desktop \
dwl-$(VERSION)
tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION)
rm -rf dwl-$(VERSION)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..48270f6 100644
--- a/config.def.h
+++ b/config.def.h
@@ -165,6 +165,22 @@ static const Key keys[] = {
CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12),
};
+static const GamepadButton gamepadbuttons[] = {
+ { BTN_DPAD_DOWN, focusstack, {.i = +1} },
+ { BTN_DPAD_UP, focusstack, {.i = -1} },
+ { BTN_DPAD_LEFT, setmfact, {.f = -0.05f} },
+ { BTN_DPAD_RIGHT, setmfact, {.f = +0.05f} },
+ { BTN_SOUTH, zoom, {0} },
+ { BTN_EAST, setlayout, {.v = &layouts[0]} },
+ { BTN_NORTH, setlayout, {.v = &layouts[1]} },
+ { BTN_WEST, setlayout, {.v = &layouts[2]} },
+ { ABS_Z, focusmon, {.i = WLR_DIRECTION_LEFT} },
+ { ABS_RZ, focusmon, {.i = WLR_DIRECTION_RIGHT} },
+ { BTN_START, spawn, SHCMD("wmenu-run") },
+ { BTN_SELECT, winview, {0} },
+ { BTN_MODE, spawn, { "steam", NULL }},
+};
+
static const Button buttons[] = {
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
diff --git a/dwl.c b/dwl.c
index 101a45f..96e1c01 100644
--- a/dwl.c
+++ b/dwl.c
@@ -63,6 +63,7 @@
#include <wlr/util/log.h>
#include <wlr/util/region.h>
#include <xkbcommon/xkbcommon.h>
+#include "gamepad.h"
#ifdef XWAYLAND
#include <wlr/xwayland.h>
#include <xcb/xcb.h>
@@ -149,6 +150,12 @@ typedef struct {
const Arg arg;
} Key;
+typedef struct {
+ unsigned int button;
+ void (*func)(const Arg *);
+ const Arg arg;
+} GamepadButton;
+
typedef struct {
struct wlr_keyboard_group *wlr_group;
@@ -289,6 +296,7 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
+static void gamepadbutton(unsigned int button, int state);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@@ -398,6 +406,7 @@ static struct wlr_session_lock_v1 *cur_lock;
static struct wlr_seat *seat;
static KeyboardGroup *kb_group;
+static struct gamepad *gamepad;
static unsigned int cursor_mode;
static Client *grabc;
static int grabcx, grabcy; /* client-relative */
@@ -713,6 +722,7 @@ cleanup(void)
wlr_xcursor_manager_destroy(cursor_mgr);
destroykeyboardgroup(&kb_group->destroy, NULL);
+ gamepad_destroy(gamepad);
/* If it's not destroyed manually, it will cause a use-after-free of wlr_seat.
* Destroy it until it's fixed on the wlroots side */
@@ -1558,6 +1568,21 @@ gpureset(struct wl_listener *listener, void *data)
wlr_renderer_destroy(old_drw);
}
+void
+gamepadbutton(unsigned int button, int state)
+{
+ const GamepadButton *b;
+ if (!state || locked)
+ return;
+ wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+ for (b = gamepadbuttons; b < END(gamepadbuttons); b++) {
+ if (button == b->button && b->func) {
+ b->func(&b->arg);
+ break;
+ }
+ }
+}
+
void
handlesig(int signo)
{
@@ -2643,6 +2668,7 @@ setup(void)
kb_group = createkeyboardgroup();
wl_list_init(&kb_group->destroy.link);
+ gamepad = gamepad_create(event_loop, session, gamepadbutton);
output_mgr = wlr_output_manager_v1_create(dpy);
wl_signal_add(&output_mgr->events.apply, &output_mgr_apply);
diff --git a/gamepad.c b/gamepad.c
new file mode 100644
index 0000000..6bad2f6
--- /dev/null
+++ b/gamepad.c
@@ -0,0 +1,255 @@
+#include <fcntl.h>
+#include <libevdev/libevdev.h>
+#include <libudev.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <wayland-server-core.h>
+#include <wlr/backend/session.h>
+
+#include "gamepad.h"
+
+struct pad {
+ struct wl_list link;
+ char *path;
+ int fd;
+ struct libevdev *dev;
+ struct wl_event_source *src;
+ unsigned char key[KEY_CNT];
+ unsigned char abs[ABS_CNT];
+ int enabled;
+ GamepadHandler fn;
+};
+
+struct gamepad {
+ struct udev *udev;
+ struct udev_monitor *mon;
+ struct wl_event_source *msrc;
+ struct wl_event_loop *loop;
+ struct wl_list pads;
+ GamepadHandler fn;
+};
+
+static int
+ispad(struct udev_device *d)
+{
+ const char *p;
+
+ p = udev_device_get_property_value(d, "ID_INPUT_JOYSTICK");
+ return !strcmp(udev_device_get_subsystem(d), "input")
+ && !strncmp(udev_device_get_sysname(d), "event", 5)
+ && p && !strcmp(p, "1");
+}
+
+static void
+padstop(struct pad *p)
+{
+ if (p->src)
+ wl_event_source_remove(p->src);
+ if (p->dev)
+ libevdev_free(p->dev);
+ if (p->fd >= 0)
+ close(p->fd);
+ p->src = NULL;
+ p->dev = NULL;
+ p->fd = -1;
+}
+
+static void
+padclose(struct pad *p)
+{
+ padstop(p);
+ wl_list_remove(&p->link);
+ free(p->path);
+ free(p);
+}
+
+static int
+padin(int fd, uint32_t mask, void *data)
+{
+ struct pad *p = data;
+ struct input_event e;
+ int r, v;
+
+ if (mask & (WL_EVENT_HANGUP | WL_EVENT_ERROR)) {
+ padclose(p);
+ return 0;
+ }
+ while ((r = libevdev_next_event(p->dev, LIBEVDEV_READ_FLAG_NORMAL, &e)) == 0
+ || r == LIBEVDEV_READ_STATUS_SYNC) {
+ if (e.type == EV_KEY) {
+ v = !!e.value;
+ if (p->key[e.code] != v) {
+ p->key[e.code] = v;
+ if (p->enabled)
+ p->fn(e.code, v);
+ if ((e.code == BTN_TL || e.code == BTN_TR)
+ && p->key[BTN_TL] && p->key[BTN_TR] && v)
+ p->enabled ^= 1;
+ }
+ } else if (e.type == EV_ABS && (e.code == ABS_Z || e.code == ABS_RZ
+ || e.code == ABS_GAS || e.code == ABS_BRAKE)) {
+ const struct input_absinfo *a = libevdev_get_abs_info(p->dev, e.code);
+
+ v = e.value > (a->minimum + a->maximum) / 2;
+ if (p->abs[e.code] != v) {
+ p->abs[e.code] = v;
+ if (p->enabled)
+ p->fn(e.code, v);
+ }
+ } else if (e.type == EV_ABS && e.code == ABS_HAT0X) {
+ v = e.value + 1;
+ if (p->abs[e.code] != v) {
+ if (p->enabled) {
+ p->fn(BTN_DPAD_LEFT, 0);
+ p->fn(BTN_DPAD_RIGHT, 0);
+ }
+ p->abs[e.code] = v;
+ if (p->enabled) {
+ p->fn(BTN_DPAD_LEFT, e.value < 0);
+ p->fn(BTN_DPAD_RIGHT, e.value > 0);
+ }
+ }
+ } else if (e.type == EV_ABS && e.code == ABS_HAT0Y) {
+ v = e.value + 1;
+ if (p->abs[e.code] != v) {
+ if (p->enabled) {
+ p->fn(BTN_DPAD_UP, 0);
+ p->fn(BTN_DPAD_DOWN, 0);
+ }
+ p->abs[e.code] = v;
+ if (p->enabled) {
+ p->fn(BTN_DPAD_UP, e.value < 0);
+ p->fn(BTN_DPAD_DOWN, e.value > 0);
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+static void
+padstart(struct pad *p, struct wl_event_loop *loop)
+{
+ if (p->fd >= 0 || (p->fd = open(p->path, O_RDONLY | O_NONBLOCK | O_CLOEXEC)) < 0)
+ return;
+ if (libevdev_new_from_fd(p->fd, &p->dev)) {
+ close(p->fd);
+ p->fd = -1;
+ return;
+ }
+ if (!(p->src = wl_event_loop_add_fd(loop, p->fd, WL_EVENT_READABLE, padin, p)))
+ padstop(p);
+}
+
+static void
+padadd(struct gamepad *g, struct udev_device *d)
+{
+ struct pad *p;
+ struct pad *q;
+ const char *path;
+
+ if (!ispad(d) || !(path = udev_device_get_devnode(d)))
+ return;
+ wl_list_for_each(q, &g->pads, link) {
+ if (!strcmp(q->path, path))
+ return;
+ }
+ if (!(p = calloc(1, sizeof(*p))))
+ return;
+ if (!(p->path = strdup(path))) {
+ free(p);
+ return;
+ }
+ p->fd = -1;
+ p->enabled = 0;
+ p->fn = g->fn;
+ wl_list_insert(&g->pads, &p->link);
+ padstart(p, g->loop);
+}
+
+static void
+padremove(struct gamepad *g, const char *path)
+{
+ struct pad *p, *t;
+
+ wl_list_for_each_safe(p, t, &g->pads, link) {
+ if (!strcmp(p->path, path)) {
+ padclose(p);
+ break;
+ }
+ }
+}
+
+static int
+monin(int fd, uint32_t mask, void *data)
+{
+ struct gamepad *g = data;
+ struct udev_device *d;
+ const char *a;
+ const char *path;
+
+ if (!(d = udev_monitor_receive_device(g->mon)))
+ return 0;
+ a = udev_device_get_action(d);
+ path = udev_device_get_devnode(d);
+ if (a && !strcmp(a, "add"))
+ padadd(g, d);
+ else if (a && !strcmp(a, "remove") && path)
+ padremove(g, path);
+ udev_device_unref(d);
+ return 0;
+}
+
+struct gamepad *
+gamepad_create(struct wl_event_loop *loop, struct wlr_session *s, GamepadHandler fn)
+{
+ struct gamepad *g;
+ struct udev_enumerate *e;
+ struct udev_list_entry *l;
+ struct udev_device *d;
+
+ if (!s || !(g = calloc(1, sizeof(*g))) || !(g->udev = udev_new()))
+ return NULL;
+ g->loop = loop;
+ g->fn = fn;
+ wl_list_init(&g->pads);
+ if ((e = udev_enumerate_new(g->udev))) {
+ udev_enumerate_add_match_subsystem(e, "input");
+ udev_enumerate_scan_devices(e);
+ udev_list_entry_foreach(l, udev_enumerate_get_list_entry(e)) {
+ d = udev_device_new_from_syspath(g->udev, udev_list_entry_get_name(l));
+ if (d) {
+ padadd(g, d);
+ udev_device_unref(d);
+ }
+ }
+ udev_enumerate_unref(e);
+ }
+ if (!(g->mon = udev_monitor_new_from_netlink(g->udev, "udev"))
+ || udev_monitor_filter_add_match_subsystem_devtype(g->mon, "input", NULL)
+ || udev_monitor_enable_receiving(g->mon)
+ || !(g->msrc = wl_event_loop_add_fd(loop, udev_monitor_get_fd(g->mon), WL_EVENT_READABLE, monin, g))) {
+ gamepad_destroy(g);
+ return NULL;
+ }
+ return g;
+}
+
+void
+gamepad_destroy(struct gamepad *g)
+{
+ struct pad *p, *t;
+
+ if (!g)
+ return;
+ wl_list_for_each_safe(p, t, &g->pads, link)
+ padclose(p);
+ if (g->msrc)
+ wl_event_source_remove(g->msrc);
+ if (g->mon)
+ udev_monitor_unref(g->mon);
+ if (g->udev)
+ udev_unref(g->udev);
+ free(g);
+}
diff --git a/gamepad.h b/gamepad.h
new file mode 100644
index 0000000..5d45d28
--- /dev/null
+++ b/gamepad.h
@@ -0,0 +1,15 @@
+#ifndef GAMEPAD_H
+#define GAMEPAD_H
+
+#include <linux/input.h>
+
+struct gamepad;
+struct wl_event_loop;
+struct wlr_session;
+
+typedef void (*GamepadHandler)(unsigned int, int);
+
+struct gamepad *gamepad_create(struct wl_event_loop *, struct wlr_session *, GamepadHandler);
+void gamepad_destroy(struct gamepad *);
+
+#endif
+3 -6
View File
@@ -4,19 +4,16 @@ Arranges windows in a grid. Except it adjusts the number of windows in the first
On widescreens (w > 2*h), it splits to three columns before splitting rows.
### Download
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid.patch)
- [2025-10-31](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20251031.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20240918.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid.patch)
- [2024-07-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20240714.patch)
- [2023-08-01](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20230801.patch)
- [git branch](https://codeberg.org/Kana/dwl/src/branch/gaplessgrid)
- [git branch](https://codeberg.org/dhruva_sambrani/dwl/src/branch/gaplessgrid)
## Pre-codeberg
- [2023-11-14](https://github.com/djpohly/dwl/compare/main...Sneethe:gaplessgrid.patch)
- [2021-07-27](https://github.com/djpohly/dwl/compare/main...vnepogodin:gaplessgrid.patch)
### Authors
- [André Desgualdo Pereira](https://codeberg.org/Kana)
- [Dhruva Sambrani](https://codeberg.org/dhruva_sambrani/) (Revived to codeberg)
- [Sneethe](https://github.com/Sneethe/)
- [Vladislav Nepogodin](https://github.com/vnepogodin)
- [Dhruva Sambrani](https://codeberg.org/dhruva_sambrani/) (Revived to codeberg)
@@ -1,89 +0,0 @@
diff --git a/config.def.h b/config.def.h
index 22d2171..014a909 100644
--- a/config.def.h
+++ b/config.def.h
@@ -34,6 +34,7 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "###", gaplessgrid },
};
/* monitors */
@@ -139,6 +140,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XKB_KEY_g, setlayout, {.v = &layouts[3]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index dc0c861..875d8cd 100644
--- a/dwl.c
+++ b/dwl.c
@@ -292,6 +292,7 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
+static void gaplessgrid(Monitor *m);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@@ -1510,6 +1511,56 @@ handlesig(int signo)
}
}
+void
+gaplessgrid(Monitor *m)
+{
+ unsigned int n = 0, i = 0, ch, cw, cn, rn, rows, cols;
+ Client *c;
+
+ wl_list_for_each(c, &clients, link)
+ if (VISIBLEON(c, m) && !c->isfloating)
+ n++;
+ if (n == 0)
+ return;
+
+ /* grid dimensions */
+ for (cols = 0; cols <= (n / 2); cols++)
+ if ((cols * cols) >= n)
+ break;
+
+ if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
+ cols = 2;
+
+ /* widescreen is better if 3 columns */
+ if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1)
+ cols = 3;
+
+ rows = n / cols;
+
+ /* window geometries */
+ cw = cols ? m->w.width / cols : m->w.width;
+ cn = 0; /* current column number */
+ rn = 0; /* current row number */
+ wl_list_for_each(c, &clients, link) {
+ unsigned int cx, cy;
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+
+ if ((i / rows + 1) > (cols - n % cols))
+ rows = n / cols + 1;
+ ch = rows ? m->w.height / rows : m->w.height;
+ cx = m->w.x + cn * cw;
+ cy = m->w.y + rn * ch;
+ resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0);
+ rn++;
+ if (rn >= rows) {
+ rn = 0;
+ cn++;
+ }
+ i++;
+ }
+}
+
void
incnmaster(const Arg *arg)
{
@@ -1,102 +0,0 @@
From 38427b81367e8b4d2aad708a1d463bc793aac65e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= <desgua@gmail.com>
Date: Fri, 31 Oct 2025 15:46:48 -0300
Subject: [PATCH] take on gaplessgrid and fix minor indentation and typos
---
config.def.h | 2 ++
dwl.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/config.def.h b/config.def.h
index 95c2afa..2054107 100644
--- a/config.def.h
+++ b/config.def.h
@@ -34,6 +34,7 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "###", gaplessgrid },
};
/* monitors */
@@ -139,6 +140,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XKB_KEY_g, setlayout, {.v = &layouts[3]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index 12f441e..7ab5323 100644
--- a/dwl.c
+++ b/dwl.c
@@ -288,6 +288,7 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
+static void gaplessgrid(Monitor *m);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@@ -1566,6 +1567,56 @@ handlesig(int signo)
quit(NULL);
}
+void
+gaplessgrid(Monitor *m)
+{
+ int n = 0, i = 0, ch, cw, cn, rn, rows, cols;
+ Client *c;
+
+ wl_list_for_each(c, &clients, link)
+ if (VISIBLEON(c, m) && !c->isfloating)
+ n++;
+ if (n == 0)
+ return;
+
+ /* grid dimensions */
+ for (cols = 0; cols <= (n / 2); cols++)
+ if ((cols * cols) >= n)
+ break;
+
+ if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
+ cols = 2;
+
+ /* widescreen is better if 3 columns */
+ if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1)
+ cols = 3;
+
+ rows = n / cols;
+
+ /* window geometries */
+ cw = cols ? m->w.width / cols : m->w.width;
+ cn = 0; /* current column number */
+ rn = 0; /* current row number */
+ wl_list_for_each(c, &clients, link) {
+ unsigned int cx, cy;
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+
+ if ((i / rows + 1) > (cols - n % cols))
+ rows = n / cols + 1;
+ ch = rows ? m->w.height / rows : m->w.height;
+ cx = m->w.x + cn * cw;
+ cy = m->w.y + rn * ch;
+ resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0);
+ rn++;
+ if (rn >= rows) {
+ rn = 0;
+ cn++;
+ }
+ i++;
+ }
+}
+
void
incnmaster(const Arg *arg)
{
--
2.51.0
+19 -32
View File
@@ -1,18 +1,8 @@
From 91d34b1c664fe273a82eb7ff01e92b828feab5a9 Mon Sep 17 00:00:00 2001
From: nate zhou <gnuunixchad@outlook.com>
Date: Sat, 28 Feb 2026 21:42:04 +0800
Subject: [PATCH] Patch: gaplessgrid.patch
---
config.def.h | 2 ++
dwl.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..8cb1782 100644
index 22d2171..014a909 100644
--- a/config.def.h
+++ b/config.def.h
@@ -33,6 +33,7 @@ static const Layout layouts[] = {
@@ -34,6 +34,7 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
@@ -20,19 +10,19 @@ index 8a6eda0..8cb1782 100644
};
/* monitors */
@@ -135,6 +136,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XKB_KEY_g, setlayout, {.v = &layouts[3]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
@@ -139,6 +140,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XKB_KEY_g, setlayout, {.v = &layouts[3]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index 44f3ad9..83c053f 100644
index dc0c861..875d8cd 100644
--- a/dwl.c
+++ b/dwl.c
@@ -288,6 +288,7 @@ static void focusstack(const Arg *arg);
@@ -292,6 +292,7 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
@@ -40,14 +30,14 @@ index 44f3ad9..83c053f 100644
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@@ -1566,6 +1567,56 @@ handlesig(int signo)
quit(NULL);
@@ -1510,6 +1511,56 @@ handlesig(int signo)
}
}
+void
+gaplessgrid(Monitor *m)
+{
+ int n = 0, i = 0, ch, cw, cn, rn, rows, cols;
+ unsigned int n = 0, i = 0, ch, cw, cn, rn, rows, cols;
+ Client *c;
+
+ wl_list_for_each(c, &clients, link)
@@ -64,12 +54,12 @@ index 44f3ad9..83c053f 100644
+ if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
+ cols = 2;
+
+ /* widescreen is better if 3 columns */
+ if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1)
+ cols = 3;
+ /* widescreen is better if 3 columns */
+ if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1)
+ cols = 3;
+
+ rows = n / cols;
+
+
+ /* window geometries */
+ cw = cols ? m->w.width / cols : m->w.width;
+ cn = 0; /* current column number */
@@ -97,6 +87,3 @@ index 44f3ad9..83c053f 100644
void
incnmaster(const Arg *arg)
{
--
2.53.0
+2 -3
View File
@@ -15,11 +15,10 @@ gaps to be as big or bigger than "inner" gaps anyway.
### Download
- [0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/genericgaps/genericgaps.patch)
- [0.7 2025-02-11](https://codeberg.org/dwl/dwl-patches/raw/commit/58e371fcb31bde1e55f99498a77afd9b567a30c8/patches/genericgaps/genericgaps-0.7.patch):
- [0.7 2025-02-11](/dwl/dwl-patches/raw/branch/main/patches/genericgaps/genericgaps-0.7.patch):
added support for `smartgaps` and `monoclegaps` settings and removed the suck
from `arrange()` function
- [0.7](https://codeberg.org/dwl/dwl-patches/raw/commit/f8d1cfad116c19c01593f7436468ec0cb7a3297b/patches/genericgaps/genericgaps.patch)
- [0.7](/dwl/dwl-patches/raw/branch/main/patches/genericgaps/genericgaps.patch)
### Authors
+134 -158
View File
@@ -1,25 +1,23 @@
From ac0b983fef16eb904b77d6b5e98bd61f5cf719f5 Mon Sep 17 00:00:00 2001
From: nate zhou <gnuunixchad@outlook.com>
Date: Sat, 28 Feb 2026 23:28:08 +0800
Subject: [PATCH] Patch: genericgaps-0.8.patch
From f2a1b84369266d252fbea57c6f1eb64253617452 Mon Sep 17 00:00:00 2001
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
Date: Thu, 12 Dec 2024 22:44:53 +0100
Subject: [PATCH] Add genericgaps
---
config.def.h | 23 ++++++
dwl.c | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 220 insertions(+), 1 deletion(-)
config.def.h | 22 +++++++
dwl.c | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 190 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..4adc866 100644
index 22d2171..930af12 100644
--- a/config.def.h
+++ b/config.def.h
@@ -6,7 +6,14 @@
/* appearance */
@@ -7,6 +7,12 @@
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 enablegaps = 1; /* 1 means gaps are enabled */
static const unsigned int borderpx = 1; /* border pixel of windows */
+static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */
+static const int monoclegaps = 0; /* 1 means outer gaps in monocle layout */
static const unsigned int borderpx = 1; /* border pixel of windows */
+static const unsigned int gappih = 10; /* horiz inner gap between windows */
+static const unsigned int gappiv = 10; /* vert inner gap between windows */
+static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
@@ -27,38 +25,45 @@ index 8a6eda0..4adc866 100644
static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
@@ -129,6 +136,22 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_h, incgaps, {.i = +1 } },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_l, incgaps, {.i = -1 } },
+ { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_H, incogaps, {.i = +1 } },
+ { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_L, incogaps, {.i = -1 } },
+ { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL, XKB_KEY_h, incigaps, {.i = +1 } },
+ { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL, XKB_KEY_l, incigaps, {.i = -1 } },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_0, togglegaps, {0} },
+ { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_parenright,defaultgaps, {0} },
+ { MODKEY, XKB_KEY_y, incihgaps, {.i = +1 } },
+ { MODKEY, XKB_KEY_o, incihgaps, {.i = -1 } },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_y, incivgaps, {.i = +1 } },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_o, incivgaps, {.i = -1 } },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_y, incohgaps, {.i = +1 } },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_o, incohgaps, {.i = -1 } },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Y, incovgaps, {.i = +1 } },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_O, incovgaps, {.i = -1 } },
{ MODKEY, XKB_KEY_Return, zoom, {0} },
{ MODKEY, XKB_KEY_Tab, view, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_c, killclient, {0} },
@@ -133,6 +139,22 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_h, incgaps, {.i = +1 } },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_l, incgaps, {.i = -1 } },
+ { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_H, incogaps, {.i = +1 } },
+ { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_L, incogaps, {.i = -1 } },
+ { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL, XKB_KEY_h, incigaps, {.i = +1 } },
+ { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL, XKB_KEY_l, incigaps, {.i = -1 } },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_0, togglegaps, {0} },
+ { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_parenright,defaultgaps, {0} },
+ { MODKEY, XKB_KEY_y, incihgaps, {.i = +1 } },
+ { MODKEY, XKB_KEY_o, incihgaps, {.i = -1 } },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_y, incivgaps, {.i = +1 } },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_o, incivgaps, {.i = -1 } },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_y, incohgaps, {.i = +1 } },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_o, incohgaps, {.i = -1 } },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Y, incovgaps, {.i = +1 } },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_O, incovgaps, {.i = -1 } },
{ MODKEY, XKB_KEY_Return, zoom, {0} },
{ MODKEY, XKB_KEY_Tab, view, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
diff --git a/dwl.c b/dwl.c
index 44f3ad9..a3164cb 100644
index def2562..c14ae43 100644
--- a/dwl.c
+++ b/dwl.c
@@ -197,6 +197,11 @@ struct Monitor {
@@ -107,6 +107,7 @@ typedef struct Monitor Monitor;
typedef struct {
/* Must keep these three elements in this order */
unsigned int type; /* XDGShell or X11* */
+ int interact;
struct wlr_box geom; /* layout-relative, includes border */
Monitor *mon;
struct wlr_scene_tree *scene;
@@ -200,6 +201,10 @@ struct Monitor {
struct wlr_box w; /* window area, layout-relative */
struct wl_list layers[4]; /* LayerSurface.link */
const Layout *lt[2];
+ int enablegaps; /* enable gaps, used by togglegaps */
+ int gappih; /* horizontal gap between windows */
+ int gappiv; /* vertical gap between windows */
+ int gappoh; /* horizontal outer gaps */
@@ -66,15 +71,7 @@ index 44f3ad9..a3164cb 100644
unsigned int seltags;
unsigned int sellt;
uint32_t tagset[2];
@@ -243,6 +248,7 @@ typedef struct {
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
static void arrange(Monitor *m);
+void arrangegaps(Monitor *m);
static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m);
@@ -271,6 +277,7 @@ static void createpopup(struct wl_listener *listener, void *data);
@@ -273,6 +278,7 @@ static void createpopup(struct wl_listener *listener, void *data);
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
static void cursorframe(struct wl_listener *listener, void *data);
static void cursorwarptohint(void);
@@ -82,7 +79,7 @@ index 44f3ad9..a3164cb 100644
static void destroydecoration(struct wl_listener *listener, void *data);
static void destroydragicon(struct wl_listener *listener, void *data);
static void destroyidleinhibitor(struct wl_listener *listener, void *data);
@@ -290,6 +297,13 @@ static void fullscreennotify(struct wl_listener *listener, void *data);
@@ -293,6 +299,13 @@ static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
@@ -96,23 +93,24 @@ index 44f3ad9..a3164cb 100644
static void inputdevice(struct wl_listener *listener, void *data);
static int keybinding(uint32_t mods, xkb_keysym_t sym);
static void keypress(struct wl_listener *listener, void *data);
@@ -310,6 +324,7 @@ static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int
static void outputmgrtest(struct wl_listener *listener, void *data);
static void pointerfocus(Client *c, struct wlr_surface *surface,
double sx, double sy, uint32_t time);
+static void preparegaps(Monitor *m);
static void printstatus(void);
static void powermgrsetmode(struct wl_listener *listener, void *data);
static void quit(const Arg *arg);
@@ -323,6 +338,7 @@ static void setcursor(struct wl_listener *listener, void *data);
@@ -320,13 +333,15 @@ static void rendermon(struct wl_listener *listener, void *data);
static void requestdecorationmode(struct wl_listener *listener, void *data);
static void requeststartdrag(struct wl_listener *listener, void *data);
static void requestmonstate(struct wl_listener *listener, void *data);
-static void resize(Client *c, struct wlr_box geo, int interact);
+static void resizeapply(Client *c, struct wlr_box geo, int interact);
+static void resizenoapply(Client *c, struct wlr_box geo, int interact);
static void run(char *startup_cmd);
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 setgamma(struct wl_listener *listener, void *data);
+static void setgaps(int oh, int ov, int ih, int iv);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, uint32_t newtags);
@@ -336,6 +352,7 @@ static void tagmon(const Arg *arg);
@@ -340,6 +355,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
@@ -120,82 +118,83 @@ index 44f3ad9..a3164cb 100644
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);
@@ -435,6 +452,7 @@ static struct wl_listener request_set_cursor_shape = {.notify = setcursorshape};
static struct wl_listener request_start_drag = {.notify = requeststartdrag};
static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener new_session_lock = {.notify = locksession};
+static int resizelock = 0; /* do not actually resize during arrange */
@@ -413,6 +429,9 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static int enablegaps = 1; /* enables gaps, used by togglegaps */
+static void (*resize)(Client *c, struct wlr_box geo, int interact) = resizeapply;
+
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
@@ -537,12 +555,52 @@ arrange(Monitor *m)
static void associatex11(struct wl_listener *listener, void *data);
@@ -481,9 +500,25 @@ applyrules(Client *c)
setmon(c, mon, newtags);
}
+void
+applygaps(Client *c)
+{
+ struct wlr_box geom = c->geom;
+
+ if (!c->mon)
+ return;
+
+ geom.x += c->mon->gappih + c->mon->gappoh;
+ geom.y += c->mon->gappiv + c->mon->gappov;
+ geom.width -= c->mon->gappih;
+ geom.height -= c->mon->gappiv;
+ resize(c, geom, 0);
+}
+
void
arrange(Monitor *m)
{
+ int save_width, save_height;
Client *c;
if (!m->wlr_output->enabled)
@@ -515,8 +550,26 @@ arrange(Monitor *m)
: c->scene->node.parent);
}
- if (m->lt[m->sellt]->arrange)
+ if (m->lt[m->sellt]->arrange) {
+ preparegaps(m);
+ save_width = m->w.width;
+ save_height = m->w.height;
+ if (enablegaps) {
+ m->w.width -= m->gappih + 2 * m->gappoh;
+ m->w.height -= m->gappiv + 2 * m->gappov;
+ }
+ resize = resizenoapply;
m->lt[m->sellt]->arrange(m);
+ arrangegaps(m);
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+ if (enablegaps)
+ applygaps(c);
+ resizeapply(c, c->geom, c->interact);
+ }
+ m->w.width = save_width;
+ m->w.height = save_height;
+ resize = resizeapply;
+ }
motionnotify(0, NULL, 0, 0, 0, 0);
checkidleinhibitor(NULL);
}
@@ -993,6 +1046,11 @@ createmon(struct wl_listener *listener, void *data)
+void
+arrangegaps(Monitor *m)
+{
+ Client *c;
+ int n, gaps;
wlr_output_state_init(&state);
/* Initialize monitor state using configured rules */
+
+ if (!m->enablegaps)
+ return;
+
+ resizelock = 0;
+
+ n = 0;
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+ n++;
+ }
+
+ gaps = !(smartgaps && n == 1) &&
+ (monoclegaps || m->lt[m->sellt]->arrange != monocle);
+ if (gaps) {
+ m->w.width += m->gappih + 2 * m->gappoh;
+ m->w.height += m->gappiv + 2 * m->gappov;
+ }
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+ if (gaps) {
+ c->geom.x += c->mon->gappih + c->mon->gappoh;
+ c->geom.y += c->mon->gappiv + c->mon->gappov;
+ c->geom.width -= c->mon->gappih;
+ c->geom.height -= c->mon->gappiv;
+ }
+ resize(c, c->geom, 0);
+ }
+}
+
void
arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int exclusive)
{
@@ -1055,6 +1113,12 @@ createmon(struct wl_listener *listener, void *data)
for (i = 0; i < LENGTH(m->layers); i++)
wl_list_init(&m->layers[i]);
+ m->enablegaps = enablegaps;
+ m->gappih = gappih;
+ m->gappiv = gappiv;
+ m->gappoh = gappoh;
+ m->gappov = gappov;
+
wlr_output_state_init(&state);
/* Initialize monitor state using configured rules */
m->tagset[0] = m->tagset[1] = 1;
@@ -1237,6 +1301,12 @@ cursorwarptohint(void)
for (r = monrules; r < END(monrules); r++) {
if (!r->name || strstr(wlr_output->name, r->name)) {
@@ -1173,6 +1231,12 @@ cursorwarptohint(void)
}
}
@@ -208,7 +207,7 @@ index 44f3ad9..a3164cb 100644
void
destroydecoration(struct wl_listener *listener, void *data)
{
@@ -1575,6 +1645,83 @@ incnmaster(const Arg *arg)
@@ -1526,6 +1590,83 @@ incnmaster(const Arg *arg)
arrange(selmon);
}
@@ -292,52 +291,31 @@ index 44f3ad9..a3164cb 100644
void
inputdevice(struct wl_listener *listener, void *data)
{
@@ -2085,6 +2232,31 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
wlr_seat_pointer_notify_motion(seat, time, sx, sy);
@@ -2180,7 +2321,7 @@ requestmonstate(struct wl_listener *listener, void *data)
}
void
-resize(Client *c, struct wlr_box geo, int interact)
+resizeapply(Client *c, struct wlr_box geo, int interact)
{
struct wlr_box *bbox;
struct wlr_box clip;
@@ -2212,6 +2353,13 @@ resize(Client *c, struct wlr_box geo, int interact)
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
}
+void
+preparegaps(Monitor *m)
+resizenoapply(Client *c, struct wlr_box geo, int interact)
+{
+ Client *c;
+ int n;
+
+ if (!m->enablegaps)
+ return;
+
+ n = 0;
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+ n++;
+ }
+
+ resizelock = 1;
+
+ if ((smartgaps && n == 1) || (!monoclegaps && m->lt[m->sellt]->arrange == monocle))
+ return;
+
+ m->w.width -= m->gappih + 2 * m->gappoh;
+ m->w.height -= m->gappiv + 2 * m->gappov;
+ c->geom = geo;
+ c->interact = interact;
+}
+
void
printstatus(void)
run(char *startup_cmd)
{
@@ -2208,6 +2380,11 @@ resize(Client *c, struct wlr_box geo, int interact)
struct wlr_box *bbox;
struct wlr_box clip;
+ if (resizelock) {
+ c->geom = geo;
+ return;
+ }
+
if (!c->mon || !client_surface(c)->mapped)
return;
@@ -2368,6 +2545,16 @@ setfullscreen(Client *c, int fullscreen)
printstatus();
@@ -2354,6 +2502,16 @@ setgamma(struct wl_listener *listener, void *data)
wlr_output_schedule_frame(m->wlr_output);
}
+void
@@ -353,16 +331,14 @@ index 44f3ad9..a3164cb 100644
void
setlayout(const Arg *arg)
{
@@ -2760,6 +2947,15 @@ togglefullscreen(const Arg *arg)
@@ -2741,6 +2899,13 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen);
}
+void
+togglegaps(const Arg *arg)
+{
+ if (!selmon)
+ return;
+ selmon->enablegaps = !selmon->enablegaps;
+ enablegaps = !enablegaps;
+ arrange(selmon);
+}
+
@@ -370,5 +346,5 @@ index 44f3ad9..a3164cb 100644
toggletag(const Arg *arg)
{
--
2.53.0
2.47.1
@@ -83,7 +83,7 @@ diff -up ../../dwl_my_contribution/dwl/dwl.c ./dwl.c
+ cols = 3;
+
+ rows = n / cols;
+
+
+ /* window geometries */
+ cw = cols ? m->w.width / cols : m->w.width;
+ cn = 0; /* current column number */
@@ -1,5 +1,5 @@
### Description
Implements `swaymsg create_output` command, it allows you to create virtual/headless outputs. But in combination with a VNC server (for example wayvnc), this allows you to essentially have additional monitors, by connecting to the VNC server with an appropriate client (for example on an tablet or laptop).
Implements `swaymsg create_output` command, it allows you to create virtual/headless outputs. But in combination with a VNC server (for example wayvnc), this allows you to essentially have additional monitors, by connecting to the VNC server with an appropiate client (for example on an tablet or laptop).
If you plan to use wayvnc, you'll need [virtual-pointer](https://codeberg.org/dwl/dwl-patches/wiki/virtual-pointer.-) patch as well
@@ -8,4 +8,4 @@ If you plan to use wayvnc, you'll need [virtual-pointer](https://codeberg.org/dw
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/0096e49402bc59b4050e12cdb9befb79d0011006/headless/headless.patch)
### Authors
- [wochap](https://codeberg.org/wochap)
- [wochap](https://codeberg.org/wochap)
-12
View File
@@ -1,12 +0,0 @@
### Description
Hides all slave clients behind last focused slave in deck layout.
### Dependencies
This patch depends on [decklayout](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/decklayout/) and [hide-behind-monocle](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/hide-behind-monocle/) patches (suggest installing it in metioned sequence).
### Download
- [0.8](/dwl/dwl-patches/raw/branch/main/patches/hide-behind-deck/hide-behind-deck.patch)
### Authors
- [tvtur](https://codeberg.org/tvtur)
@@ -1,132 +0,0 @@
From 295945a45db881627501eb4dbca151aaa6b8b8ed Mon Sep 17 00:00:00 2001
From: tvtur <tur.timothy@gmail.com>
Date: Mon, 13 Apr 2026 13:21:13 +0300
Subject: [PATCH] hide-behind-deck
---
dwl.c | 54 +++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 37 insertions(+), 17 deletions(-)
diff --git a/dwl.c b/dwl.c
index 5d6db1a..090d44d 100644
--- a/dwl.c
+++ b/dwl.c
@@ -137,7 +137,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, ismaster;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -290,7 +290,7 @@ static Client *focustop(Monitor *m, int onlytiled);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
static void handlesig(int signo);
-static void hidebehindmonocle(Monitor *m);
+static void hidebehind(Monitor *m);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
static int keybinding(uint32_t mods, xkb_keysym_t sym);
@@ -1431,7 +1431,7 @@ focusclient(Client *c, int lift)
wl_list_insert(&fstack, &c->flink);
selmon = c->mon;
c->isurgent = 0;
- hidebehindmonocle(c->mon);
+ hidebehind(c->mon);
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
@@ -1573,21 +1573,38 @@ handlesig(int signo)
}
void
-hidebehindmonocle(Monitor *m)
+hidebehind(Monitor *m)
{
Client *c;
- if (m && m->lt[m->sellt]->arrange == monocle) {
- wl_list_for_each(c, &clients, link) {
- if (c->mon != m)
- continue;
- wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m) && c->isfloating);
- }
+ int check1 = 0;
- c = NULL;
-
- /* Enable top tiled client, fullscreen is considered tiled */
- if ((c = focustop(m, 1)))
- wlr_scene_node_set_enabled(&c->scene->node, 1);
+ if (m) {
+ if (m && m->lt[m->sellt]->arrange == monocle) {
+ wl_list_for_each(c, &clients, link) {
+ if (c->mon != m)
+ continue;
+ wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m) && c->isfloating);
+ }
+ c = NULL;
+ /* Enable top tiled client, fullscreen is considered tiled */
+ if ((c = focustop(m, 1)))
+ wlr_scene_node_set_enabled(&c->scene->node, 1);
+ } else if (m && m->lt[m->sellt]->arrange == deck) {
+ wl_list_for_each(c, &fstack, flink) {
+ if (!VISIBLEON(c, m))
+ continue;
+ if (c->isfloating || c->ismaster) {
+ wlr_scene_node_set_enabled(&c->scene->node, 1);
+ continue;
+ }
+ if (!check1 && !c->ismaster) {
+ wlr_scene_node_set_enabled(&c->scene->node, 1);
+ check1 = 1;
+ continue;
+ }
+ wlr_scene_node_set_enabled(&c->scene->node, 0);
+ }
+ }
}
}
@@ -1859,7 +1876,7 @@ monocle(Monitor *m)
}
if (n)
snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n);
- hidebehindmonocle(m);
+ hidebehind(m);
}
void
@@ -1871,7 +1888,6 @@ deck(Monitor *m)
/* count tiled clients */
wl_list_for_each(c, &clients, link)
-
/* if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) */
if (VISIBLEON(c, m) && !c->isfloating)
n++;
@@ -1909,6 +1925,7 @@ deck(Monitor *m)
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)
}, 0);
my += c->geom.height;
+ c->ismaster = 1;
} else {
/* deck clients: overlap in stack area */
resize(c, (struct wlr_box){
@@ -1917,9 +1934,12 @@ deck(Monitor *m)
.width = m->w.width - mw,
.height = m->w.height
}, 0);
+ c->ismaster = 0;
}
i++;
}
+
+ hidebehind(m);
}
void
--
2.53.0
-2
View File
@@ -5,8 +5,6 @@ Hide all clients behind the focused one in the monocle layout
- [git branch](https://codeberg.org/sevz/dwl/src/branch/hide-behind-monocle)
- [main 2025-01-20](/dwl/dwl-patches/raw/branch/main/patches/hide-behind-monocle/hide-behind-monocle.patch)
- [hide-behind-monocle-0.7.patch](/dwl/dwl-patches/raw/branch/main/patches/hide-behind-monocle/hide-behind-monocle-0.7.patch)
- [hide-behind-monocle-0.8.patch](/dwl/dwl-patches/raw/branch/main/patches/hide-behind-monocle/hide-behind-monocle-0.8.patch)
### Authors
- [tvtur](https://codeberg.org/tvtur)
- [sevz](https://codeberg.org/sevz)
@@ -1,327 +0,0 @@
From de87e122a354fde6f22610c1a15d6cc0b17f465a Mon Sep 17 00:00:00 2001
From: tvtur <tur.timothy@gmail.com>
Date: Sun, 23 Aug 2026 20:45:49 +0300
Subject: [PATCH] patch
---
dwl.c | 87 +++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 55 insertions(+), 32 deletions(-)
diff --git a/dwl.c b/dwl.c
index 44f3ad9..ec712e9 100644
--- a/dwl.c
+++ b/dwl.c
@@ -285,10 +285,11 @@ static Monitor *dirtomon(enum wlr_direction dir);
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
-static Client *focustop(Monitor *m);
+static Client *focustop(Monitor *m, int onlytiled);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
static void handlesig(int signo);
+static void hidebehindmonocle(Monitor *m);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
static int keybinding(uint32_t mods, xkb_keysym_t sym);
@@ -519,7 +520,7 @@ arrange(Monitor *m)
}
wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
- (c = focustop(m)) && c->isfullscreen);
+ (c = focustop(m, 0)) && c->isfullscreen);
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
@@ -813,7 +814,7 @@ closemon(Monitor *m)
if (c->mon == m)
setmon(c, selmon, c->tags);
}
- focusclient(focustop(selmon), 1);
+ focusclient(focustop(selmon, 0), 1);
printstatus();
}
@@ -1250,7 +1251,7 @@ void
destroydragicon(struct wl_listener *listener, void *data)
{
/* Focus enter isn't sent during drag, so refocus the focused node. */
- focusclient(focustop(selmon), 1);
+ focusclient(focustop(selmon, 0), 1);
motionnotify(0, NULL, 0, 0, 0, 0);
wl_list_remove(&listener->link);
free(listener);
@@ -1289,7 +1290,7 @@ destroylock(SessionLock *lock, int unlock)
wlr_scene_node_set_enabled(&locked_bg->node, 0);
- focusclient(focustop(selmon), 0);
+ focusclient(focustop(selmon, 0), 0);
motionnotify(0, NULL, 0, 0, 0, 0);
destroy:
@@ -1318,7 +1319,7 @@ destroylocksurface(struct wl_listener *listener, void *data)
surface = wl_container_of(cur_lock->surfaces.next, surface, link);
client_notify_enter(surface->surface, wlr_seat_get_keyboard(seat));
} else if (!locked) {
- focusclient(focustop(selmon), 1);
+ focusclient(focustop(selmon, 0), 1);
} else {
wlr_seat_keyboard_clear_focus(seat);
}
@@ -1429,6 +1430,7 @@ focusclient(Client *c, int lift)
wl_list_insert(&fstack, &c->flink);
selmon = c->mon;
c->isurgent = 0;
+ hidebehindmonocle(c->mon);
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
@@ -1482,14 +1484,14 @@ focusmon(const Arg *arg)
selmon = dirtomon(arg->i);
while (!selmon->wlr_output->enabled && i++ < nmons);
}
- focusclient(focustop(selmon), 1);
+ focusclient(focustop(selmon, 0), 1);
}
void
focusstack(const Arg *arg)
{
/* Focus the next or previous client (in tiling order) on selmon */
- Client *c, *sel = focustop(selmon);
+ Client *c, *sel = focustop(selmon, 0);
if (!sel || (sel->isfullscreen && !client_has_children(sel)))
return;
if (arg->i > 0) {
@@ -1515,12 +1517,15 @@ focusstack(const Arg *arg)
* will focus the topmost client of this mon, when actually will
* only return that client */
Client *
-focustop(Monitor *m)
+focustop(Monitor *m, int onlytiled)
{
Client *c;
wl_list_for_each(c, &fstack, flink) {
- if (VISIBLEON(c, m))
+ if (VISIBLEON(c, m)) {
+ if (onlytiled && c->isfloating)
+ continue;
return c;
+ }
}
return NULL;
}
@@ -1566,6 +1571,25 @@ handlesig(int signo)
quit(NULL);
}
+void
+hidebehindmonocle(Monitor *m)
+{
+ Client *c;
+ if (m && m->lt[m->sellt]->arrange == monocle) {
+ wl_list_for_each(c, &clients, link) {
+ if (c->mon != m)
+ continue;
+ wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m) && c->isfloating);
+ }
+
+ c = NULL;
+
+ /* Enable top tiled client, fullscreen is considered tiled */
+ if ((c = focustop(m, 1)))
+ wlr_scene_node_set_enabled(&c->scene->node, 1);
+ }
+}
+
void
incnmaster(const Arg *arg)
{
@@ -1705,7 +1729,7 @@ keyrepeat(void *data)
void
killclient(const Arg *arg)
{
- Client *sel = focustop(selmon);
+ Client *sel = focustop(selmon, 0);
if (sel)
client_send_close(sel);
}
@@ -1834,8 +1858,7 @@ monocle(Monitor *m)
}
if (n)
snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n);
- if ((c = focustop(m)))
- wlr_scene_node_raise_to_top(&c->scene->node);
+ hidebehindmonocle(m);
}
void
@@ -2101,7 +2124,7 @@ printstatus(void)
if (c->isurgent)
urg |= c->tags;
}
- if ((c = focustop(m))) {
+ if ((c = focustop(m, 0))) {
printf("%s title %s\n", m->wlr_output->name, client_get_title(c));
printf("%s appid %s\n", m->wlr_output->name, client_get_appid(c));
printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen);
@@ -2417,7 +2440,7 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
setfloating(c, c->isfloating);
}
- focusclient(focustop(selmon), 1);
+ focusclient(focustop(selmon, 0), 1);
}
void
@@ -2691,12 +2714,12 @@ startdrag(struct wl_listener *listener, void *data)
void
tag(const Arg *arg)
{
- Client *sel = focustop(selmon);
+ Client *sel = focustop(selmon, 0);
if (!sel || (arg->ui & TAGMASK) == 0)
return;
sel->tags = arg->ui & TAGMASK;
- focusclient(focustop(selmon), 1);
+ focusclient(focustop(selmon, 0), 1);
arrange(selmon);
printstatus();
}
@@ -2704,7 +2727,7 @@ tag(const Arg *arg)
void
tagmon(const Arg *arg)
{
- Client *sel = focustop(selmon);
+ Client *sel = focustop(selmon, 0);
if (sel)
setmon(sel, dirtomon(arg->i), 0);
}
@@ -2746,7 +2769,7 @@ tile(Monitor *m)
void
togglefloating(const Arg *arg)
{
- Client *sel = focustop(selmon);
+ Client *sel = focustop(selmon, 0);
/* return if fullscreen */
if (sel && !sel->isfullscreen)
setfloating(sel, !sel->isfloating);
@@ -2755,7 +2778,7 @@ togglefloating(const Arg *arg)
void
togglefullscreen(const Arg *arg)
{
- Client *sel = focustop(selmon);
+ Client *sel = focustop(selmon, 0);
if (sel)
setfullscreen(sel, !sel->isfullscreen);
}
@@ -2764,12 +2787,12 @@ void
toggletag(const Arg *arg)
{
uint32_t newtags;
- Client *sel = focustop(selmon);
+ Client *sel = focustop(selmon, 0);
if (!sel || !(newtags = sel->tags ^ (arg->ui & TAGMASK)))
return;
sel->tags = newtags;
- focusclient(focustop(selmon), 1);
+ focusclient(focustop(selmon, 0), 1);
arrange(selmon);
printstatus();
}
@@ -2782,7 +2805,7 @@ toggleview(const Arg *arg)
return;
selmon->tagset[selmon->seltags] = newtagset;
- focusclient(focustop(selmon), 1);
+ focusclient(focustop(selmon, 0), 1);
arrange(selmon);
printstatus();
}
@@ -2806,7 +2829,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
arrangelayers(l->mon);
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
- focusclient(focustop(selmon), 1);
+ focusclient(focustop(selmon, 0), 1);
motionnotify(0, NULL, 0, 0, 0, 0);
}
@@ -2823,7 +2846,7 @@ unmapnotify(struct wl_listener *listener, void *data)
if (client_is_unmanaged(c)) {
if (c == exclusive_focus) {
exclusive_focus = NULL;
- focusclient(focustop(selmon), 1);
+ focusclient(focustop(selmon, 0), 1);
}
} else {
wl_list_remove(&c->link);
@@ -2904,7 +2927,7 @@ updatemons(struct wl_listener *listener, void *data)
/* Don't move clients to the left output when plugging monitors */
arrange(m);
/* make sure fullscreen clients have the right size */
- if ((c = focustop(m)) && c->isfullscreen)
+ if ((c = focustop(m, 0)) && c->isfullscreen)
resize(c, m->m, 0);
/* Try to re-set the gamma LUT when updating monitors,
@@ -2924,7 +2947,7 @@ updatemons(struct wl_listener *listener, void *data)
if (!c->mon && client_surface(c)->mapped)
setmon(c, selmon, c->tags);
}
- focusclient(focustop(selmon), 1);
+ focusclient(focustop(selmon, 0), 1);
if (selmon->lock_surface) {
client_notify_enter(selmon->lock_surface->surface,
wlr_seat_get_keyboard(seat));
@@ -2946,7 +2969,7 @@ void
updatetitle(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, set_title);
- if (c == focustop(c->mon))
+ if (c == focustop(c->mon, 0))
printstatus();
}
@@ -2956,7 +2979,7 @@ urgent(struct wl_listener *listener, void *data)
struct wlr_xdg_activation_v1_request_activate_event *event = data;
Client *c = NULL;
toplevel_from_wlr_surface(event->surface, &c, NULL);
- if (!c || c == focustop(selmon))
+ if (!c || c == focustop(selmon, 0))
return;
c->isurgent = 1;
@@ -2974,7 +2997,7 @@ view(const Arg *arg)
selmon->seltags ^= 1; /* toggle sel tagset */
if (arg->ui & TAGMASK)
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
- focusclient(focustop(selmon), 1);
+ focusclient(focustop(selmon, 0), 1);
arrange(selmon);
printstatus();
}
@@ -3045,7 +3068,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
void
zoom(const Arg *arg)
{
- Client *c, *sel = focustop(selmon);
+ Client *c, *sel = focustop(selmon, 0);
if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
return;
@@ -3156,7 +3179,7 @@ sethints(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, set_hints);
struct wlr_surface *surface = client_surface(c);
- if (c == focustop(selmon) || !c->surface.xwayland->hints)
+ if (c == focustop(selmon, 0) || !c->surface.xwayland->hints)
return;
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
--
2.54.0
-15
View File
@@ -1,15 +0,0 @@
### Description
Hide the mouse cursor when you start typing, and restore it again when the
mouse cursor moves or a mouse button is pressed, just like
[xbanish](https://github.com/jcs/xbanish).
### credits
Some code is taken from the
[unclutter](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/unclutter) patch.
### Download
[v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/hide-cursor-when-typing/hide-cursor-when-typing.patch)
### Authors
- [unixchad](https://codeberg.org/unixchad/)
@@ -1,204 +0,0 @@
From a73f5a4c7dd636d999cfab15610e68e170d2f597 Mon Sep 17 00:00:00 2001
From: nate zhou <gnuunixchad@outlook.com>
Date: Fri, 10 Apr 2026 19:38:43 +0800
Subject: [PATCH] Patch: hide-cursor-when-typing-0.8.patch
---
config.def.h | 2 ++
dwl.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 85 insertions(+), 7 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..6205c0a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -102,6 +102,8 @@ LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
*/
static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
+static const int hide_cursor_when_typing = 1;
+
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
#define MODKEY WLR_MODIFIER_ALT
diff --git a/dwl.c b/dwl.c
index 44f3ad9..7325f7a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -288,6 +288,8 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
+static void handlecursoractivity(void);
+static int hidecursor(void *data);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@@ -389,6 +391,14 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
static struct wlr_cursor *cursor;
static struct wlr_xcursor_manager *cursor_mgr;
+static bool cursor_hidden = false;
+static struct {
+ enum wp_cursor_shape_device_v1_shape shape;
+ struct wlr_surface *surface;
+ int hotspot_x;
+ int hotspot_y;
+ struct wl_listener destroy;
+} last_cursor;
static struct wlr_scene_rect *root_bg;
static struct wlr_session_lock_manager_v1 *session_lock_mgr;
@@ -610,6 +620,7 @@ axisnotify(struct wl_listener *listener, void *data)
* for example when you move the scroll wheel. */
struct wlr_pointer_axis_event *event = data;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+ handlecursoractivity();
/* TODO: allow usage of scroll wheel for mousebindings, it can be implemented
* by checking the event's orientation and the delta of the event */
/* Notify the client with pointer focus of the axis event. */
@@ -628,6 +639,7 @@ buttonpress(struct wl_listener *listener, void *data)
const Button *b;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+ handlecursoractivity();
switch (event->state) {
case WL_POINTER_BUTTON_STATE_PRESSED:
@@ -1566,6 +1578,33 @@ handlesig(int signo)
quit(NULL);
}
+void
+handlecursoractivity(void)
+{
+ if (!cursor_hidden)
+ return;
+
+ cursor_hidden = false;
+
+ if (last_cursor.shape) {
+ wlr_cursor_set_xcursor(cursor, cursor_mgr,
+ wlr_cursor_shape_v1_name(last_cursor.shape));
+ } else if (last_cursor.surface) {
+ wlr_cursor_set_surface(cursor, last_cursor.surface,
+ last_cursor.hotspot_x, last_cursor.hotspot_y);
+ } else {
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
+ }
+}
+
+int
+hidecursor(void *data)
+{
+ wlr_cursor_unset_image(cursor);
+ cursor_hidden = true;
+ return 1;
+}
+
void
incnmaster(const Arg *arg)
{
@@ -1645,6 +1684,11 @@ keypress(struct wl_listener *listener, void *data)
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+ /* hide cursor when typing starts */
+ if (hide_cursor_when_typing && !cursor_hidden && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
+ hidecursor(NULL);
+ }
+
/* On _press_ if there is no active screen locker,
* attempt to process a compositor keybinding. */
if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
@@ -1907,6 +1951,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
wlr_cursor_move(cursor, device, dx, dy);
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+ handlecursoractivity();
/* Update selmon (even while dragging a window) */
if (sloppyfocus)
@@ -1931,7 +1976,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
/* If there's no client surface under the cursor, set the cursor image to a
* default. This is what makes the cursor image appear when you move it
* off of a client or over its border. */
- if (!surface && !seat->drag)
+ if (!surface && !seat->drag && !cursor_hidden)
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
pointerfocus(c, surface, sx, sy, time);
@@ -2296,6 +2341,15 @@ run(char *startup_cmd)
wl_display_run(dpy);
}
+void
+unlastcursor(struct wl_listener *listener, void *data)
+{
+ /* When the surface is destroyed, clear our reference to it */
+ last_cursor.surface = NULL;
+ wl_list_remove(&last_cursor.destroy.link);
+ wl_list_init(&last_cursor.destroy.link);
+}
+
void
setcursor(struct wl_listener *listener, void *data)
{
@@ -2311,9 +2365,23 @@ setcursor(struct wl_listener *listener, void *data)
* use the provided surface as the cursor image. It will set the
* hardware cursor on the output that it's currently on and continue to
* do so as the cursor moves between outputs. */
- if (event->seat_client == seat->pointer_state.focused_client)
- wlr_cursor_set_surface(cursor, event->surface,
- event->hotspot_x, event->hotspot_y);
+ if (event->seat_client == seat->pointer_state.focused_client) {
+ last_cursor.shape = 0;
+ last_cursor.surface = event->surface;
+ last_cursor.hotspot_x = event->hotspot_x;
+ last_cursor.hotspot_y = event->hotspot_y;
+
+ wl_list_remove(&last_cursor.destroy.link);
+ wl_list_init(&last_cursor.destroy.link);
+ if (event->surface) {
+ last_cursor.destroy.notify = unlastcursor;
+ wl_signal_add(&event->surface->events.destroy, &last_cursor.destroy);
+ }
+
+ if (!cursor_hidden)
+ wlr_cursor_set_surface(cursor, event->surface,
+ event->hotspot_x, event->hotspot_y);
+ }
}
void
@@ -2325,9 +2393,14 @@ setcursorshape(struct wl_listener *listener, void *data)
/* This can be sent by any client, so we check to make sure this one
* actually has pointer focus first. If so, we can tell the cursor to
* use the provided cursor shape. */
- if (event->seat_client == seat->pointer_state.focused_client)
- wlr_cursor_set_xcursor(cursor, cursor_mgr,
- wlr_cursor_shape_v1_name(event->shape));
+ if (event->seat_client == seat->pointer_state.focused_client) {
+ last_cursor.shape = event->shape;
+ last_cursor.surface = NULL;
+
+ if (!cursor_hidden)
+ wlr_cursor_set_xcursor(cursor, cursor_mgr,
+ wlr_cursor_shape_v1_name(event->shape));
+ }
}
void
@@ -2592,6 +2665,9 @@ setup(void)
cursor = wlr_cursor_create();
wlr_cursor_attach_output_layout(cursor, output_layout);
+ /* Initialize the last_cursor destroy listener link so it's safe to remove later */
+ wl_list_init(&last_cursor.destroy.link);
+
/* Creates an xcursor manager, another wlroots utility which loads up
* Xcursor themes to source cursor images from and makes sure that cursor
* images are available at all scale factors on the screen (necessary for
--
2.53.0
+5 -5
View File
@@ -15,7 +15,7 @@ So in short:
#### Limitations
Reloading the compositor will replace all functionality except for `main`, `setup`, `run` and the reload logic.
Note that you're responsible yourself for reloading resources like fonts, which may only get acquired once.
Note that you're responsible yourself for reloading ressources like fonts, which may only get acquired once.
A lot of components of dwl will also only get run on a trigger (the tiling for example).
So not every change will be immediate.
Furthermore, any patch adding more global state to dwl cannot currently be reloaded properly since
@@ -47,13 +47,13 @@ From the cold part there are some newly available macros:
* `CSYM(T, v)` dynamically accesses the value of the symbol `v` of type `T` from the shared object. Use this to query values from config.h for example.
* `LISTEN_GLOBAL(E, L)` is similar to the `LISTEN` macro. `E` is an event and `L` the name of a global
listener. Current implementation is a bit messy and I may fix it if someone bothers me about it.
* `UNLISTEN(L)` takes a listener and unregisters it. This is important for reloading.
* `UNLISTEN(L)` takes a listener and unregisteres it. This is important for reloading.
When adding new code there are some considerations to be made. Since dwl decorates all symbols with `static` by default, we cannot access them as-is.
C's macro system is a bit too powerful though and we use this to our advantage. We will repeatedly define and
undefine a macro called `static` in order to replace the `static` keyword inside some sections.
This allows us to do less refactoring and preserve a lot of the original patch compatibility since we're only
strategically adding lines. We're trying to be as minimally invasive as we can.
This allows us to do less refactoring and preserve a lot of the original patch compatability since we're only
strategically adding lines. We're tring to be as minimally invasive as we can.
As a general guide:
* global state should be global for the cold part and `extern` in the cold part meaning it should be inside a block like this:
```C
@@ -87,7 +87,7 @@ Thus, we enclose them the same way we do functions:
#ifdef HOT
... // function definitions here
#endif
* enforce use of the `LISTEN_GLOBAL` and `UNLISTEN` macros (I know this sucks but what can I do, I need to get
* enfore use of the `LISTEN_GLOBAL` and `UNLISTEN` macros (I know this sucks but what can I do, I need to get
access to the callbacks somehow). So you want
* `wl_list_remove(listener.link)` to become `UNLISTEN(listener)` and
* `wl_signal_add(event, global_listener)` to become `LISTEN_GLOBAL(event, global_listener)`.
+1 -1
View File
@@ -509,7 +509,7 @@ index def2562..1c9ab67 100644
+ wlr_log_init(CSYM(enum wlr_log_importance, log_level), NULL);
/* The Wayland display is managed by libwayland. It handles accepting
* clients from the Unix socket, managing Wayland globals, and so on. */
* clients from the Unix socket, manging Wayland globals, and so on. */
@@ -2454,7 +2576,7 @@ setup(void)
/* Initialize the scene graph used to lay out windows */
+1 -1
View File
@@ -637,7 +637,7 @@ index 4816159..70e99be 100644
+ wlr_log_init(CSYM(enum wlr_log_importance, log_level), NULL);
/* The Wayland display is managed by libwayland. It handles accepting
* clients from the Unix socket, managing Wayland globals, and so on. */
* clients from the Unix socket, manging Wayland globals, and so on. */
@@ -2463,7 +2602,7 @@ setup(void)
/* Initialize the scene graph used to lay out windows */
+1 -2
View File
@@ -10,10 +10,9 @@ Examples provided:
- exclude certain keyboards (eg ydotool) from keyboard group
### Download
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/inputdevicerules/inputdevicerules-v0.8.patch)
- [git branch](https://codeberg.org/bencc/dwl/src/branch/inputdevicerules)
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/inputdevicerules/inputdevicerules-v0.7.patch)
- [v0.6](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/inputdevicerules/inputdevicerules-v0.6.patch)
### Authors
- [Viktor Woloszczuk](https://codeberg.org/vwoloszczuk)
- [Ben Collerson](https://codeberg.org/bencc)
@@ -1,173 +0,0 @@
From 31c8493d7f2a863949a91cd14769e28894f259e7 Mon Sep 17 00:00:00 2001
From: Viktor Woloszczuk <viktor@woloszcz.uk>
Date: Wed, 11 Mar 2026 19:41:02 +0000
Subject: [PATCH] input device rules (v0.8)
* customise input device handling
* ignore unwanted input devices
* configure a toggle for an input device
---
config.def.h | 13 ++++++++++
dwl.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 79 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..4dbcfd1 100644
--- a/config.def.h
+++ b/config.def.h
@@ -56,6 +56,18 @@ static const struct xkb_rule_names xkb_rules = {
.options = NULL,
};
+/* input devices */
+static const InputRule inputrules[] = {
+ /* name kbcreate ptrcreate */
+ /* ignore bad device - like a touchpad ;) */
+ { "BAD DEVICE", NULL, NULL },
+ /* ungroup ydotool device - fixes a bug */
+ { "ydotoold virtual device", createungroupedkeyboard, createpointer },
+ /* put your touchpad name here to enable toggle touchpad */
+ { "Elan Touchpad", createkeyboard, createtogglepointer },
+ { NULL, createkeyboard, createpointer },
+};
+
static const int repeat_rate = 25;
static const int repeat_delay = 600;
@@ -138,6 +150,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_u, togglepointer, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
diff --git a/dwl.c b/dwl.c
index 44f3ad9..42557fe 100644
--- a/dwl.c
+++ b/dwl.c
@@ -141,6 +141,12 @@ typedef struct {
uint32_t resize; /* configure serial of a pending resize */
} Client;
+typedef struct {
+ const char *name;
+ void (*kbcreate)(struct wlr_keyboard *);
+ void (*ptrcreate)(struct wlr_pointer *);
+} InputRule;
+
typedef struct {
uint32_t mod;
xkb_keysym_t keysym;
@@ -268,6 +274,8 @@ static void createnotify(struct wl_listener *listener, void *data);
static void createpointer(struct wlr_pointer *pointer);
static void createpointerconstraint(struct wl_listener *listener, void *data);
static void createpopup(struct wl_listener *listener, void *data);
+static void createtogglepointer(struct wlr_pointer *pointer);
+static void createungroupedkeyboard(struct wlr_keyboard *keyboard);
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
static void cursorframe(struct wl_listener *listener, void *data);
static void cursorwarptohint(void);
@@ -336,6 +344,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 togglepointer(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);
@@ -406,6 +415,8 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static struct libinput_device *togglepointerdevice = NULL;
+
/* global event handlers */
static struct wl_listener cursor_axis = {.notify = axisnotify};
static struct wl_listener cursor_button = {.notify = buttonpress};
@@ -1199,6 +1210,33 @@ createpopup(struct wl_listener *listener, void *data)
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
}
+void
+createtogglepointer(struct wlr_pointer *pointer)
+{
+ struct libinput_device *device;
+
+ createpointer(pointer);
+
+ if (wlr_input_device_is_libinput(&pointer->base)
+ && (device = wlr_libinput_get_device_handle(&pointer->base))) {
+ togglepointerdevice = device;
+ }
+}
+
+void
+createungroupedkeyboard(struct wlr_keyboard *keyboard)
+{
+ /* for keyboards that need their own keyboard group */
+ KeyboardGroup *group = createkeyboardgroup();
+
+ /* Set the keymap to match the group keymap */
+ wlr_keyboard_set_keymap(keyboard, group->wlr_group->keyboard.keymap);
+ LISTEN(&keyboard->base.events.destroy, &group->destroy, destroykeyboardgroup);
+
+ /* Add the new keyboard to the group */
+ wlr_keyboard_group_add_keyboard(group->wlr_group, keyboard);
+}
+
void
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
{
@@ -1582,13 +1620,27 @@ inputdevice(struct wl_listener *listener, void *data)
* available. */
struct wlr_input_device *device = data;
uint32_t caps;
+ const InputRule *r;
switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:
- createkeyboard(wlr_keyboard_from_input_device(device));
+ for (r = inputrules; r < END(inputrules); r++) {
+ if (!r->name || strstr(device->name, r->name)) {
+ if (r->kbcreate)
+ r->kbcreate(wlr_keyboard_from_input_device(device));
+ break;
+ }
+ }
+
break;
case WLR_INPUT_DEVICE_POINTER:
- createpointer(wlr_pointer_from_input_device(device));
+ for (r = inputrules; r < END(inputrules); r++) {
+ if (!r->name || strstr(device->name, r->name)) {
+ if (r->ptrcreate)
+ r->ptrcreate(wlr_pointer_from_input_device(device));
+ break;
+ }
+ }
break;
default:
/* TODO handle other input device types */
@@ -2760,6 +2812,18 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen);
}
+void
+togglepointer(const Arg *arg)
+{
+ if (!togglepointerdevice)
+ return;
+
+ libinput_device_config_send_events_set_mode(
+ togglepointerdevice,
+ libinput_device_config_send_events_get_mode(togglepointerdevice) ^ LIBINPUT_CONFIG_SEND_EVENTS_DISABLED
+ );
+}
+
void
toggletag(const Arg *arg)
{
--
2.53.0
+15 -4
View File
@@ -1,17 +1,28 @@
### Description
Largely based on [raphi](https://sr.ht/~raphi/)'s [somebar](https://sr.ht/~raphi/somebar/), this patch provides an ipc for wayland clients to get and set dwl state. The ipc is intended for status bars, but can also be scripted with tools like [dwlmsg](https://codeberg.org/julmajustus/dwlmsg).
Largely based on [raphi](https://sr.ht/~raphi/)'s [somebar](https://sr.ht/~raphi/somebar/), this patch provides an ipc for wayland clients to get and set dwl state. The ipc is intended for status bars, but can also be scripted with tools like [dwlmsg](https://codeberg.org/notchoc/dwlmsg).
Status information to stdout is currently disabled as dwl tends to freeze. For now, `dwlmsg -w` should act as a drop-in replacement.
Note to [pertag](../pertag/) users: apply [this](./ipcpertag.patch) for ipc tagsetting to work as expected
### Download
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/ipc-0.9)
- [main-d16036e](./ipc.patch)
- [git branch](https://codeberg.org/notchoc/dwl/src/branch/ipc)
- [2024-08-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/ipc/ipc.patch)
- [2024-07-29](https://codeberg.org/dwl/dwl-patches/raw/commit/d235f0f88ed069eca234da5a544fb1c6e19f1d33/patches/ipc/ipc.patch) don't focus other outputs (apply [this minipatch](./focus-tagset-output.patch) if you'd prefer that)
- [2024-07-16](https://codeberg.org/dwl/dwl-patches/raw/commit/642b2559d522034785c1c1203c6d426855ec19ca/patches/ipc/ipc.patch)
- [2024-06-30](https://codeberg.org/dwl/dwl-patches/raw/commit/9a751e5020133d3ab9219e68a43109c6f3c931a7/patches/ipc/ipc.patch)
- [2024-06-21](https://codeberg.org/dwl/dwl-patches/raw/commit/f96ee44cbaef06bd38b8fa29ac7ecba8b1b5abd5/patches/ipc/ipc.patch)
- [2024-06-19](https://codeberg.org/dwl/dwl-patches/raw/commit/e69afc7263b8d982a7923e5d4910f2e1f7140bb8/patches/ipc/ipc.patch)
- [2024-06-08](https://codeberg.org/dwl/dwl-patches/raw/commit/f8598a91b44acc3bd7e9041be97265bbce8fa219/patches/ipc/ipc.patch)
- [2024-03-13](https://codeberg.org/dwl/dwl-patches/raw/commit/0150cfebbcd85f2d6e6728afad345a11a0c45947/ipc/ipc.patch)
- [2024-02-20](https://codeberg.org/dwl/dwl-patches/raw/commit/0c5ae06e4bc1d7f641376e8fcb86b43bd48ce2ee/ipc/ipc.patch)
- [2023-10-28](https://gist.githubusercontent.com/fbushstone/b116c44340eb7a7878de1119dd931ca5/raw/ee66ac9e2a5dddd9b528df553e21080c2811e974/ipc-v2-fixed.patch) Updated version of 2023-04-29, prevents ipc from freezing the compositor in printstatus.
- [2023-04-29](https://github.com/djpohly/dwl/compare/main...madcowog:ipc-v2.patch) Use this for dwl-ipc-unstable-v2. If you are using commit [9d68554](https://github.com/djpohly/dwl/commit/9d68554c59a886b641d27a364884fb461af2d4f1) or later, use this. For status bars this protocol is supported by dwlb, Waybar and dwl-bar.
- [2023-04-29](https://github.com/djpohly/dwl/compare/main...madcowog:ipc-bbdf2.patch) Use this for dwl-ipc-unstable-v1. If you are using commit [bbdaf2a9](https://github.com/djpohly/dwl/commit/bbdf2a913b72e7a308ee0dfde6518a4285d4a775), [release 0.4](https://github.com/djpohly/dwl/releases/tag/v0.4) or earlier, use this. For status bars, this protocol is supported by dwl-bar.
- [2023-02-20](https://lists.sr.ht/~raphi/public-inbox/patches/39166) Use this for net-tapesoftware-dwl-wm-unstable-v1. If you are using commit [c69a2bec](https://github.com/djpohly/dwl/commit/c69a2bec3ff417fbc4ea8fec0a49096773e01e7d) or later, use this. For status bars this protocol is supported by somebar.
### Authors
- [MadcowOG](https://github.com/MadcowOG)
- [fbushstone](https://github.com/fbushstone)
- [notchoc](https://codeberg.org/notchoc)
- [snuk](https://codeberg.org/snuk)
- [julmajustus](https://codeberg.org/julmajustus)

Some files were not shown because too many files have changed in this diff Show More