nageyqma·git
HTTPS https://git.nageyqma.icu/nageyqma/wm.git SSH git@git.nageyqma.icu:nageyqma/wm.git

HTTPS 链接可直接 git clone;推送代码请使用 SSH。

仅展示默认分支 main 最近 100 条提交。

remove my stupid compile argumentnageyqma · 2026-10-28 · ff6c03b
查看变更
Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 620fe3d..de016a0 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@ dwl: dwl.c client.h config.h ime.h util.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
-	$(CC) -O3 dwl.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
+	$(CC) dwl.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
 
 # wayland-scanner is a tool which generates C headers and rigging for Wayland
 # protocols, which are specified in XML. wlroots requires you to rig these up
clean stupid functions that i never actually usenageyqma · 2026-10-28 · a0733b9
查看变更
config.def.h |  3 ---
 dwl.c        | 51 ++++++---------------------------------------------
 2 files changed, 6 insertions(+), 48 deletions(-)
diff --git a/config.def.h b/config.def.h
index 06d96ef..2adcc4f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -164,10 +164,7 @@ static const Key keys[] = {
 	{ MODKEY,                    XKB_KEY_w,           focusstack,       {.i = +1} },
 	{ MODKEY,                    XKB_KEY_Up,          focusstack,       {.i = -1} },
 	{ MODKEY,                    XKB_KEY_Down,        focusstack,       {.i = +1} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_j,           focusstackhid,    {.i = +1} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_k,           focusstackhid,    {.i = -1} },
 	{ MODKEY,                    XKB_KEY_h,           hide,             {0} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_h,           show,             {0} },
 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_s,           showall,          {0} },
 	{ MODKEY,                    XKB_KEY_a,           setmfact,         {.f = -0.05f} },
 	{ MODKEY,                    XKB_KEY_s,           setmfact,         {.f = +0.05f} },
diff --git a/dwl.c b/dwl.c
index 45752a3..9c22b69 100644
--- a/dwl.c
+++ b/dwl.c
@@ -168,7 +168,7 @@ typedef struct {
 	unsigned int bw;
 	uint32_t tags;
 	int isfloating, isurgent, isfullscreen;
-	int ishidden, tempshow; /* hidden from its tags, or only while focused */
+	int ishidden; /* hidden from its tags */
 	/* Position-only slide; c->geom stays the authoritative layout box. */
 	struct timespec animstart; /* CLOCK_MONOTONIC start of the slide */
 	int animx, animy;          /* displayed position when the slide started */
@@ -351,8 +351,6 @@ static void drawbars(void);
 static void focusclient(Client *c, LayerSurface *l, int lift);
 static void focusmon(const Arg *arg);
 static void focusstack(const Arg *arg);
-static void focusstackdir(int inc, int hid);
-static void focusstackhid(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);
@@ -400,7 +398,6 @@ 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);
@@ -2004,13 +2001,6 @@ focusclient(Client *c, LayerSurface *l, int lift)
 				&& !(old_c && client_wants_focus(old_c))
 				&& !seat->drag)
 			client_set_border_color(c, focuscolor);
-
-		/* Focusing a hidden client shows it until focus moves away */
-		if (c->ishidden) {
-			c->ishidden = 0;
-			c->tempshow = 1;
-			arrange(c->mon);
-		}
 	}
 
 	/* If an overlay is focused, don't focus or activate the client,
@@ -2029,8 +2019,6 @@ focusclient(Client *c, LayerSurface *l, int lift)
 			client_set_border_color(focused_client, bordercolor);
 		if (s && s->mapped)
 			client_activate_surface(s, 0);
-		if (focused_client->tempshow)
-			hideclient(focused_client);
 		focused_client = NULL;
 	}
 	printstatus();
@@ -2071,35 +2059,22 @@ focusmon(const Arg *arg)
 void
 focusstack(const Arg *arg)
 {
-	focusstackdir(arg->i, 0);
-}
-
-void
-focusstackhid(const Arg *arg)
-{
-	focusstackdir(arg->i, 1);
-}
-
-void
-focusstackdir(int inc, int hid)
-{
-	/* Focus the next or previous client (in tiling order) on selmon. hid
-	 * also visits hidden clients, which focusclient() then shows. */
+	/* Focus the next or previous client (in tiling order) on selmon */
 	Client *c, *sel = focustop(selmon);
 	if (!sel || (sel->isfullscreen && !client_has_children(sel)))
 		return;
-	if (inc > 0) {
+	if (arg->i > 0) {
 		wl_list_for_each(c, &sel->link, link) {
 			if (&c->link == &clients)
 				continue; /* wrap past the sentinel node */
-			if (hid ? VISIBLE(c, selmon) : VISIBLEON(c, selmon))
+			if (VISIBLEON(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 (hid ? VISIBLE(c, selmon) : VISIBLEON(c, selmon))
+			if (VISIBLEON(c, selmon))
 				break; /* found it */
 		}
 	}
@@ -2179,7 +2154,6 @@ hideclient(Client *c)
 	/* The surface stays mapped: arrange() disables the scene node and
 	 * suspends the client until it is shown again. */
 	c->ishidden = 1;
-	c->tempshow = 0;
 	arrange(c->mon);
 }
 
@@ -3439,16 +3413,6 @@ setup(void)
 #endif
 }
 
-void
-show(const Arg *arg)
-{
-	Client *c = focustop(selmon);
-
-	/* Keep a peeked-at client visible once focus moves away */
-	if (c)
-		c->tempshow = 0;
-}
-
 void
 showall(const Arg *arg)
 {
@@ -3458,10 +3422,8 @@ showall(const Arg *arg)
 		return;
 
 	wl_list_for_each(c, &clients, link) {
-		if (VISIBLE(c, selmon)) {
+		if (VISIBLE(c, selmon))
 			c->ishidden = 0;
-			c->tempshow = 0;
-		}
 	}
 	arrange(selmon);
 	focusclient(focustop(selmon), NULL, 1);
@@ -3636,7 +3598,6 @@ togglewin(const Arg *arg)
 	} else {
 		if (c->ishidden) {
 			c->ishidden = 0;
-			c->tempshow = 0;
 			arrange(c->mon);
 		}
 		focusclient(c, NULL, 1);
some autostart scripts changesnageyqma · 2026-10-27 · da5939f
查看变更
AGENT.md  | 4 +++-
 README.md | 4 +++-
 dwl.c     | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/AGENT.md b/AGENT.md
index c2b9319..98acfac 100644
--- a/AGENT.md
+++ b/AGENT.md
@@ -23,7 +23,9 @@ Two properties matter more than features:
 
 The bar is native: `drawbar()` renders it into a pixman image. The
 system-information text is read from `$XDG_RUNTIME_DIR/dwl-status`, written by
-`~/scripts/dwl-status.sh`. Do not replace it with an external bar program.
+`~/scripts/status.sh`; tmux reads the compact `$XDG_RUNTIME_DIR/tmux-status`
+written by the same script, and starts the script when dwl is not running. Do
+not replace it with an external bar program.
 
 The practical consequences:
 
diff --git a/README.md b/README.md
index f15977b..c7538d9 100644
--- a/README.md
+++ b/README.md
@@ -103,7 +103,9 @@ INFORMATION` section in `_dwl_(1)`). This information can be used to populate
 an external status bar with a script that parses it.
 
 The built-in bar also shows the contents of `$XDG_RUNTIME_DIR/dwl-status`;
-`~/scripts/dwl-status.sh` writes that file.
+`~/scripts/status.sh` writes that file and the compact
+`$XDG_RUNTIME_DIR/tmux-status` that tmux reads.  tmux starts the script when dwl
+is not running.
 
 To get a list of external status bars that work with dwl consult our [wiki].
 
diff --git a/dwl.c b/dwl.c
index 0502804..45752a3 100644
--- a/dwl.c
+++ b/dwl.c
@@ -3011,7 +3011,7 @@ run(void)
 	spawn(&autostartcmd);
 
 	/* The bar reads its system information from this file, which
-	 * ~/scripts/dwl-status.sh keeps current. */
+	 * ~/scripts/status.sh keeps current. */
 	snprintf(statuspath, sizeof(statuspath), "%s/dwl-status",
 			getenv("XDG_RUNTIME_DIR"));
 	status_timer = wl_event_loop_add_timer(event_loop, statusupdate, NULL);
remove system tray
Keep the bar and its $XDG_RUNTIME_DIR/dwl-status text. Drop the StatusNotifier watcher, tray menu, icon rendering, and the dbus-1 / gdk-pixbuf build dependencies.
nageyqma · 2026-10-26 · b0afe2a
查看变更
AGENT.md     |   15 +-
 Makefile     |   12 +-
 README.md    |    6 +-
 config.def.h |    5 -
 dwl.c        |   67 +---
 systray.c    | 2452 ------------------------------------------------------------------------------------------------------------------------------------------
 systray.h    |   55 ----
 7 files changed, 24 insertions(+), 2588 deletions(-)
diff --git a/AGENT.md b/AGENT.md
index b98f283..c2b9319 100644
--- a/AGENT.md
+++ b/AGENT.md
@@ -21,11 +21,9 @@ Two properties matter more than features:
    one pass. A clever abstraction that saves repetition but costs a jump is a
    regression here.
 
-The bar's tray is native: `systray.c` implements the
-`org.kde.StatusNotifierWatcher` service and draws icons into the same pixman
-image as `drawbar()`. The system-information text is read from
-`$XDG_RUNTIME_DIR/dwl-status`, written by `~/scripts/dwl-status.sh`. Do not
-replace either with an external bar or tray program.
+The bar is native: `drawbar()` renders it into a pixman image. The
+system-information text is read from `$XDG_RUNTIME_DIR/dwl-status`, written by
+`~/scripts/dwl-status.sh`. Do not replace it with an external bar program.
 
 The practical consequences:
 
@@ -34,10 +32,9 @@ The practical consequences:
 - Reuse what dwl/wlroots already provides: `spawn`, `SHCMD`, `Arg`, `LISTEN`,
   listeners, wlroots helpers. Do not build a second mechanism beside one that
   already exists.
-- No new dependencies beyond the bar's tray (`dbus-1`, `gdk-pixbuf`), no new
-  source files beyond `systray.c`, no build-system layers, no generated code,
-  no configuration parser, no IPC beyond the tray's D-Bus service, no plugin
-  system, no runtime reload, no animation framework.
+- No new dependencies beyond the bar (`fcft`, `pixman`), no new source
+  files, no build-system layers, no generated code, no configuration parser,
+  no IPC, no plugin system, no runtime reload, no animation framework.
 - Do not generalize for a hypothetical future request. The owner will ask for
   the next feature when they want it.
 - Prefer deleting a special case to adding a flag. Prefer one fixed path to a
diff --git a/Makefile b/Makefile
index 29ff7e1..620fe3d 100644
--- a/Makefile
+++ b/Makefile
@@ -12,16 +12,16 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
 	-Wfloat-conversion
 
 # CFLAGS / LDFLAGS
-PKGS      = wayland-server xkbcommon libinput dbus-1 gdk-pixbuf-2.0 $(XLIBS)
+PKGS      = wayland-server xkbcommon libinput $(XLIBS)
 DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(SCENEFX_INCS) $(WLR_INCS) $(FCFT_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
 LDLIBS    = $(SCENEFX_LIBS) `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) $(FCFT_LIBS) -lm $(LIBS)
 
 all: dwl
-dwl: dwl.c systray.c systray.h client.h config.h ime.h util.h config.mk \
-	cursor-shape-v1-protocol.h ext-image-copy-capture-v1-protocol.h \
+dwl: dwl.c client.h config.h ime.h util.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
-	$(CC) -O3 dwl.c systray.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
+	$(CC) -O3 dwl.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
 
 # wayland-scanner is a tool which generates C headers and rigging for Wayland
 # protocols, which are specified in XML. wlroots requires you to rig these up
@@ -56,8 +56,8 @@ 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 systray.c systray.h ime.h util.h \
-		dwl.desktop dwl-$(VERSION)
+		config.mk protocols dwl.1 dwl.c ime.h util.h dwl.desktop \
+		dwl-$(VERSION)
 	tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION)
 	rm -rf dwl-$(VERSION)
 
diff --git a/README.md b/README.md
index c1aee9f..f15977b 100644
--- a/README.md
+++ b/README.md
@@ -35,8 +35,6 @@ version of `wlroots` should target this branch.
 ### Building dwl
 dwl has the following dependencies:
 - fcft (bar font)
-- gdk-pixbuf (themed tray icons)
-- libdbus (system tray)
 - libinput
 - pixman (bar image)
 - wayland
@@ -104,8 +102,8 @@ selected/occupied/urgent tags is written to standard output (see the `STATUS
 INFORMATION` section in `_dwl_(1)`). This information can be used to populate
 an external status bar with a script that parses it.
 
-The built-in bar also shows a StatusNotifierItem tray and the contents of
-`$XDG_RUNTIME_DIR/dwl-status`; `~/scripts/dwl-status.sh` writes that file.
+The built-in bar also shows the contents of `$XDG_RUNTIME_DIR/dwl-status`;
+`~/scripts/dwl-status.sh` writes that file.
 
 To get a list of external status bars that work with dwl consult our [wiki].
 
diff --git a/config.def.h b/config.def.h
index 094ec79..06d96ef 100644
--- a/config.def.h
+++ b/config.def.h
@@ -26,11 +26,6 @@ static const float barfg[]                 = COLOR(0xbbbbbbff);
 static const float barselbg[]              = COLOR(0x005577ff);
 static const float barselfg[]              = COLOR(0xffffffff);
 static const float barhidfg[]              = COLOR(0x555555ff);
-/* system tray; its icons are drawn in the bar, scaled with the output */
-static const unsigned int trayiconsize     = 18; /* icon size, in layout pixels */
-static const unsigned int trayspacing      = 6;  /* space between icons */
-static const unsigned int menupad          = 4;  /* tray menu padding, in layout pixels */
-static const unsigned int menuwidth        = 240; /* maximum tray menu width, in layout pixels */
 
 static const int blur = 1; /* background blur */
 static const struct blur_data blur_data = {
diff --git a/dwl.c b/dwl.c
index ec6457a..0502804 100644
--- a/dwl.c
+++ b/dwl.c
@@ -83,7 +83,6 @@
 
 #include "xdg-shell-protocol.h"
 #include "util.h"
-#include "systray.h"
 
 /* macros */
 #define CLEANMASK(mask)         (mask & ~WLR_MODIFIER_CAPS)
@@ -302,8 +301,13 @@ static BarBuffer *barbuffer_create(int width, int height);
 static void barbuffer_destroy(struct wlr_buffer *buffer);
 static void barbuffer_end(struct wlr_buffer *buffer);
 static pixman_color_t barcolor(const float color[4]);
+static void barfill(pixman_image_t *image, const float color[4], int x,
+		int y, int width, int height);
 static const char *barlabel(unsigned int tag);
 static int baradvance(const struct fcft_glyph *glyph);
+static void bartext(pixman_image_t *image, struct fcft_font *font,
+		const char *text, int x, int baseline, int maxx, const float color[4]);
+static int bartextwidth(struct fcft_font *font, const char *text);
 static uint32_t barutf8(const char **s);
 static void buttonpress(struct wl_listener *listener, void *data);
 static void capturerequest(struct wl_listener *listener, void *data);
@@ -729,7 +733,7 @@ barclick(Monitor *m, double x, double y, uint32_t button)
 	Client *c;
 	Arg arg;
 	double scale;
-	int bx, pad, width, cx, i, n, tabw, tw, right, trayleft;
+	int bx, pad, width, cx, i, n, tabw, tw, right;
 
 	if (!m || !m->bar || !m->barfont || !m->wlr_output->enabled)
 		return 0;
@@ -745,13 +749,7 @@ barclick(Monitor *m, double x, double y, uint32_t button)
 	bx = (int)((x - m->m.x) * scale + 0.5);
 	width = (int)(m->m.width * scale + 0.5);
 	pad = (int)(barpad * scale + 0.5);
-	trayleft = MAX(0, width - (int)(systray_width() * scale + 0.5));
-	if (bx >= trayleft) {
-		systray_click(bx, width, scale, button, x, y, m->barfont,
-				&m->m, m->barheight);
-		return 1;
-	}
-	right = trayleft;
+	right = width;
 	if (barstatus[0])
 		right = MAX(0, right - bartextwidth(m->barfont, barstatus) - 2 * pad);
 	if (button != BTN_LEFT)
@@ -841,15 +839,6 @@ barbuffer_create(int width, int height)
 	return bar;
 }
 
-struct wlr_buffer *
-barimage_create(int width, int height, pixman_image_t **image)
-{
-	BarBuffer *bar = barbuffer_create(width, height);
-
-	*image = bar->image;
-	return &bar->base;
-}
-
 pixman_color_t
 barcolor(const float color[4])
 {
@@ -1032,8 +1021,6 @@ buttonpress(struct wl_listener *listener, void *data)
 		selmon = xytomon(cursor->x, cursor->y);
 		if (locked)
 			break;
-		if (systray_menu_click(cursor->x, cursor->y, event->button))
-			return;
 		if (barclick(selmon, cursor->x, cursor->y, event->button))
 			return;
 
@@ -1131,7 +1118,6 @@ cleanup(void)
 #endif
 	if (status_timer)
 		wl_event_source_remove(status_timer);
-	systray_fini();
 	wl_display_destroy_clients(dpy);
 	wlr_xcursor_manager_destroy(cursor_mgr);
 
@@ -1172,10 +1158,8 @@ cleanupmon(struct wl_listener *listener, void *data)
 		destroylocksurface(&m->destroy_lock_surface, NULL);
 	if (m->bar)
 		wlr_scene_node_destroy(&m->bar->node);
-	if (m->barfont) {
-		systray_menu_font_destroyed(m->barfont);
+	if (m->barfont)
 		fcft_destroy(m->barfont);
-	}
 	m->wlr_output->data = NULL;
 	wlr_output_layout_remove(output_layout, m->wlr_output);
 	wlr_scene_output_destroy(m->scene_output);
@@ -1902,7 +1886,7 @@ drawbar(Monitor *m)
 	}
 	pad = (int)(barpad * scale + 0.5);
 	baseline = (height - font->height) / 2 + font->ascent;
-	right = MAX(0, width - (int)(systray_width() * scale + 0.5));
+	right = width;
 	statusw = barstatus[0] ? bartextwidth(font, barstatus) + 2 * pad : 0;
 	statusx = MAX(0, right - statusw);
 
@@ -1966,7 +1950,6 @@ drawbar(Monitor *m)
 	if (barstatus[0])
 		bartext(image, font, barstatus, statusx + pad, baseline,
 				right - pad, barfg);
-	systray_draw(image, font, baseline, height, scale, barfg);
 
 	wlr_scene_node_set_position(&m->bar->node, m->m.x, m->m.y);
 	wlr_scene_buffer_set_dest_size(m->bar, m->m.width, m->barheight);
@@ -2277,14 +2260,6 @@ keypress(struct wl_listener *listener, void *data)
 
 	wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
 
-	/* The tray menu takes Escape without moving keyboard focus. */
-	if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED
-			&& systray_menu_key(group->keysyms[0])) {
-		consumed[event->keycode] = 1;
-		wl_event_source_timer_update(group->key_repeat_source, 0);
-		return;
-	}
-
 	/* On _press_ if there is no active screen locker,
 	 * attempt to process a compositor keybinding. */
 	if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
@@ -2380,7 +2355,6 @@ locksession(struct wl_listener *listener, void *data)
 	lock->scene = wlr_scene_tree_create(layers[LyrBlock]);
 	cur_lock = lock->lock = session_lock;
 	locked = 1;
-	systray_menu_close();
 
 	/* Cancel any interactive move/resize and take the pointer focus away
 	 * from the clients below the lock screen */
@@ -2599,8 +2573,6 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
 			selmon = xytomon(cursor->x, cursor->y);
 	}
 
-	systray_menu_motion(cursor->x, cursor->y);
-
 	/* Update drag icon's position */
 	wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x), (int)round(cursor->y));
 
@@ -3020,8 +2992,6 @@ roundbuffer(struct wlr_scene_buffer *buffer, int sx, int sy, void *data)
 void
 run(void)
 {
-	TrayConfig traycfg;
-
 	/* Add a Unix socket to the Wayland display. */
 	const char *socket = wl_display_add_socket_auto(dpy);
 	if (!socket)
@@ -3037,21 +3007,6 @@ run(void)
 	setenv("DISPLAY", xwaylanddisplay, 1);
 	spawn(&xwaylandcmd);
 
-	/* Start the system tray before the autostart script, so tray clients find
-	 * the watcher. */
-	traycfg = (TrayConfig){
-		.iconsize = trayiconsize,
-		.spacing = trayspacing,
-		.menupad = menupad,
-		.menuwidth = menuwidth,
-		.bg = barbg,
-		.fg = barfg,
-		.selbg = barselbg,
-		.selfg = barselfg,
-		.hidfg = barhidfg,
-	};
-	systray_init(event_loop, layers[LyrOverlay], &traycfg, drawbars);
-
 	/* Start the autostart command in the background */
 	spawn(&autostartcmd);
 
@@ -3760,10 +3715,8 @@ updatebar(Monitor *m)
 		scale = 1;
 	if (m->barfont && m->barscale == scale)
 		return;
-	if (m->barfont) {
-		systray_menu_font_destroyed(m->barfont);
+	if (m->barfont)
 		fcft_destroy(m->barfont);
-	}
 
 	/* Render at the output's resolution instead of scaling the bar up. */
 	snprintf(attr, sizeof(attr), "dpi=%d", (int)(96 * scale + 0.5));
diff --git a/systray.c b/systray.c
deleted file mode 100644
index 30b119e..0000000
--- a/systray.c
+++ /dev/null
@@ -1,2452 +0,0 @@
-/*
- * StatusNotifierItem host for the dwl bar.
- *
- * The bar is drawn by drawbar() into a pixman image.  This file implements the
- * org.kde.StatusNotifierWatcher service and draws registered items into that
- * same image, so the tray is part of the bar rather than a separate window.
- */
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <linux/input-event-codes.h>
-#include <glib.h>
-#include <pixman.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <dbus/dbus.h>
-#include <scenefx/types/wlr_scene.h>
-#include <wayland-server-core.h>
-#include <wlr/util/box.h>
-#include <xkbcommon/xkbcommon-keysyms.h>
-
-#include "systray.h"
-
-#define WATCHER          "org.kde.StatusNotifierWatcher"
-#define WATCHER_PATH     "/StatusNotifierWatcher"
-#define ITEM_IFACE       "org.kde.StatusNotifierItem"
-#define MENU_IFACE       "com.canonical.dbusmenu"
-#define PROPERTIES_IFACE "org.freedesktop.DBus.Properties"
-
-#define MAXTHEMES        32
-#define MENU_TIMEOUT     1000 /* ms for the menu's blocking calls */
-#define MENU_DEPTH       2    /* GetLayout levels: top level and submenus */
-#define MENU_MAXITEMS    256  /* refuse absurd menus */
-
-typedef struct TrayItem {
-	struct wl_list link;
-	char *service;
-	char *path;
-	char *owner;
-	char *key;
-	char *id;
-	char *title;
-	char *iconname;
-	char *icontheme;
-	char *menupath;
-	int itemismenu;
-	pixman_image_t *icon;
-	int iconw, iconh;
-	pixman_image_t *scaled;
-	int scaled_size;
-} TrayItem;
-
-/* drawbar() runs during backend start, before systray_init(). */
-static struct wl_list items = { &items, &items };
-static struct wl_list work = { &work, &work };
-static struct wl_event_loop *event_loop;
-static DBusConnection *bus;
-static struct wl_event_source *work_source;
-static unsigned int icon_size = 18;
-static unsigned int icon_spacing = 6;
-static TrayConfig cfg;
-static void (*redraw)(void);
-
-enum { WorkAdd, WorkUpdate, WorkRemove, WorkMenu, WorkMenuRefresh };
-typedef struct {
-	struct wl_list link;
-	int type;
-	char *service;
-	char *path;
-	char *menupath;
-	struct wlr_box mon;
-	int barheight, anchor;
-	double scale;
-	struct fcft_font *font;
-	dbus_int32_t sx, sy;
-} Work;
-
-enum { ToggleNone, ToggleCheck, ToggleRadio };
-typedef struct MenuItem {
-	struct wl_list link;
-	struct wl_list children;
-	int id;
-	char *label;
-	char *iconname;
-	int enabled, visible;
-	int separator, submenu;
-	int toggle, toggled;
-	int y, h; /* row, in output pixels of its panel */
-} MenuItem;
-
-static struct {
-	int open, loading;
-	char *service, *owner, *path, *key;
-	struct wl_list items; /* MenuItem.link */
-	MenuItem *sub, *hover;
-	struct wlr_scene_buffer *node, *subnode;
-	struct wlr_box mon;
-	int barheight, anchor;
-	double scale;
-	struct fcft_font *font;
-	int x, y, wpx, hpx;
-	int subx, suby, subwpx, subhpx;
-	int subopen;
-} menu;
-
-static void process_work(void *data);
-
-static void add_item(const char *service, const char *path);
-static void update_item(TrayItem *item);
-static void remove_item(TrayItem *item);
-static void remove_service(const char *name);
-static void emit_signal(const char *member, const char *key);
-
-static void clear_menu(void);
-static void close_menu(int notify);
-static void menu_draw(void);
-static void open_menu(const char *service, const char *path,
-		const char *menupath, const struct wlr_box *mon, int barheight,
-		int anchor, double scale, struct fcft_font *font,
-		dbus_int32_t sx, dbus_int32_t sy);
-static void reload_menu(void);
-static void queue_menu(const char *service, const char *path,
-		const char *menupath, const struct wlr_box *mon, int barheight,
-		int anchor, double scale, struct fcft_font *font,
-		dbus_int32_t sx, dbus_int32_t sy);
-static void queue_refresh(void);
-static void send_item(const char *service, const char *path,
-		const char *method, dbus_int32_t sx, dbus_int32_t sy);
-
-static void *
-xcalloc(size_t nmemb, size_t size)
-{
-	void *p = calloc(nmemb, size);
-
-	if (!p) {
-		fprintf(stderr, "systray: out of memory\n");
-		exit(1);
-	}
-	return p;
-}
-
-static void
-free_item(TrayItem *item)
-{
-	g_free(item->service);
-	g_free(item->path);
-	g_free(item->owner);
-	g_free(item->key);
-	g_free(item->id);
-	g_free(item->title);
-	g_free(item->iconname);
-	g_free(item->icontheme);
-	g_free(item->menupath);
-	if (item->icon)
-		pixman_image_unref(item->icon);
-	if (item->scaled)
-		pixman_image_unref(item->scaled);
-	free(item);
-}
-
-static int
-item_count(void)
-{
-	TrayItem *item;
-	int n = 0;
-
-	wl_list_for_each(item, &items, link)
-		n++;
-	return n;
-}
-
-/* ---- D-Bus / wl_event_loop glue ------------------------------------- */
-
-static int
-watch_handle(int fd, uint32_t mask, void *data)
-{
-	DBusWatch *watch = data;
-	uint32_t flags = 0;
-
-	if (!dbus_watch_get_enabled(watch))
-		return 0;
-	if (mask & WL_EVENT_READABLE)
-		flags |= DBUS_WATCH_READABLE;
-	if (mask & WL_EVENT_WRITABLE)
-		flags |= DBUS_WATCH_WRITABLE;
-	if (mask & WL_EVENT_HANGUP)
-		flags |= DBUS_WATCH_HANGUP;
-	if (mask & WL_EVENT_ERROR)
-		flags |= DBUS_WATCH_ERROR;
-	dbus_watch_handle(watch, flags);
-	/* Method handlers only queue work, so dispatching here cannot block the
-	 * event loop on an item that is waiting for us. */
-	while (bus && dbus_connection_get_dispatch_status(bus)
-			== DBUS_DISPATCH_DATA_REMAINS)
-		dbus_connection_dispatch(bus);
-	return 0;
-}
-
-static dbus_bool_t
-add_watch(DBusWatch *watch, void *data)
-{
-	struct wl_event_loop *loop = data;
-	struct wl_event_source *source;
-	uint32_t flags, mask = 0;
-
-	if (!dbus_watch_get_enabled(watch))
-		return TRUE;
-	flags = dbus_watch_get_flags(watch);
-	if (flags & DBUS_WATCH_READABLE)
-		mask |= WL_EVENT_READABLE;
-	if (flags & DBUS_WATCH_WRITABLE)
-		mask |= WL_EVENT_WRITABLE;
-	source = wl_event_loop_add_fd(loop, dbus_watch_get_unix_fd(watch),
-			mask, watch_handle, watch);
-	dbus_watch_set_data(watch, source, NULL);
-	return TRUE;
-}
-
-static void
-remove_watch(DBusWatch *watch, void *data)
-{
-	struct wl_event_source *source = dbus_watch_get_data(watch);
-
-	if (source)
-		wl_event_source_remove(source);
-}
-
-static int
-timeout_handle(void *data)
-{
-	DBusTimeout *timeout = data;
-
-	if (dbus_timeout_get_enabled(timeout))
-		dbus_timeout_handle(timeout);
-	return 0;
-}
-
-static dbus_bool_t
-add_timeout(DBusTimeout *timeout, void *data)
-{
-	struct wl_event_loop *loop = data;
-	struct wl_event_source *source;
-
-	if (!dbus_timeout_get_enabled(timeout))
-		return TRUE;
-	source = wl_event_loop_add_timer(loop, timeout_handle, timeout);
-	if (!source)
-		return FALSE;
-	if (wl_event_source_timer_update(source,
-			dbus_timeout_get_interval(timeout)) < 0) {
-		wl_event_source_remove(source);
-		return FALSE;
-	}
-	dbus_timeout_set_data(timeout, source, NULL);
-	return TRUE;
-}
-
-static void
-remove_timeout(DBusTimeout *timeout, void *data)
-{
-	struct wl_event_source *source = dbus_timeout_get_data(timeout);
-
-	if (source)
-		wl_event_source_remove(source);
-}
-
-static int
-startbus(DBusConnection *conn, struct wl_event_loop *loop)
-{
-	dbus_connection_set_exit_on_disconnect(conn, FALSE);
-	if (!dbus_connection_set_watch_functions(conn, add_watch,
-			remove_watch, NULL, loop, NULL)
-			|| !dbus_connection_set_timeout_functions(conn,
-			add_timeout, remove_timeout, NULL, loop, NULL)) {
-		dbus_connection_set_watch_functions(conn, NULL, NULL, NULL,
-				NULL, NULL);
-		dbus_connection_set_timeout_functions(conn, NULL, NULL, NULL,
-				NULL, NULL);
-		return 0;
-	}
-	return 1;
-}
-
-static void
-stopbus(DBusConnection *conn)
-{
-	dbus_connection_set_watch_functions(conn, NULL, NULL, NULL, NULL, NULL);
-	dbus_connection_set_timeout_functions(conn, NULL, NULL, NULL, NULL, NULL);
-}
-
-/* ---- icon theme lookup ---------------------------------------------- */
-
-static char *
-settings_theme(void)
-{
-	const char *home = getenv("HOME");
-	const char *xdg = getenv("XDG_CONFIG_HOME");
-	char *path, *theme = NULL;
-	GKeyFile *kf;
-	gsize len;
-
-	if (xdg && *xdg)
-		path = g_build_filename(xdg, "gtk-3.0", "settings.ini", NULL);
-	else if (home)
-		path = g_build_filename(home, ".config", "gtk-3.0",
-				"settings.ini", NULL);
-	else
-		return NULL;
-	kf = g_key_file_new();
-	if (g_key_file_load_from_file(kf, path, G_KEY_FILE_NONE, NULL))
-		theme = g_key_file_get_string(kf, "Settings",
-				"gtk-icon-theme-name", NULL);
-	g_key_file_free(kf);
-	g_free(path);
-	if (!theme)
-		return NULL;
-	g_strstrip(theme);
-	len = strlen(theme);
-	if (len >= 2 && (theme[0] == '"' || theme[0] == '\'')
-			&& theme[len - 1] == theme[0]) {
-		memmove(theme, theme + 1, len - 2);
-		theme[len - 2] = '\0';
-	}
-	return theme;
-}
-
-static GPtrArray *
-icon_roots(void)
-{
-	GPtrArray *roots = g_ptr_array_new_with_free_func(g_free);
-	const char *home = getenv("HOME");
-	const char *xdg = getenv("XDG_DATA_HOME");
-	const char *data_dirs = getenv("XDG_DATA_DIRS");
-	char **parts;
-	int i;
-
-	if (xdg && *xdg)
-		g_ptr_array_add(roots, g_build_filename(xdg, "icons", NULL));
-	else if (home)
-		g_ptr_array_add(roots, g_build_filename(home, ".local", "share",
-				"icons", NULL));
-	if (home)
-		g_ptr_array_add(roots, g_build_filename(home, ".icons", NULL));
-	if (!data_dirs || !*data_dirs)
-		data_dirs = "/usr/local/share:/usr/share";
-	parts = g_strsplit(data_dirs, ":", -1);
-	for (i = 0; parts[i]; i++)
-		if (*parts[i])
-			g_ptr_array_add(roots, g_build_filename(parts[i],
-					"icons", NULL));
-	g_strfreev(parts);
-	g_ptr_array_add(roots, g_strdup("/usr/share/pixmaps"));
-	return roots;
-}
-
-static int
-dir_score(const char *dir, const char *ext, int symbolic)
-{
-	const char *p;
-	int size = 0, score;
-
-	if (strstr(dir, "scalable")) {
-		score = 1200;
-	} else {
-		for (p = dir; *p; p++) {
-			if (g_ascii_isdigit(*p)) {
-				size = atoi(p);
-				break;
-			}
-		}
-		score = size ? 1000 - abs(size - 24) : 500;
-	}
-	if (strstr(dir, "symbolic")) {
-		if (!symbolic)
-			score -= 600;
-	} else if (symbolic) {
-		score -= 200;
-	}
-	if (g_str_has_suffix(ext, "svg"))
-		score += 20;
-	else if (g_str_has_suffix(ext, "png"))
-		score += 10;
-	return score;
-}
-
-static char *
-search_theme(const char *dir, const char *name)
-{
-	static const char *exts[] = { "svg", "png", "xpm" };
-	static const char *common[] = { "apps", "devices", "status", "actions",
-		"places", "notifications", "panel", "categories", "mimetypes",
-		"emblems", "scalable", "symbolic" };
-	char *index, *path, *best = NULL, *filename, *value;
-	char **dirs = NULL;
-	gsize n = 0, i, j;
-	GKeyFile *kf;
-	int bestscore = -100000, score, symbolic, e;
-
-	if (!name || !*name)
-		return NULL;
-	symbolic = strstr(name, "symbolic") != NULL;
-
-	/* IconThemePath may point directly at a directory of icons. */
-	for (e = 0; e < 3; e++) {
-		filename = g_strdup_printf("%s.%s", name, exts[e]);
-		path = g_build_filename(dir, filename, NULL);
-		g_free(filename);
-		if (access(path, R_OK) == 0) {
-			g_free(best);
-			best = path;
-			bestscore = 2000;
-		} else {
-			g_free(path);
-		}
-	}
-	if (best)
-		return best;
-
-	index = g_build_filename(dir, "index.theme", NULL);
-	kf = g_key_file_new();
-	if (g_key_file_load_from_file(kf, index, G_KEY_FILE_NONE, NULL)) {
-		/* index.theme uses commas, while GKeyFile lists use semicolons. */
-		value = g_key_file_get_string(kf, "Icon Theme", "Directories",
-				NULL);
-		if (value) {
-			dirs = g_strsplit_set(value, ",;", -1);
-			n = g_strv_length(dirs);
-			for (j = 0; j < n; j++)
-				g_strstrip(dirs[j]);
-			g_free(value);
-		}
-	}
-	if (!dirs || n == 0) {
-		g_strfreev(dirs);
-		dirs = g_new0(char *, G_N_ELEMENTS(common) + 1);
-		for (i = 0; i < G_N_ELEMENTS(common); i++)
-			dirs[i] = g_strdup(common[i]);
-		n = G_N_ELEMENTS(common);
-	}
-
-	for (i = 0; i < n; i++) {
-		for (e = 0; e < 3; e++) {
-			int found = 0;
-
-			filename = g_strdup_printf("%s.%s", name, exts[e]);
-			path = g_build_filename(dir, dirs[i], filename, NULL);
-			g_free(filename);
-			score = dir_score(dirs[i], exts[e], symbolic);
-			found = access(path, R_OK) == 0;
-			if (found && score > bestscore) {
-				g_free(best);
-				best = path;
-				bestscore = score;
-			} else {
-				g_free(path);
-			}
-		}
-	}
-	g_strfreev(dirs);
-	g_key_file_free(kf);
-	g_free(index);
-	return best;
-}
-
-static void
-add_theme(char **themes, int *n, const char *name)
-{
-	int i;
-
-	if (!name || !*name)
-		return;
-	for (i = 0; i < *n; i++)
-		if (!strcmp(themes[i], name))
-			return;
-	if (*n < MAXTHEMES)
-		themes[(*n)++] = g_strdup(name);
-}
-
-/* Resolve index.theme directly; linking GTK just to look up icons would pull
- * a full toolkit into the compositor. */
-static char *
-find_icon(const char *name, const char *extrapath)
-{
-	static const char *defaults[] = { "hicolor", "Adwaita", "breeze" };
-	char *themes[MAXTHEMES], *best = NULL, *tdir, *index;
-	GPtrArray *roots;
-	GKeyFile *kf;
-	char **list;
-	gsize i;
-	int nthemes = 0, r, t, depth;
-	char *theme, *value;
-
-	if (!name || !*name)
-		return NULL;
-	if (name[0] == '/' || strchr(name, '/')) {
-		if (access(name, R_OK) == 0)
-			return g_strdup(name);
-		return NULL;
-	}
-	if (extrapath && *extrapath) {
-		best = search_theme(extrapath, name);
-		if (best)
-			return best;
-	}
-
-	theme = settings_theme();
-	if (theme)
-		add_theme(themes, &nthemes, theme);
-	for (i = 0; i < G_N_ELEMENTS(defaults); i++)
-		add_theme(themes, &nthemes, defaults[i]);
-	roots = icon_roots();
-
-	/* Follow Inherits= so a custom theme can fall back to its parents. */
-	for (depth = 0; depth < 4; depth++) {
-		int before = nthemes;
-		for (t = depth; t < before; t++) {
-			for (r = 0; r < (int)roots->len; r++) {
-				tdir = g_build_filename(roots->pdata[r], themes[t],
-						NULL);
-				index = g_build_filename(tdir, "index.theme", NULL);
-				kf = g_key_file_new();
-				if (g_key_file_load_from_file(kf, index,
-						G_KEY_FILE_NONE, NULL)) {
-					value = g_key_file_get_string(kf,
-							"Icon Theme", "Inherits", NULL);
-					if (value) {
-						list = g_strsplit_set(value, ",;", -1);
-						for (i = 0; list[i]; i++) {
-							g_strstrip(list[i]);
-							add_theme(themes, &nthemes,
-									list[i]);
-						}
-						g_strfreev(list);
-						g_free(value);
-					}
-				}
-				g_key_file_free(kf);
-				g_free(index);
-				g_free(tdir);
-			}
-		}
-		if (nthemes == before)
-			break;
-	}
-
-	for (t = 0; t < nthemes && !best; t++) {
-		for (r = 0; r < (int)roots->len && !best; r++) {
-			tdir = g_build_filename(roots->pdata[r], themes[t], NULL);
-			best = search_theme(tdir, name);
-			g_free(tdir);
-		}
-	}
-	/* /usr/share/pixmaps has no theme directory. */
-	for (r = 0; r < (int)roots->len && !best; r++)
-		best = search_theme(roots->pdata[r], name);
-
-	for (i = 0; i < (gsize)nthemes; i++)
-		g_free(themes[i]);
-	g_free(theme);
-	g_ptr_array_free(roots, TRUE);
-	return best;
-}
-
-static pixman_image_t *
-pixbuf_to_pixman(GdkPixbuf *pixbuf)
-{
-	int w = gdk_pixbuf_get_width(pixbuf);
-	int h = gdk_pixbuf_get_height(pixbuf);
-	int stride = gdk_pixbuf_get_rowstride(pixbuf);
-	int channels = gdk_pixbuf_get_n_channels(pixbuf);
-	guchar *pixels = gdk_pixbuf_get_pixels(pixbuf);
-	pixman_image_t *image;
-	uint32_t *out;
-	uint8_t a, r, g, b;
-	guchar *p;
-	int x, y;
-
-	if (w <= 0 || h <= 0)
-		return NULL;
-	image = pixman_image_create_bits(PIXMAN_a8r8g8b8, w, h, NULL, w * 4);
-	if (!image)
-		return NULL;
-	out = pixman_image_get_data(image);
-	for (y = 0; y < h; y++) {
-		p = pixels + y * stride;
-		for (x = 0; x < w; x++, p += channels) {
-			a = channels == 4 ? p[3] : 255;
-			r = p[0];
-			g = p[1];
-			b = p[2];
-			out[y * w + x] = ((uint32_t)a << 24) | ((uint32_t)r << 16)
-					| ((uint32_t)g << 8) | b;
-		}
-	}
-	return image;
-}
-
-static pixman_image_t *
-load_theme_icon(const char *name, const char *extrapath)
-{
-	char *path;
-	GdkPixbuf *pixbuf;
-	GError *error = NULL;
-	pixman_image_t *image;
-
-	path = find_icon(name, extrapath);
-	if (!path)
-		return NULL;
-	if (g_str_has_suffix(path, ".svg"))
-		pixbuf = gdk_pixbuf_new_from_file_at_scale(path, 64, 64, TRUE,
-				&error);
-	else
-		pixbuf = gdk_pixbuf_new_from_file(path, &error);
-	g_free(path);
-	if (!pixbuf) {
-		g_clear_error(&error);
-		return NULL;
-	}
-	image = pixbuf_to_pixman(pixbuf);
-	g_object_unref(pixbuf);
-	return image;
-}
-
-/* ---- status notifier items ------------------------------------------ */
-
-/* IconPixmap is ARGB32 in network byte order; pixman wants native 0xAARRGGBB. */
-static pixman_image_t *
-parse_pixmap(DBusMessageIter *variant, int *outw, int *outh)
-{
-	DBusMessageIter array, entry, data;
-	const void *raw;
-	const uint8_t *best = NULL;
-	pixman_image_t *image;
-	uint32_t *pixels;
-	int bestw = 0, besth = 0, w, h, len, i, alpha = 0;
-
-	if (dbus_message_iter_get_arg_type(variant) != DBUS_TYPE_ARRAY)
-		return NULL;
-	dbus_message_iter_recurse(variant, &array);
-	while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) {
-		dbus_message_iter_recurse(&array, &entry);
-		dbus_message_iter_get_basic(&entry, &w);
-		dbus_message_iter_next(&entry);
-		dbus_message_iter_get_basic(&entry, &h);
-		dbus_message_iter_next(&entry);
-		dbus_message_iter_recurse(&entry, &data);
-		dbus_message_iter_get_fixed_array(&data, &raw, &len);
-		if (w > 0 && h > 0 && len >= w * h * 4
-				&& w * h > bestw * besth) {
-			bestw = w;
-			besth = h;
-			best = raw;
-		}
-		dbus_message_iter_next(&array);
-	}
-	if (!best)
-		return NULL;
-	image = pixman_image_create_bits(PIXMAN_a8r8g8b8, bestw, besth,
-			NULL, bestw * 4);
-	if (!image)
-		return NULL;
-	pixels = pixman_image_get_data(image);
-	for (i = 0; i < bestw * besth; i++) {
-		const uint8_t *p = best + i * 4;
-		uint8_t a = p[0], r = p[1], g = p[2], b = p[3];
-
-		if (a)
-			alpha = 1;
-		pixels[i] = ((uint32_t)a << 24) | ((uint32_t)r << 16)
-				| ((uint32_t)g << 8) | b;
-	}
-	if (!alpha)
-		for (i = 0; i < bestw * besth; i++)
-			pixels[i] |= 0xff000000;
-	*outw = bestw;
-	*outh = besth;
-	return image;
-}
-
-static const char *
-get_string(DBusMessageIter *iter)
-{
-	const char *s;
-
-	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING
-			&& dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_OBJECT_PATH)
-		return NULL;
-	dbus_message_iter_get_basic(iter, &s);
-	return s;
-}
-
-static int
-get_bool(DBusMessageIter *iter, dbus_bool_t *value)
-{
-	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BOOLEAN)
-		return 0;
-	dbus_message_iter_get_basic(iter, value);
-	return 1;
-}
-
-static void
-update_item(TrayItem *item)
-{
-	DBusMessage *message, *reply;
-	DBusMessageIter iter, dict, entry, variant;
-	DBusError error;
-	char *id = NULL, *title = NULL, *iconname = NULL, *icontheme = NULL;
-	char *menupath = NULL;
-	const char *key, *string, *interface = ITEM_IFACE;
-	pixman_image_t *icon = NULL;
-	dbus_bool_t itemismenu = FALSE;
-	int iconw = 0, iconh = 0, w, h;
-
-	dbus_error_init(&error);
-	message = dbus_message_new_method_call(item->service, item->path,
-			PROPERTIES_IFACE, "GetAll");
-	if (!message)
-		return;
-	dbus_message_append_args(message, DBUS_TYPE_STRING, &interface,
-			DBUS_TYPE_INVALID);
-	reply = dbus_connection_send_with_reply_and_block(bus, message, 1000,
-			&error);
-	dbus_message_unref(message);
-	if (!reply) {
-		dbus_error_free(&error);
-		return;
-	}
-	if (!dbus_message_iter_init(reply, &iter)
-			|| dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
-		goto out;
-	dbus_message_iter_recurse(&iter, &dict);
-	while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
-		dbus_message_iter_recurse(&dict, &entry);
-		dbus_message_iter_get_basic(&entry, &key);
-		dbus_message_iter_next(&entry);
-		dbus_message_iter_recurse(&entry, &variant);
-		if (!strcmp(key, "Id")) {
-			if ((string = get_string(&variant))) {
-				g_free(id);
-				id = g_strdup(string);
-			}
-		} else if (!strcmp(key, "Title")) {
-			if ((string = get_string(&variant))) {
-				g_free(title);
-				title = g_strdup(string);
-			}
-		} else if (!strcmp(key, "IconName")) {
-			if ((string = get_string(&variant))) {
-				g_free(iconname);
-				iconname = g_strdup(string);
-			}
-		} else if (!strcmp(key, "IconThemePath")) {
-			if ((string = get_string(&variant))) {
-				g_free(icontheme);
-				icontheme = g_strdup(string);
-			}
-		} else if (!strcmp(key, "Menu")) {
-			if ((string = get_string(&variant))) {
-				g_free(menupath);
-				menupath = g_strdup(string);
-			}
-		} else if (!strcmp(key, "ItemIsMenu")) {
-			get_bool(&variant, &itemismenu);
-		} else if (!strcmp(key, "IconPixmap")) {
-			pixman_image_t *pixmap;
-
-			pixmap = parse_pixmap(&variant, &w, &h);
-			if (pixmap) {
-				if (icon)
-					pixman_image_unref(icon);
-				icon = pixmap;
-				iconw = w;
-				iconh = h;
-			}
-		}
-		dbus_message_iter_next(&dict);
-	}
-out:
-	dbus_message_unref(reply);
-	/* Both spellings mean "this item has no menu" (the spec's convention). */
-	if (menupath && (!strcmp(menupath, "/")
-			|| !strcmp(menupath, "/NO_DBUSMENU"))) {
-		g_free(menupath);
-		menupath = NULL;
-	}
-	if (!icon && iconname) {
-		icon = load_theme_icon(iconname, icontheme);
-		if (icon) {
-			iconw = pixman_image_get_width(icon);
-			iconh = pixman_image_get_height(icon);
-		}
-	}
-
-	g_free(item->id);
-	g_free(item->title);
-	g_free(item->iconname);
-	g_free(item->icontheme);
-	g_free(item->menupath);
-	if (item->icon)
-		pixman_image_unref(item->icon);
-	if (item->scaled)
-		pixman_image_unref(item->scaled);
-	item->id = id;
-	item->title = title;
-	item->iconname = iconname;
-	item->icontheme = icontheme;
-	item->menupath = menupath;
-	item->itemismenu = itemismenu;
-	item->icon = icon;
-	item->iconw = iconw;
-	item->iconh = iconh;
-	item->scaled = NULL;
-	item->scaled_size = 0;
-	if (menu.open && menu.key && item->key
-			&& !strcmp(menu.key, item->key)
-			&& (!item->menupath || !menu.path
-			|| strcmp(item->menupath, menu.path)))
-		close_menu(1);
-	if (redraw)
-		redraw();
-}
-
-static char *
-name_owner(const char *service)
-{
-	DBusMessage *message, *reply;
-	DBusError error;
-	const char *owner;
-	char *result = NULL;
-
-	message = dbus_message_new_method_call("org.freedesktop.DBus",
-			"/org/freedesktop/DBus", "org.freedesktop.DBus",
-			"GetNameOwner");
-	if (!message)
-		return NULL;
-	dbus_message_append_args(message, DBUS_TYPE_STRING, &service,
-			DBUS_TYPE_INVALID);
-	dbus_error_init(&error);
-	reply = dbus_connection_send_with_reply_and_block(bus, message, 1000,
-			&error);
-	dbus_message_unref(message);
-	if (!reply) {
-		dbus_error_free(&error);
-		return NULL;
-	}
-	if (dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &owner,
-			DBUS_TYPE_INVALID))
-		result = g_strdup(owner);
-	dbus_message_unref(reply);
-	return result;
-}
-
-static void
-add_item(const char *service, const char *path)
-{
-	TrayItem *item, *other;
-	char *key;
-
-	if (!service || !path || !*service || !*path)
-		return;
-	key = g_strconcat(service, path, NULL);
-	wl_list_for_each(other, &items, link) {
-		if (!strcmp(other->key, key)) {
-			g_free(key);
-			return;
-		}
-	}
-	g_free(key);
-	item = xcalloc(1, sizeof(*item));
-	item->service = g_strdup(service);
-	item->path = g_strdup(path);
-	item->key = g_strconcat(service, path, NULL);
-	item->owner = name_owner(service);
-	wl_list_insert(items.prev, &item->link);
-	update_item(item);
-	if (!item->id && !item->title && !item->icon && !item->iconname) {
-		wl_list_remove(&item->link);
-		free_item(item);
-		return;
-	}
-	emit_signal("StatusNotifierItemRegistered", item->key);
-	if (redraw)
-		redraw();
-}
-
-static void
-remove_item(TrayItem *item)
-{
-	char *key = item->key ? g_strdup(item->key) : NULL;
-
-	if (menu.open && menu.key && item->key
-			&& !strcmp(menu.key, item->key))
-		close_menu(1);
-	wl_list_remove(&item->link);
-	if (key)
-		emit_signal("StatusNotifierItemUnregistered", key);
-	g_free(key);
-	free_item(item);
-}
-
-static void
-remove_service(const char *name)
-{
-	TrayItem *item, *tmp;
-	int changed = 0;
-
-	wl_list_for_each_safe(item, tmp, &items, link) {
-		if (!strcmp(item->service, name)
-				|| (item->owner && !strcmp(item->owner, name))) {
-			remove_item(item);
-			changed = 1;
-		}
-	}
-	if (changed && redraw)
-		redraw();
-}
-
-static TrayItem *
-find_item(const char *service, const char *path)
-{
-	TrayItem *item;
-
-	if (!path)
-		return NULL;
-	wl_list_for_each(item, &items, link)
-		if (!strcmp(item->service, service)
-				&& !strcmp(item->path, path))
-			return item;
-	return NULL;
-}
-
-/* D-Bus callbacks run inside dbus_connection_dispatch().  A blocking GetAll
- * there would deadlock a client that is still waiting for our reply, so the
- * actual work is queued and run from an idle callback instead. */
-static void
-queue_work(int type, const char *service, const char *path)
-{
-	Work *w = xcalloc(1, sizeof(*w));
-
-	w->type = type;
-	w->service = g_strdup(service);
-	w->path = path ? g_strdup(path) : NULL;
-	wl_list_insert(work.prev, &w->link);
-	if (!work_source && event_loop)
-		work_source = wl_event_loop_add_idle(event_loop, process_work, NULL);
-}
-
-static void
-process_work(void *data)
-{
-	Work *w, *tmp;
-	TrayItem *item;
-
-	work_source = NULL;
-	wl_list_for_each_safe(w, tmp, &work, link) {
-		wl_list_remove(&w->link);
-		if (w->type == WorkAdd) {
-			add_item(w->service, w->path);
-		} else if (w->type == WorkUpdate) {
-			item = find_item(w->service, w->path);
-			if (item)
-				update_item(item);
-		} else if (w->type == WorkRemove) {
-			remove_service(w->service);
-		} else if (w->type == WorkMenu) {
-			open_menu(w->service, w->path, w->menupath, &w->mon,
-					w->barheight, w->anchor, w->scale,
-					w->font, w->sx, w->sy);
-		} else if (w->type == WorkMenuRefresh) {
-			reload_menu();
-		}
-		g_free(w->service);
-		g_free(w->path);
-		g_free(w->menupath);
-		free(w);
-	}
-}
-
-static TrayItem *
-item_for_signal(DBusMessage *message)
-{
-	const char *path = dbus_message_get_path(message);
-	const char *sender = dbus_message_get_sender(message);
-	TrayItem *item;
-
-	if (!path || !sender)
-		return NULL;
-	wl_list_for_each(item, &items, link) {
-		if (!strcmp(item->path, path)
-				&& (!strcmp(item->service, sender)
-				|| (item->owner && !strcmp(item->owner, sender))))
-			return item;
-	}
-	return NULL;
-}
-
-static int
-sender_matches(const char *service, const char *owner, const char *sender)
-{
-	return sender && ((service && !strcmp(service, sender))
-			|| (owner && !strcmp(owner, sender)));
-}
-
-static DBusHandlerResult
-filter(DBusConnection *conn, DBusMessage *message, void *data)
-{
-	const char *interface, *member, *name, *old, *new;
-	TrayItem *item;
-
-	if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL)
-		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-	interface = dbus_message_get_interface(message);
-	member = dbus_message_get_member(message);
-	if (interface && !strcmp(interface, ITEM_IFACE)) {
-		if (!strcmp(member, "NewIcon") || !strcmp(member, "NewTitle")
-				|| !strcmp(member, "NewStatus")
-				|| !strcmp(member, "NewMenu")) {
-			item = item_for_signal(message);
-			if (item)
-				queue_work(WorkUpdate, item->service, item->path);
-		}
-	} else if (interface && !strcmp(interface, MENU_IFACE)
-			&& !strcmp(member, "LayoutUpdated")) {
-		if (menu.open && !menu.loading && menu.path
-				&& dbus_message_get_path(message)
-				&& !strcmp(menu.path, dbus_message_get_path(message))
-				&& sender_matches(menu.service, menu.owner,
-					dbus_message_get_sender(message)))
-			queue_refresh();
-	} else if (interface && !strcmp(interface, "org.freedesktop.DBus")
-			&& !strcmp(member, "NameOwnerChanged")) {
-		if (dbus_message_get_args(message, NULL,
-				DBUS_TYPE_STRING, &name,
-				DBUS_TYPE_STRING, &old,
-				DBUS_TYPE_STRING, &new,
-				DBUS_TYPE_INVALID))
-			if (old[0] && strcmp(old, new))
-				queue_work(WorkRemove, name, NULL);
-	}
-	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-}
-
-/* ---- com.canonical.dbusmenu ------------------------------------------ */
-
-static void
-hide_node(struct wlr_scene_buffer *node)
-{
-	if (!node)
-		return;
-	wlr_scene_buffer_set_buffer(node, NULL);
-	wlr_scene_node_set_enabled(&node->node, 0);
-}
-
-static void
-send_event(const char *service, const char *path, int id, const char *name)
-{
-	DBusMessage *message;
-	DBusMessageIter iter, variant;
-	const char *event = name;
-	dbus_int32_t value = 0;
-	dbus_uint32_t stamp;
-
-	if (!bus || !service || !path)
-		return;
-	message = dbus_message_new_method_call(service, path, MENU_IFACE,
-			"Event");
-	if (!message)
-		return;
-	stamp = (dbus_uint32_t)time(NULL);
-	dbus_message_iter_init_append(message, &iter);
-	dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &id);
-	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &event);
-	dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, "i",
-			&variant);
-	dbus_message_iter_append_basic(&variant, DBUS_TYPE_INT32, &value);
-	dbus_message_iter_close_container(&iter, &variant);
-	dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &stamp);
-	dbus_connection_send(bus, message, NULL);
-	dbus_message_unref(message);
-	dbus_connection_flush(bus);
-}
-
-static void
-send_item(const char *service, const char *path, const char *method,
-		dbus_int32_t sx, dbus_int32_t sy)
-{
-	DBusMessage *message;
-
-	if (!bus || !service || !path)
-		return;
-	message = dbus_message_new_method_call(service, path, ITEM_IFACE,
-			method);
-	if (!message)
-		return;
-	dbus_message_append_args(message, DBUS_TYPE_INT32, &sx,
-			DBUS_TYPE_INT32, &sy, DBUS_TYPE_INVALID);
-	dbus_connection_send(bus, message, NULL);
-	dbus_message_unref(message);
-	dbus_connection_flush(bus);
-}
-
-static void
-free_menu_item(MenuItem *item)
-{
-	MenuItem *child, *tmp;
-
-	wl_list_for_each_safe(child, tmp, &item->children, link) {
-		wl_list_remove(&child->link);
-		free_menu_item(child);
-	}
-	g_free(item->label);
-	g_free(item->iconname);
-	free(item);
-}
-
-static void
-free_menu_items(struct wl_list *list)
-{
-	MenuItem *item, *tmp;
-
-	wl_list_for_each_safe(item, tmp, list, link) {
-		wl_list_remove(&item->link);
-		free_menu_item(item);
-	}
-}
-
-static void
-clear_menu(void)
-{
-	free_menu_items(&menu.items);
-	g_free(menu.service);
-	g_free(menu.owner);
-	g_free(menu.path);
-	g_free(menu.key);
-	menu.service = menu.owner = menu.path = menu.key = NULL;
-	menu.font = NULL;
-	menu.open = 0;
-	menu.loading = 0;
-	menu.sub = NULL;
-	menu.hover = NULL;
-	menu.subopen = 0;
-	hide_node(menu.node);
-	hide_node(menu.subnode);
-}
-
-static void
-close_menu(int notify)
-{
-	if (!menu.open)
-		return;
-	if (notify && menu.sub)
-		send_event(menu.service, menu.path, menu.sub->id, "closed");
-	clear_menu();
-}
-
-static void
-queue_refresh(void)
-{
-	Work *w = xcalloc(1, sizeof(*w));
-
-	w->type = WorkMenuRefresh;
-	wl_list_insert(work.prev, &w->link);
-	if (!work_source && event_loop)
-		work_source = wl_event_loop_add_idle(event_loop, process_work, NULL);
-}
-
-static void
-drop_work(Work *w)
-{
-	wl_list_remove(&w->link);
-	g_free(w->service);
-	g_free(w->path);
-	g_free(w->menupath);
-	free(w);
-}
-
-static void
-queue_menu(const char *service, const char *path, const char *menupath,
-		const struct wlr_box *mon, int barheight, int anchor, double scale,
-		struct fcft_font *font, dbus_int32_t sx, dbus_int32_t sy)
-{
-	Work *w = xcalloc(1, sizeof(*w));
-
-	w->type = WorkMenu;
-	w->service = g_strdup(service);
-	w->path = g_strdup(path);
-	w->menupath = menupath ? g_strdup(menupath) : NULL;
-	w->mon = *mon;
-	w->barheight = barheight;
-	w->anchor = anchor;
-	w->scale = scale;
-	w->font = font;
-	w->sx = sx;
-	w->sy = sy;
-	wl_list_insert(work.prev, &w->link);
-	if (!work_source && event_loop)
-		work_source = wl_event_loop_add_idle(event_loop, process_work, NULL);
-}
-
-static DBusMessage *
-menu_call(DBusMessage *message)
-{
-	DBusError error;
-	DBusMessage *reply;
-
-	if (!bus) {
-		dbus_message_unref(message);
-		return NULL;
-	}
-	dbus_error_init(&error);
-	reply = dbus_connection_send_with_reply_and_block(bus, message,
-			MENU_TIMEOUT, &error);
-	dbus_message_unref(message);
-	if (!reply)
-		dbus_error_free(&error);
-	return reply;
-}
-
-static void
-parse_props(DBusMessageIter *dict, MenuItem *item)
-{
-	DBusMessageIter entry, variant;
-	const char *key, *value;
-	dbus_bool_t boolean;
-	dbus_int32_t integer;
-
-	while (dbus_message_iter_get_arg_type(dict) == DBUS_TYPE_DICT_ENTRY) {
-		dbus_message_iter_recurse(dict, &entry);
-		if (dbus_message_iter_get_arg_type(&entry)
-				!= DBUS_TYPE_STRING)
-			break;
-		dbus_message_iter_get_basic(&entry, &key);
-		dbus_message_iter_next(&entry);
-		dbus_message_iter_recurse(&entry, &variant);
-		if (!strcmp(key, "label")) {
-			if ((value = get_string(&variant))) {
-				g_free(item->label);
-				item->label = g_strdup(value);
-			}
-		} else if (!strcmp(key, "enabled")) {
-			if (get_bool(&variant, &boolean))
-				item->enabled = boolean;
-		} else if (!strcmp(key, "visible")) {
-			if (get_bool(&variant, &boolean))
-				item->visible = boolean;
-		} else if (!strcmp(key, "type")) {
-			if ((value = get_string(&variant)))
-				item->separator = !strcmp(value, "separator");
-		} else if (!strcmp(key, "children-display")) {
-			if ((value = get_string(&variant)))
-				item->submenu = !strcmp(value, "submenu");
-		} else if (!strcmp(key, "toggle-type")) {
-			if ((value = get_string(&variant))) {
-				if (!strcmp(value, "check"))
-					item->toggle = ToggleCheck;
-				else if (!strcmp(value, "radio"))
-					item->toggle = ToggleRadio;
-			}
-		} else if (!strcmp(key, "toggle-state")) {
-			if (dbus_message_iter_get_arg_type(&variant)
-					== DBUS_TYPE_INT32) {
-				dbus_message_iter_get_basic(&variant, &integer);
-				item->toggled = integer > 0;
-			}
-		} else if (!strcmp(key, "icon-name")) {
-			if ((value = get_string(&variant))) {
-				g_free(item->iconname);
-				item->iconname = g_strdup(value);
-			}
-		}
-		dbus_message_iter_next(dict);
-	}
-}
-
-static int parse_layout_children(DBusMessageIter *iter,
-		struct wl_list *list, int depth, int *count);
-
-static int
-parse_layout_node(DBusMessageIter *iter, struct wl_list *list, int depth,
-		int *count)
-{
-	DBusMessageIter entry, props;
-	MenuItem *item;
-	dbus_int32_t id;
-
-	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRUCT)
-		return 0;
-	dbus_message_iter_recurse(iter, &entry);
-	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_INT32)
-		return 0;
-	dbus_message_iter_get_basic(&entry, &id);
-	dbus_message_iter_next(&entry);
-	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_ARRAY)
-		return 0;
-
-	item = xcalloc(1, sizeof(*item));
-	item->id = id;
-	item->enabled = 1;
-	item->visible = 1;
-	wl_list_init(&item->children);
-	dbus_message_iter_recurse(&entry, &props);
-	parse_props(&props, item);
-	dbus_message_iter_next(&entry);
-	if (depth > 0 && dbus_message_iter_get_arg_type(&entry)
-			== DBUS_TYPE_ARRAY)
-		parse_layout_children(&entry, &item->children, depth - 1,
-				count);
-	(*count)++;
-	wl_list_insert(list->prev, &item->link);
-	return 1;
-}
-
-static int
-parse_layout_children(DBusMessageIter *iter, struct wl_list *list, int depth,
-		int *count)
-{
-	DBusMessageIter children, variant;
-
-	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
-		return 0;
-	dbus_message_iter_recurse(iter, &children);
-	while (dbus_message_iter_get_arg_type(&children)
-			== DBUS_TYPE_VARIANT) {
-		dbus_message_iter_recurse(&children, &variant);
-		if (dbus_message_iter_get_arg_type(&variant) == DBUS_TYPE_STRUCT
-				&& *count < MENU_MAXITEMS)
-			parse_layout_node(&variant, list, depth, count);
-		dbus_message_iter_next(&children);
-	}
-	return 1;
-}
-
-static int
-fetch_layout(struct wl_list *list)
-{
-	DBusMessage *message, *reply;
-	DBusMessageIter iter, args, array, root;
-	dbus_int32_t id = 0, depth = MENU_DEPTH;
-	int count = 0;
-
-	if (!bus || !menu.service || !menu.path)
-		return 0;
-
-	message = dbus_message_new_method_call(menu.service, menu.path,
-			MENU_IFACE, "AboutToShow");
-	if (message) {
-		dbus_message_append_args(message, DBUS_TYPE_INT32, &id,
-				DBUS_TYPE_INVALID);
-		reply = menu_call(message);
-		if (reply)
-			dbus_message_unref(reply);
-	}
-
-	message = dbus_message_new_method_call(menu.service, menu.path,
-			MENU_IFACE, "GetLayout");
-	if (!message)
-		return 0;
-	dbus_message_iter_init_append(message, &args);
-	dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &id);
-	dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &depth);
-	dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY, "s", &array);
-	dbus_message_iter_close_container(&args, &array);
-	reply = menu_call(message);
-	if (!reply)
-		return 0;
-	if (!dbus_message_iter_init(reply, &iter)
-			|| dbus_message_iter_get_arg_type(&iter)
-			!= DBUS_TYPE_UINT32
-			|| !dbus_message_iter_next(&iter)
-			|| dbus_message_iter_get_arg_type(&iter)
-			!= DBUS_TYPE_STRUCT) {
-		dbus_message_unref(reply);
-		return 0;
-	}
-	dbus_message_iter_recurse(&iter, &root);
-	if (dbus_message_iter_get_arg_type(&root) != DBUS_TYPE_INT32) {
-		dbus_message_unref(reply);
-		return 0;
-	}
-	dbus_message_iter_next(&root);
-	dbus_message_iter_next(&root);
-	if (dbus_message_iter_get_arg_type(&root) != DBUS_TYPE_ARRAY
-			|| !parse_layout_children(&root, list, 1, &count)
-			|| count == 0) {
-		dbus_message_unref(reply);
-		return 0;
-	}
-	dbus_message_unref(reply);
-	return 1;
-}
-
-static int
-menu_usable(struct wl_list *list)
-{
-	MenuItem *item;
-
-	wl_list_for_each(item, list, link)
-		if (item->visible && !item->separator)
-			return 1;
-	return 0;
-}
-
-static MenuItem *
-find_menu_item(struct wl_list *list, int id)
-{
-	MenuItem *item, *found;
-
-	wl_list_for_each(item, list, link) {
-		if (item->id == id)
-			return item;
-		if ((found = find_menu_item(&item->children, id)))
-			return found;
-	}
-	return NULL;
-}
-
-static int
-usable_menu_path(const char *path)
-{
-	return path && *path && strcmp(path, "/")
-			&& strcmp(path, "/NO_DBUSMENU");
-}
-
-static int
-tolayout(int px, double scale)
-{
-	if (scale <= 0)
-		return px;
-	return (int)(px / scale + 0.5);
-}
-
-static int
-menu_inside(double x, double y, int bx, int by, int wpx, int hpx)
-{
-	double px, py;
-
-	if (menu.scale <= 0)
-		return 0;
-	px = (x - bx) * menu.scale;
-	py = (y - by) * menu.scale;
-	return px >= 0 && py >= 0 && px < wpx && py < hpx;
-}
-
-static MenuItem *
-panel_item_at(struct wl_list *list, double x, double y, int bx, int by)
-{
-	MenuItem *item;
-	int py = (int)((y - by) * menu.scale);
-
-	wl_list_for_each(item, list, link)
-		if (item->visible && item->h > 0 && py >= item->y
-				&& py < item->y + item->h)
-			return item;
-	return NULL;
-}
-
-typedef struct {
-	int pad, rowh, left, arroww;
-	int hastoggle, hassub;
-} MenuMetrics;
-
-static MenuMetrics
-panel_metrics(struct wl_list *list, int arrow)
-{
-	MenuMetrics metrics;
-	MenuItem *item;
-
-	metrics.pad = (int)(cfg.menupad * menu.scale + 0.5);
-	metrics.rowh = menu.font->height + 2 * metrics.pad;
-	metrics.hastoggle = 0;
-	metrics.hassub = 0;
-	wl_list_for_each(item, list, link) {
-		if (!item->visible)
-			continue;
-		if (item->toggle)
-			metrics.hastoggle = 1;
-		if (arrow && item->submenu && !wl_list_empty(&item->children))
-			metrics.hassub = 1;
-	}
-	metrics.left = metrics.pad + (metrics.hastoggle
-			? menu.font->height + metrics.pad : 0);
-	metrics.arroww = metrics.hassub
-			? bartextwidth(menu.font, ">") + metrics.pad : 0;
-	return metrics;
-}
-
-static void
-layout_panel(struct wl_list *list, int maxw, int maxh, int arrow,
-		int *outw, int *outh)
-{
-	MenuMetrics metrics = panel_metrics(list, arrow);
-	MenuItem *item;
-	int w, h, limit, tw;
-
-	w = metrics.left + metrics.pad;
-	h = metrics.pad;
-	limit = maxw - metrics.left - metrics.arroww - metrics.pad;
-	if (limit < 1)
-		limit = 1;
-	if (maxh < 2 * metrics.pad + metrics.rowh) {
-		wl_list_for_each(item, list, link) {
-			item->y = 0;
-			item->h = 0;
-		}
-		*outw = *outh = 0;
-		return;
-	}
-	wl_list_for_each(item, list, link) {
-		if (!item->visible) {
-			item->y = 0;
-			item->h = 0;
-			continue;
-		}
-		if (h + metrics.rowh + metrics.pad > maxh) {
-			item->y = 0;
-			item->h = 0;
-			continue;
-		}
-		item->y = h;
-		item->h = metrics.rowh;
-		tw = item->label ? bartextwidth(menu.font, item->label) : 0;
-		if (tw > limit)
-			tw = limit;
-		if (metrics.left + tw + metrics.arroww + metrics.pad > w)
-			w = metrics.left + tw + metrics.arroww + metrics.pad;
-		h += metrics.rowh;
-	}
-	if (w > maxw)
-		w = maxw;
-	*outw = w;
-	*outh = h + metrics.pad;
-	if (*outh > maxh)
-		*outh = maxh;
-}
-
-static void
-layout_main(void)
-{
-	int limit, maxw, maxh, w, h;
-
-	menu.wpx = menu.hpx = 0;
-	limit = menu.mon.width;
-	if ((int)cfg.menuwidth < limit)
-		limit = (int)cfg.menuwidth;
-	maxw = (int)(limit * menu.scale + 0.5);
-	maxh = (int)((menu.mon.height - menu.barheight) * menu.scale + 0.5);
-	if (maxw < 1 || maxh < 1)
-		return;
-	layout_panel(&menu.items, maxw, maxh, 1, &menu.wpx, &menu.hpx);
-	if (menu.wpx < 1 || menu.hpx < 1)
-		return;
-	w = tolayout(menu.wpx, menu.scale);
-	h = tolayout(menu.hpx, menu.scale);
-	menu.x = menu.anchor;
-	if (menu.x + w > menu.mon.x + menu.mon.width)
-		menu.x = menu.mon.x + menu.mon.width - w;
-	if (menu.x < menu.mon.x)
-		menu.x = menu.mon.x;
-	menu.y = menu.mon.y + menu.barheight;
-	if (menu.y + h > menu.mon.y + menu.mon.height)
-		menu.y = menu.mon.y + menu.mon.height - h;
-	if (menu.y < menu.mon.y + menu.barheight)
-		menu.y = menu.mon.y + menu.barheight;
-}
-
-static void
-layout_sub(void)
-{
-	int limit, maxw, maxh, w, h;
-
-	menu.subopen = 0;
-	menu.subwpx = menu.subhpx = 0;
-	if (!menu.sub || wl_list_empty(&menu.sub->children))
-		return;
-	limit = menu.mon.width;
-	if ((int)cfg.menuwidth < limit)
-		limit = (int)cfg.menuwidth;
-	maxw = (int)(limit * menu.scale + 0.5);
-	maxh = (int)(menu.mon.height * menu.scale + 0.5);
-	if (maxw < 1 || maxh < 1)
-		return;
-	layout_panel(&menu.sub->children, maxw, maxh, 0, &menu.subwpx,
-			&menu.subhpx);
-	if (menu.subwpx < 1 || menu.subhpx < 1)
-		return;
-	w = tolayout(menu.subwpx, menu.scale);
-	h = tolayout(menu.subhpx, menu.scale);
-	menu.subx = menu.x + tolayout(menu.wpx, menu.scale);
-	if (menu.subx + w > menu.mon.x + menu.mon.width)
-		menu.subx = menu.x - w;
-	if (menu.subx < menu.mon.x)
-		menu.subx = menu.mon.x;
-	if (menu.subx + w > menu.mon.x + menu.mon.width)
-		menu.subx = menu.mon.x + menu.mon.width - w;
-	menu.suby = menu.y + tolayout(menu.sub->y, menu.scale);
-	if (menu.suby + h > menu.mon.y + menu.mon.height)
-		menu.suby = menu.mon.y + menu.mon.height - h;
-	if (menu.suby < menu.mon.y)
-		menu.suby = menu.mon.y;
-	menu.subopen = 1;
-}
-
-static void
-draw_toggle(pixman_image_t *image, MenuItem *item, int x, int w, int cy,
-		const float *color)
-{
-	int size = menu.font->height / 2;
-	int bx, by, d;
-
-	if (size < 5)
-		size = 5;
-	bx = x + (w - size) / 2;
-	by = cy - size / 2;
-	if (item->toggle == ToggleCheck) {
-		if (item->toggled) {
-			barfill(image, color, bx, by, size, size);
-		} else {
-			barfill(image, color, bx, by, size, 1);
-			barfill(image, color, bx, by + size - 1, size, 1);
-			barfill(image, color, bx, by, 1, size);
-			barfill(image, color, bx + size - 1, by, 1, size);
-		}
-		return;
-	}
-	d = size / 2;
-	if (d < 3)
-		d = 3;
-	bx = x + (w - d) / 2;
-	by = cy - d / 2;
-	if (item->toggled) {
-		barfill(image, color, bx, by, d, d);
-	} else {
-		barfill(image, color, bx, by, d, 1);
-		barfill(image, color, bx, by + d - 1, d, 1);
-		barfill(image, color, bx, by, 1, d);
-		barfill(image, color, bx + d - 1, by, 1, d);
-	}
-}
-
-static void
-draw_panel(struct wl_list *list, int wpx, int hpx, int arrow,
-		struct wlr_scene_buffer *node, int x, int y)
-{
-	MenuMetrics metrics = panel_metrics(list, arrow);
-	pixman_image_t *image;
-	struct wlr_buffer *buffer;
-	MenuItem *item;
-	const float *fg;
-	int selected, baseline, tx, arrowx, maxx;
-
-	if (!node || wpx < 1 || hpx < 1)
-		return;
-	buffer = barimage_create(wpx, hpx, &image);
-	barfill(image, cfg.bg, 0, 0, wpx, hpx);
-	maxx = wpx - metrics.pad - metrics.arroww;
-	wl_list_for_each(item, list, link) {
-		if (!item->visible || item->h <= 0)
-			continue;
-		if (item->separator) {
-			barfill(image, cfg.hidfg, metrics.pad,
-					item->y + item->h / 2,
-					wpx - 2 * metrics.pad, 1);
-			continue;
-		}
-		selected = item == menu.hover && item->enabled;
-		if (selected)
-			barfill(image, cfg.selbg, 0, item->y, wpx, item->h);
-		fg = selected ? cfg.selfg
-				: item->enabled ? cfg.fg : cfg.hidfg;
-		baseline = item->y + (item->h - menu.font->height) / 2
-				+ menu.font->ascent;
-		if (metrics.hastoggle && item->toggle)
-			draw_toggle(image, item, metrics.pad,
-					menu.font->height + metrics.pad,
-					item->y + item->h / 2, fg);
-		tx = metrics.left;
-		if (item->label && item->label[0])
-			bartext(image, menu.font, item->label, tx, baseline, maxx,
-					fg);
-		if (item->submenu && !wl_list_empty(&item->children)) {
-			arrowx = wpx - metrics.pad
-					- bartextwidth(menu.font, ">");
-			bartext(image, menu.font, ">", arrowx, baseline,
-					wpx - metrics.pad, fg);
-		}
-	}
-	wlr_scene_buffer_set_buffer(node, buffer);
-	wlr_scene_buffer_set_dest_size(node, tolayout(wpx, menu.scale),
-			tolayout(hpx, menu.scale));
-	wlr_scene_node_set_position(&node->node, x, y);
-	wlr_scene_node_set_enabled(&node->node, 1);
-	wlr_buffer_drop(buffer);
-}
-
-static void
-menu_draw(void)
-{
-	if (!menu.open || !menu.node || !menu.subnode || !menu.font)
-		return;
-	layout_main();
-	if (menu.wpx < 1 || menu.hpx < 1)
-		return;
-	draw_panel(&menu.items, menu.wpx, menu.hpx, 1, menu.node, menu.x,
-			menu.y);
-	wlr_scene_node_raise_to_top(&menu.node->node);
-	if (menu.sub && !wl_list_empty(&menu.sub->children)) {
-		layout_sub();
-		if (menu.subopen) {
-			draw_panel(&menu.sub->children, menu.subwpx,
-					menu.subhpx, 0, menu.subnode,
-					menu.subx, menu.suby);
-			wlr_scene_node_raise_to_top(&menu.subnode->node);
-		}
-	} else {
-		menu.subopen = 0;
-	}
-	if (!menu.subopen)
-		hide_node(menu.subnode);
-}
-
-static void
-open_menu(const char *service, const char *path, const char *menupath,
-		const struct wlr_box *mon, int barheight, int anchor, double scale,
-		struct fcft_font *font, dbus_int32_t sx, dbus_int32_t sy)
-{
-	TrayItem *item;
-
-	close_menu(1);
-	item = find_item(service, path);
-	if (!bus || !item || !font || !mon || !usable_menu_path(menupath)
-			|| mon->width <= 0 || mon->height <= barheight)
-		goto fallback;
-
-	menu.service = g_strdup(service);
-	menu.owner = item->owner ? g_strdup(item->owner) : NULL;
-	menu.path = g_strdup(menupath);
-	menu.key = item->key ? g_strdup(item->key) : NULL;
-	menu.mon = *mon;
-	menu.barheight = barheight;
-	menu.anchor = anchor;
-	menu.scale = scale;
-	menu.font = font;
-	wl_list_init(&menu.items);
-	menu.loading = 1;
-	if (!fetch_layout(&menu.items) || !menu_usable(&menu.items)) {
-		menu.loading = 0;
-		clear_menu();
-		goto fallback;
-	}
-	menu.loading = 0;
-	menu.open = 1;
-	menu.sub = NULL;
-	menu.hover = NULL;
-	menu.subopen = 0;
-	menu_draw();
-	return;
-
-fallback:
-	send_item(service, path, "ContextMenu", sx, sy);
-}
-
-static void
-reload_menu(void)
-{
-	struct wl_list list;
-	MenuItem *item;
-	int subid, hoverid;
-
-	if (!menu.open || !bus)
-		return;
-	subid = menu.sub ? menu.sub->id : -1;
-	hoverid = menu.hover ? menu.hover->id : -1;
-	wl_list_init(&list);
-	menu.loading = 1;
-	if (!fetch_layout(&list) || !menu_usable(&list)) {
-		menu.loading = 0;
-		free_menu_items(&list);
-		close_menu(1);
-		return;
-	}
-	menu.loading = 0;
-	menu.sub = NULL;
-	menu.hover = NULL;
-	menu.subopen = 0;
-	free_menu_items(&menu.items);
-	menu.items = list;
-	menu.items.next->prev = &menu.items;
-	menu.items.prev->next = &menu.items;
-	if (subid >= 0 && (item = find_menu_item(&menu.items, subid))
-			&& item->submenu && !wl_list_empty(&item->children)) {
-		menu.sub = item;
-		menu.subopen = 1;
-	} else if (subid >= 0) {
-		send_event(menu.service, menu.path, subid, "closed");
-	}
-	if (hoverid >= 0)
-		menu.hover = find_menu_item(&menu.items, hoverid);
-	menu_draw();
-}
-
-static void
-toggle_submenu(MenuItem *item)
-{
-	if (menu.sub == item) {
-		send_event(menu.service, menu.path, item->id, "closed");
-		menu.sub = NULL;
-		menu.subopen = 0;
-	} else {
-		if (menu.sub)
-			send_event(menu.service, menu.path, menu.sub->id,
-					"closed");
-		menu.sub = item;
-		send_event(menu.service, menu.path, item->id, "opened");
-	}
-	menu.hover = item;
-	menu_draw();
-}
-
-int
-systray_menu_click(double x, double y, uint32_t button)
-{
-	MenuItem *item;
-
-	if (!menu.open)
-		return 0;
-	if (menu.subopen && menu_inside(x, y, menu.subx, menu.suby,
-			menu.subwpx, menu.subhpx)) {
-		item = panel_item_at(&menu.sub->children, x, y, menu.subx,
-				menu.suby);
-		if (!item || item->separator || !item->enabled
-				|| button != BTN_LEFT)
-			return 1;
-		/* Only one nested level is rendered; a deeper submenu is inert. */
-		if (item->submenu)
-			return 1;
-		send_event(menu.service, menu.path, item->id, "clicked");
-		close_menu(1);
-		return 1;
-	}
-	if (menu_inside(x, y, menu.x, menu.y, menu.wpx, menu.hpx)) {
-		item = panel_item_at(&menu.items, x, y, menu.x, menu.y);
-		if (!item || item->separator || !item->enabled
-				|| button != BTN_LEFT)
-			return 1;
-		if (item->submenu) {
-			if (!wl_list_empty(&item->children))
-				toggle_submenu(item);
-			return 1;
-		}
-		send_event(menu.service, menu.path, item->id, "clicked");
-		close_menu(1);
-		return 1;
-	}
-	close_menu(1);
-	return 0;
-}
-
-void
-systray_menu_motion(double x, double y)
-{
-	MenuItem *item = NULL;
-
-	if (!menu.open)
-		return;
-	if (menu.subopen && menu_inside(x, y, menu.subx, menu.suby,
-			menu.subwpx, menu.subhpx))
-		item = panel_item_at(&menu.sub->children, x, y, menu.subx,
-				menu.suby);
-	else if (menu_inside(x, y, menu.x, menu.y, menu.wpx, menu.hpx))
-		item = panel_item_at(&menu.items, x, y, menu.x, menu.y);
-	if (item == menu.hover)
-		return;
-	menu.hover = item;
-	menu_draw();
-}
-
-int
-systray_menu_key(xkb_keysym_t sym)
-{
-	if (!menu.open || sym != XKB_KEY_Escape)
-		return 0;
-	close_menu(1);
-	return 1;
-}
-
-void
-systray_menu_close(void)
-{
-	close_menu(1);
-}
-
-void
-systray_menu_font_destroyed(struct fcft_font *font)
-{
-	Work *w, *tmp;
-
-	/* A queued menu open cannot draw with a font that is about to go away. */
-	wl_list_for_each_safe(w, tmp, &work, link) {
-		if (w->type == WorkMenu && w->font == font) {
-			send_item(w->service, w->path, "ContextMenu",
-					w->sx, w->sy);
-			drop_work(w);
-		}
-	}
-	if (menu.open && menu.font == font)
-		close_menu(1);
-}
-
-/* ---- watcher service ------------------------------------------------- */
-
-static void
-emit_signal(const char *member, const char *key)
-{
-	DBusMessage *message;
-
-	if (!bus)
-		return;
-	message = dbus_message_new_signal(WATCHER_PATH, WATCHER, member);
-	if (!message)
-		return;
-	if (key)
-		dbus_message_append_args(message, DBUS_TYPE_STRING, &key,
-				DBUS_TYPE_INVALID);
-	dbus_connection_send(bus, message, NULL);
-	dbus_message_unref(message);
-	dbus_connection_flush(bus);
-}
-
-static void
-append_item_array(DBusMessageIter *iter)
-{
-	DBusMessageIter array;
-	TrayItem *item;
-
-	dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "s", &array);
-	wl_list_for_each(item, &items, link)
-		dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING,
-				&item->key);
-	dbus_message_iter_close_container(iter, &array);
-}
-
-static void
-append_prop_array(DBusMessageIter *dict)
-{
-	DBusMessageIter entry, variant;
-	const char *name = "RegisteredStatusNotifierItems";
-
-	dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL,
-			&entry);
-	dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &name);
-	dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, "as",
-			&variant);
-	append_item_array(&variant);
-	dbus_message_iter_close_container(&entry, &variant);
-	dbus_message_iter_close_container(dict, &entry);
-}
-
-static void
-append_prop_bool(DBusMessageIter *dict, const char *name, dbus_bool_t value)
-{
-	DBusMessageIter entry, variant;
-
-	dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL,
-			&entry);
-	dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &name);
-	dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, "b",
-			&variant);
-	dbus_message_iter_append_basic(&variant, DBUS_TYPE_BOOLEAN, &value);
-	dbus_message_iter_close_container(&entry, &variant);
-	dbus_message_iter_close_container(dict, &entry);
-}
-
-static void
-append_prop_int(DBusMessageIter *dict, const char *name, dbus_int32_t value)
-{
-	DBusMessageIter entry, variant;
-
-	dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL,
-			&entry);
-	dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &name);
-	dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, "i",
-			&variant);
-	dbus_message_iter_append_basic(&variant, DBUS_TYPE_INT32, &value);
-	dbus_message_iter_close_container(&entry, &variant);
-	dbus_message_iter_close_container(dict, &entry);
-}
-
-static void
-send_reply(DBusConnection *conn, DBusMessage *reply)
-{
-	if (!reply)
-		return;
-	dbus_connection_send(conn, reply, NULL);
-	dbus_message_unref(reply);
-	dbus_connection_flush(conn);
-}
-
-static DBusHandlerResult
-properties_message(DBusConnection *conn, DBusMessag
…… diff 过长已截断 ……
somechanges on systemtraynageyqma · 2026-10-26 · 6987faa
查看变更
AGENT.md     |   22 +-
 Makefile     |   12 +-
 README.md    |   61 ++--
 config.def.h |    5 +
 dwl.1        |   21 --
 dwl.c        |  183 ++++++++---
 systray.c    | 2452 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 systray.h    |   55 ++++
 8 files changed, 2686 insertions(+), 125 deletions(-)
diff --git a/AGENT.md b/AGENT.md
index f4188b2..b98f283 100644
--- a/AGENT.md
+++ b/AGENT.md
@@ -21,16 +21,23 @@ Two properties matter more than features:
    one pass. A clever abstraction that saves repetition but costs a jump is a
    regression here.
 
+The bar's tray is native: `systray.c` implements the
+`org.kde.StatusNotifierWatcher` service and draws icons into the same pixman
+image as `drawbar()`. The system-information text is read from
+`$XDG_RUNTIME_DIR/dwl-status`, written by `~/scripts/dwl-status.sh`. Do not
+replace either with an external bar or tray program.
+
 The practical consequences:
 
 - Configuration belongs in `config.h`. If a behavior can be selected there,
   implement it there, not as a runtime option.
 - Reuse what dwl/wlroots already provides: `spawn`, `SHCMD`, `Arg`, `LISTEN`,
-  listeners, the `-s` startup command, wlroots helpers. Do not build a second
-  mechanism beside one that already exists.
-- No new dependencies, no new source files, no build-system layers, no
-  generated code, no configuration parser, no IPC, no plugin system, no
-  runtime reload, no animation framework.
+  listeners, wlroots helpers. Do not build a second mechanism beside one that
+  already exists.
+- No new dependencies beyond the bar's tray (`dbus-1`, `gdk-pixbuf`), no new
+  source files beyond `systray.c`, no build-system layers, no generated code,
+  no configuration parser, no IPC beyond the tray's D-Bus service, no plugin
+  system, no runtime reload, no animation framework.
 - Do not generalize for a hypothetical future request. The owner will ask for
   the next feature when they want it.
 - Prefer deleting a special case to adding a flag. Prefer one fixed path to a
@@ -46,7 +53,7 @@ The practical consequences:
    an existing function, a small helper, a new file (almost never).
 3. Check the side effects: environment (`WAYLAND_DISPLAY`,
    `XDG_RUNTIME_DIR`), child processes and shutdown, focus and keyboard
-   groups, multi-monitor, XWayland, and the `-s` status pipe.
+   groups, multi-monitor, XWayland, and the status output.
 4. Write the diff in the surrounding style. It should be hard to tell your hunk
    from upstream code.
 5. Build. Do not restart the live session. Report what you verified and what
@@ -93,7 +100,8 @@ not the physical QWERTY position. That is intended.
 
 `Arg autostartcmd` and the `spawn(&autostartcmd)` call in `run()` are the
 whole autostart implementation. Keep it that way: one command, one path, no
-directory search, and no blocking/non-blocking pair.
+directory search, and no blocking/non-blocking pair. There is no `-s` command
+line option; do not reintroduce one.
 
 ## Local invariants
 
diff --git a/Makefile b/Makefile
index 620fe3d..29ff7e1 100644
--- a/Makefile
+++ b/Makefile
@@ -12,16 +12,16 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
 	-Wfloat-conversion
 
 # CFLAGS / LDFLAGS
-PKGS      = wayland-server xkbcommon libinput $(XLIBS)
+PKGS      = wayland-server xkbcommon libinput dbus-1 gdk-pixbuf-2.0 $(XLIBS)
 DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(SCENEFX_INCS) $(WLR_INCS) $(FCFT_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
 LDLIBS    = $(SCENEFX_LIBS) `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) $(FCFT_LIBS) -lm $(LIBS)
 
 all: dwl
-dwl: dwl.c client.h config.h ime.h util.h config.mk cursor-shape-v1-protocol.h \
-	ext-image-copy-capture-v1-protocol.h \
+dwl: dwl.c systray.c systray.h client.h config.h ime.h util.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
-	$(CC) -O3 dwl.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
+	$(CC) -O3 dwl.c systray.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
 
 # wayland-scanner is a tool which generates C headers and rigging for Wayland
 # protocols, which are specified in XML. wlroots requires you to rig these up
@@ -56,8 +56,8 @@ 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 ime.h util.h dwl.desktop \
-		dwl-$(VERSION)
+		config.mk protocols dwl.1 dwl.c systray.c systray.h ime.h util.h \
+		dwl.desktop dwl-$(VERSION)
 	tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION)
 	rm -rf dwl-$(VERSION)
 
diff --git a/README.md b/README.md
index fd72785..c1aee9f 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,11 @@ version of `wlroots` should target this branch.
 
 ### Building dwl
 dwl has the following dependencies:
+- fcft (bar font)
+- gdk-pixbuf (themed tray icons)
+- libdbus (system tray)
 - libinput
+- pixman (bar image)
 - wayland
 - wlroots (compiled with the libinput backend)
 - xkbcommon
@@ -76,26 +80,17 @@ otherwise you need to add yourself in the `seat` group and enable/start the
 seatd daemon.
 
 When dwl is run with no arguments, it will launch the server and begin handling
-any shortcuts configured in `config.h`. There is no status bar or other
-decoration initially; these are instead clients that can be run within the
-Wayland session. Do note that the default background color is grey. This can be
-modified in `config.h`.
-
-If you would like to run a script or command automatically at startup, you can
-specify the command using the `-s` option. This command will be executed as a
-shell command using `/bin/sh -c`.  It serves a similar function to `.xinitrc`,
-but differs in that the display server will not shut down when this process
-terminates. Instead, dwl will send this process a SIGTERM at shutdown and wait
-for it to terminate (if it hasn't already). This makes it ideal for execing into
-a user service manager like [s6], [anopa], [runit], [dinit], or [`systemd
---user`].
-
-Note: The `-s` command is run as a *child process* of dwl, which means that it
-does not have the ability to affect the environment of dwl or of any processes
-that it spawns. If you need to set environment variables that affect the entire
-dwl session, these must be set prior to running dwl. For example, Wayland
-requires a valid `XDG_RUNTIME_DIR`, which is usually set up by a session manager
-such as `elogind` or `systemd-logind`.  If your system doesn't do this
+any shortcuts configured in `config.h`. dwl draws a small bar at the top of
+each monitor; everything else is a Wayland client. Do note that the default
+background color is grey. This can be modified in `config.h`.
+
+Programs that should start with the session are started from `autostartcmd` in
+`config.h`, which is spawned once after the backend and XWayland are ready.
+There is no command-line startup command; `autostartcmd` is the only entry
+point, and one `SHCMD` entry can start as many programs as needed.
+
+Wayland requires a valid `XDG_RUNTIME_DIR`, which is usually set up by a session
+manager such as `elogind` or `systemd-logind`. If your system doesn't do this
 automatically, you will need to configure it prior to launching `dwl`, e.g.:
 
     export XDG_RUNTIME_DIR=/tmp/xdg-runtime-$(id -u)
@@ -105,21 +100,14 @@ automatically, you will need to configure it prior to launching `dwl`, e.g.:
 ### Status information
 
 Information about selected layouts, current window title, app-id, and
-selected/occupied/urgent tags is written to the stdin of the `-s` command (see
-the `STATUS INFORMATION` section in `_dwl_(1)`).  This information can be used to
-populate an external status bar with a script that parses the
-information. Failing to read this information will cause dwl to block, so if you
-do want to run a startup command that does not consume the status information,
-you can close standard input with the `<&-` shell redirection, for example:
-
-    dwl -s 'foot --server <&-'
-
-If your startup command is a shell script, you can achieve the same inside the
-script with the line
+selected/occupied/urgent tags is written to standard output (see the `STATUS
+INFORMATION` section in `_dwl_(1)`). This information can be used to populate
+an external status bar with a script that parses it.
 
-    exec <&-
+The built-in bar also shows a StatusNotifierItem tray and the contents of
+`$XDG_RUNTIME_DIR/dwl-status`; `~/scripts/dwl-status.sh` writes that file.
 
-To get a list of status bars that work with dwl consult our [wiki].
+To get a list of external status bars that work with dwl consult our [wiki].
 
 ### (Known) Java nonreparenting WM issue
 Certain IDEs don't display correctly unless an environmental variable for Java AWT
@@ -148,7 +136,7 @@ given the base on which it is built. Implemented default features are:
 - Configurable HiDPI/multi-DPI support
 - Idle-inhibit protocol which lets applications such as mpv disable idle
   monitoring
-- Provide information to external status bars via stdout/stdin
+- Provide information to external status bars via stdout
 - Urgency hints via xdg-activate protocol
 - Support screen lockers via ext-session-lock-v1 protocol
 - Various Wayland protocols
@@ -196,19 +184,14 @@ Also, thanks to our current lead developers:
 
 [wlroots]: https://gitlab.freedesktop.org/wlroots
 [dwm]: https://dwm.suckless.org/
-[`systemd --user`]: https://wiki.archlinux.org/title/Systemd/User
 [#dwl on Libera Chat]: https://web.libera.chat/?channels=#dwl
 [0.7-rc1]: https://codeberg.org/dwl/dwl/releases/tag/v0.7-rc1
 [0.x branch]: https://codeberg.org/dwl/dwl/branches
-[anopa]: https://jjacky.com/anopa/
-[dinit]: https://davmac.org/projects/dinit/
 [dwl-patches]: https://codeberg.org/dwl/dwl-patches
 [list of useful resources on our wiki]: https://codeberg.org/dwl/dwl/wiki/Home#migrating-from-x
 [main]: https://codeberg.org/dwl/dwl/src/branch/main
 [wlroots-next]: https://codeberg.org/dwl/dwl/src/branch/wlroots-next
 [release]: https://codeberg.org/dwl/dwl/releases
-[runit]: http://smarden.org/runit/faq.html#userservices
-[s6]: https://skarnet.org/software/s6/
 [wlroots]: https://gitlab.freedesktop.org/wlroots/wlroots/
 [wiki]: https://codeberg.org/dwl/dwl/wiki/Home#compatible-status-bars
 [Discord server]: https://discord.gg/jJxZnrGPWN
diff --git a/config.def.h b/config.def.h
index 06d96ef..094ec79 100644
--- a/config.def.h
+++ b/config.def.h
@@ -26,6 +26,11 @@ static const float barfg[]                 = COLOR(0xbbbbbbff);
 static const float barselbg[]              = COLOR(0x005577ff);
 static const float barselfg[]              = COLOR(0xffffffff);
 static const float barhidfg[]              = COLOR(0x555555ff);
+/* system tray; its icons are drawn in the bar, scaled with the output */
+static const unsigned int trayiconsize     = 18; /* icon size, in layout pixels */
+static const unsigned int trayspacing      = 6;  /* space between icons */
+static const unsigned int menupad          = 4;  /* tray menu padding, in layout pixels */
+static const unsigned int menuwidth        = 240; /* maximum tray menu width, in layout pixels */
 
 static const int blur = 1; /* background blur */
 static const struct blur_data blur_data = {
diff --git a/dwl.1 b/dwl.1
index 51c07b8..bf3fedd 100644
--- a/dwl.1
+++ b/dwl.1
@@ -8,7 +8,6 @@
 .Nm
 .Op Fl v
 .Op Fl d
-.Op Fl s Ar startup command
 .Sh DESCRIPTION
 .Nm
 is a Wayland compositor based on wlroots.
@@ -28,17 +27,6 @@ option,
 .Nm
 enables full wlroots logging, including debug information.
 .Pp
-When given the
-.Fl s
-option,
-.Nm
-starts a shell process running
-.Ar command
-when starting.
-When stopping, it sends
-.Dv SIGTERM
-to the child process group and waits for it to exit.
-.Pp
 Users are encouraged to customize
 .Nm
 by editing the sources, in particular
@@ -115,10 +103,6 @@ Tiled windows will be toggled to the floating state.
 .Sh STATUS INFORMATION
 .Nm
 writes its status information to standard output.
-If the
-.Fl s
-option is given, the status information is written to the standard input of the
-child process instead.
 .Pp
 Said information has the following format:
 .Bd -ragged -offset indent
@@ -245,11 +229,6 @@ tell how to connect to the
 .Nm Xwayland
 server.
 .El
-.Sh EXAMPLES
-Start
-.Nm
-with s6 in the background:
-.Dl dwl \-s \(aqs6\-svscan <&\-\(aq
 .Sh SEE ALSO
 .Xr dwm 1 ,
 .Xr foot 1 ,
diff --git a/dwl.c b/dwl.c
index 135e147..ec6457a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -83,6 +83,7 @@
 
 #include "xdg-shell-protocol.h"
 #include "util.h"
+#include "systray.h"
 
 /* macros */
 #define CLEANMASK(mask)         (mask & ~WLR_MODIFIER_CAPS)
@@ -91,6 +92,7 @@
 #define TAGMASK                 ((1u << TAGCOUNT) - 1)
 #define LISTEN(E, L, H)         wl_signal_add((E), ((L)->notify = (H), (L)))
 #define LISTEN_STATIC(E, H)     do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0)
+#define STATUSPOLL              1000 /* ms between reads of the status file */
 
 /* enums */
 enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
@@ -300,12 +302,8 @@ static BarBuffer *barbuffer_create(int width, int height);
 static void barbuffer_destroy(struct wlr_buffer *buffer);
 static void barbuffer_end(struct wlr_buffer *buffer);
 static pixman_color_t barcolor(const float color[4]);
-static void barfill(pixman_image_t *image, const float color[4], int x,
-		int y, int width, int height);
 static const char *barlabel(unsigned int tag);
-static void bartext(pixman_image_t *image, struct fcft_font *font,
-		const char *text, int x, int baseline, int maxx, const float color[4]);
-static int bartextwidth(struct fcft_font *font, const char *text);
+static int baradvance(const struct fcft_glyph *glyph);
 static uint32_t barutf8(const char **s);
 static void buttonpress(struct wl_listener *listener, void *data);
 static void capturerequest(struct wl_listener *listener, void *data);
@@ -387,7 +385,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 roundbuffer(struct wlr_scene_buffer *buffer, int sx, int sy, void *data);
-static void run(char *startup_cmd);
+static void run(void);
 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);
@@ -402,6 +400,7 @@ 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 statusupdate(void *data);
 static void tag(const Arg *arg);
 static void tagmon(const Arg *arg);
 static void tile(Monitor *m);
@@ -426,11 +425,13 @@ static void xytonode(double x, double y, struct wlr_surface **psurface,
 static void zoom(const Arg *arg);
 
 /* variables */
-static pid_t child_pid = -1;
 static int locked;
 static Client *focused_client;
 static struct wl_display *dpy;
 static struct wl_event_loop *event_loop;
+static char barstatus[256]; /* system information at the right of the bar */
+static char statuspath[PATH_MAX];
+static struct wl_event_source *status_timer;
 static struct wlr_backend *backend;
 static struct wlr_scene *scene;
 static struct wlr_scene_tree *layers[NUM_LAYERS];
@@ -728,7 +729,7 @@ barclick(Monitor *m, double x, double y, uint32_t button)
 	Client *c;
 	Arg arg;
 	double scale;
-	int bx, pad, width, cx, i, n, tabw, tw;
+	int bx, pad, width, cx, i, n, tabw, tw, right, trayleft;
 
 	if (!m || !m->bar || !m->barfont || !m->wlr_output->enabled)
 		return 0;
@@ -739,13 +740,22 @@ barclick(Monitor *m, double x, double y, uint32_t button)
 	if (wlr_scene_node_at(&scene->tree.node, x, y, NULL, NULL)
 			!= &m->bar->node)
 		return 0;
-	if (button != BTN_LEFT)
-		return 1;
 
 	scale = m->wlr_output->scale;
 	bx = (int)((x - m->m.x) * scale + 0.5);
 	width = (int)(m->m.width * scale + 0.5);
 	pad = (int)(barpad * scale + 0.5);
+	trayleft = MAX(0, width - (int)(systray_width() * scale + 0.5));
+	if (bx >= trayleft) {
+		systray_click(bx, width, scale, button, x, y, m->barfont,
+				&m->m, m->barheight);
+		return 1;
+	}
+	right = trayleft;
+	if (barstatus[0])
+		right = MAX(0, right - bartextwidth(m->barfont, barstatus) - 2 * pad);
+	if (button != BTN_LEFT)
+		return 1;
 	selmon = m;
 
 	cx = 0;
@@ -772,7 +782,7 @@ barclick(Monitor *m, double x, double y, uint32_t button)
 			n++;
 	if (n == 0)
 		return 1;
-	tabw = (width - cx) / n;
+	tabw = (right - cx) / n;
 	if (tabw <= 0 || bx < cx)
 		return 1;
 	i = (bx - cx) / tabw;
@@ -831,6 +841,15 @@ barbuffer_create(int width, int height)
 	return bar;
 }
 
+struct wlr_buffer *
+barimage_create(int width, int height, pixman_image_t **image)
+{
+	BarBuffer *bar = barbuffer_create(width, height);
+
+	*image = bar->image;
+	return &bar->base;
+}
+
 pixman_color_t
 barcolor(const float color[4])
 {
@@ -868,6 +887,18 @@ barlabel(unsigned int tag)
 	return label;
 }
 
+int
+baradvance(const struct fcft_glyph *glyph)
+{
+	int advance = glyph->advance.x;
+
+	/* A fallback icon can be wider than its advance; using the visual width
+	 * keeps the next glyph from being drawn on top of it. */
+	if (glyph->x + glyph->width > advance)
+		advance = glyph->x + glyph->width;
+	return advance;
+}
+
 void
 bartext(pixman_image_t *image, struct fcft_font *font, const char *text,
 		int x, int baseline, int maxx, const float color[4])
@@ -884,7 +915,7 @@ bartext(pixman_image_t *image, struct fcft_font *font, const char *text,
 		if (!(glyph = fcft_rasterize_char_utf32(font, cp,
 				FCFT_SUBPIXEL_NONE)))
 			continue;
-		if (x + glyph->advance.x > maxx)
+		if (x + baradvance(glyph) > maxx)
 			break;
 		if (glyph->is_color_glyph)
 			pixman_image_composite32(PIXMAN_OP_OVER, glyph->pix, NULL,
@@ -894,7 +925,7 @@ bartext(pixman_image_t *image, struct fcft_font *font, const char *text,
 			pixman_image_composite32(PIXMAN_OP_OVER, src, glyph->pix,
 					image, 0, 0, 0, 0, x + glyph->x,
 					baseline - glyph->y, glyph->width, glyph->height);
-		x += glyph->advance.x;
+		x += baradvance(glyph);
 	}
 	pixman_image_unref(src);
 }
@@ -909,7 +940,7 @@ bartextwidth(struct fcft_font *font, const char *text)
 		glyph = fcft_rasterize_char_utf32(font, barutf8(&text),
 				FCFT_SUBPIXEL_NONE);
 		if (glyph)
-			width += glyph->advance.x;
+			width += baradvance(glyph);
 	}
 	return width;
 }
@@ -1001,6 +1032,8 @@ buttonpress(struct wl_listener *listener, void *data)
 		selmon = xytomon(cursor->x, cursor->y);
 		if (locked)
 			break;
+		if (systray_menu_click(cursor->x, cursor->y, event->button))
+			return;
 		if (barclick(selmon, cursor->x, cursor->y, event->button))
 			return;
 
@@ -1096,11 +1129,10 @@ cleanup(void)
 	wlr_xwayland_destroy(xwayland);
 	xwayland = NULL;
 #endif
+	if (status_timer)
+		wl_event_source_remove(status_timer);
+	systray_fini();
 	wl_display_destroy_clients(dpy);
-	if (child_pid > 0) {
-		kill(-child_pid, SIGTERM);
-		waitpid(child_pid, NULL, 0);
-	}
 	wlr_xcursor_manager_destroy(cursor_mgr);
 
 	destroykeyboardgroup(&kb_group->destroy, NULL);
@@ -1140,8 +1172,10 @@ cleanupmon(struct wl_listener *listener, void *data)
 		destroylocksurface(&m->destroy_lock_surface, NULL);
 	if (m->bar)
 		wlr_scene_node_destroy(&m->bar->node);
-	if (m->barfont)
+	if (m->barfont) {
+		systray_menu_font_destroyed(m->barfont);
 		fcft_destroy(m->barfont);
+	}
 	m->wlr_output->data = NULL;
 	wlr_output_layout_remove(output_layout, m->wlr_output);
 	wlr_scene_output_destroy(m->scene_output);
@@ -1846,7 +1880,8 @@ drawbar(Monitor *m)
 	pixman_image_t *image;
 	struct fcft_font *font;
 	const float *fg;
-	int i, x = 0, width, height, pad, baseline, n = 0, tabw;
+	int i, x = 0, width, height, pad, baseline, n = 0, tabw, right,
+			statusw, statusx;
 	uint32_t occ = 0, urg = 0, tag;
 	double scale;
 
@@ -1867,6 +1902,9 @@ drawbar(Monitor *m)
 	}
 	pad = (int)(barpad * scale + 0.5);
 	baseline = (height - font->height) / 2 + font->ascent;
+	right = MAX(0, width - (int)(systray_width() * scale + 0.5));
+	statusw = barstatus[0] ? bartextwidth(font, barstatus) + 2 * pad : 0;
+	statusx = MAX(0, right - statusw);
 
 	bar = barbuffer_create(width, height);
 	image = bar->image;
@@ -1908,7 +1946,7 @@ drawbar(Monitor *m)
 	x += tabw;
 
 	sel = focustop(m);
-	if (n > 0 && (tabw = (width - x) / n) > 0) {
+	if (n > 0 && (tabw = (statusx - x) / n) > 0) {
 		wl_list_for_each(c, &clients, link) {
 			if (!VISIBLE(c, m))
 				continue;
@@ -1925,6 +1963,11 @@ drawbar(Monitor *m)
 		}
 	}
 
+	if (barstatus[0])
+		bartext(image, font, barstatus, statusx + pad, baseline,
+				right - pad, barfg);
+	systray_draw(image, font, baseline, height, scale, barfg);
+
 	wlr_scene_node_set_position(&m->bar->node, m->m.x, m->m.y);
 	wlr_scene_buffer_set_dest_size(m->bar, m->m.width, m->barheight);
 	wlr_scene_node_set_enabled(&m->bar->node, 1);
@@ -2234,6 +2277,14 @@ keypress(struct wl_listener *listener, void *data)
 
 	wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
 
+	/* The tray menu takes Escape without moving keyboard focus. */
+	if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED
+			&& systray_menu_key(group->keysyms[0])) {
+		consumed[event->keycode] = 1;
+		wl_event_source_timer_update(group->key_repeat_source, 0);
+		return;
+	}
+
 	/* On _press_ if there is no active screen locker,
 	 * attempt to process a compositor keybinding. */
 	if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
@@ -2329,6 +2380,7 @@ locksession(struct wl_listener *listener, void *data)
 	lock->scene = wlr_scene_tree_create(layers[LyrBlock]);
 	cur_lock = lock->lock = session_lock;
 	locked = 1;
+	systray_menu_close();
 
 	/* Cancel any interactive move/resize and take the pointer focus away
 	 * from the clients below the lock screen */
@@ -2547,6 +2599,8 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
 			selmon = xytomon(cursor->x, cursor->y);
 	}
 
+	systray_menu_motion(cursor->x, cursor->y);
+
 	/* Update drag icon's position */
 	wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x), (int)round(cursor->y));
 
@@ -2964,8 +3018,10 @@ roundbuffer(struct wlr_scene_buffer *buffer, int sx, int sy, void *data)
 }
 
 void
-run(char *startup_cmd)
+run(void)
 {
+	TrayConfig traycfg;
+
 	/* Add a Unix socket to the Wayland display. */
 	const char *socket = wl_display_add_socket_auto(dpy);
 	if (!socket)
@@ -2981,33 +3037,34 @@ run(char *startup_cmd)
 	setenv("DISPLAY", xwaylanddisplay, 1);
 	spawn(&xwaylandcmd);
 
-	/* Now that the socket exists and the backend is started, run the startup command */
-	if (startup_cmd) {
-		int piperw[2];
-		if (pipe(piperw) < 0)
-			die("startup: pipe:");
-		if ((child_pid = fork()) < 0)
-			die("startup: fork:");
-		if (child_pid == 0) {
-			setsid();
-			dup2(piperw[0], STDIN_FILENO);
-			close(piperw[0]);
-			close(piperw[1]);
-			execl("/bin/sh", "/bin/sh", "-c", startup_cmd, NULL);
-			die("startup: execl:");
-		}
-		dup2(piperw[1], STDOUT_FILENO);
-		close(piperw[1]);
-		close(piperw[0]);
-	}
+	/* Start the system tray before the autostart script, so tray clients find
+	 * the watcher. */
+	traycfg = (TrayConfig){
+		.iconsize = trayiconsize,
+		.spacing = trayspacing,
+		.menupad = menupad,
+		.menuwidth = menuwidth,
+		.bg = barbg,
+		.fg = barfg,
+		.selbg = barselbg,
+		.selfg = barselfg,
+		.hidfg = barhidfg,
+	};
+	systray_init(event_loop, layers[LyrOverlay], &traycfg, drawbars);
 
 	/* Start the autostart command in the background */
 	spawn(&autostartcmd);
 
-	/* Mark stdout as non-blocking to avoid the startup script
-	 * causing dwl to freeze when a user neither closes stdin
-	 * nor consumes standard input in his startup script */
+	/* The bar reads its system information from this file, which
+	 * ~/scripts/dwl-status.sh keeps current. */
+	snprintf(statuspath, sizeof(statuspath), "%s/dwl-status",
+			getenv("XDG_RUNTIME_DIR"));
+	status_timer = wl_event_loop_add_timer(event_loop, statusupdate, NULL);
+	if (status_timer)
+		wl_event_source_timer_update(status_timer, STATUSPOLL);
 
+	/* Mark stdout as non-blocking so a pipe that nobody reads cannot
+	 * freeze dwl while it prints status information. */
 	if (fd_set_nonblock(STDOUT_FILENO) < 0)
 		close(STDOUT_FILENO);
 
@@ -3477,6 +3534,29 @@ startdrag(struct wl_listener *listener, void *data)
 	LISTEN_STATIC(&drag->icon->events.destroy, destroydragicon);
 }
 
+int
+statusupdate(void *data)
+{
+	char buf[sizeof(barstatus)];
+	FILE *f;
+	size_t n;
+
+	if ((f = fopen(statuspath, "r"))) {
+		n = fread(buf, 1, sizeof(buf) - 1, f);
+		fclose(f);
+		while (n > 0 && (buf[n - 1] == '\n' || buf[n - 1] == '\r'))
+			n--;
+		buf[n] = '\0';
+		if (strcmp(buf, barstatus)) {
+			memcpy(barstatus, buf, n + 1);
+			drawbars();
+		}
+	}
+
+	wl_event_source_timer_update(status_timer, STATUSPOLL);
+	return 0;
+}
+
 void
 tag(const Arg *arg)
 {
@@ -3680,8 +3760,10 @@ updatebar(Monitor *m)
 		scale = 1;
 	if (m->barfont && m->barscale == scale)
 		return;
-	if (m->barfont)
+	if (m->barfont) {
+		systray_menu_font_destroyed(m->barfont);
 		fcft_destroy(m->barfont);
+	}
 
 	/* Render at the output's resolution instead of scaling the bar up. */
 	snprintf(attr, sizeof(attr), "dpi=%d", (int)(96 * scale + 0.5));
@@ -4064,13 +4146,10 @@ xwaylandready(struct wl_listener *listener, void *data)
 int
 main(int argc, char *argv[])
 {
-	char *startup_cmd = NULL;
 	int c;
 
-	while ((c = getopt(argc, argv, "s:hdv")) != -1) {
-		if (c == 's')
-			startup_cmd = optarg;
-		else if (c == 'd')
+	while ((c = getopt(argc, argv, "hdv")) != -1) {
+		if (c == 'd')
 			log_level = WLR_DEBUG;
 		else if (c == 'v')
 			die("dwl " VERSION);
@@ -4084,10 +4163,10 @@ main(int argc, char *argv[])
 	if (!getenv("XDG_RUNTIME_DIR"))
 		die("XDG_RUNTIME_DIR must be set");
 	setup();
-	run(startup_cmd);
+	run();
 	cleanup();
 	return EXIT_SUCCESS;
 
 usage:
-	die("Usage: %s [-v] [-d] [-s startup command]", argv[0]);
+	die("Usage: %s [-v] [-d]", argv[0]);
 }
diff --git a/systray.c b/systray.c
new file mode 100644
index 0000000..30b119e
--- /dev/null
+++ b/systray.c
@@ -0,0 +1,2452 @@
+/*
+ * StatusNotifierItem host for the dwl bar.
+ *
+ * The bar is drawn by drawbar() into a pixman image.  This file implements the
+ * org.kde.StatusNotifierWatcher service and draws registered items into that
+ * same image, so the tray is part of the bar rather than a separate window.
+ */
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <linux/input-event-codes.h>
+#include <glib.h>
+#include <pixman.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#include <dbus/dbus.h>
+#include <scenefx/types/wlr_scene.h>
+#include <wayland-server-core.h>
+#include <wlr/util/box.h>
+#include <xkbcommon/xkbcommon-keysyms.h>
+
+#include "systray.h"
+
+#define WATCHER          "org.kde.StatusNotifierWatcher"
+#define WATCHER_PATH     "/StatusNotifierWatcher"
+#define ITEM_IFACE       "org.kde.StatusNotifierItem"
+#define MENU_IFACE       "com.canonical.dbusmenu"
+#define PROPERTIES_IFACE "org.freedesktop.DBus.Properties"
+
+#define MAXTHEMES        32
+#define MENU_TIMEOUT     1000 /* ms for the menu's blocking calls */
+#define MENU_DEPTH       2    /* GetLayout levels: top level and submenus */
+#define MENU_MAXITEMS    256  /* refuse absurd menus */
+
+typedef struct TrayItem {
+	struct wl_list link;
+	char *service;
+	char *path;
+	char *owner;
+	char *key;
+	char *id;
+	char *title;
+	char *iconname;
+	char *icontheme;
+	char *menupath;
+	int itemismenu;
+	pixman_image_t *icon;
+	int iconw, iconh;
+	pixman_image_t *scaled;
+	int scaled_size;
+} TrayItem;
+
+/* drawbar() runs during backend start, before systray_init(). */
+static struct wl_list items = { &items, &items };
+static struct wl_list work = { &work, &work };
+static struct wl_event_loop *event_loop;
+static DBusConnection *bus;
+static struct wl_event_source *work_source;
+static unsigned int icon_size = 18;
+static unsigned int icon_spacing = 6;
+static TrayConfig cfg;
+static void (*redraw)(void);
+
+enum { WorkAdd, WorkUpdate, WorkRemove, WorkMenu, WorkMenuRefresh };
+typedef struct {
+	struct wl_list link;
+	int type;
+	char *service;
+	char *path;
+	char *menupath;
+	struct wlr_box mon;
+	int barheight, anchor;
+	double scale;
+	struct fcft_font *font;
+	dbus_int32_t sx, sy;
+} Work;
+
+enum { ToggleNone, ToggleCheck, ToggleRadio };
+typedef struct MenuItem {
+	struct wl_list link;
+	struct wl_list children;
+	int id;
+	char *label;
+	char *iconname;
+	int enabled, visible;
+	int separator, submenu;
+	int toggle, toggled;
+	int y, h; /* row, in output pixels of its panel */
+} MenuItem;
+
+static struct {
+	int open, loading;
+	char *service, *owner, *path, *key;
+	struct wl_list items; /* MenuItem.link */
+	MenuItem *sub, *hover;
+	struct wlr_scene_buffer *node, *subnode;
+	struct wlr_box mon;
+	int barheight, anchor;
+	double scale;
+	struct fcft_font *font;
+	int x, y, wpx, hpx;
+	int subx, suby, subwpx, subhpx;
+	int subopen;
+} menu;
+
+static void process_work(void *data);
+
+static void add_item(const char *service, const char *path);
+static void update_item(TrayItem *item);
+static void remove_item(TrayItem *item);
+static void remove_service(const char *name);
+static void emit_signal(const char *member, const char *key);
+
+static void clear_menu(void);
+static void close_menu(int notify);
+static void menu_draw(void);
+static void open_menu(const char *service, const char *path,
+		const char *menupath, const struct wlr_box *mon, int barheight,
+		int anchor, double scale, struct fcft_font *font,
+		dbus_int32_t sx, dbus_int32_t sy);
+static void reload_menu(void);
+static void queue_menu(const char *service, const char *path,
+		const char *menupath, const struct wlr_box *mon, int barheight,
+		int anchor, double scale, struct fcft_font *font,
+		dbus_int32_t sx, dbus_int32_t sy);
+static void queue_refresh(void);
+static void send_item(const char *service, const char *path,
+		const char *method, dbus_int32_t sx, dbus_int32_t sy);
+
+static void *
+xcalloc(size_t nmemb, size_t size)
+{
+	void *p = calloc(nmemb, size);
+
+	if (!p) {
+		fprintf(stderr, "systray: out of memory\n");
+		exit(1);
+	}
+	return p;
+}
+
+static void
+free_item(TrayItem *item)
+{
+	g_free(item->service);
+	g_free(item->path);
+	g_free(item->owner);
+	g_free(item->key);
+	g_free(item->id);
+	g_free(item->title);
+	g_free(item->iconname);
+	g_free(item->icontheme);
+	g_free(item->menupath);
+	if (item->icon)
+		pixman_image_unref(item->icon);
+	if (item->scaled)
+		pixman_image_unref(item->scaled);
+	free(item);
+}
+
+static int
+item_count(void)
+{
+	TrayItem *item;
+	int n = 0;
+
+	wl_list_for_each(item, &items, link)
+		n++;
+	return n;
+}
+
+/* ---- D-Bus / wl_event_loop glue ------------------------------------- */
+
+static int
+watch_handle(int fd, uint32_t mask, void *data)
+{
+	DBusWatch *watch = data;
+	uint32_t flags = 0;
+
+	if (!dbus_watch_get_enabled(watch))
+		return 0;
+	if (mask & WL_EVENT_READABLE)
+		flags |= DBUS_WATCH_READABLE;
+	if (mask & WL_EVENT_WRITABLE)
+		flags |= DBUS_WATCH_WRITABLE;
+	if (mask & WL_EVENT_HANGUP)
+		flags |= DBUS_WATCH_HANGUP;
+	if (mask & WL_EVENT_ERROR)
+		flags |= DBUS_WATCH_ERROR;
+	dbus_watch_handle(watch, flags);
+	/* Method handlers only queue work, so dispatching here cannot block the
+	 * event loop on an item that is waiting for us. */
+	while (bus && dbus_connection_get_dispatch_status(bus)
+			== DBUS_DISPATCH_DATA_REMAINS)
+		dbus_connection_dispatch(bus);
+	return 0;
+}
+
+static dbus_bool_t
+add_watch(DBusWatch *watch, void *data)
+{
+	struct wl_event_loop *loop = data;
+	struct wl_event_source *source;
+	uint32_t flags, mask = 0;
+
+	if (!dbus_watch_get_enabled(watch))
+		return TRUE;
+	flags = dbus_watch_get_flags(watch);
+	if (flags & DBUS_WATCH_READABLE)
+		mask |= WL_EVENT_READABLE;
+	if (flags & DBUS_WATCH_WRITABLE)
+		mask |= WL_EVENT_WRITABLE;
+	source = wl_event_loop_add_fd(loop, dbus_watch_get_unix_fd(watch),
+			mask, watch_handle, watch);
+	dbus_watch_set_data(watch, source, NULL);
+	return TRUE;
+}
+
+static void
+remove_watch(DBusWatch *watch, void *data)
+{
+	struct wl_event_source *source = dbus_watch_get_data(watch);
+
+	if (source)
+		wl_event_source_remove(source);
+}
+
+static int
+timeout_handle(void *data)
+{
+	DBusTimeout *timeout = data;
+
+	if (dbus_timeout_get_enabled(timeout))
+		dbus_timeout_handle(timeout);
+	return 0;
+}
+
+static dbus_bool_t
+add_timeout(DBusTimeout *timeout, void *data)
+{
+	struct wl_event_loop *loop = data;
+	struct wl_event_source *source;
+
+	if (!dbus_timeout_get_enabled(timeout))
+		return TRUE;
+	source = wl_event_loop_add_timer(loop, timeout_handle, timeout);
+	if (!source)
+		return FALSE;
+	if (wl_event_source_timer_update(source,
+			dbus_timeout_get_interval(timeout)) < 0) {
+		wl_event_source_remove(source);
+		return FALSE;
+	}
+	dbus_timeout_set_data(timeout, source, NULL);
+	return TRUE;
+}
+
+static void
+remove_timeout(DBusTimeout *timeout, void *data)
+{
+	struct wl_event_source *source = dbus_timeout_get_data(timeout);
+
+	if (source)
+		wl_event_source_remove(source);
+}
+
+static int
+startbus(DBusConnection *conn, struct wl_event_loop *loop)
+{
+	dbus_connection_set_exit_on_disconnect(conn, FALSE);
+	if (!dbus_connection_set_watch_functions(conn, add_watch,
+			remove_watch, NULL, loop, NULL)
+			|| !dbus_connection_set_timeout_functions(conn,
+			add_timeout, remove_timeout, NULL, loop, NULL)) {
+		dbus_connection_set_watch_functions(conn, NULL, NULL, NULL,
+				NULL, NULL);
+		dbus_connection_set_timeout_functions(conn, NULL, NULL, NULL,
+				NULL, NULL);
+		return 0;
+	}
+	return 1;
+}
+
+static void
+stopbus(DBusConnection *conn)
+{
+	dbus_connection_set_watch_functions(conn, NULL, NULL, NULL, NULL, NULL);
+	dbus_connection_set_timeout_functions(conn, NULL, NULL, NULL, NULL, NULL);
+}
+
+/* ---- icon theme lookup ---------------------------------------------- */
+
+static char *
+settings_theme(void)
+{
+	const char *home = getenv("HOME");
+	const char *xdg = getenv("XDG_CONFIG_HOME");
+	char *path, *theme = NULL;
+	GKeyFile *kf;
+	gsize len;
+
+	if (xdg && *xdg)
+		path = g_build_filename(xdg, "gtk-3.0", "settings.ini", NULL);
+	else if (home)
+		path = g_build_filename(home, ".config", "gtk-3.0",
+				"settings.ini", NULL);
+	else
+		return NULL;
+	kf = g_key_file_new();
+	if (g_key_file_load_from_file(kf, path, G_KEY_FILE_NONE, NULL))
+		theme = g_key_file_get_string(kf, "Settings",
+				"gtk-icon-theme-name", NULL);
+	g_key_file_free(kf);
+	g_free(path);
+	if (!theme)
+		return NULL;
+	g_strstrip(theme);
+	len = strlen(theme);
+	if (len >= 2 && (theme[0] == '"' || theme[0] == '\'')
+			&& theme[len - 1] == theme[0]) {
+		memmove(theme, theme + 1, len - 2);
+		theme[len - 2] = '\0';
+	}
+	return theme;
+}
+
+static GPtrArray *
+icon_roots(void)
+{
+	GPtrArray *roots = g_ptr_array_new_with_free_func(g_free);
+	const char *home = getenv("HOME");
+	const char *xdg = getenv("XDG_DATA_HOME");
+	const char *data_dirs = getenv("XDG_DATA_DIRS");
+	char **parts;
+	int i;
+
+	if (xdg && *xdg)
+		g_ptr_array_add(roots, g_build_filename(xdg, "icons", NULL));
+	else if (home)
+		g_ptr_array_add(roots, g_build_filename(home, ".local", "share",
+				"icons", NULL));
+	if (home)
+		g_ptr_array_add(roots, g_build_filename(home, ".icons", NULL));
+	if (!data_dirs || !*data_dirs)
+		data_dirs = "/usr/local/share:/usr/share";
+	parts = g_strsplit(data_dirs, ":", -1);
+	for (i = 0; parts[i]; i++)
+		if (*parts[i])
+			g_ptr_array_add(roots, g_build_filename(parts[i],
+					"icons", NULL));
+	g_strfreev(parts);
+	g_ptr_array_add(roots, g_strdup("/usr/share/pixmaps"));
+	return roots;
+}
+
+static int
+dir_score(const char *dir, const char *ext, int symbolic)
+{
+	const char *p;
+	int size = 0, score;
+
+	if (strstr(dir, "scalable")) {
+		score = 1200;
+	} else {
+		for (p = dir; *p; p++) {
+			if (g_ascii_isdigit(*p)) {
+				size = atoi(p);
+				break;
+			}
+		}
+		score = size ? 1000 - abs(size - 24) : 500;
+	}
+	if (strstr(dir, "symbolic")) {
+		if (!symbolic)
+			score -= 600;
+	} else if (symbolic) {
+		score -= 200;
+	}
+	if (g_str_has_suffix(ext, "svg"))
+		score += 20;
+	else if (g_str_has_suffix(ext, "png"))
+		score += 10;
+	return score;
+}
+
+static char *
+search_theme(const char *dir, const char *name)
+{
+	static const char *exts[] = { "svg", "png", "xpm" };
+	static const char *common[] = { "apps", "devices", "status", "actions",
+		"places", "notifications", "panel", "categories", "mimetypes",
+		"emblems", "scalable", "symbolic" };
+	char *index, *path, *best = NULL, *filename, *value;
+	char **dirs = NULL;
+	gsize n = 0, i, j;
+	GKeyFile *kf;
+	int bestscore = -100000, score, symbolic, e;
+
+	if (!name || !*name)
+		return NULL;
+	symbolic = strstr(name, "symbolic") != NULL;
+
+	/* IconThemePath may point directly at a directory of icons. */
+	for (e = 0; e < 3; e++) {
+		filename = g_strdup_printf("%s.%s", name, exts[e]);
+		path = g_build_filename(dir, filename, NULL);
+		g_free(filename);
+		if (access(path, R_OK) == 0) {
+			g_free(best);
+			best = path;
+			bestscore = 2000;
+		} else {
+			g_free(path);
+		}
+	}
+	if (best)
+		return best;
+
+	index = g_build_filename(dir, "index.theme", NULL);
+	kf = g_key_file_new();
+	if (g_key_file_load_from_file(kf, index, G_KEY_FILE_NONE, NULL)) {
+		/* index.theme uses commas, while GKeyFile lists use semicolons. */
+		value = g_key_file_get_string(kf, "Icon Theme", "Directories",
+				NULL);
+		if (value) {
+			dirs = g_strsplit_set(value, ",;", -1);
+			n = g_strv_length(dirs);
+			for (j = 0; j < n; j++)
+				g_strstrip(dirs[j]);
+			g_free(value);
+		}
+	}
+	if (!dirs || n == 0) {
+		g_strfreev(dirs);
+		dirs = g_new0(char *, G_N_ELEMENTS(common) + 1);
+		for (i = 0; i < G_N_ELEMENTS(common); i++)
+			dirs[i] = g_strdup(common[i]);
+		n = G_N_ELEMENTS(common);
+	}
+
+	for (i = 0; i < n; i++) {
+		for (e = 0; e < 3; e++) {
+			int found = 0;
+
+			filename = g_strdup_printf("%s.%s", name, exts[e]);
+			path = g_build_filename(dir, dirs[i], filename, NULL);
+			g_free(filename);
+			score = dir_score(dirs[i], exts[e], symbolic);
+			found = access(path, R_OK) == 0;
+			if (found && score > bestscore) {
+				g_free(best);
+				best = path;
+				bestscore = score;
+			} else {
+				g_free(path);
+			}
+		}
+	}
+	g_strfreev(dirs);
+	g_key_file_free(kf);
+	g_free(index);
+	return best;
+}
+
+static void
+add_theme(char **themes, int *n, const char *name)
+{
+	int i;
+
+	if (!name || !*name)
+		return;
+	for (i = 0; i < *n; i++)
+		if (!strcmp(themes[i], name))
+			return;
+	if (*n < MAXTHEMES)
+		themes[(*n)++] = g_strdup(name);
+}
+
+/* Resolve index.theme directly; linking GTK just to look up icons would pull
+ * a full toolkit into the compositor. */
+static char *
+find_icon(const char *name, const char *extrapath)
+{
+	static const char *defaults[] = { "hicolor", "Adwaita", "breeze" };
+	char *themes[MAXTHEMES], *best = NULL, *tdir, *index;
+	GPtrArray *roots;
+	GKeyFile *kf;
+	char **list;
+	gsize i;
+	int nthemes = 0, r, t, depth;
+	char *theme, *value;
+
+	if (!name || !*name)
+		return NULL;
+	if (name[0] == '/' || strchr(name, '/')) {
+		if (access(name, R_OK) == 0)
+			return g_strdup(name);
+		return NULL;
+	}
+	if (extrapath && *extrapath) {
+		best = search_theme(extrapath, name);
+		if (best)
+			return best;
+	}
+
+	theme = settings_theme();
+	if (theme)
+		add_theme(themes, &nthemes, theme);
+	for (i = 0; i < G_N_ELEMENTS(defaults); i++)
+		add_theme(themes, &nthemes, defaults[i]);
+	roots = icon_roots();
+
+	/* Follow Inherits= so a custom theme can fall back to its parents. */
+	for (depth = 0; depth < 4; depth++) {
+		int before = nthemes;
+		for (t = depth; t < before; t++) {
+			for (r = 0; r < (int)roots->len; r++) {
+				tdir = g_build_filename(roots->pdata[r], themes[t],
+						NULL);
+				index = g_build_filename(tdir, "index.theme", NULL);
+				kf = g_key_file_new();
+				if (g_key_file_load_from_file(kf, index,
+						G_KEY_FILE_NONE, NULL)) {
+					value = g_key_file_get_string(kf,
+							"Icon Theme", "Inherits", NULL);
+					if (value) {
+						list = g_strsplit_set(value, ",;", -1);
+						for (i = 0; list[i]; i++) {
+							g_strstrip(list[i]);
+							add_theme(themes, &nthemes,
+									list[i]);
+						}
+						g_strfreev(list);
+						g_free(value);
+					}
+				}
+				g_key_file_free(kf);
+				g_free(index);
+				g_free(tdir);
+			}
+		}
+		if (nthemes == before)
+			break;
+	}
+
+	for (t = 0; t < nthemes && !best; t++) {
+		for (r = 0; r < (int)roots->len && !best; r++) {
+			tdir = g_build_filename(roots->pdata[r], themes[t], NULL);
+			best = search_theme(tdir, name);
+			g_free(tdir);
+		}
+	}
+	/* /usr/share/pixmaps has no theme directory. */
+	for (r = 0; r < (int)roots->len && !best; r++)
+		best = search_theme(roots->pdata[r], name);
+
+	for (i = 0; i < (gsize)nthemes; i++)
+		g_free(themes[i]);
+	g_free(theme);
+	g_ptr_array_free(roots, TRUE);
+	return best;
+}
+
+static pixman_image_t *
+pixbuf_to_pixman(GdkPixbuf *pixbuf)
+{
+	int w = gdk_pixbuf_get_width(pixbuf);
+	int h = gdk_pixbuf_get_height(pixbuf);
+	int stride = gdk_pixbuf_get_rowstride(pixbuf);
+	int channels = gdk_pixbuf_get_n_channels(pixbuf);
+	guchar *pixels = gdk_pixbuf_get_pixels(pixbuf);
+	pixman_image_t *image;
+	uint32_t *out;
+	uint8_t a, r, g, b;
+	guchar *p;
+	int x, y;
+
+	if (w <= 0 || h <= 0)
+		return NULL;
+	image = pixman_image_create_bits(PIXMAN_a8r8g8b8, w, h, NULL, w * 4);
+	if (!image)
+		return NULL;
+	out = pixman_image_get_data(image);
+	for (y = 0; y < h; y++) {
+		p = pixels + y * stride;
+		for (x = 0; x < w; x++, p += channels) {
+			a = channels == 4 ? p[3] : 255;
+			r = p[0];
+			g = p[1];
+			b = p[2];
+			out[y * w + x] = ((uint32_t)a << 24) | ((uint32_t)r << 16)
+					| ((uint32_t)g << 8) | b;
+		}
+	}
+	return image;
+}
+
+static pixman_image_t *
+load_theme_icon(const char *name, const char *extrapath)
+{
+	char *path;
+	GdkPixbuf *pixbuf;
+	GError *error = NULL;
+	pixman_image_t *image;
+
+	path = find_icon(name, extrapath);
+	if (!path)
+		return NULL;
+	if (g_str_has_suffix(path, ".svg"))
+		pixbuf = gdk_pixbuf_new_from_file_at_scale(path, 64, 64, TRUE,
+				&error);
+	else
+		pixbuf = gdk_pixbuf_new_from_file(path, &error);
+	g_free(path);
+	if (!pixbuf) {
+		g_clear_error(&error);
+		return NULL;
+	}
+	image = pixbuf_to_pixman(pixbuf);
+	g_object_unref(pixbuf);
+	return image;
+}
+
+/* ---- status notifier items ------------------------------------------ */
+
+/* IconPixmap is ARGB32 in network byte order; pixman wants native 0xAARRGGBB. */
+static pixman_image_t *
+parse_pixmap(DBusMessageIter *variant, int *outw, int *outh)
+{
+	DBusMessageIter array, entry, data;
+	const void *raw;
+	const uint8_t *best = NULL;
+	pixman_image_t *image;
+	uint32_t *pixels;
+	int bestw = 0, besth = 0, w, h, len, i, alpha = 0;
+
+	if (dbus_message_iter_get_arg_type(variant) != DBUS_TYPE_ARRAY)
+		return NULL;
+	dbus_message_iter_recurse(variant, &array);
+	while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRUCT) {
+		dbus_message_iter_recurse(&array, &entry);
+		dbus_message_iter_get_basic(&entry, &w);
+		dbus_message_iter_next(&entry);
+		dbus_message_iter_get_basic(&entry, &h);
+		dbus_message_iter_next(&entry);
+		dbus_message_iter_recurse(&entry, &data);
+		dbus_message_iter_get_fixed_array(&data, &raw, &len);
+		if (w > 0 && h > 0 && len >= w * h * 4
+				&& w * h > bestw * besth) {
+			bestw = w;
+			besth = h;
+			best = raw;
+		}
+		dbus_message_iter_next(&array);
+	}
+	if (!best)
+		return NULL;
+	image = pixman_image_create_bits(PIXMAN_a8r8g8b8, bestw, besth,
+			NULL, bestw * 4);
+	if (!image)
+		return NULL;
+	pixels = pixman_image_get_data(image);
+	for (i = 0; i < bestw * besth; i++) {
+		const uint8_t *p = best + i * 4;
+		uint8_t a = p[0], r = p[1], g = p[2], b = p[3];
+
+		if (a)
+			alpha = 1;
+		pixels[i] = ((uint32_t)a << 24) | ((uint32_t)r << 16)
+				| ((uint32_t)g << 8) | b;
+	}
+	if (!alpha)
+		for (i = 0; i < bestw * besth; i++)
+			pixels[i] |= 0xff000000;
+	*outw = bestw;
+	*outh = besth;
+	return image;
+}
+
+static const char *
+get_string(DBusMessageIter *iter)
+{
+	const char *s;
+
+	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING
+			&& dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_OBJECT_PATH)
+		return NULL;
+	dbus_message_iter_get_basic(iter, &s);
+	return s;
+}
+
+static int
+get_bool(DBusMessageIter *iter, dbus_bool_t *value)
+{
+	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BOOLEAN)
+		return 0;
+	dbus_message_iter_get_basic(iter, value);
+	return 1;
+}
+
+static void
+update_item(TrayItem *item)
+{
+	DBusMessage *message, *reply;
+	DBusMessageIter iter, dict, entry, variant;
+	DBusError error;
+	char *id = NULL, *title = NULL, *iconname = NULL, *icontheme = NULL;
+	char *menupath = NULL;
+	const char *key, *string, *interface = ITEM_IFACE;
+	pixman_image_t *icon = NULL;
+	dbus_bool_t itemismenu = FALSE;
+	int iconw = 0, iconh = 0, w, h;
+
+	dbus_error_init(&error);
+	message = dbus_message_new_method_call(item->service, item->path,
+			PROPERTIES_IFACE, "GetAll");
+	if (!message)
+		return;
+	dbus_message_append_args(message, DBUS_TYPE_STRING, &interface,
+			DBUS_TYPE_INVALID);
+	reply = dbus_connection_send_with_reply_and_block(bus, message, 1000,
+			&error);
+	dbus_message_unref(message);
+	if (!reply) {
+		dbus_error_free(&error);
+		return;
+	}
+	if (!dbus_message_iter_init(reply, &iter)
+			|| dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
+		goto out;
+	dbus_message_iter_recurse(&iter, &dict);
+	while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+		dbus_message_iter_recurse(&dict, &entry);
+		dbus_message_iter_get_basic(&entry, &key);
+		dbus_message_iter_next(&entry);
+		dbus_message_iter_recurse(&entry, &variant);
+		if (!strcmp(key, "Id")) {
+			if ((string = get_string(&variant))) {
+				g_free(id);
+				id = g_strdup(string);
+			}
+		} else if (!strcmp(key, "Title")) {
+			if ((string = get_string(&variant))) {
+				g_free(title);
+				title = g_strdup(string);
+			}
+		} else if (!strcmp(key, "IconName")) {
+			if ((string = get_string(&variant))) {
+				g_free(iconname);
+				iconname = g_strdup(string);
+			}
+		} else if (!strcmp(key, "IconThemePath")) {
+			if ((string = get_string(&variant))) {
+				g_free(icontheme);
+				icontheme = g_strdup(string);
+			}
+		} else if (!strcmp(key, "Menu")) {
+			if ((string = get_string(&variant))) {
+				g_free(menupath);
+				menupath = g_strdup(string);
+			}
+		} else if (!strcmp(key, "ItemIsMenu")) {
+			get_bool(&variant, &itemismenu);
+		} else if (!strcmp(key, "IconPixmap")) {
+			pixman_image_t *pixmap;
+
+			pixmap = parse_pixmap(&variant, &w, &h);
+			if (pixmap) {
+				if (icon)
+					pixman_image_unref(icon);
+				icon = pixmap;
+				iconw = w;
+				iconh = h;
+			}
+		}
+		dbus_message_iter_next(&dict);
+	}
+out:
+	dbus_message_unref(reply);
+	/* Both spellings mean "this item has no menu" (the spec's convention). */
+	if (menupath && (!strcmp(menupath, "/")
+			|| !strcmp(menupath, "/NO_DBUSMENU"))) {
+		g_free(menupath);
+		menupath = NULL;
+	}
+	if (!icon && iconname) {
+		icon = load_theme_icon(iconname, icontheme);
+		if (icon) {
+			iconw = pixman_image_get_width(icon);
+			iconh = pixman_image_get_height(icon);
+		}
+	}
+
+	g_free(item->id);
+	g_free(item->title);
+	g_free(item->iconname);
+	g_free(item->icontheme);
+	g_free(item->menupath);
+	if (item->icon)
+		pixman_image_unref(item->icon);
+	if (item->scaled)
+		pixman_image_unref(item->scaled);
+	item->id = id;
+	item->title = title;
+	item->iconname = iconname;
+	item->icontheme = icontheme;
+	item->menupath = menupath;
+	item->itemismenu = itemismenu;
+	item->icon = icon;
+	item->iconw = iconw;
+	item->iconh = iconh;
+	item->scaled = NULL;
+	item->scaled_size = 0;
+	if (menu.open && menu.key && item->key
+			&& !strcmp(menu.key, item->key)
+			&& (!item->menupath || !menu.path
+			|| strcmp(item->menupath, menu.path)))
+		close_menu(1);
+	if (redraw)
+		redraw();
+}
+
+static char *
+name_owner(const char *service)
+{
+	DBusMessage *message, *reply;
+	DBusError error;
+	const char *owner;
+	char *result = NULL;
+
+	message = dbus_message_new_method_call("org.freedesktop.DBus",
+			"/org/freedesktop/DBus", "org.freedesktop.DBus",
+			"GetNameOwner");
+	if (!message)
+		return NULL;
+	dbus_message_append_args(message, DBUS_TYPE_STRING, &service,
+			DBUS_TYPE_INVALID);
+	dbus_error_init(&error);
+	reply = dbus_connection_send_with_reply_and_block(bus, message, 1000,
+			&error);
+	dbus_message_unref(message);
+	if (!reply) {
+		dbus_error_free(&error);
+		return NULL;
+	}
+	if (dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &owner,
+			DBUS_TYPE_INVALID))
+		result = g_strdup(owner);
+	dbus_message_unref(reply);
+	return result;
+}
+
+static void
+add_item(const char *service, const char *path)
+{
+	TrayItem *item, *other;
+	char *key;
+
+	if (!service || !path || !*service || !*path)
+		return;
+	key = g_strconcat(service, path, NULL);
+	wl_list_for_each(other, &items, link) {
+		if (!strcmp(other->key, key)) {
+			g_free(key);
+			return;
+		}
+	}
+	g_free(key);
+	item = xcalloc(1, sizeof(*item));
+	item->service = g_strdup(service);
+	item->path = g_strdup(path);
+	item->key = g_strconcat(service, path, NULL);
+	item->owner = name_owner(service);
+	wl_list_insert(items.prev, &item->link);
+	update_item(item);
+	if (!item->id && !item->title && !item->icon && !item->iconname) {
+		wl_list_remove(&item->link);
+		free_item(item);
+		return;
+	}
+	emit_signal("StatusNotifierItemRegistered", item->key);
+	if (redraw)
+		redraw();
+}
+
+static void
+remove_item(TrayItem *item)
+{
+	char *key = item->key ? g_strdup(item->key) : NULL;
+
+	if (menu.open && menu.key && item->key
+			&& !strcmp(menu.key, item->key))
+		close_menu(1);
+	wl_list_remove(&item->link);
+	if (key)
+		emit_signal("StatusNotifierItemUnregistered", key);
+	g_free(key);
+	free_item(item);
+}
+
+static void
+remove_service(const char *name)
+{
+	TrayItem *item, *tmp;
+	int changed = 0;
+
+	wl_list_for_each_safe(item, tmp, &items, link) {
+		if (!strcmp(item->service, name)
+				|| (item->owner && !strcmp(item->owner, name))) {
+			remove_item(item);
+			changed = 1;
+		}
+	}
+	if (changed && redraw)
+		redraw();
+}
+
+static TrayItem *
+find_item(const char *service, const char *path)
+{
+	TrayItem *item;
+
+	if (!path)
+		return NULL;
+	wl_list_for_each(item, &items, link)
+		if (!strcmp(item->service, service)
+				&& !strcmp(item->path, path))
+			return item;
+	return NULL;
+}
+
+/* D-Bus callbacks run inside dbus_connection_dispatch().  A blocking GetAll
+ * there would deadlock a client that is still waiting for our reply, so the
+ * actual work is queued and run from an idle callback instead. */
+static void
+queue_work(int type, const char *service, const char *path)
+{
+	Work *w = xcalloc(1, sizeof(*w));
+
+	w->type = type;
+	w->service = g_strdup(service);
+	w->path = path ? g_strdup(path) : NULL;
+	wl_list_insert(work.prev, &w->link);
+	if (!work_source && event_loop)
+		work_source = wl_event_loop_add_idle(event_loop, process_work, NULL);
+}
+
+static void
+process_work(void *data)
+{
+	Work *w, *tmp;
+	TrayItem *item;
+
+	work_source = NULL;
+	wl_list_for_each_safe(w, tmp, &work, link) {
+		wl_list_remove(&w->link);
+		if (w->type == WorkAdd) {
+			add_item(w->service, w->path);
+		} else if (w->type == WorkUpdate) {
+			item = find_item(w->service, w->path);
+			if (item)
+				update_item(item);
+		} else if (w->type == WorkRemove) {
+			remove_service(w->service);
+		} else if (w->type == WorkMenu) {
+			open_menu(w->service, w->path, w->menupath, &w->mon,
+					w->barheight, w->anchor, w->scale,
+					w->font, w->sx, w->sy);
+		} else if (w->type == WorkMenuRefresh) {
+			reload_menu();
+		}
+		g_free(w->service);
+		g_free(w->path);
+		g_free(w->menupath);
+		free(w);
+	}
+}
+
+static TrayItem *
+item_for_signal(DBusMessage *message)
+{
+	const char *path = dbus_message_get_path(message);
+	const char *sender = dbus_message_get_sender(message);
+	TrayItem *item;
+
+	if (!path || !sender)
+		return NULL;
+	wl_list_for_each(item, &items, link) {
+		if (!strcmp(item->path, path)
+				&& (!strcmp(item->service, sender)
+				|| (item->owner && !strcmp(item->owner, sender))))
+			return item;
+	}
+	return NULL;
+}
+
+static int
+sender_matches(const char *service, const char *owner, const char *sender)
+{
+	return sender && ((service && !strcmp(service, sender))
+			|| (owner && !strcmp(owner, sender)));
+}
+
+static DBusHandlerResult
+filter(DBusConnection *conn, DBusMessage *message, void *data)
+{
+	const char *interface, *member, *name, *old, *new;
+	TrayItem *item;
+
+	if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL)
+		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+	interface = dbus_message_get_interface(message);
+	member = dbus_message_get_member(message);
+	if (interface && !strcmp(interface, ITEM_IFACE)) {
+		if (!strcmp(member, "NewIcon") || !strcmp(member, "NewTitle")
+				|| !strcmp(member, "NewStatus")
+				|| !strcmp(member, "NewMenu")) {
+			item = item_for_signal(message);
+			if (item)
+				queue_work(WorkUpdate, item->service, item->path);
+		}
+	} else if (interface && !strcmp(interface, MENU_IFACE)
+			&& !strcmp(member, "LayoutUpdated")) {
+		if (menu.open && !menu.loading && menu.path
+				&& dbus_message_get_path(message)
+				&& !strcmp(menu.path, dbus_message_get_path(message))
+				&& sender_matches(menu.service, menu.owner,
+					dbus_message_get_sender(message)))
+			queue_refresh();
+	} else if (interface && !strcmp(interface, "org.freedesktop.DBus")
+			&& !strcmp(member, "NameOwnerChanged")) {
+		if (dbus_message_get_args(message, NULL,
+				DBUS_TYPE_STRING, &name,
+				DBUS_TYPE_STRING, &old,
+				DBUS_TYPE_STRING, &new,
+				DBUS_TYPE_INVALID))
+			if (old[0] && strcmp(old, new))
+				queue_work(WorkRemove, name, NULL);
+	}
+	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+/* ---- com.canonical.dbusmenu ------------------------------------------ */
+
+static void
+hide_node(struct wlr_scene_buffer *node)
+{
+	if (!node)
+		return;
+	wlr_scene_buffer_set_buffer(node, NULL);
+	wlr_scene_node_set_enabled(&node->node, 0);
+}
+
+static void
+send_event(const char *service, const char *path, int id, const char *name)
+{
+	DBusMessage *message;
+	DBusMessageIter iter, variant;
+	const char *event = name;
+	dbus_int32_t value = 0;
+	dbus_uint32_t stamp;
+
+	if (!bus || !service || !path)
+		return;
+	message = dbus_message_new_method_call(service, path, MENU_IFACE,
+			"Event");
+	if (!message)
+		return;
+	stamp = (dbus_uint32_t)time(NULL);
+	dbus_message_iter_init_append(message, &iter);
+	dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &id);
+	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &event);
+	dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, "i",
+			&variant);
+	dbus_message_iter_append_basic(&variant, DBUS_TYPE_INT32, &value);
+	dbus_message_iter_close_container(&iter, &variant);
+	dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &stamp);
+	dbus_connection_send(bus, message, NULL);
+	dbus_message_unref(message);
+	dbus_connection_flush(bus);
+}
+
+static void
+send_item(const char *service, const char *path, const char *method,
+		dbus_int32_t sx, dbus_int32_t sy)
+{
+	DBusMessage *message;
+
+	if (!bus || !service || !path)
+		return;
+	message = dbus_message_new_method_call(service, path, ITEM_IFACE,
+			method);
+	if (!message)
+		return;
+	dbus_message_append_args(message, DBUS_TYPE_INT32, &sx,
+			DBUS_TYPE_INT32, &sy, DBUS_TYPE_INVALID);
+	dbus_connection_send(bus, message, NULL);
+	dbus_message_unref(message);
+	dbus_connection_flush(bus);
+}
+
+static void
+free_menu_item(MenuItem *item)
+{
+	MenuItem *child, *tmp;
+
+	wl_list_for_each_safe(child, tmp, &item->children, link) {
+		wl_list_remove(&child->link);
+		free_menu_item(child);
+	}
+	g_free(item->label);
+	g_free(item->iconname);
+	free(item);
+}
+
+static void
+free_menu_items(struct wl_list *list)
+{
+	MenuItem *item, *tmp;
+
+	wl_list_for_each_safe(item, tmp, list, link) {
+		wl_list_remove(&item->link);
+		free_menu_item(item);
+	}
+}
+
+static void
+clear_menu(void)
+{
+	free_menu_items(&menu.items);
+	g_free(menu.service);
+	g_free(menu.owner);
+	g_free(menu.path);
+	g_free(menu.key);
+	menu.service = menu.owner = menu.path = menu.key = NULL;
+	menu.font = NULL;
+	menu.open = 0;
+	menu.loading = 0;
+	menu.sub = NULL;
+	menu.hover = NULL;
+	menu.subopen = 0;
+	hide_node(menu.node);
+	hide_node(menu.subnode);
+}
+
+static void
+close_menu(int notify)
+{
+	if (!menu.open)
+		return;
+	if (notify && menu.sub)
+		send_event(menu.service, menu.path, menu.sub->id, "closed");
+	clear_menu();
+}
+
+static void
+queue_refresh(void)
+{
+	Work *w = xcalloc(1, sizeof(*w));
+
+	w->type = WorkMenuRefresh;
+	wl_list_insert(work.prev, &w->link);
+	if (!work_source && event_loop)
+		work_source = wl_event_loop_add_idle(event_loop, process_work, NULL);
+}
+
+static void
+drop_work(Work *w)
+{
+	wl_list_remove(&w->link);
+	g_free(w->service);
+	g_free(w->path);
+	g_free(w->menupath);
+	free(w);
+}
+
+static void
+queue_menu(const char *service, const char *path, const char *menupath,
+		const struct wlr_box *mon, int barheight, int anchor, double scale,
+		struct fcft_font *font, dbus_int32_t sx, dbus_int32_t sy)
+{
+	Work *w = xcalloc(1, sizeof(*w));
+
+	w->type = WorkMenu;
+	w->service = g_strdup(service);
+	w->path = g_strdup(path);
+	w->menupath = menupath ? g_strdup(menupath) : NULL;
+	w->mon = *mon;
+	w->barheight = barheight;
+	w->anchor = anchor;
+	w->scale = scale;
+	w->font = font;
+	w->sx = sx;
+	w->sy = sy;
+	wl_list_insert(work.prev, &w->link);
+	if (!work_source && event_loop)
+		work_source = wl_event_loop_add_idle(event_loop, process_work, NULL);
+}
+
+static DBusMessage *
+menu_call(DBusMessage *message)
+{
+	DBusError error;
+	DBusMessage *reply;
+
+	if (!bus) {
+		dbus_message_unref(message);
+		return NULL;
+	}
+	dbus_error_init(&error);
+	reply = dbus_connection_send_with_reply_and_block(bus, message,
+			MENU_TIMEOUT, &error);
+	dbus_message_unref(message);
+	if (!reply)
+		dbus_error_free(&error);
+	return reply;
+}
+
+static void
+parse_props(DBusMessageIter *dict, MenuItem *item)
+{
+	DBusMessageIter entry, variant;
+	const char *key, *value;
+	dbus_bool_t boolean;
+	dbus_int32_t integer;
+
+	while (dbus_message_iter_get_arg_type(dict) == DBUS_TYPE_DICT_ENTRY) {
+		dbus_message_iter_recurse(dict, &entry);
+		if (dbus_message_iter_get_arg_type(&entry)
+				!= DBUS_TYPE_STRING)
+			break;
+		dbus_message_iter_get_basic(&entry, &key);
+		dbus_message_iter_next(&entry);
+		dbus_message_iter_recurse(&entry, &variant);
+		if (!strcmp(key, "label")) {
+			if ((value = get_string(&variant))) {
+				g_free(item->label);
+				item->label = g_strdup(value);
+			}
+		} else if (!strcmp(key, "enabled")) {
+			if (get_bool(&variant, &boolean))
+				item->enabled = boolean;
+		} else if (!strcmp(key, "visible")) {
+			if (get_bool(&variant, &boolean))
+				item->visible = boolean;
+		} else if (!strcmp(key, "type")) {
+			if ((value = get_string(&variant)))
+				item->separator = !strcmp(value, "separator");
+		} else if (!strcmp(key, "children-display")) {
+			if ((value = get_string(&variant)))
+				item->submenu = !strcmp(value, "submenu");
+		} else if (!strcmp(key, "toggle-type")) {
+			if ((value = get_string(&variant))) {
+				if (!strcmp(value, "check"))
+					item->toggle = ToggleCheck;
+				else if (!strcmp(value, "radio"))
+					item->toggle = ToggleRadio;
+			}
+		} else if (!strcmp(key, "toggle-state")) {
+			if (dbus_message_iter_get_arg_type(&variant)
+					== DBUS_TYPE_INT32) {
+				dbus_message_iter_get_basic(&variant, &integer);
+				item->toggled = integer > 0;
+			}
+		} else if (!strcmp(key, "icon-name")) {
+			if ((value = get_string(&variant))) {
+				g_free(item->iconname);
+				item->iconname = g_strdup(value);
+			}
+		}
+		dbus_message_iter_next(dict);
+	}
+}
+
+static int parse_layout_children(DBusMessageIter *iter,
+		struct wl_list *list, int depth, int *count);
+
+static int
+parse_layout_node(DBusMessageIter *iter, struct wl_list *list, int depth,
+		int *count)
+{
+	DBusMessageIter entry, props;
+	MenuItem *item;
+	dbus_int32_t id;
+
+	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRUCT)
+		return 0;
+	dbus_message_iter_recurse(iter, &entry);
+	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_INT32)
+		return 0;
+	dbus_message_iter_get_basic(&entry, &id);
+	dbus_message_iter_next(&entry);
+	if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_ARRAY)
+		return 0;
+
+	item = xcalloc(1, sizeof(*item));
+	item->id = id;
+	item->enabled = 1;
+	item->visible = 1;
+	wl_list_init(&item->children);
+	dbus_message_iter_recurse(&entry, &props);
+	parse_props(&props, item);
+	dbus_message_iter_next(&entry);
+	if (depth > 0 && dbus_message_iter_get_arg_type(&entry)
+			== DBUS_TYPE_ARRAY)
+		parse_layout_children(&entry, &item->children, depth - 1,
+				count);
+	(*count)++;
+	wl_list_insert(list->prev, &item->link);
+	return 1;
+}
+
+static int
+parse_layout_children(DBusMessageIter *iter, struct wl_list *list, int depth,
+		int *count)
+{
+	DBusMessageIter children, variant;
+
+	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
+		return 0;
+	dbus_message_iter_recurse(iter, &children);
+	while (dbus_message_iter_get_arg_type(&children)
+			== DBUS_TYPE_VARIANT) {
+		dbus_message_iter_recurse(&children, &variant);
+		if (dbus_message_iter_get_arg_type(&variant) == DBUS_TYPE_STRUCT
+				&& *count < MENU_MAXITEMS)
+			parse_layout_node(&variant, list, depth, count);
+		dbus_message_iter_next(&children);
+	}
+	return 1;
+}
+
+static int
+fetch_layout(struct wl_list *list)
+{
+	DBusMessage *message, *reply;
+	DBusMessageIter iter, args, array, root;
+	dbus_int32_t id = 0, depth = MENU_DEPTH;
+	int count = 0;
+
+	if (!bus || !menu.service || !menu.path)
+		return 0;
+
+	message = dbus_message_new_method_call(menu.service, menu.path,
+			MENU_IFACE, "AboutToShow");
+	if (message) {
+		dbus_message_append_args(message, DBUS_TYPE_INT32, &id,
+				DBUS_TYPE_INVALID);
+		reply = menu_call(message);
+		if (reply)
+			dbus_message_unref(reply);
+	}
+
+	message = dbus_message_new_method_call(menu.service, menu.path,
+			MENU_IFACE, "GetLayout");
+	if (!message)
+		return 0;
+	dbus_message_iter_init_append(message, &args);
+	dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &id);
+	dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &depth);
+	dbus_message_iter_open_container(&args, DBUS_TYPE_ARRAY, "s", &array);
+	dbus_message_iter_close_container(&args, &array);
+	reply = menu_call(message);
+	if (!reply)
+		return 0;
+	if (!dbus_message_iter_init(reply, &iter)
+			|| dbus_message_iter_get_arg_type(&iter)
+			!= DBUS_TYPE_UINT32
+			|| !dbus_message_iter_next(&iter)
+			|| dbus_message_iter_get_arg_type(&iter)
+			!= DBUS_TYPE_STRUCT) {
+		dbus_message_unref(reply);
+		return 0;
+	}
+	dbus_message_iter_recurse(&iter, &root);
+	if (dbus_message_iter_get_arg_type(&root) != DBUS_TYPE_INT32) {
+		dbus_message_unref(reply);
+		return 0;
+	}
+	dbus_message_iter_next(&root);
+	dbus_message_iter_next(&root);
+	if (dbus_message_iter_get_arg_type(&root) != DBUS_TYPE_ARRAY
+			|| !parse_layout_children(&root, list, 1, &count)
+			|| count == 0) {
+		dbus_message_unref(reply);
+		return 0;
+	}
+	dbus_message_unref(reply);
+	return 1;
+}
+
+static int
+menu_usable(struct wl_list *list)
+{
+	MenuItem *item;
+
+	wl_list_for_each(item, list, link)
+		if (item->visible && !item->separator)
+			return 1;
+	return 0;
+}
+
+static MenuItem *
+find_menu_item(struct wl_list *list, int id)
+{
+	MenuItem *item, *found;
+
+	wl_list_for_each(item, list, link) {
+		if (item->id == id)
+			return item;
+		if ((found = find_menu_item(&item->children, id)))
+			return found;
+	}
+	return NULL;
+}
+
+static int
+usable_menu_path(const char *path)
+{
+	return path && *path && strcmp(path, "/")
+			&& strcmp(path, "/NO_DBUSMENU");
+}
+
+static int
+tolayout(int px, double scale)
+{
+	if (scale <= 0)
+		return px;
+	return (int)(px / scale + 0.5);
+}
+
+static int
+menu_inside(double x, double y, int bx, int by, int wpx, int hpx)
+{
+	double px, py;
+
+	if (menu.scale <= 0)
+		return 0;
+	px = (x - bx) * menu.scale;
+	py = (y - by) * menu.scale;
+	return px >= 0 && py >= 0 && px < wpx && py < hpx;
+}
+
+static MenuItem *
+panel_item_at(struct wl_list *list, double x, double y, int bx, int by)
+{
+	MenuItem *item;
+	int py = (int)((y - by) * menu.scale);
+
+	wl_list_for_each(item, list, link)
+		if (item->visible && item->h > 0 && py >= item->y
+				&& py < item->y + item->h)
+			return item;
+	return NULL;
+}
+
+typedef struct {
+	int pad, rowh, left, arroww;
+	int hastoggle, hassub;
+} MenuMetrics;
+
+static MenuMetrics
+panel_metrics(struct wl_list *list, int arrow)
+{
+	MenuMetrics metrics;
+	MenuItem *item;
+
+	metrics.pad = (int)(cfg.menupad * menu.scale + 0.5);
+	metrics.rowh = menu.font->height + 2 * metrics.pad;
+	metrics.hastoggle = 0;
+	metrics.hassub = 0;
+	wl_list_for_each(item, list, link) {
+		if (!item->visible)
+			continue;
+	
…… diff 过长已截断 ……
awesome bar addednageyqma · 2026-10-25 · bcdc517
查看变更
Makefile     |   4 +-
 config.def.h |  18 +++++
 config.mk    |   6 ++
 dwl.c        | 549 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 4 files changed, 560 insertions(+), 17 deletions(-)
diff --git a/Makefile b/Makefile
index 8f0f913..620fe3d 100644
--- a/Makefile
+++ b/Makefile
@@ -13,8 +13,8 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
 
 # CFLAGS / LDFLAGS
 PKGS      = wayland-server xkbcommon libinput $(XLIBS)
-DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(SCENEFX_INCS) $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
-LDLIBS    = $(SCENEFX_LIBS) `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
+DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(SCENEFX_INCS) $(WLR_INCS) $(FCFT_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
+LDLIBS    = $(SCENEFX_LIBS) `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) $(FCFT_LIBS) -lm $(LIBS)
 
 all: dwl
 dwl: dwl.c client.h config.h ime.h util.h config.mk cursor-shape-v1-protocol.h \
diff --git a/config.def.h b/config.def.h
index 90dfd63..06d96ef 100644
--- a/config.def.h
+++ b/config.def.h
@@ -18,6 +18,15 @@ 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 */
 
+/* bar; the font is scaled with the output */
+static const char *barfont                 = "monospace:size=11";
+static const unsigned int barpad           = 6; /* padding, in layout pixels */
+static const float barbg[]                 = COLOR(0x222222ff);
+static const float barfg[]                 = COLOR(0xbbbbbbff);
+static const float barselbg[]              = COLOR(0x005577ff);
+static const float barselfg[]              = COLOR(0xffffffff);
+static const float barhidfg[]              = COLOR(0x555555ff);
+
 static const int blur = 1; /* background blur */
 static const struct blur_data blur_data = {
 	.radius = 5,
@@ -50,6 +59,10 @@ static const Layout layouts[] = {
 };
 
 /* monitors */
+/* Prefer the fastest mode of the monitor's preferred resolution: panels often
+ * advertise 60Hz as their preferred mode while supporting much more. */
+static const int high_refresh              = 1;
+
 /* (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 */
@@ -151,6 +164,11 @@ static const Key keys[] = {
 	{ MODKEY,                    XKB_KEY_w,           focusstack,       {.i = +1} },
 	{ MODKEY,                    XKB_KEY_Up,          focusstack,       {.i = -1} },
 	{ MODKEY,                    XKB_KEY_Down,        focusstack,       {.i = +1} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_j,           focusstackhid,    {.i = +1} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_k,           focusstackhid,    {.i = -1} },
+	{ MODKEY,                    XKB_KEY_h,           hide,             {0} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_h,           show,             {0} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_s,           showall,          {0} },
 	{ MODKEY,                    XKB_KEY_a,           setmfact,         {.f = -0.05f} },
 	{ MODKEY,                    XKB_KEY_s,           setmfact,         {.f = +0.05f} },
 	{ MODKEY,                    XKB_KEY_comma,       incnmaster,       {.i = +1} },
diff --git a/config.mk b/config.mk
index 4f7ad89..72ac9db 100644
--- a/config.mk
+++ b/config.mk
@@ -15,6 +15,12 @@ SCENEFX_LIBS = `$(PKG_CONFIG) --libs scenefx-0.5`
 WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.20`
 WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.20`
 
+# fcft.pc puts the header-only tllist in Requires.private, so pkg-config
+# refuses to report fcft's flags when tllist.pc is absent. fcft's own header
+# only needs pixman, and the shared library records the rest.
+FCFT_INCS = `$(PKG_CONFIG) --cflags fcft 2>/dev/null || $(PKG_CONFIG) --cflags pixman-1`
+FCFT_LIBS = `$(PKG_CONFIG) --libs fcft 2>/dev/null || echo -lfcft` `$(PKG_CONFIG) --libs pixman-1`
+
 # Allow using an alternative wlroots installation
 # This has to have all the includes required by wlroots, e.g:
 # Assuming wlroots git repo is "${PWD}/wlroots" and you only ran "meson setup build && ninja -C build"
diff --git a/dwl.c b/dwl.c
index 6393468..135e147 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1,11 +1,14 @@
 /*
  * See LICENSE file for copyright and license details.
  */
+#include <drm_fourcc.h>
+#include <fcft/fcft.h>
 #include <getopt.h>
 #include <libinput.h>
 #include <limits.h>
 #include <linux/input-event-codes.h>
 #include <math.h>
+#include <pixman.h>
 #include <scenefx/render/fx_renderer/fx_renderer.h>
 #include <scenefx/types/fx/blur_data.h>
 #include <scenefx/types/wlr_scene.h>
@@ -18,6 +21,7 @@
 #include <wayland-server-core.h>
 #include <wlr/backend.h>
 #include <wlr/backend/libinput.h>
+#include <wlr/interfaces/wlr_buffer.h>
 #include <wlr/render/allocator.h>
 #include <wlr/render/swapchain.h>
 #include <wlr/render/wlr_renderer.h>
@@ -82,7 +86,8 @@
 
 /* macros */
 #define CLEANMASK(mask)         (mask & ~WLR_MODIFIER_CAPS)
-#define VISIBLEON(C, M)         ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
+#define VISIBLE(C, M)           ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
+#define VISIBLEON(C, M)         (VISIBLE(C, M) && !(C)->ishidden)
 #define TAGMASK                 ((1u << TAGCOUNT) - 1)
 #define LISTEN(E, L, H)         wl_signal_add((E), ((L)->notify = (H), (L)))
 #define LISTEN_STATIC(E, H)     do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0)
@@ -162,6 +167,7 @@ typedef struct {
 	unsigned int bw;
 	uint32_t tags;
 	int isfloating, isurgent, isfullscreen;
+	int ishidden, tempshow; /* hidden from its tags, or only while focused */
 	/* Position-only slide; c->geom stays the authoritative layout box. */
 	struct timespec animstart; /* CLOCK_MONOTONIC start of the slide */
 	int animx, animy;          /* displayed position when the slide started */
@@ -218,6 +224,10 @@ struct Monitor {
 	struct wlr_output *wlr_output;
 	struct wlr_scene_output *scene_output;
 	struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
+	struct wlr_scene_buffer *bar;
+	struct fcft_font *barfont;
+	double barscale;
+	int barheight; /* bar is this many layout pixels tall */
 	struct wl_listener frame;
 	struct wl_listener destroy;
 	struct wl_listener request_state;
@@ -248,6 +258,11 @@ typedef struct {
 	int x, y;
 } MonitorRule;
 
+typedef struct {
+	struct wlr_buffer base;
+	pixman_image_t *image;
+} BarBuffer;
+
 typedef struct {
 	struct wlr_pointer_constraint_v1 *constraint;
 	struct wl_listener destroy;
@@ -278,6 +293,20 @@ 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);
+static int barclick(Monitor *m, double x, double y, uint32_t button);
+static bool barbuffer_begin(struct wlr_buffer *buffer, uint32_t flags,
+		void **data, uint32_t *format, size_t *stride);
+static BarBuffer *barbuffer_create(int width, int height);
+static void barbuffer_destroy(struct wlr_buffer *buffer);
+static void barbuffer_end(struct wlr_buffer *buffer);
+static pixman_color_t barcolor(const float color[4]);
+static void barfill(pixman_image_t *image, const float color[4], int x,
+		int y, int width, int height);
+static const char *barlabel(unsigned int tag);
+static void bartext(pixman_image_t *image, struct fcft_font *font,
+		const char *text, int x, int baseline, int maxx, const float color[4]);
+static int bartextwidth(struct fcft_font *font, const char *text);
+static uint32_t barutf8(const char **s);
 static void buttonpress(struct wl_listener *listener, void *data);
 static void capturerequest(struct wl_listener *listener, void *data);
 static void chvt(const Arg *arg);
@@ -315,13 +344,19 @@ 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 drawbar(Monitor *m);
+static void drawbars(void);
 static void focusclient(Client *c, LayerSurface *l, int lift);
 static void focusmon(const Arg *arg);
 static void focusstack(const Arg *arg);
+static void focusstackdir(int inc, int hid);
+static void focusstackhid(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 hideclient(Client *c);
 static void incnmaster(const Arg *arg);
 static void inputdevice(struct wl_listener *listener, void *data);
 static const Key *keybinding(uint32_t mods, xkb_keysym_t sym);
@@ -363,6 +398,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 void tag(const Arg *arg);
@@ -372,9 +409,11 @@ 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);
+static void updatebar(Monitor *m);
 static void updatemons(struct wl_listener *listener, void *data);
 static void updatetitle(struct wl_listener *listener, void *data);
 static void urgent(struct wl_listener *listener, void *data);
@@ -652,6 +691,10 @@ arrangelayers(Monitor *m)
 	if (!m->wlr_output->enabled)
 		return;
 
+	/* The bar is not a layer surface, so keep layer surfaces below it. */
+	usable_area.y += m->barheight;
+	usable_area.height = MAX(0, usable_area.height - m->barheight);
+
 	/* Arrange exclusive surfaces from top->bottom */
 	for (i = 3; i >= 0; i--)
 		arrangelayer(m, &m->layers[i], &usable_area, 1);
@@ -679,6 +722,233 @@ arrangelayers(Monitor *m)
 	}
 }
 
+int
+barclick(Monitor *m, double x, double y, uint32_t button)
+{
+	Client *c;
+	Arg arg;
+	double scale;
+	int bx, pad, width, cx, i, n, tabw, tw;
+
+	if (!m || !m->bar || !m->barfont || !m->wlr_output->enabled)
+		return 0;
+	if (x < m->m.x || x >= m->m.x + m->m.width
+			|| y < m->m.y || y >= m->m.y + m->barheight)
+		return 0;
+	/* A fullscreen client or overlay above the bar owns the click. */
+	if (wlr_scene_node_at(&scene->tree.node, x, y, NULL, NULL)
+			!= &m->bar->node)
+		return 0;
+	if (button != BTN_LEFT)
+		return 1;
+
+	scale = m->wlr_output->scale;
+	bx = (int)((x - m->m.x) * scale + 0.5);
+	width = (int)(m->m.width * scale + 0.5);
+	pad = (int)(barpad * scale + 0.5);
+	selmon = m;
+
+	cx = 0;
+	for (i = 0; i < TAGCOUNT; i++) {
+		tw = bartextwidth(m->barfont, barlabel(i)) + 2 * pad;
+		if (bx < cx + tw) {
+			arg.ui = 1u << i;
+			view(&arg);
+			return 1;
+		}
+		cx += tw;
+	}
+
+	tw = bartextwidth(m->barfont, m->ltsymbol) + 2 * pad;
+	if (bx < cx + tw) {
+		setlayout(NULL);
+		return 1;
+	}
+	cx += tw;
+
+	n = 0;
+	wl_list_for_each(c, &clients, link)
+		if (VISIBLE(c, m))
+			n++;
+	if (n == 0)
+		return 1;
+	tabw = (width - cx) / n;
+	if (tabw <= 0 || bx < cx)
+		return 1;
+	i = (bx - cx) / tabw;
+	wl_list_for_each(c, &clients, link) {
+		if (!VISIBLE(c, m) || i-- > 0)
+			continue;
+		arg.v = c;
+		togglewin(&arg);
+		break;
+	}
+	return 1;
+}
+
+bool
+barbuffer_begin(struct wlr_buffer *buffer, uint32_t flags, void **data,
+		uint32_t *format, size_t *stride)
+{
+	BarBuffer *bar = wl_container_of(buffer, bar, base);
+
+	*data = pixman_image_get_data(bar->image);
+	*format = DRM_FORMAT_ARGB8888;
+	*stride = pixman_image_get_stride(bar->image);
+	return true;
+}
+
+void
+barbuffer_destroy(struct wlr_buffer *buffer)
+{
+	BarBuffer *bar = wl_container_of(buffer, bar, base);
+
+	pixman_image_unref(bar->image);
+	free(bar);
+}
+
+void
+barbuffer_end(struct wlr_buffer *buffer)
+{
+}
+
+static const struct wlr_buffer_impl barbuffer_impl = {
+	.destroy = barbuffer_destroy,
+	.begin_data_ptr_access = barbuffer_begin,
+	.end_data_ptr_access = barbuffer_end,
+};
+
+BarBuffer *
+barbuffer_create(int width, int height)
+{
+	BarBuffer *bar = ecalloc(1, sizeof(*bar));
+
+	bar->image = pixman_image_create_bits(PIXMAN_a8r8g8b8, width, height,
+			NULL, width * 4);
+	if (!bar->image)
+		die("couldn't create bar image");
+	wlr_buffer_init(&bar->base, &barbuffer_impl, width, height);
+	return bar;
+}
+
+pixman_color_t
+barcolor(const float color[4])
+{
+	return (pixman_color_t){
+		.red = (uint16_t)(color[0] * color[3] * 0xffff),
+		.green = (uint16_t)(color[1] * color[3] * 0xffff),
+		.blue = (uint16_t)(color[2] * color[3] * 0xffff),
+		.alpha = (uint16_t)(color[3] * 0xffff),
+	};
+}
+
+void
+barfill(pixman_image_t *image, const float color[4], int x, int y,
+		int width, int height)
+{
+	pixman_color_t c = barcolor(color);
+	pixman_box32_t box = {.x1 = x, .y1 = y, .x2 = x + width, .y2 = y + height};
+
+	pixman_image_fill_boxes(PIXMAN_OP_SRC, image, &c, 1, &box);
+}
+
+const char *
+barlabel(unsigned int tag)
+{
+	static char label[8];
+	const Key *k;
+
+	/* Label a tag with the key that views it, as the config does. */
+	for (k = keys; k < END(keys); k++) {
+		if (k->func == view && k->arg.ui == 1u << tag
+				&& xkb_keysym_to_utf8(k->keysym, label, sizeof(label)) > 0)
+			return label;
+	}
+	snprintf(label, sizeof(label), "%u", tag + 1);
+	return label;
+}
+
+void
+bartext(pixman_image_t *image, struct fcft_font *font, const char *text,
+		int x, int baseline, int maxx, const float color[4])
+{
+	const struct fcft_glyph *glyph;
+	pixman_image_t *src;
+	pixman_color_t c = barcolor(color);
+	uint32_t cp;
+
+	if (!(src = pixman_image_create_solid_fill(&c)))
+		return;
+	while (*text) {
+		cp = barutf8(&text);
+		if (!(glyph = fcft_rasterize_char_utf32(font, cp,
+				FCFT_SUBPIXEL_NONE)))
+			continue;
+		if (x + glyph->advance.x > maxx)
+			break;
+		if (glyph->is_color_glyph)
+			pixman_image_composite32(PIXMAN_OP_OVER, glyph->pix, NULL,
+					image, 0, 0, 0, 0, x + glyph->x,
+					baseline - glyph->y, glyph->width, glyph->height);
+		else
+			pixman_image_composite32(PIXMAN_OP_OVER, src, glyph->pix,
+					image, 0, 0, 0, 0, x + glyph->x,
+					baseline - glyph->y, glyph->width, glyph->height);
+		x += glyph->advance.x;
+	}
+	pixman_image_unref(src);
+}
+
+int
+bartextwidth(struct fcft_font *font, const char *text)
+{
+	const struct fcft_glyph *glyph;
+	int width = 0;
+
+	while (*text) {
+		glyph = fcft_rasterize_char_utf32(font, barutf8(&text),
+				FCFT_SUBPIXEL_NONE);
+		if (glyph)
+			width += glyph->advance.x;
+	}
+	return width;
+}
+
+uint32_t
+barutf8(const char **s)
+{
+	const unsigned char *p = (const unsigned char *)*s;
+	uint32_t cp;
+	int i, len;
+
+	if (p[0] < 0x80) {
+		*s += 1;
+		return p[0];
+	}
+	if ((p[0] & 0xe0) == 0xc0) {
+		cp = p[0] & 0x1f;
+		len = 2;
+	} else if ((p[0] & 0xf0) == 0xe0) {
+		cp = p[0] & 0x0f;
+		len = 3;
+	} else if ((p[0] & 0xf8) == 0xf0) {
+		cp = p[0] & 0x07;
+		len = 4;
+	} else {
+		*s += 1;
+		return 0xfffd;
+	}
+	for (i = 1; i < len; i++) {
+		if ((p[i] & 0xc0) != 0x80) {
+			*s += i;
+			return 0xfffd;
+		}
+		cp = (cp << 6) | (p[i] & 0x3f);
+	}
+	*s += len;
+	return cp;
+}
+
 void
 axisnotify(struct wl_listener *listener, void *data)
 {
@@ -731,6 +1001,8 @@ buttonpress(struct wl_listener *listener, void *data)
 		selmon = xytomon(cursor->x, cursor->y);
 		if (locked)
 			break;
+		if (barclick(selmon, cursor->x, cursor->y, event->button))
+			return;
 
 		/* Change focus if the button was _pressed_ over a client
 		   or a layer surface with on-demand keyboard interactivity */
@@ -844,6 +1116,7 @@ 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);
+	fcft_fini();
 }
 
 void
@@ -865,6 +1138,10 @@ cleanupmon(struct wl_listener *listener, void *data)
 	wl_list_remove(&m->request_state.link);
 	if (m->lock_surface)
 		destroylocksurface(&m->destroy_lock_surface, NULL);
+	if (m->bar)
+		wlr_scene_node_destroy(&m->bar->node);
+	if (m->barfont)
+		fcft_destroy(m->barfont);
 	m->wlr_output->data = NULL;
 	wlr_output_layout_remove(output_layout, m->wlr_output);
 	wlr_scene_output_destroy(m->scene_output);
@@ -1185,6 +1462,7 @@ createmon(struct wl_listener *listener, void *data)
 	struct wlr_output *wlr_output = data;
 	const MonitorRule *r;
 	size_t i;
+	struct wlr_output_mode *best, *mode;
 	struct wlr_output_state state;
 	Monitor *m;
 
@@ -1216,10 +1494,18 @@ createmon(struct wl_listener *listener, void *data)
 	}
 
 	/* The mode is a tuple of (width, height, refresh rate), and each
-	 * monitor supports only a specific set of modes. We just pick the
-	 * monitor's preferred mode; a more sophisticated compositor would let
-	 * the user configure it. */
-	wlr_output_state_set_mode(&state, wlr_output_preferred_mode(wlr_output));
+	 * monitor supports only a specific set of modes. Panels often advertise
+	 * a 60Hz mode as preferred even when they support more, so take the
+	 * fastest mode of the preferred resolution. */
+	mode = wlr_output_preferred_mode(wlr_output);
+	if (high_refresh && mode) {
+		wl_list_for_each(best, &wlr_output->modes, link) {
+			if (best->width == mode->width && best->height == mode->height
+					&& best->refresh > mode->refresh)
+				mode = best;
+		}
+	}
+	wlr_output_state_set_mode(&state, mode);
 
 	/* Set up event listeners */
 	LISTEN(&wlr_output->events.frame, &m->frame, rendermon);
@@ -1230,6 +1516,9 @@ createmon(struct wl_listener *listener, void *data)
 	wlr_output_commit_state(wlr_output, &state);
 	wlr_output_state_finish(&state);
 
+	updatebar(m);
+	m->bar = wlr_scene_buffer_create(layers[LyrTop], NULL);
+
 	wl_list_insert(&mons, &m->link);
 	printstatus();
 
@@ -1549,6 +1838,109 @@ dirtomon(enum wlr_direction dir)
 	return selmon;
 }
 
+void
+drawbar(Monitor *m)
+{
+	BarBuffer *bar;
+	Client *c, *sel;
+	pixman_image_t *image;
+	struct fcft_font *font;
+	const float *fg;
+	int i, x = 0, width, height, pad, baseline, n = 0, tabw;
+	uint32_t occ = 0, urg = 0, tag;
+	double scale;
+
+	if (!m->bar)
+		return;
+	font = m->barfont;
+	if (!font || !m->wlr_output->enabled || m->m.width <= 0) {
+		wlr_scene_node_set_enabled(&m->bar->node, 0);
+		return;
+	}
+
+	scale = m->wlr_output->scale;
+	width = (int)(m->m.width * scale + 0.5);
+	height = (int)(m->barheight * scale + 0.5);
+	if (width <= 0 || height <= 0) {
+		wlr_scene_node_set_enabled(&m->bar->node, 0);
+		return;
+	}
+	pad = (int)(barpad * scale + 0.5);
+	baseline = (height - font->height) / 2 + font->ascent;
+
+	bar = barbuffer_create(width, height);
+	image = bar->image;
+	barfill(image, barbg, 0, 0, width, height);
+
+	wl_list_for_each(c, &clients, link) {
+		if (c->mon != m)
+			continue;
+		occ |= c->tags;
+		if (c->isurgent)
+			urg |= c->tags;
+		if (VISIBLE(c, m))
+			n++;
+	}
+
+	for (i = 0; i < TAGCOUNT; i++) {
+		tag = 1u << i;
+		tabw = bartextwidth(font, barlabel(i)) + 2 * pad;
+		if (tag & m->tagset[m->seltags]) {
+			barfill(image, barselbg, x, 0, tabw, height);
+			bartext(image, font, barlabel(i), x + pad, baseline,
+					x + tabw - pad, barselfg);
+		} else {
+			fg = barfg;
+			if (tag & urg) {
+				barfill(image, urgentcolor, x, 0, tabw, height);
+				fg = barselfg;
+			} else if (!(tag & occ))
+				fg = barhidfg;
+			bartext(image, font, barlabel(i), x + pad, baseline,
+					x + tabw - pad, fg);
+		}
+		x += tabw;
+	}
+
+	tabw = bartextwidth(font, m->ltsymbol) + 2 * pad;
+	bartext(image, font, m->ltsymbol, x + pad, baseline, x + tabw - pad,
+			barfg);
+	x += tabw;
+
+	sel = focustop(m);
+	if (n > 0 && (tabw = (width - x) / n) > 0) {
+		wl_list_for_each(c, &clients, link) {
+			if (!VISIBLE(c, m))
+				continue;
+			if (c == sel) {
+				barfill(image, barselbg, x, 0, tabw, height);
+				bartext(image, font, client_get_title(c), x + pad,
+						baseline, x + tabw - pad, barselfg);
+			} else {
+				bartext(image, font, client_get_title(c), x + pad,
+						baseline, x + tabw - pad,
+						c->ishidden ? barhidfg : barfg);
+			}
+			x += tabw;
+		}
+	}
+
+	wlr_scene_node_set_position(&m->bar->node, m->m.x, m->m.y);
+	wlr_scene_buffer_set_dest_size(m->bar, m->m.width, m->barheight);
+	wlr_scene_node_set_enabled(&m->bar->node, 1);
+	wlr_scene_buffer_set_buffer(m->bar, &bar->base);
+	wlr_buffer_drop(&bar->base);
+}
+
+void
+drawbars(void)
+{
+	Monitor *m;
+
+	wl_list_for_each(m, &mons, link)
+		drawbar(m);
+}
+
 void
 focusclient(Client *c, LayerSurface *l, int lift)
 {
@@ -1586,6 +1978,13 @@ focusclient(Client *c, LayerSurface *l, int lift)
 				&& !(old_c && client_wants_focus(old_c))
 				&& !seat->drag)
 			client_set_border_color(c, focuscolor);
+
+		/* Focusing a hidden client shows it until focus moves away */
+		if (c->ishidden) {
+			c->ishidden = 0;
+			c->tempshow = 1;
+			arrange(c->mon);
+		}
 	}
 
 	/* If an overlay is focused, don't focus or activate the client,
@@ -1604,6 +2003,8 @@ focusclient(Client *c, LayerSurface *l, int lift)
 			client_set_border_color(focused_client, bordercolor);
 		if (s && s->mapped)
 			client_activate_surface(s, 0);
+		if (focused_client->tempshow)
+			hideclient(focused_client);
 		focused_client = NULL;
 	}
 	printstatus();
@@ -1644,22 +2045,35 @@ focusmon(const Arg *arg)
 void
 focusstack(const Arg *arg)
 {
-	/* Focus the next or previous client (in tiling order) on selmon */
+	focusstackdir(arg->i, 0);
+}
+
+void
+focusstackhid(const Arg *arg)
+{
+	focusstackdir(arg->i, 1);
+}
+
+void
+focusstackdir(int inc, int hid)
+{
+	/* Focus the next or previous client (in tiling order) on selmon. hid
+	 * also visits hidden clients, which focusclient() then shows. */
 	Client *c, *sel = focustop(selmon);
 	if (!sel || (sel->isfullscreen && !client_has_children(sel)))
 		return;
-	if (arg->i > 0) {
+	if (inc > 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 ? VISIBLE(c, selmon) : VISIBLEON(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 ? VISIBLE(c, selmon) : VISIBLEON(c, selmon))
 				break; /* found it */
 		}
 	}
@@ -1722,6 +2136,27 @@ handlesig(int signo)
 		quit(NULL);
 }
 
+void
+hide(const Arg *arg)
+{
+	Client *c = focustop(selmon);
+
+	if (c && !client_is_unmanaged(c) && !c->isfullscreen && !c->ishidden) {
+		hideclient(c);
+		focusclient(focustop(c->mon), NULL, 1);
+	}
+}
+
+void
+hideclient(Client *c)
+{
+	/* The surface stays mapped: arrange() disables the scene node and
+	 * suspends the client until it is shown again. */
+	c->ishidden = 1;
+	c->tempshow = 0;
+	arrange(c->mon);
+}
+
 void
 incnmaster(const Arg *arg)
 {
@@ -2345,6 +2780,7 @@ printstatus(void)
 			m->wlr_output->name, occ, m->tagset[m->seltags], sel, urg);
 		printf("%s layout %s\n", m->wlr_output->name, m->ltsymbol);
 	}
+	drawbars();
 	fflush(stdout);
 }
 
@@ -2755,6 +3191,8 @@ setup(void)
 		sigaction(sig[i], &sa, NULL);
 
 	wlr_log_init(log_level, NULL);
+	if (!fcft_init(FCFT_LOG_COLORIZE_NEVER, false, FCFT_LOG_CLASS_ERROR))
+		die("couldn't initialize fcft");
 
 	/* The Wayland display is managed by libwayland. It handles accepting
 	 * clients from the Unix socket, managing Wayland globals, and so on. */
@@ -2989,6 +3427,34 @@ setup(void)
 #endif
 }
 
+void
+show(const Arg *arg)
+{
+	Client *c = focustop(selmon);
+
+	/* Keep a peeked-at client visible once focus moves away */
+	if (c)
+		c->tempshow = 0;
+}
+
+void
+showall(const Arg *arg)
+{
+	Client *c;
+
+	if (!selmon)
+		return;
+
+	wl_list_for_each(c, &clients, link) {
+		if (VISIBLE(c, selmon)) {
+			c->ishidden = 0;
+			c->tempshow = 0;
+		}
+	}
+	arrange(selmon);
+	focusclient(focustop(selmon), NULL, 1);
+}
+
 void
 spawn(const Arg *arg)
 {
@@ -3121,6 +3587,27 @@ toggleview(const Arg *arg)
 	printstatus();
 }
 
+void
+togglewin(const Arg *arg)
+{
+	Client *c = (Client *)arg->v;
+
+	if (!c || !c->mon || client_is_unmanaged(c))
+		return;
+	selmon = c->mon;
+	if (c == focustop(c->mon) && !c->ishidden) {
+		hideclient(c);
+		focusclient(focustop(c->mon), NULL, 1);
+	} else {
+		if (c->ishidden) {
+			c->ishidden = 0;
+			c->tempshow = 0;
+			arrange(c->mon);
+		}
+		focusclient(c, NULL, 1);
+	}
+}
+
 void
 unlocksession(struct wl_listener *listener, void *data)
 {
@@ -3182,6 +3669,29 @@ unmapnotify(struct wl_listener *listener, void *data)
 	motionnotify(0, NULL, 0, 0, 0, 0);
 }
 
+void
+updatebar(Monitor *m)
+{
+	char attr[32];
+	const char *names[] = {barfont};
+	double scale = m->wlr_output->scale;
+
+	if (scale <= 0)
+		scale = 1;
+	if (m->barfont && m->barscale == scale)
+		return;
+	if (m->barfont)
+		fcft_destroy(m->barfont);
+
+	/* Render at the output's resolution instead of scaling the bar up. */
+	snprintf(attr, sizeof(attr), "dpi=%d", (int)(96 * scale + 0.5));
+	if (!(m->barfont = fcft_from_name(1, names, attr)))
+		die("couldn't load bar font");
+	m->barscale = scale;
+	m->barheight = (int)((m->barfont->height + 2 * barpad * scale) / scale
+			+ 0.5);
+}
+
 void
 updatemons(struct wl_listener *listener, void *data)
 {
@@ -3248,6 +3758,7 @@ updatemons(struct wl_listener *listener, void *data)
 			wlr_session_lock_surface_v1_configure(m->lock_surface, m->m.width, m->m.height);
 		}
 
+		updatebar(m);
 		/* Calculate the effective monitor geometry to use for clients */
 		arrangelayers(m);
 		/* Don't move clients to the left output when plugging monitors */
@@ -3297,6 +3808,8 @@ updatetitle(struct wl_listener *listener, void *data)
 	Client *c = wl_container_of(listener, c, set_title);
 	if (c == focustop(c->mon))
 		printstatus();
+	else if (c->mon)
+		drawbar(c->mon);
 
 	if (c->foreign_toplevel_handle) {
 		struct wlr_ext_foreign_toplevel_handle_v1_state foreign_toplevel_state = {
@@ -3376,18 +3889,24 @@ void
 xytonode(double x, double y, struct wlr_surface **psurface,
 		Client **pc, LayerSurface **pl, double *nx, double *ny)
 {
+	struct wlr_scene_surface *scene_surface;
 	struct wlr_scene_node *node;
 	struct wlr_surface *surface = NULL;
 	int layer;
 
-	for (layer = NUM_LAYERS - 1; !surface && layer >= (locked ? LyrBlock : 0); layer--) {
-		if (layer == LyrIMPopup ||
-				!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny)))
+	for (layer = NUM_LAYERS - 1; layer >= (locked ? LyrBlock : 0); layer--) {
+		if (layer == LyrIMPopup
+				|| !(node = wlr_scene_node_at(&layers[layer]->node,
+					x, y, nx, ny))
+				|| node->type != WLR_SCENE_NODE_BUFFER)
 			continue;
 
-		if (node->type == WLR_SCENE_NODE_BUFFER)
-			surface = wlr_scene_surface_try_from_buffer(
-					wlr_scene_buffer_from_node(node))->surface;
+		/* A plain buffer is the bar: it swallows the pointer, so stop here. */
+		if (!(scene_surface = wlr_scene_surface_try_from_buffer(
+				wlr_scene_buffer_from_node(node))))
+			break;
+		surface = scene_surface->surface;
+		break;
 	}
 
 	if (psurface) *psurface = surface;
corner & gapnageyqma · 2026-10-24 · e730a1d
查看变更
client.h     |  4 +---
 config.def.h |  2 ++
 dwl.c        | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
 3 files changed, 60 insertions(+), 28 deletions(-)
diff --git a/client.h b/client.h
index eb1bb47..df5e7e6 100644
--- a/client.h
+++ b/client.h
@@ -342,9 +342,7 @@ client_send_close(Client *c)
 static inline void
 client_set_border_color(Client *c, const float color[static 4])
 {
-	int i;
-	for (i = 0; i < 4; i++)
-		wlr_scene_rect_set_color(c->border[i], color);
+	wlr_scene_rect_set_color(c->border, color);
 }
 
 static inline void
diff --git a/config.def.h b/config.def.h
index bf5a23e..90dfd63 100644
--- a/config.def.h
+++ b/config.def.h
@@ -8,6 +8,8 @@ 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 unsigned int snap             = 32; /* snap pixel */
+static const int gapp                      = 8;  /* gap around and between tiled windows */
+static const int corner_radius             = 8;  /* window corner radius; 0 disables */
 static const int anim_ms                   = 160; /* slide duration in milliseconds; 0 disables */
 static const float rootcolor[]             = COLOR(0x222222ff);
 static const float bordercolor[]           = COLOR(0x444444ff);
diff --git a/dwl.c b/dwl.c
index b7deeed..6393468 100644
--- a/dwl.c
+++ b/dwl.c
@@ -123,7 +123,7 @@ typedef struct {
 	Monitor *mon;
 	struct wlr_scene_tree *scene;
 	struct wlr_scene_blur *blur;
-	struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
+	struct wlr_scene_rect *border;
 	struct wlr_scene_tree *scene_surface;
 	struct wl_list link;
 	struct wl_list flink;
@@ -351,6 +351,7 @@ 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 roundbuffer(struct wlr_scene_buffer *buffer, int sx, int sy, void *data);
 static void run(char *startup_cmd);
 static void setcursor(struct wl_listener *listener, void *data);
 static void setcursorshape(struct wl_listener *listener, void *data);
@@ -1914,7 +1915,6 @@ mapnotify(struct wl_listener *listener, void *data)
 	Client *p = NULL;
 	Client *w, *c = wl_container_of(listener, c, map);
 	Monitor *m;
-	int i;
 
 	struct wlr_ext_foreign_toplevel_handle_v1_state foreign_toplevel_state = {
 		.app_id = client_get_appid(c),
@@ -1947,11 +1947,9 @@ mapnotify(struct wl_listener *listener, void *data)
 		wlr_scene_node_lower_to_bottom(&c->blur->node);
 	}
 
-	for (i = 0; i < 4; i++) {
-		c->border[i] = wlr_scene_rect_create(c->scene, 0, 0,
-				c->isurgent ? urgentcolor : bordercolor);
-		c->border[i]->node.data = c;
-	}
+	c->border = wlr_scene_rect_create(c->scene, 0, 0,
+			c->isurgent ? urgentcolor : bordercolor);
+	c->border->node.data = c;
 
 	/* Initialize client geometry with room for border */
 	client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
@@ -2027,7 +2025,9 @@ monocle(Monitor *m)
 	wl_list_for_each(c, &clients, link) {
 		if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
 			continue;
-		resize(c, m->w, 0);
+		resize(c, (struct wlr_box){.x = m->w.x + gapp, .y = m->w.y + gapp,
+			.width = m->w.width - 2 * gapp,
+			.height = m->w.height - 2 * gapp}, 0);
 		n++;
 	}
 	if (n)
@@ -2451,7 +2451,7 @@ resize(Client *c, struct wlr_box geo, int interact)
 	struct wlr_box *bbox;
 	struct wlr_box clip;
 	struct wlr_box old;
-	int animate;
+	int animate, radius, inner;
 
 	if (!c->mon || !client_surface(c)->mapped)
 		return;
@@ -2489,23 +2489,44 @@ resize(Client *c, struct wlr_box geo, int interact)
 		wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
 	}
 
+	/* A fullscreen window keeps square corners. The border is a single
+	 * rounded rectangle with the client area clipped out of it. */
+	radius = c->isfullscreen ? 0 : corner_radius;
+	inner = MAX(radius - (int)c->bw, 0);
+
 	/* Update scene-graph, including borders */
 	wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
-	if (blur)
+	if (blur) {
 		wlr_scene_blur_set_size(c->blur, c->geom.width, c->geom.height);
-	wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
-	wlr_scene_rect_set_size(c->border[1], c->geom.width, c->bw);
-	wlr_scene_rect_set_size(c->border[2], c->bw, c->geom.height - 2 * c->bw);
-	wlr_scene_rect_set_size(c->border[3], c->bw, c->geom.height - 2 * c->bw);
-	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_blur_set_corner_radius(c->blur, radius);
+	}
+	wlr_scene_rect_set_size(c->border, c->geom.width, c->geom.height);
+	wlr_scene_rect_set_corner_radius(c->border, radius);
+	wlr_scene_rect_set_clipped_region(c->border, (struct clipped_region){
+		.area = {c->bw, c->bw, c->geom.width - 2 * c->bw,
+				c->geom.height - 2 * c->bw},
+		.corners = corner_radii_all(inner),
+	});
+	wlr_scene_node_for_each_buffer(&c->scene_surface->node, roundbuffer, c);
 
 	client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw);
 	client_get_clip(c, &clip);
 	wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
 }
 
+void
+roundbuffer(struct wlr_scene_buffer *buffer, int sx, int sy, void *data)
+{
+	Client *c = data;
+	struct wlr_scene_surface *scene_surface;
+
+	/* Round the toplevel surface itself, not its popups or subsurfaces. */
+	if ((scene_surface = wlr_scene_surface_try_from_buffer(buffer))
+			&& scene_surface->surface == client_surface(c))
+		wlr_scene_buffer_set_corner_radius(buffer, c->isfullscreen ? 0
+				: MAX(corner_radius - (int)c->bw, 0));
+}
+
 void
 run(char *startup_cmd)
 {
@@ -3016,6 +3037,7 @@ tile(Monitor *m)
 {
 	unsigned int mw, my, ty;
 	int i, n = 0;
+	struct wlr_box w;
 	Client *c;
 
 	wl_list_for_each(c, &clients, link)
@@ -3024,22 +3046,32 @@ tile(Monitor *m)
 	if (n == 0)
 		return;
 
+	/* The outer gap insets the tiled area; the inner gaps come off the
+	 * height of each column before its tiles are measured. */
+	w = m->w;
+	w.x += gapp;
+	w.y += gapp;
+	w.width -= 2 * gapp;
+	w.height -= 2 * gapp;
+
 	if (n > m->nmaster)
-		mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
+		mw = m->nmaster ? (int)roundf(w.width * m->mfact) : 0;
 	else
-		mw = m->w.width;
+		mw = w.width;
 	i = my = ty = 0;
 	wl_list_for_each(c, &clients, link) {
 		if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
 			continue;
 		if (i < m->nmaster) {
-			resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
-				.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
-			my += c->geom.height;
+			resize(c, (struct wlr_box){.x = w.x, .y = w.y + my, .width = mw,
+				.height = (w.height - my - gapp * (MIN(n, m->nmaster) - i - 1))
+					/ (MIN(n, m->nmaster) - i)}, 0);
+			my += c->geom.height + gapp;
 		} else {
-			resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
-				.width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
-			ty += c->geom.height;
+			resize(c, (struct wlr_box){.x = w.x + mw + gapp, .y = w.y + ty,
+				.width = w.width - mw - gapp,
+				.height = (w.height - ty - gapp * (n - i - 1)) / (n - i)}, 0);
+			ty += c->geom.height + gapp;
 		}
 		i++;
 	}
some little changesnageyqma · 2026-10-24 · ee555e8
查看变更
AGENT.md    |   4 +-
 LICENSE     |   2 +-
 LICENSE.dwl | 692 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Makefile    |   2 +-
 4 files changed, 696 insertions(+), 4 deletions(-)
diff --git a/AGENT.md b/AGENT.md
index cac7db0..f4188b2 100644
--- a/AGENT.md
+++ b/AGENT.md
@@ -2,8 +2,8 @@
 
 This is a local fork of [dwl](https://github.com/djpohly/dwl), the wlroots port
 of [dwm](https://dwm.suckless.org/). The owner is customizing it step by step.
-The tree started from upstream plus the wlroots 0.20 -> 0.21 port; every change
-after that is deliberately a small layer, not a rewrite.
+The tree started from upstream; every change after that is deliberately a small
+layer, not a rewrite.
 
 Read this before editing. If a rule below conflicts with generic "good
 engineering" advice, this file wins. The background is
diff --git a/LICENSE b/LICENSE
index 658085a..e3c6cff 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
 dwl - dwm for Wayland
 
-Copyright © 2020 dwl team
+Copyright © 2026 nageyqma7
 
 See also the files LICENSE.tinywl, LICENSE.dwm and LICENSE.sway.
 
diff --git a/LICENSE.dwl b/LICENSE.dwl
new file mode 100644
index 0000000..658085a
--- /dev/null
+++ b/LICENSE.dwl
@@ -0,0 +1,692 @@
+dwl - dwm for Wayland
+
+Copyright © 2020 dwl team
+
+See also the files LICENSE.tinywl, LICENSE.dwm and LICENSE.sway.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+----
+
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<https://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<https://www.gnu.org/licenses/why-not-lgpl.html>.
diff --git a/Makefile b/Makefile
index b41daa8..8f0f913 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@ dwl: dwl.c client.h config.h ime.h util.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
-	$(CC) dwl.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
+	$(CC) -O3 dwl.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
 
 # wayland-scanner is a tool which generates C headers and rigging for Wayland
 # protocols, which are specified in XML. wlroots requires you to rig these up
fix blurnageyqma · 2026-10-24 · 84436d4
查看变更
dwl.c | 52 ++++++++++++++++++----------------------------------
 1 file changed, 18 insertions(+), 34 deletions(-)
diff --git a/dwl.c b/dwl.c
index b0101f8..b7deeed 100644
--- a/dwl.c
+++ b/dwl.c
@@ -90,7 +90,7 @@
 /* enums */
 enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
 enum { XDGShell, LayerShell, X11 }; /* client types */
-enum { LyrBg, LyrBottom, LyrBlur, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
+enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
 	LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
 enum { AxisUp, AxisRight, AxisDown, AxisLeft };
 
@@ -122,6 +122,7 @@ typedef struct {
 
 	Monitor *mon;
 	struct wlr_scene_tree *scene;
+	struct wlr_scene_blur *blur;
 	struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
 	struct wlr_scene_tree *scene_surface;
 	struct wl_list link;
@@ -195,6 +196,7 @@ typedef struct {
 
 	Monitor *mon;
 	struct wlr_scene_tree *scene;
+	struct wlr_scene_blur *blur;
 	struct wlr_scene_tree *popups;
 	struct wlr_scene_layer_surface_v1 *scene_layer;
 	struct wl_list link;
@@ -215,7 +217,6 @@ struct Monitor {
 	struct wl_list link;
 	struct wlr_output *wlr_output;
 	struct wlr_scene_output *scene_output;
-	struct wlr_scene_optimized_blur *blur_layer;
 	struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
 	struct wl_listener frame;
 	struct wl_listener destroy;
@@ -586,15 +587,6 @@ arrange(Monitor *m)
 	wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
 			(c = focustop(m)) && c->isfullscreen);
 
-	if (blur) {
-		wlr_scene_node_set_enabled(&m->blur_layer->node, 1);
-		wlr_scene_node_set_position(&m->blur_layer->node, m->m.x, m->m.y);
-		if (m->blur_layer->width != m->m.width
-				|| m->blur_layer->height != m->m.height)
-			wlr_scene_optimized_blur_set_size(m->blur_layer,
-					m->m.width, m->m.height);
-	}
-
 	strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
 
 	/* We move all clients (except fullscreen and unmanaged) to LyrTile while
@@ -638,6 +630,10 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int
 			continue;
 
 		wlr_scene_layer_surface_v1_configure(l->scene_layer, &full_area, usable_area);
+		if (blur)
+			wlr_scene_blur_set_size(l->blur,
+					layer_surface->surface->current.width,
+					layer_surface->surface->current.height);
 		wlr_scene_node_set_position(&l->popups->node, l->scene->node.x, l->scene->node.y);
 	}
 }
@@ -874,8 +870,6 @@ cleanupmon(struct wl_listener *listener, void *data)
 
 	closemon(m);
 	wlr_scene_node_destroy(&m->fullscreen_bg->node);
-	if (blur)
-		wlr_scene_node_destroy(&m->blur_layer->node);
 	free(m);
 }
 
@@ -962,17 +956,10 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
 		old_state = l->layer_surface->current;
 		l->layer_surface->current = l->layer_surface->pending;
 		arrangelayers(l->mon);
-		if (blur && (layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND
-				|| layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM))
-			wlr_scene_optimized_blur_mark_dirty(l->mon->blur_layer);
 		l->layer_surface->current = old_state;
 		return;
 	}
 
-	if (blur && (layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND
-			|| layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM))
-		wlr_scene_optimized_blur_mark_dirty(l->mon->blur_layer);
-
 	if (layer_surface->current.committed == 0 && l->mapped == layer_surface->surface->mapped)
 		return;
 	l->mapped = layer_surface->surface->mapped;
@@ -1157,6 +1144,10 @@ createlayersurface(struct wl_listener *listener, void *data)
 	l->mon = layer_surface->output->data;
 	l->scene_layer = wlr_scene_layer_surface_v1_create(scene_layer, layer_surface);
 	l->scene = l->scene_layer->tree;
+	if (blur) {
+		l->blur = wlr_scene_blur_create(l->scene, 0, 0);
+		wlr_scene_node_lower_to_bottom(&l->blur->node);
+	}
 	l->popups = surface->data = wlr_scene_tree_create(layer_surface->current.layer
 			< ZWLR_LAYER_SHELL_V1_LAYER_TOP ? layers[LyrTop] : scene_layer);
 	l->scene->node.data = l->popups->node.data = l;
@@ -1253,11 +1244,6 @@ createmon(struct wl_listener *listener, void *data)
 	m->fullscreen_bg = wlr_scene_rect_create(layers[LyrFS], 0, 0, fullscreen_bg);
 	wlr_scene_node_set_enabled(&m->fullscreen_bg->node, 0);
 
-	if (blur) {
-		m->blur_layer = wlr_scene_optimized_blur_create(layers[LyrBlur], 0, 0);
-		wlr_scene_node_set_enabled(&m->blur_layer->node, 0);
-	}
-
 	/* Adds this to the output layout in the order it was configured.
 	 *
 	 * The output layout utility automatically adds a wl_output global to the
@@ -1720,8 +1706,6 @@ gpureset(struct wl_listener *listener, void *data)
 
 	wl_list_for_each(m, &mons, link) {
 		wlr_output_init_render(m->wlr_output, alloc, drw);
-		if (blur)
-			wlr_scene_optimized_blur_mark_dirty(m->blur_layer);
 	}
 
 	wlr_allocator_destroy(old_alloc);
@@ -1958,6 +1942,11 @@ mapnotify(struct wl_listener *listener, void *data)
 		goto unset_fullscreen;
 	}
 
+	if (blur) {
+		c->blur = wlr_scene_blur_create(c->scene, 0, 0);
+		wlr_scene_node_lower_to_bottom(&c->blur->node);
+	}
+
 	for (i = 0; i < 4; i++) {
 		c->border[i] = wlr_scene_rect_create(c->scene, 0, 0,
 				c->isurgent ? urgentcolor : bordercolor);
@@ -2502,6 +2491,8 @@ resize(Client *c, struct wlr_box geo, int interact)
 
 	/* Update scene-graph, including borders */
 	wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
+	if (blur)
+		wlr_scene_blur_set_size(c->blur, c->geom.width, c->geom.height);
 	wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
 	wlr_scene_rect_set_size(c->border[1], c->geom.width, c->bw);
 	wlr_scene_rect_set_size(c->border[2], c->bw, c->geom.height - 2 * c->bw);
@@ -3114,9 +3105,6 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
 	wlr_scene_node_set_enabled(&l->scene->node, 0);
 	if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
 		arrangelayers(l->mon);
-	if (blur && l->mon && (l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND
-			|| l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM))
-		wlr_scene_optimized_blur_mark_dirty(l->mon->blur_layer);
 	if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
 		focusclient(focustop(selmon), NULL, 1);
 	motionnotify(0, NULL, 0, 0, 0, 0);
@@ -3184,8 +3172,6 @@ updatemons(struct wl_listener *listener, void *data)
 			continue;
 		config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
 		config_head->state.enabled = 0;
-		if (blur)
-			wlr_scene_node_set_enabled(&m->blur_layer->node, 0);
 		if (m->asleep)
 			continue;
 
@@ -3234,8 +3220,6 @@ updatemons(struct wl_listener *listener, void *data)
 		arrangelayers(m);
 		/* Don't move clients to the left output when plugging monitors */
 		arrange(m);
-		if (blur)
-			wlr_scene_optimized_blur_mark_dirty(m->blur_layer);
 		/* make sure fullscreen clients have the right size */
 		if ((c = focustop(m)) && c->isfullscreen)
 			resize(c, m->m, 0);
add blurnageyqma · 2026-10-24 · 04c143a
查看变更
Makefile     |  4 ++--
 config.def.h | 10 ++++++++++
 config.mk    |  4 ++++
 dwl.c        | 48 ++++++++++++++++++++++++++++++++++++++++++++----
 4 files changed, 60 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index 8304245..b41daa8 100644
--- a/Makefile
+++ b/Makefile
@@ -13,8 +13,8 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
 
 # CFLAGS / LDFLAGS
 PKGS      = wayland-server xkbcommon libinput $(XLIBS)
-DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
-LDLIBS    = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
+DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(SCENEFX_INCS) $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
+LDLIBS    = $(SCENEFX_LIBS) `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
 
 all: dwl
 dwl: dwl.c client.h config.h ime.h util.h config.mk cursor-shape-v1-protocol.h \
diff --git a/config.def.h b/config.def.h
index 5252dbd..bf5a23e 100644
--- a/config.def.h
+++ b/config.def.h
@@ -16,6 +16,16 @@ 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 blur = 1; /* background blur */
+static const struct blur_data blur_data = {
+	.radius = 5,
+	.num_passes = 3,
+	.noise = 0.02f,
+	.brightness = 0.9f,
+	.contrast = 0.9f,
+	.saturation = 1.1f,
+};
+
 /* tagging - TAGCOUNT must be no greater than 31 */
 #define TAGCOUNT (9)
 
diff --git a/config.mk b/config.mk
index 0da079c..4f7ad89 100644
--- a/config.mk
+++ b/config.mk
@@ -8,6 +8,10 @@ PREFIX = /usr/local
 MANDIR = $(PREFIX)/share/man
 DATADIR = $(PREFIX)/share
 
+# scenefx 0.5 headers are not -Wpedantic-clean; include them as system headers.
+SCENEFX_INCS = `$(PKG_CONFIG) --cflags scenefx-0.5 | sed 's/-I/-isystem /g'`
+SCENEFX_LIBS = `$(PKG_CONFIG) --libs scenefx-0.5`
+
 WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.20`
 WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.20`
 
diff --git a/dwl.c b/dwl.c
index 33c4678..b0101f8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -6,6 +6,9 @@
 #include <limits.h>
 #include <linux/input-event-codes.h>
 #include <math.h>
+#include <scenefx/render/fx_renderer/fx_renderer.h>
+#include <scenefx/types/fx/blur_data.h>
+#include <scenefx/types/wlr_scene.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -51,7 +54,6 @@
 #include <wlr/types/wlr_primary_selection.h>
 #include <wlr/types/wlr_primary_selection_v1.h>
 #include <wlr/types/wlr_relative_pointer_v1.h>
-#include <wlr/types/wlr_scene.h>
 #include <wlr/types/wlr_screencopy_v1.h>
 #include <wlr/types/wlr_seat.h>
 #include <wlr/types/wlr_server_decoration.h>
@@ -88,7 +90,7 @@
 /* enums */
 enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
 enum { XDGShell, LayerShell, X11 }; /* client types */
-enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
+enum { LyrBg, LyrBottom, LyrBlur, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
 	LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
 enum { AxisUp, AxisRight, AxisDown, AxisLeft };
 
@@ -213,6 +215,7 @@ struct Monitor {
 	struct wl_list link;
 	struct wlr_output *wlr_output;
 	struct wlr_scene_output *scene_output;
+	struct wlr_scene_optimized_blur *blur_layer;
 	struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
 	struct wl_listener frame;
 	struct wl_listener destroy;
@@ -583,6 +586,15 @@ arrange(Monitor *m)
 	wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
 			(c = focustop(m)) && c->isfullscreen);
 
+	if (blur) {
+		wlr_scene_node_set_enabled(&m->blur_layer->node, 1);
+		wlr_scene_node_set_position(&m->blur_layer->node, m->m.x, m->m.y);
+		if (m->blur_layer->width != m->m.width
+				|| m->blur_layer->height != m->m.height)
+			wlr_scene_optimized_blur_set_size(m->blur_layer,
+					m->m.width, m->m.height);
+	}
+
 	strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
 
 	/* We move all clients (except fullscreen and unmanaged) to LyrTile while
@@ -862,6 +874,8 @@ cleanupmon(struct wl_listener *listener, void *data)
 
 	closemon(m);
 	wlr_scene_node_destroy(&m->fullscreen_bg->node);
+	if (blur)
+		wlr_scene_node_destroy(&m->blur_layer->node);
 	free(m);
 }
 
@@ -948,10 +962,17 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
 		old_state = l->layer_surface->current;
 		l->layer_surface->current = l->layer_surface->pending;
 		arrangelayers(l->mon);
+		if (blur && (layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND
+				|| layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM))
+			wlr_scene_optimized_blur_mark_dirty(l->mon->blur_layer);
 		l->layer_surface->current = old_state;
 		return;
 	}
 
+	if (blur && (layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND
+			|| layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM))
+		wlr_scene_optimized_blur_mark_dirty(l->mon->blur_layer);
+
 	if (layer_surface->current.committed == 0 && l->mapped == layer_surface->surface->mapped)
 		return;
 	l->mapped = layer_surface->surface->mapped;
@@ -1232,6 +1253,11 @@ createmon(struct wl_listener *listener, void *data)
 	m->fullscreen_bg = wlr_scene_rect_create(layers[LyrFS], 0, 0, fullscreen_bg);
 	wlr_scene_node_set_enabled(&m->fullscreen_bg->node, 0);
 
+	if (blur) {
+		m->blur_layer = wlr_scene_optimized_blur_create(layers[LyrBlur], 0, 0);
+		wlr_scene_node_set_enabled(&m->blur_layer->node, 0);
+	}
+
 	/* Adds this to the output layout in the order it was configured.
 	 *
 	 * The output layout utility automatically adds a wl_output global to the
@@ -1681,7 +1707,7 @@ gpureset(struct wl_listener *listener, void *data)
 	struct wlr_renderer *old_drw = drw;
 	struct wlr_allocator *old_alloc = alloc;
 	struct Monitor *m;
-	if (!(drw = wlr_renderer_autocreate(backend)))
+	if (!(drw = fx_renderer_create(backend)))
 		die("couldn't recreate renderer");
 
 	if (!(alloc = wlr_allocator_autocreate(backend, drw)))
@@ -1694,6 +1720,8 @@ gpureset(struct wl_listener *listener, void *data)
 
 	wl_list_for_each(m, &mons, link) {
 		wlr_output_init_render(m->wlr_output, alloc, drw);
+		if (blur)
+			wlr_scene_optimized_blur_mark_dirty(m->blur_layer);
 	}
 
 	wlr_allocator_destroy(old_alloc);
@@ -2739,11 +2767,16 @@ setup(void)
 	drag_icon = wlr_scene_tree_create(&scene->tree);
 	wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
 
+	if (blur)
+		wlr_scene_set_blur_data(scene, blur_data.num_passes,
+				(int)blur_data.radius, blur_data.noise, blur_data.brightness,
+				blur_data.contrast, blur_data.saturation);
+
 	/* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user
 	 * can also specify a renderer using the WLR_RENDERER env var.
 	 * The renderer is responsible for defining the various pixel formats it
 	 * supports for shared memory, this configures that for clients. */
-	if (!(drw = wlr_renderer_autocreate(backend)))
+	if (!(drw = fx_renderer_create(backend)))
 		die("couldn't create renderer");
 	wl_signal_add(&drw->events.lost, &gpu_reset);
 
@@ -3081,6 +3114,9 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
 	wlr_scene_node_set_enabled(&l->scene->node, 0);
 	if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
 		arrangelayers(l->mon);
+	if (blur && l->mon && (l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND
+			|| l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM))
+		wlr_scene_optimized_blur_mark_dirty(l->mon->blur_layer);
 	if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
 		focusclient(focustop(selmon), NULL, 1);
 	motionnotify(0, NULL, 0, 0, 0, 0);
@@ -3148,6 +3184,8 @@ updatemons(struct wl_listener *listener, void *data)
 			continue;
 		config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
 		config_head->state.enabled = 0;
+		if (blur)
+			wlr_scene_node_set_enabled(&m->blur_layer->node, 0);
 		if (m->asleep)
 			continue;
 
@@ -3196,6 +3234,8 @@ updatemons(struct wl_listener *listener, void *data)
 		arrangelayers(m);
 		/* Don't move clients to the left output when plugging monitors */
 		arrange(m);
+		if (blur)
+			wlr_scene_optimized_blur_mark_dirty(m->blur_layer);
 		/* make sure fullscreen clients have the right size */
 		if ((c = focustop(m)) && c->isfullscreen)
 			resize(c, m->m, 0);
slide aniamtionnageyqma · 2026-10-23 · 0cc162a
查看变更
AGENT.md     |  4 ++++
 config.def.h |  1 +
 dwl.c        | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 88 insertions(+), 3 deletions(-)
diff --git a/AGENT.md b/AGENT.md
index e49b4b7..cac7db0 100644
--- a/AGENT.md
+++ b/AGENT.md
@@ -107,6 +107,10 @@ directory search, and no blocking/non-blocking pair.
 ## Build and verify
 
 - `make` is the only build step. Keep it clean.
+- Never run `make -B`: the `config.h:` target has no prerequisites, so `-B`
+  forces `cp config.def.h config.h` and overwrites the owner's live,
+  git-ignored config. Use plain `make` or `make clean && make`; to force a
+  rebuild, remove `dwl` or touch `dwl.c`.
 - Compile-time checks are the default. Run `git diff` before reporting.
 - Do not start, stop, or restart dwl, KDE, the display manager, or the owner's
   session to test a change. The owner will test it.
diff --git a/config.def.h b/config.def.h
index 3d8c0b8..5252dbd 100644
--- a/config.def.h
+++ b/config.def.h
@@ -8,6 +8,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 unsigned int snap             = 32; /* snap pixel */
+static const int anim_ms                   = 160; /* slide duration in milliseconds; 0 disables */
 static const float rootcolor[]             = COLOR(0x222222ff);
 static const float bordercolor[]           = COLOR(0x444444ff);
 static const float focuscolor[]            = COLOR(0x005577ff);
diff --git a/dwl.c b/dwl.c
index 3860e08..33c4678 100644
--- a/dwl.c
+++ b/dwl.c
@@ -159,6 +159,12 @@ typedef struct {
 	unsigned int bw;
 	uint32_t tags;
 	int isfloating, isurgent, isfullscreen;
+	/* Position-only slide; c->geom stays the authoritative layout box. */
+	struct timespec animstart; /* CLOCK_MONOTONIC start of the slide */
+	int animx, animy;          /* displayed position when the slide started */
+	int animtox, animtoy;      /* c->geom position the slide is heading to */
+	int animating;
+	int animready;             /* position is settled; a resize may slide */
 } Client;
 
 typedef struct {
@@ -556,8 +562,19 @@ arrange(Monitor *m)
 
 	wl_list_for_each(c, &clients, link) {
 		if (c->mon == m) {
-			wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m));
-			client_set_suspended(c, !VISIBLEON(c, m)
+			int visible = VISIBLEON(c, m);
+
+			/* Do not slide across a reparent, a hide, or a layout that
+			 * no longer tiles. */
+			if (c->animating && (!visible || c->isfloating
+					|| c->isfullscreen
+					|| !m->lt[m->sellt]->arrange)) {
+				c->animating = 0;
+				wlr_scene_node_set_position(&c->scene->node,
+						c->geom.x, c->geom.y);
+			}
+			wlr_scene_node_set_enabled(&c->scene->node, visible);
+			client_set_suspended(c, !visible
 					&& (!c->image_capture_source
 					|| wl_list_empty(&c->image_capture_source->resources)));
 		}
@@ -584,6 +601,11 @@ arrange(Monitor *m)
 
 	if (m->lt[m->sellt]->arrange)
 		m->lt[m->sellt]->arrange(m);
+	/* Windows that just appeared snapped in the layout pass above; let the
+	 * next layout change slide them. */
+	wl_list_for_each(c, &clients, link)
+		if (c->mon == m)
+			c->animready = VISIBLEON(c, m);
 	motionnotify(0, NULL, 0, 0, 0, 0);
 	checkidleinhibitor(NULL);
 }
@@ -2339,7 +2361,34 @@ rendermon(struct wl_listener *listener, void *data)
 	/* This function is called every time an output is ready to display a frame,
 	 * generally at the output's refresh rate (e.g. 60Hz). */
 	Monitor *m = wl_container_of(listener, m, frame);
+	Client *c;
 	struct timespec now;
+	long elapsed;
+	double t, x, y;
+	int active = 0;
+
+	clock_gettime(CLOCK_MONOTONIC, &now);
+	wl_list_for_each(c, &clients, link) {
+		if (!c->animating || c->mon != m)
+			continue;
+		elapsed = (now.tv_sec - c->animstart.tv_sec) * 1000
+				+ (now.tv_nsec - c->animstart.tv_nsec) / 1000000;
+		if (elapsed >= anim_ms) {
+			c->animating = 0;
+			wlr_scene_node_set_position(&c->scene->node,
+					c->geom.x, c->geom.y);
+			continue;
+		}
+		t = 1.0 - (double)elapsed / anim_ms;
+		t = 1.0 - t * t * t; /* ease out cubic */
+		x = c->animx + (c->animtox - c->animx) * t;
+		y = c->animy + (c->animtoy - c->animy) * t;
+		wlr_scene_node_set_position(&c->scene->node,
+				(int)round(x), (int)round(y));
+		active = 1;
+	}
+	if (active)
+		wlr_output_schedule_frame(m->wlr_output);
 
 	if (!wlr_scene_output_needs_frame(m->scene_output)) {
 		return;
@@ -2384,6 +2433,8 @@ resize(Client *c, struct wlr_box geo, int interact)
 {
 	struct wlr_box *bbox;
 	struct wlr_box clip;
+	struct wlr_box old;
+	int animate;
 
 	if (!c->mon || !client_surface(c)->mapped)
 		return;
@@ -2391,11 +2442,37 @@ resize(Client *c, struct wlr_box geo, int interact)
 	bbox = interact ? &sgeom : &c->mon->w;
 
 	client_set_bounds(c, geo.width, geo.height);
+	old = c->geom;
 	c->geom = geo;
 	applybounds(c, bbox);
 
+	/* Slide an already placed tiling client whose x/y changes. Everything
+	 * else snaps: anim_ms == 0, interactive drags, floating and fullscreen
+	 * clients, and windows that were not visible in the previous arrange
+	 * (first map, tag switch, monitor change). */
+	animate = anim_ms > 0 && !interact && c->animready
+			&& !c->isfullscreen && !c->isfloating
+			&& VISIBLEON(c, c->mon)
+			&& c->mon->lt[c->mon->sellt]->arrange
+			&& (c->animating || c->geom.x != old.x || c->geom.y != old.y);
+	if (animate) {
+		if (!c->animating || c->animtox != c->geom.x
+				|| c->animtoy != c->geom.y) {
+			/* Retarget from what is on screen, which may be mid-slide. */
+			c->animx = c->scene->node.x;
+			c->animy = c->scene->node.y;
+			c->animtox = c->geom.x;
+			c->animtoy = c->geom.y;
+			clock_gettime(CLOCK_MONOTONIC, &c->animstart);
+			c->animating = 1;
+			wlr_output_schedule_frame(c->mon->wlr_output);
+		}
+	} else {
+		c->animating = 0;
+		wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
+	}
+
 	/* Update scene-graph, including borders */
-	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);
 	wlr_scene_rect_set_size(c->border[1], c->geom.width, c->bw);
@@ -2533,6 +2610,7 @@ setfullscreen(Client *c, int fullscreen)
 	c->isfullscreen = fullscreen;
 	if (!c->mon || !client_surface(c)->mapped)
 		return;
+	c->animready = 0; /* snap into and out of fullscreen */
 	c->bw = fullscreen ? 0 : borderpx;
 	client_set_fullscreen(c, fullscreen);
 	wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
@@ -2588,6 +2666,8 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
 		return;
 	c->mon = m;
 	c->prev = c->geom;
+	/* A new monitor or an unmap has no slide to continue. */
+	c->animating = c->animready = 0;
 
 	/* Scene graph sends surface leave/enter events on move and resize */
 	if (oldmon)
revert wlroots 0.21 migration
Go back to wlroots 0.20 in config.mk and restore the 0.20 capture request and xdg-decoration APIs in dwl.c. This reverts the wlroots part of 548a178; the local config, keymap, and man page are kept.
nageyqma · 2026-10-23 · b229f30
查看变更
AGENT.md  |  2 +-
 config.mk | 12 ++++++------
 dwl.c     |  6 +++---
 3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/AGENT.md b/AGENT.md
index 8f0c0cd..e49b4b7 100644
--- a/AGENT.md
+++ b/AGENT.md
@@ -97,7 +97,7 @@ directory search, and no blocking/non-blocking pair.
 
 ## Local invariants
 
-- Build against wlroots 0.21 (`config.mk`). Do not migrate, downgrade, or
+- Build against wlroots 0.20 (`config.mk`). Do not migrate, downgrade, or
   adopt `wlroots-next` APIs without an explicit request.
 - The compositor's startup environment is not this repository's business. Do
   not add display-manager, systemd, or login-session integration.
diff --git a/config.mk b/config.mk
index 8f8ce54..0da079c 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.21`
-WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.21`
+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:
@@ -17,12 +17,12 @@ WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.21`
 #WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
 #	-I$(PWD)/wlroots/include
 # Set -rpath to avoid using the wrong library.
-#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/build -L$(PWD)/wlroots/build -lwlroots-0.21
+#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/build -L$(PWD)/wlroots/build -lwlroots-0.20
 
-# Assuming you ran "meson setup --prefix ${PWD}/0.21 build && ninja -C build install"
+# Assuming you ran "meson setup --prefix ${PWD}/0.20 build && ninja -C build install"
 #WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
-#	-I$(PWD)/wlroots/0.21/include/wlroots-0.21
-#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/0.21/lib64 -L$(PWD)/wlroots/0.21/lib64 -lwlroots-0.21
+#	-I$(PWD)/wlroots/0.20/include/wlroots-0.20
+#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/0.20/lib64 -L$(PWD)/wlroots/0.20/lib64 -lwlroots-0.20
 
 XWAYLAND =
 XLIBS =
diff --git a/dwl.c b/dwl.c
index 03e0653..3860e08 100644
--- a/dwl.c
+++ b/dwl.c
@@ -745,7 +745,7 @@ buttonpress(struct wl_listener *listener, void *data)
 void
 capturerequest(struct wl_listener *listener, void *data)
 {
-	struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_event *request = data;
+	struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request *request = data;
 	Client *view = request->toplevel_handle->data;
 
 	if (!view->image_capture_source) {
@@ -2764,14 +2764,14 @@ setup(void)
 	foreign_toplevel_list = wlr_ext_foreign_toplevel_list_v1_create(dpy,1);
 	ext_foreign_toplevel_image_capture_source_manager_v1 =
             wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create(dpy, 1);
-	wl_signal_add(&ext_foreign_toplevel_image_capture_source_manager_v1->events.capture_request,
+	wl_signal_add(&ext_foreign_toplevel_image_capture_source_manager_v1->events.new_request,
 			&new_foreign_toplevel_capture_request);
 
 	/* Use decoration protocols to negotiate server-side decorations */
 	wlr_server_decoration_manager_set_default_mode(
 			wlr_server_decoration_manager_create(dpy),
 			WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
-	xdg_decoration_mgr = wlr_xdg_decoration_manager_v1_create(dpy, 2);
+	xdg_decoration_mgr = wlr_xdg_decoration_manager_v1_create(dpy);
 	wl_signal_add(&xdg_decoration_mgr->events.new_toplevel_decoration, &new_xdg_decoration);
 
 	pointer_constraints = wlr_pointer_constraints_v1_create(dpy);
wayland 1.5x zoomnageyqma · 2026-10-22 · 410114e
查看变更
config.def.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config.def.h b/config.def.h
index 80fa3ba..3d8c0b8 100644
--- a/config.def.h
+++ b/config.def.h
@@ -44,7 +44,7 @@ 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 }, */
-	{ NULL,       0.55f, 1,      1,    &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL,   -1,  -1 },
+	{ NULL,       0.55f, 1,      1.5f, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL,   -1,  -1 },
 	/* default monitor rule: can be changed but cannot be eliminated; at least one monitor rule must exist */
 };
 
added xwayland support,default colemak keyboard layout and autostart scriptnageyqma · 2026-10-22 · 71f6083
查看变更
AGENT.md     | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 config.def.h |  30 +++++++++++++++---------------
 dwl.c        |   7 +++++++
 3 files changed, 157 insertions(+), 15 deletions(-)
diff --git a/AGENT.md b/AGENT.md
new file mode 100644
index 0000000..8f0c0cd
--- /dev/null
+++ b/AGENT.md
@@ -0,0 +1,135 @@
+# AGENT.md
+
+This is a local fork of [dwl](https://github.com/djpohly/dwl), the wlroots port
+of [dwm](https://dwm.suckless.org/). The owner is customizing it step by step.
+The tree started from upstream plus the wlroots 0.20 -> 0.21 port; every change
+after that is deliberately a small layer, not a rewrite.
+
+Read this before editing. If a rule below conflicts with generic "good
+engineering" advice, this file wins. The background is
+[suckless philosophy](https://suckless.org/philosophy/) and
+[suckless coding style](https://suckless.org/coding_style/).
+
+## The project's bar
+
+Two properties matter more than features:
+
+1. **Small.** A line that is not necessary is a line the owner must read and
+   maintain forever. Prefer no code to a little code, and a config value to a
+   new function.
+2. **Readable.** A stranger who knows C and dwm should understand a change in
+   one pass. A clever abstraction that saves repetition but costs a jump is a
+   regression here.
+
+The practical consequences:
+
+- Configuration belongs in `config.h`. If a behavior can be selected there,
+  implement it there, not as a runtime option.
+- Reuse what dwl/wlroots already provides: `spawn`, `SHCMD`, `Arg`, `LISTEN`,
+  listeners, the `-s` startup command, wlroots helpers. Do not build a second
+  mechanism beside one that already exists.
+- No new dependencies, no new source files, no build-system layers, no
+  generated code, no configuration parser, no IPC, no plugin system, no
+  runtime reload, no animation framework.
+- Do not generalize for a hypothetical future request. The owner will ask for
+  the next feature when they want it.
+- Prefer deleting a special case to adding a flag. Prefer one fixed path to a
+  search path. Prefer one command to two blocking/non-blocking variants.
+- A change that touches unrelated lines is wrong even if it looks "cleaner".
+  Reformatting, sorting, and include churn are not welcome.
+
+## How to approach a request
+
+1. Read the relevant code, `config.def.h`, `config.h`, and the man page first.
+   Search for an existing hook before designing one.
+2. Choose the smallest lever, in this order: a `config.h` constant, a call to
+   an existing function, a small helper, a new file (almost never).
+3. Check the side effects: environment (`WAYLAND_DISPLAY`,
+   `XDG_RUNTIME_DIR`), child processes and shutdown, focus and keyboard
+   groups, multi-monitor, XWayland, and the `-s` status pipe.
+4. Write the diff in the surrounding style. It should be hard to tell your hunk
+   from upstream code.
+5. Build. Do not restart the live session. Report what you verified and what
+   you did not.
+
+A worked example from this tree: the dwm autostart patch searches three XDG
+directories, supports two script names, and distinguishes blocking from
+background startup. The actual requirement was "run one known script once".
+The small solution is one `SHCMD` entry in `config.h` plus one `spawn()` call
+in `run()`; `/bin/sh` already reports a missing script.
+
+## C style
+
+Match the file. In practice that means:
+
+- Tabs for indentation, spaces for alignment; keep lines near the surrounding
+  width.
+- Function return type on its own line, name on the next, opening brace on the
+  next line. Control-flow braces on the same line.
+- Declarations before statements (`-Wdeclaration-after-statement` is on).
+- `/* ... */` comments, lowercase names, `static` for file-local functions,
+  forward declarations near the top, `ecalloc`/`die` as the rest of dwl uses
+  them.
+- No new compiler warnings. Do not silence warnings with casts or pragmas when
+  the code can simply be written correctly.
+- Do not run `clang-format`, sort includes, reorder keybindings, or re-align
+  existing tables. Touch only the lines the change needs.
+- Comments explain *why*, not *what*. Do not narrate the code.
+
+## config.h and config.def.h
+
+`config.h` is the owner's live, git-ignored config. `config.def.h` is the
+tracked default. They are edited separately and intentionally differ: the
+owner's tag order is not the default order. Never copy one over the other.
+
+When a change is a new default, add it to both files. When it is only the
+owner's preference, leave `config.def.h` alone.
+
+Do not touch the owner's existing keybindings, tag order, monitor rules, DRM
+device list, or mouse settings while doing an unrelated change. In particular,
+the keyboard layout is US Colemak with `caps:escape`; the key table was
+deliberately left alone. dwl matches keysyms, so a binding follows the letter,
+not the physical QWERTY position. That is intended.
+
+`Arg autostartcmd` and the `spawn(&autostartcmd)` call in `run()` are the
+whole autostart implementation. Keep it that way: one command, one path, no
+directory search, and no blocking/non-blocking pair.
+
+## Local invariants
+
+- Build against wlroots 0.21 (`config.mk`). Do not migrate, downgrade, or
+  adopt `wlroots-next` APIs without an explicit request.
+- The compositor's startup environment is not this repository's business. Do
+  not add display-manager, systemd, or login-session integration.
+- The live desktop belongs to the owner. This agent does not restart, log out
+  of, or reconfigure it to test code.
+
+## Build and verify
+
+- `make` is the only build step. Keep it clean.
+- Compile-time checks are the default. Run `git diff` before reporting.
+- Do not start, stop, or restart dwl, KDE, the display manager, or the owner's
+  session to test a change. The owner will test it.
+- A headless smoke test is acceptable when it cannot touch the real session:
+  `WLR_BACKENDS=headless`, a temporary `HOME`, a temporary
+  `XDG_RUNTIME_DIR`, and a fake autostart script that only writes a marker.
+  Clean up afterwards. Never run the real `~/scripts/autostart-dwl.sh`
+  against a throwaway compositor.
+- Do not install packages, edit system config, or change the running
+  environment.
+
+## Git and reporting
+
+- Do not commit unless asked. Do not amend, rebase, force-push, or touch
+  unrelated branches.
+- `config.h`, `patches/`, build products, and generated protocol headers are
+  ignored; do not "fix" that.
+- Report in the language the owner used. Include the files changed, the reason
+  for the smallest design, what was built and tested, and what was not tested.
+  Do not claim a live-session test you did not perform.
+- If you had to make a tradeoff, say it plainly. Do not hide it in a
+  changelog entry.
+
+This file is not a changelog. Update it only when the working rules change.
+
+When in doubt, do less, keep the diff obvious, and report the tradeoff.
diff --git a/config.def.h b/config.def.h
index 2a479ac..80fa3ba 100644
--- a/config.def.h
+++ b/config.def.h
@@ -15,9 +15,8 @@ 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 */
 
-/* tagging - TAGCOUNT must be no greater than 31
- * 13 tags to match the reference keymap: 1-9, p, c, v, t */
-#define TAGCOUNT (13)
+/* tagging - TAGCOUNT must be no greater than 31 */
+#define TAGCOUNT (9)
 
 /* logging */
 static int log_level = WLR_ERROR;
@@ -58,10 +57,10 @@ static const char *drmdevices = "/dev/dri/card1:/dev/dri/card0";
 /* keyboard */
 static const struct xkb_rule_names xkb_rules = {
 	/* can specify fields: rules, model, layout, variant, options */
-	/* example:
-	.options = "ctrl:nocaps",
-	*/
-	.options = NULL,
+	/* US Colemak, with Caps Lock as an extra Escape */
+	.layout = "us",
+	.variant = "colemak",
+	.options = "caps:escape",
 };
 
 static const int repeat_rate = 25;
@@ -125,6 +124,11 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
 /* commands */
 static const char *termcmd[] = { "foot", NULL };
 static const char *menucmd[] = { "rofi", "-show", "run", NULL };
+/* started in the background once the compositor is ready */
+static const Arg autostartcmd = SHCMD("exec \"$HOME/scripts/autostart-dwl.sh\"");
+/* X11 clients use the display served by xwayland-satellite */
+static const char xwaylanddisplay[] = ":2";
+static const Arg xwaylandcmd = SHCMD("exec xwayland-satellite \"$DISPLAY\"");
 
 static const Key keys[] = {
 	/* modifier                  key                  function          argument */
@@ -154,14 +158,10 @@ static const Key keys[] = {
 	TAGKEYS(                     XKB_KEY_3,           2),
 	TAGKEYS(                     XKB_KEY_4,           3),
 	TAGKEYS(                     XKB_KEY_5,           4),
-	TAGKEYS(                     XKB_KEY_6,           5),
-	TAGKEYS(                     XKB_KEY_7,           6),
-	TAGKEYS(                     XKB_KEY_8,           7),
-	TAGKEYS(                     XKB_KEY_9,           8),
-	TAGKEYS(                     XKB_KEY_t,           9),
-	TAGKEYS(                     XKB_KEY_c,           10),
-	TAGKEYS(                     XKB_KEY_v,           11),
-	TAGKEYS(                     XKB_KEY_p,           12),
+	TAGKEYS(                     XKB_KEY_t,           5),
+	TAGKEYS(                     XKB_KEY_c,           6),
+	TAGKEYS(                     XKB_KEY_v,           7),
+	TAGKEYS(                     XKB_KEY_p,           8),
 	{ MODKEY|WLR_MODIFIER_CTRL,  XKB_KEY_F12,         quit,             {0} },
 
 	/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
diff --git a/dwl.c b/dwl.c
index 5b9039b..03e0653 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2424,6 +2424,10 @@ run(char *startup_cmd)
 	if (!wlr_backend_start(backend))
 		die("startup: backend_start");
 
+	/* Start xwayland-satellite and point DISPLAY at it. */
+	setenv("DISPLAY", xwaylanddisplay, 1);
+	spawn(&xwaylandcmd);
+
 	/* Now that the socket exists and the backend is started, run the startup command */
 	if (startup_cmd) {
 		int piperw[2];
@@ -2444,6 +2448,9 @@ run(char *startup_cmd)
 		close(piperw[0]);
 	}
 
+	/* Start the autostart command in the background */
+	spawn(&autostartcmd);
+
 	/* Mark stdout as non-blocking to avoid the startup script
 	 * causing dwl to freeze when a user neither closes stdin
 	 * nor consumes standard input in his startup script */
add wlroots21 supportnageyqma · 2026-10-21 · 548a178
查看变更
.gitignore   |  2 ++
 config.def.h | 63 ++++++++++++++++++++++++++++++++++++---------------------------
 config.mk    | 12 ++++++------
 dwl.1        | 73 +++++++++++++++++++++++++++++++++++++------------------------------------
 dwl.c        |  9 ++++++---
 5 files changed, 87 insertions(+), 72 deletions(-)
diff --git a/.gitignore b/.gitignore
index 0dde90e..48430f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,5 @@ dwl
 *-protocol.h
 .ccls-cache
 config.h
+config.reference.dwm.h
+patches/
diff --git a/config.def.h b/config.def.h
index a4019d3..2a479ac 100644
--- a/config.def.h
+++ b/config.def.h
@@ -15,8 +15,9 @@ 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 */
 
-/* tagging - TAGCOUNT must be no greater than 31 */
-#define TAGCOUNT (9)
+/* tagging - TAGCOUNT must be no greater than 31
+ * 13 tags to match the reference keymap: 1-9, p, c, v, t */
+#define TAGCOUNT (13)
 
 /* logging */
 static int log_level = WLR_ERROR;
@@ -48,6 +49,12 @@ static const MonitorRule monrules[] = {
 	/* default monitor rule: can be changed but cannot be eliminated; at least one monitor rule must exist */
 };
 
+/* DRM devices, colon separated; the first existing device is the primary GPU.
+ * On hybrid GPUs, list the GPU driving the display first. Here card1 is the
+ * Intel iGPU and card0 the NVIDIA dGPU; wlroots skips missing devices.
+ * NULL lets wlroots auto-detect, which usually picks the discrete GPU first. */
+static const char *drmdevices = "/dev/dri/card1:/dev/dri/card0";
+
 /* keyboard */
 static const struct xkb_rule_names xkb_rules = {
 	/* can specify fields: rules, model, layout, variant, options */
@@ -103,8 +110,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;
 
-/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
-#define MODKEY WLR_MODIFIER_ALT
+/* Use the windows key for MODKEY, as in the reference dwm config */
+#define MODKEY WLR_MODIFIER_LOGO
 
 #define TAGKEYS(KEY,TAG) \
 	{ MODKEY,                    KEY,            view,            {.ui = 1 << TAG} }, \
@@ -117,33 +124,31 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
 
 /* commands */
 static const char *termcmd[] = { "foot", NULL };
-static const char *menucmd[] = { "wmenu-run", NULL };
+static const char *menucmd[] = { "rofi", "-show", "run", NULL };
 
 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_j,           focusstack,       {.i = +1} },
-	{ MODKEY,                    XKB_KEY_k,           focusstack,       {.i = -1} },
-	{ MODKEY,                    XKB_KEY_i,           incnmaster,       {.i = +1} },
-	{ MODKEY,                    XKB_KEY_d,           incnmaster,       {.i = -1} },
-	{ MODKEY,                    XKB_KEY_h,           setmfact,         {.f = -0.05f} },
-	{ MODKEY,                    XKB_KEY_l,           setmfact,         {.f = +0.05f} },
-	{ MODKEY,                    XKB_KEY_Return,      zoom,             {0} },
+	{ MODKEY,                    XKB_KEY_Return,      spawn,            {.v = termcmd} },
+	{ MODKEY,                    XKB_KEY_r,           spawn,            {.v = menucmd} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return,      zoom,             {0} },
+	{ MODKEY,                    XKB_KEY_w,           focusstack,       {.i = +1} },
+	{ MODKEY,                    XKB_KEY_Up,          focusstack,       {.i = -1} },
+	{ MODKEY,                    XKB_KEY_Down,        focusstack,       {.i = +1} },
+	{ MODKEY,                    XKB_KEY_a,           setmfact,         {.f = -0.05f} },
+	{ MODKEY,                    XKB_KEY_s,           setmfact,         {.f = +0.05f} },
+	{ MODKEY,                    XKB_KEY_comma,       incnmaster,       {.i = +1} },
+	{ MODKEY,                    XKB_KEY_period,      incnmaster,       {.i = -1} },
+	{ MODKEY,                    XKB_KEY_f,           togglefloating,   {0} },
+	{ MODKEY,                    XKB_KEY_F11,         togglefullscreen, {0} },
 	{ MODKEY,                    XKB_KEY_Tab,         view,             {0} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_c,           killclient,       {0} },
-	{ MODKEY,                    XKB_KEY_t,           setlayout,        {.v = &layouts[0]} },
-	{ MODKEY,                    XKB_KEY_f,           setlayout,        {.v = &layouts[1]} },
-	{ MODKEY,                    XKB_KEY_m,           setlayout,        {.v = &layouts[2]} },
 	{ MODKEY,                    XKB_KEY_space,       setlayout,        {0} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space,       togglefloating,   {0} },
-	{ MODKEY,                    XKB_KEY_e,           togglefullscreen, {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} },
-	{ MODKEY,                    XKB_KEY_period,      focusmon,         {.i = WLR_DIRECTION_RIGHT} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_comma,       tagmon,           {.i = WLR_DIRECTION_LEFT} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_period,      tagmon,           {.i = WLR_DIRECTION_RIGHT} },
+	{ MODKEY,                    XKB_KEY_m,           setlayout,        {.v = &layouts[2]} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_q,           killclient,       {0} },
+	/* The reference cycles monitors with Mod+0; focusmon is directional here */
+	{ MODKEY,                    XKB_KEY_0,           focusmon,         {.i = WLR_DIRECTION_RIGHT} },
+	{ MODKEY|WLR_MODIFIER_CTRL,  XKB_KEY_0,           focusmon,         {.i = WLR_DIRECTION_LEFT} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_0,           tagmon,           {.i = WLR_DIRECTION_RIGHT} },
+	{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT, XKB_KEY_0, tagmon,  {.i = WLR_DIRECTION_LEFT} },
 	TAGKEYS(                     XKB_KEY_1,           0),
 	TAGKEYS(                     XKB_KEY_2,           1),
 	TAGKEYS(                     XKB_KEY_3,           2),
@@ -153,7 +158,11 @@ static const Key keys[] = {
 	TAGKEYS(                     XKB_KEY_7,           6),
 	TAGKEYS(                     XKB_KEY_8,           7),
 	TAGKEYS(                     XKB_KEY_9,           8),
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_q,           quit,             {0} },
+	TAGKEYS(                     XKB_KEY_t,           9),
+	TAGKEYS(                     XKB_KEY_c,           10),
+	TAGKEYS(                     XKB_KEY_v,           11),
+	TAGKEYS(                     XKB_KEY_p,           12),
+	{ MODKEY|WLR_MODIFIER_CTRL,  XKB_KEY_F12,         quit,             {0} },
 
 	/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
 	{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_BackSpace, quit, {0} },
diff --git a/config.mk b/config.mk
index 0da079c..8f8ce54 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.20`
-WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.20`
+WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.21`
+WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.21`
 
 # Allow using an alternative wlroots installation
 # This has to have all the includes required by wlroots, e.g:
@@ -17,12 +17,12 @@ WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.20`
 #WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
 #	-I$(PWD)/wlroots/include
 # Set -rpath to avoid using the wrong library.
-#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/build -L$(PWD)/wlroots/build -lwlroots-0.20
+#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/build -L$(PWD)/wlroots/build -lwlroots-0.21
 
-# Assuming you ran "meson setup --prefix ${PWD}/0.20 build && ninja -C build install"
+# Assuming you ran "meson setup --prefix ${PWD}/0.21 build && ninja -C build install"
 #WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
-#	-I$(PWD)/wlroots/0.20/include/wlroots-0.20
-#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/0.20/lib64 -L$(PWD)/wlroots/0.20/lib64 -lwlroots-0.20
+#	-I$(PWD)/wlroots/0.21/include/wlroots-0.21
+#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/0.21/lib64 -L$(PWD)/wlroots/0.21/lib64 -lwlroots-0.21
 
 XWAYLAND =
 XLIBS =
diff --git a/dwl.1 b/dwl.1
index 7fee870..51c07b8 100644
--- a/dwl.1
+++ b/dwl.1
@@ -45,57 +45,58 @@ by editing the sources, in particular
 .Pa config.h .
 The default key bindings are as follows:
 .Bl -tag -width 20n -offset indent -compact
-.It Mod-[1-9]
+.It Mod-[1-9pcvt]
 Show only all windows with a tag.
-.It Mod-Ctrl-[1-9]
+.It Mod-Ctrl-[1-9pcvt]
 Show all windows with a tag.
-.It Mod-Shift-[1-9]
+.It Mod-Shift-[1-9pcvt]
 Move window to a single tag.
-.It Mod-Ctrl-Shift-[1-9]
+.It Mod-Ctrl-Shift-[1-9pcvt]
 Toggle tag for window.
-.It Mod-p
-Spawn
-.Xr wmenu-run 1 .
-.It Mod-Shift-Return
+.It Mod-Return
 Spawn
 .Xr foot 1 .
-.It Mod-[jk]
-Move focus down/up the stack.
-.It Mod-[id]
-Increase/decrease number of windows in master area.
-.It Mod-[hl]
-Decrease/increase master area.
-.It Mod-Return
+.It Mod-Shift-Return
 Move window on top of stack or switch top of stack with second window.
+.It Mod-r
+Spawn
+.Xr rofi 1
+with the run dialog.
+.It Mod-w
+Move focus down the stack.
+.It Mod-Up
+Move focus up the stack.
+.It Mod-Down
+Move focus down the stack.
+.It Mod-a
+Decrease master area.
+.It Mod-s
+Increase master area.
+.It Mod-,
+Increase number of windows in master area.
+.It Mod-.
+Decrease number of windows in master area.
 .It Mod-Tab
 Show only all windows with previous tag.
-.It Mod-Shift-c
-Close window.
-.It Mod-t
-Switch to tabbed layout.
 .It Mod-f
-Switch to floating layout.
-.It Mod-m
-Switch to monocle layout.
-.It Mod-Space
-Switch to previous layout.
-.It Mod-Shift-Space
 Toggle floating state of window.
-.It Mod-e
+.It Mod-F11
 Toggle fullscreen state of window.
+.It Mod-Space
+Switch to previous layout.
+.It Mod-m
+Switch to monocle layout.
+.It Mod-Shift-q
+Close window.
 .It Mod-0
-Show all windows.
-.It Mod-Shift-0
-Set all tags for window.
-.It Mod-,
-Move focus to previous monitor.
-.It Mod-.
 Move focus to next monitor.
-.It Mod-Shift-,
-Move window to previous monitor.
-.It Mod-Shift-.
+.It Mod-Ctrl-0
+Move focus to previous monitor.
+.It Mod-Shift-0
 Move window to next monitor.
-.It Mod-Shift-q
+.It Mod-Ctrl-Shift-0
+Move window to previous monitor.
+.It Mod-Ctrl-F12
 Quit
 .Nm .
 .El
diff --git a/dwl.c b/dwl.c
index 216deb5..5b9039b 100644
--- a/dwl.c
+++ b/dwl.c
@@ -745,7 +745,7 @@ buttonpress(struct wl_listener *listener, void *data)
 void
 capturerequest(struct wl_listener *listener, void *data)
 {
-	struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request *request = data;
+	struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_event *request = data;
 	Client *view = request->toplevel_handle->data;
 
 	if (!view->image_capture_source) {
@@ -2638,6 +2638,9 @@ setup(void)
 	 * output hardware. The autocreate option will choose the most suitable
 	 * backend based on the current environment, such as opening an X11 window
 	 * if an X11 server is running. */
+	/* On hybrid GPUs prefer the configured display GPU; see config.h. */
+	if (drmdevices && !getenv("WLR_DRM_DEVICES"))
+		setenv("WLR_DRM_DEVICES", drmdevices, 1);
 	if (!(backend = wlr_backend_autocreate(event_loop, &session)))
 		die("couldn't create backend");
 
@@ -2754,14 +2757,14 @@ setup(void)
 	foreign_toplevel_list = wlr_ext_foreign_toplevel_list_v1_create(dpy,1);
 	ext_foreign_toplevel_image_capture_source_manager_v1 =
             wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create(dpy, 1);
-	wl_signal_add(&ext_foreign_toplevel_image_capture_source_manager_v1->events.new_request,
+	wl_signal_add(&ext_foreign_toplevel_image_capture_source_manager_v1->events.capture_request,
 			&new_foreign_toplevel_capture_request);
 
 	/* Use decoration protocols to negotiate server-side decorations */
 	wlr_server_decoration_manager_set_default_mode(
 			wlr_server_decoration_manager_create(dpy),
 			WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
-	xdg_decoration_mgr = wlr_xdg_decoration_manager_v1_create(dpy);
+	xdg_decoration_mgr = wlr_xdg_decoration_manager_v1_create(dpy, 2);
 	wl_signal_add(&xdg_decoration_mgr->events.new_toplevel_decoration, &new_xdg_decoration);
 
 	pointer_constraints = wlr_pointer_constraints_v1_create(dpy);
fix popup positioning
Related: https://codeberg.org/dwl/dwl/pulls/1244 Co-authored-by: DanD <dandgg.ftw@gmail.com>
Guido Cella · 2026-09-29 · e203845
查看变更
dwl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dwl.c b/dwl.c
index 26fb3a0..216deb5 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1014,8 +1014,8 @@ commitpopup(struct wl_listener *listener, void *data)
 		return;
 	}
 	box = type == LayerShell ? l->mon->m : c->mon->w;
-	box.x -= (type == LayerShell ? l->scene->node.x : c->geom.x);
-	box.y -= (type == LayerShell ? l->scene->node.y : c->geom.y);
+	box.x -= (type == LayerShell ? l->scene->node.x : c->geom.x - c->surface.xdg->geometry.x);
+	box.y -= (type == LayerShell ? l->scene->node.y : c->geom.y - c->surface.xdg->geometry.y);
 	wlr_xdg_popup_unconstrain_from_box(popup, &box);
 	wl_list_remove(&listener->link);
 	free(listener);
fix X11 clients shifting by the border width on map
c->geom includes the border, but client_get_geometry() returns the content position. Subtract the border, clamped to the layout edges.
save196 · 2026-09-15 · 4fd683c
查看变更
dwl.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/dwl.c b/dwl.c
index e07a269..26fb3a0 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1919,6 +1919,11 @@ mapnotify(struct wl_listener *listener, void *data)
 			WLR_EDGE_RIGHT);
 	c->geom.width += 2 * c->bw;
 	c->geom.height += 2 * c->bw;
+	if (client_is_x11(c)) {
+		int x = c->geom.x - (int)c->bw, y = c->geom.y - (int)c->bw;
+		c->geom.x = c->geom.x < sgeom.x ? x : MAX(x, sgeom.x);
+		c->geom.y = c->geom.y < sgeom.y ? y : MAX(y, sgeom.y);
+	}
 
 	/* Insert this client into client lists. */
 	wl_list_insert(&clients, &c->link);
refactor focusclient()Guido Cella · 2026-09-28 · d29259c
查看变更
dwl.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/dwl.c b/dwl.c
index 3e94fa2..e07a269 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1517,7 +1517,7 @@ dirtomon(enum wlr_direction dir)
 void
 focusclient(Client *c, LayerSurface *l, int lift)
 {
-	struct wlr_surface *old = seat->keyboard_state.focused_surface;
+	struct wlr_surface *surface, *old = seat->keyboard_state.focused_surface;
 	int unused_lx, unused_ly, old_client_type;
 	Client *old_c = NULL;
 	LayerSurface *old_l = NULL;
@@ -1573,30 +1573,22 @@ focusclient(Client *c, LayerSurface *l, int lift)
 	}
 	printstatus();
 
-	if (l) {
-		/* Focus a layer surface and let the input method follow it */
-		input_method_relay_set_focus(input_method_relay, l->layer_surface->surface);
-		client_notify_enter(l->layer_surface->surface, wlr_seat_get_keyboard(seat));
-		return;
-	}
-
-	if (!c) {
+	if (!c && !l) {
 		/* With no client, all we have left is to clear focus */
 		input_method_relay_set_focus(input_method_relay, NULL);
 		wlr_seat_keyboard_notify_clear_focus(seat);
 		return;
 	}
 
-	/* Change cursor surface */
-	motionnotify(0, NULL, 0, 0, 0, 0);
+	surface = c ? client_surface(c) : l->layer_surface->surface;
+	input_method_relay_set_focus(input_method_relay, surface);
+	client_notify_enter(surface, wlr_seat_get_keyboard(seat));
 
-	input_method_relay_set_focus(input_method_relay, client_surface(c));
-
-	/* Have a client, so focus its top-level wlr_surface */
-	client_notify_enter(client_surface(c), wlr_seat_get_keyboard(seat));
+	if (l)
+		return;
 
-	/* Activate the new client */
-	client_activate_surface(client_surface(c), 1);
+	client_activate_surface(surface, 1);
+	motionnotify(0, NULL, 0, 0, 0, 0);
 
 	if (!client_is_unmanaged(c))
 		focused_client = c;
remove obsolete comment
No longer accurate since a514a92.
Guido Cella · 2026-09-28 · fccce97
查看变更
dwl.c | 1 -
 1 file changed, 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index cca1ea4..3e94fa2 100644
--- a/dwl.c
+++ b/dwl.c
@@ -642,7 +642,6 @@ arrangelayers(Monitor *m)
 					l->layer_surface->current.keyboard_interactive != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE ||
 					!l->mapped)
 				continue;
-			/* Deactivate the focused client. */
 			focusclient(NULL, l, 0);
 			return;
 		}
also make clients tiled on map
While making them tiled on the first commit was needed to fix Firefox starting with rounded corners, if you don't set them tiled again on map resizing mpv after starting it with a rule that makes it floating behaves wrong. Fixes d1ebf3c. Fixes https://codeberg.org/dwl/dwl/issues/1247.
Guido Cella · 2026-09-26 · d9ddaba
查看变更
dwl.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/dwl.c b/dwl.c
index ca97c30..cca1ea4 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1924,6 +1924,8 @@ mapnotify(struct wl_listener *listener, void *data)
 	}
 
 	/* 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;
 	c->geom.height += 2 * c->bw;
 
Revert "client: do not drop configure events based on current committed size"
This reverts commit 242ffd7a7521a74fc9edf68bcc7e6a3cd75ec860. Removing this conditon can cause a xdg_toplevel.configure ↔ wl_surface.commit loop that uses 100% CPU. Fixes https://codeberg.org/dwl/dwl/issues/1245 Fixes https://codeberg.org/dwl/dwl/issues/1246
Guido Cella · 2026-09-23 · f1675a4
查看变更
client.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/client.h b/client.h
index a6fe207..eb1bb47 100644
--- a/client.h
+++ b/client.h
@@ -376,7 +376,9 @@ client_set_size(Client *c, uint32_t width, uint32_t height)
 		return;
 	}
 #endif
-	wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
+	if ((int32_t)width != c->surface.xdg->toplevel->current.width
+			|| (int32_t)height != c->surface.xdg->toplevel->current.height)
+		wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
 }
 
 static inline void
add missing void
Needed to compile on OpenBSD.
Guido Cella · 2026-09-22 · a75ca79
查看变更
ime.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ime.h b/ime.h
index b9591f5..454a044 100644
--- a/ime.h
+++ b/ime.h
@@ -594,7 +594,7 @@ handle_focused_surface_destroy(struct wl_listener *listener,
 }
 
 struct input_method_relay *
-input_method_relay_create()
+input_method_relay_create(void)
 {
 	struct input_method_relay *relay = ecalloc(1, sizeof(*relay));
 	wl_list_init(&relay->text_inputs);
remove exclusive_focus variable
This is not needed because focusclient() already calls toplevel_from_wlr_surface(seat->keyboard_state.focused_surface) and can check if that should have exclusive focus. When it was added there was no function to get the focused layer shell surface in this way.
Guido Cella · 2026-09-22 · 87029e2
查看变更
dwl.c | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)
diff --git a/dwl.c b/dwl.c
index 7af9465..ca97c30 100644
--- a/dwl.c
+++ b/dwl.c
@@ -378,7 +378,6 @@ static void zoom(const Arg *arg);
 /* variables */
 static pid_t child_pid = -1;
 static int locked;
-static void *exclusive_focus;
 static Client *focused_client;
 static struct wl_display *dpy;
 static struct wl_event_loop *event_loop;
@@ -645,7 +644,6 @@ arrangelayers(Monitor *m)
 				continue;
 			/* Deactivate the focused client. */
 			focusclient(NULL, l, 0);
-			exclusive_focus = l;
 			return;
 		}
 	}
@@ -933,11 +931,6 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
 		return;
 	}
 
-	if (layer_surface == exclusive_focus
-			&& layer_surface->current.keyboard_interactive !=
-				ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
-		exclusive_focus = NULL;
-
 	if (layer_surface->current.committed == 0 && l->mapped == layer_surface->surface->mapped)
 		return;
 	l->mapped = layer_surface->surface->mapped;
@@ -1546,9 +1539,6 @@ focusclient(Client *c, LayerSurface *l, int lift)
 			wlr_xdg_popup_destroy(popup);
 	}
 
-	if (old_c && old_c == exclusive_focus && client_wants_focus(old_c))
-		exclusive_focus = NULL;
-
 	/* Put the new client atop the focus stack and select its monitor */
 	if (c && !client_is_unmanaged(c)) {
 		wl_list_remove(&c->flink);
@@ -1558,7 +1548,9 @@ focusclient(Client *c, LayerSurface *l, 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 (!(old_l && old_l->layer_surface->current.keyboard_interactive == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
+				&& !(old_c && client_wants_focus(old_c))
+				&& !seat->drag)
 			client_set_border_color(c, focuscolor);
 	}
 
@@ -1920,10 +1912,8 @@ mapnotify(struct wl_listener *listener, void *data)
 		/* Unmanaged clients always are floating */
 		wlr_scene_node_reparent(&c->scene->node, layers[LyrUnmanaged]);
 		wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
-		if (client_wants_focus(c)) {
+		if (client_wants_focus(c))
 			focusclient(c, NULL, 1);
-			exclusive_focus = c;
-		}
 		goto unset_fullscreen;
 	}
 
@@ -3001,8 +2991,6 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
 
 	l->mapped = 0;
 	wlr_scene_node_set_enabled(&l->scene->node, 0);
-	if (l == exclusive_focus)
-		exclusive_focus = NULL;
 	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)
@@ -3022,15 +3010,12 @@ unmapnotify(struct wl_listener *listener, void *data)
 	if (c == focused_client)
 		focused_client = NULL;
 
-	if (client_is_unmanaged(c)) {
-		if (c == exclusive_focus) {
-			exclusive_focus = NULL;
-			focusclient(focustop(selmon), NULL, 1);
-		}
-	} else {
+	if (!client_is_unmanaged(c)) {
 		wl_list_remove(&c->link);
 		setmon(c, NULL, 0);
 		wl_list_remove(&c->flink);
+	} else if (client_wants_focus(c)) {
+		focusclient(focustop(selmon), NULL, 1);
 	}
 
 	if (c->foreign_toplevel_handle) {
focusclient: set input method focus for layer surfaces
Focusing a layer surface only set the keyboard focus, not the text-input focus, so layer-shell clients (launchers, menus, ...) never received a text-input enter event and IME input didn't work. Pass the layer surface to focusclient() and set the input method focus there, like we already do for regular clients.
aloires · 2026-09-22 · a514a92
查看变更
dwl.c | 60 ++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 32 insertions(+), 28 deletions(-)
diff --git a/dwl.c b/dwl.c
index d009ef4..7af9465 100644
--- a/dwl.c
+++ b/dwl.c
@@ -305,7 +305,7 @@ 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 focusclient(Client *c, int lift);
+static void focusclient(Client *c, LayerSurface *l, int lift);
 static void focusmon(const Arg *arg);
 static void focusstack(const Arg *arg);
 static Client *focustop(Monitor *m);
@@ -644,9 +644,8 @@ arrangelayers(Monitor *m)
 					!l->mapped)
 				continue;
 			/* Deactivate the focused client. */
-			focusclient(NULL, 0);
+			focusclient(NULL, l, 0);
 			exclusive_focus = l;
-			client_notify_enter(l->layer_surface->surface, wlr_seat_get_keyboard(seat));
 			return;
 		}
 	}
@@ -709,10 +708,9 @@ buttonpress(struct wl_listener *listener, void *data)
 		   or a layer surface with on-demand keyboard interactivity */
 		xytonode(cursor->x, cursor->y, NULL, &c, &l, NULL, NULL);
 		if (c && (!client_is_unmanaged(c) || client_wants_focus(c))) {
-			focusclient(c, 1);
+			focusclient(c, NULL, 1);
 		} else if (l && l->layer_surface->current.keyboard_interactive) {
-			focusclient(NULL, 0);
-			client_notify_enter(l->layer_surface->surface, wlr_seat_get_keyboard(seat));
+			focusclient(NULL, l, 0);
 		}
 
 		keyboard = wlr_seat_get_keyboard(seat);
@@ -911,7 +909,7 @@ closemon(Monitor *m)
 		if (c->mon == m)
 			setmon(c, selmon, c->tags);
 	}
-	focusclient(focustop(selmon), 1);
+	focusclient(focustop(selmon), NULL, 1);
 	printstatus();
 }
 
@@ -1368,7 +1366,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), NULL, 1);
 	motionnotify(0, NULL, 0, 0, 0, 0);
 	wl_list_remove(&listener->link);
 	free(listener);
@@ -1407,7 +1405,7 @@ destroylock(SessionLock *lock, int unlock)
 
 	wlr_scene_node_set_enabled(&locked_bg->node, 0);
 
-	focusclient(focustop(selmon), 0);
+	focusclient(focustop(selmon), NULL, 0);
 	motionnotify(0, NULL, 0, 0, 0, 0);
 
 destroy:
@@ -1437,7 +1435,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), NULL, 1);
 	} else {
 		wlr_seat_keyboard_clear_focus(seat);
 	}
@@ -1525,7 +1523,7 @@ dirtomon(enum wlr_direction dir)
 }
 
 void
-focusclient(Client *c, int lift)
+focusclient(Client *c, LayerSurface *l, int lift)
 {
 	struct wlr_surface *old = seat->keyboard_state.focused_surface;
 	int unused_lx, unused_ly, old_client_type;
@@ -1567,7 +1565,7 @@ focusclient(Client *c, int lift)
 	/* If an overlay is focused, don't focus or activate the client,
 	 * but only update its position in fstack to render its border with focuscolor
 	 * and focus it after the overlay is closed. */
-	if (old && (!c || client_surface(c) != old)
+	if (!l && old && (!c || client_surface(c) != old)
 			&& old_client_type == LayerShell && wlr_scene_node_coords(
 				&old_l->scene->node, &unused_lx, &unused_ly)
 			&& old_l->layer_surface->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP
@@ -1584,6 +1582,13 @@ focusclient(Client *c, int lift)
 	}
 	printstatus();
 
+	if (l) {
+		/* Focus a layer surface and let the input method follow it */
+		input_method_relay_set_focus(input_method_relay, l->layer_surface->surface);
+		client_notify_enter(l->layer_surface->surface, wlr_seat_get_keyboard(seat));
+		return;
+	}
+
 	if (!c) {
 		/* With no client, all we have left is to clear focus */
 		input_method_relay_set_focus(input_method_relay, NULL);
@@ -1615,7 +1620,7 @@ focusmon(const Arg *arg)
 			selmon = dirtomon(arg->i);
 		while (!selmon->wlr_output->enabled && i++ < nmons);
 	}
-	focusclient(focustop(selmon), 1);
+	focusclient(focustop(selmon), NULL, 1);
 }
 
 void
@@ -1641,7 +1646,7 @@ focusstack(const Arg *arg)
 		}
 	}
 	/* If only one client is visible on selmon, then c == sel */
-	focusclient(c, 1);
+	focusclient(c, NULL, 1);
 }
 
 /* We probably should change the name of this: it sounds like it
@@ -1866,7 +1871,7 @@ locksession(struct wl_listener *listener, void *data)
 		return;
 	}
 	lock = session_lock->data = ecalloc(1, sizeof(*lock));
-	focusclient(NULL, 0);
+	focusclient(NULL, NULL, 0);
 
 	lock->scene = wlr_scene_tree_create(layers[LyrBlock]);
 	cur_lock = lock->lock = session_lock;
@@ -1916,7 +1921,7 @@ mapnotify(struct wl_listener *listener, void *data)
 		wlr_scene_node_reparent(&c->scene->node, layers[LyrUnmanaged]);
 		wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
 		if (client_wants_focus(c)) {
-			focusclient(c, 1);
+			focusclient(c, NULL, 1);
 			exclusive_focus = c;
 		}
 		goto unset_fullscreen;
@@ -2254,10 +2259,9 @@ pointerfocus(Client *c, LayerSurface *l, struct wlr_surface *surface, double sx,
 
 	if (surface != seat->pointer_state.focused_surface && sloppyfocus && time) {
 		if (c && (!client_is_unmanaged(c) || client_wants_focus(c))) {
-			focusclient(c, 0);
+			focusclient(c, NULL, 0);
 		} else if (l && l->layer_surface->current.keyboard_interactive) {
-			focusclient(NULL, 0);
-			client_notify_enter(l->layer_surface->surface, wlr_seat_get_keyboard(seat));
+			focusclient(NULL, l, 0);
 		}
 	}
 
@@ -2600,7 +2604,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), NULL, 1);
 }
 
 void
@@ -2892,7 +2896,7 @@ tag(const Arg *arg)
 		return;
 
 	sel->tags = arg->ui & TAGMASK;
-	focusclient(focustop(selmon), 1);
+	focusclient(focustop(selmon), NULL, 1);
 	arrange(selmon);
 	printstatus();
 }
@@ -2965,7 +2969,7 @@ toggletag(const Arg *arg)
 		return;
 
 	sel->tags = newtags;
-	focusclient(focustop(selmon), 1);
+	focusclient(focustop(selmon), NULL, 1);
 	arrange(selmon);
 	printstatus();
 }
@@ -2978,7 +2982,7 @@ toggleview(const Arg *arg)
 		return;
 
 	selmon->tagset[selmon->seltags] = newtagset;
-	focusclient(focustop(selmon), 1);
+	focusclient(focustop(selmon), NULL, 1);
 	arrange(selmon);
 	printstatus();
 }
@@ -3002,7 +3006,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), NULL, 1);
 	motionnotify(0, NULL, 0, 0, 0, 0);
 }
 
@@ -3021,7 +3025,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), NULL, 1);
 		}
 	} else {
 		wl_list_remove(&c->link);
@@ -3140,7 +3144,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), NULL, 1);
 		if (selmon->lock_surface) {
 			client_notify_enter(selmon->lock_surface->surface,
 					wlr_seat_get_keyboard(seat));
@@ -3199,7 +3203,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), NULL, 1);
 	arrange(selmon);
 	printstatus();
 }
@@ -3290,7 +3294,7 @@ zoom(const Arg *arg)
 	wl_list_remove(&sel->link);
 	wl_list_insert(&clients, &sel->link);
 
-	focusclient(sel, 1);
+	focusclient(sel, NULL, 1);
 	arrange(selmon);
 }
 
client: do not drop configure events based on current committed sizeAndré Desgualdo Pereira · 2026-09-21 · 242ffd7
查看变更
client.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/client.h b/client.h
index eb1bb47..a6fe207 100644
--- a/client.h
+++ b/client.h
@@ -376,9 +376,7 @@ client_set_size(Client *c, uint32_t width, uint32_t height)
 		return;
 	}
 #endif
-	if ((int32_t)width != c->surface.xdg->toplevel->current.width
-			|| (int32_t)height != c->surface.xdg->toplevel->current.height)
-		wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
+	wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
 }
 
 static inline void
don't run keybindings on keyrepeat while lockedsave196 · 2026-09-21 · f22c223
查看变更
dwl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index 15b0bb8..d009ef4 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1830,7 +1830,7 @@ int
 keyrepeat(void *data)
 {
 	KeyboardGroup *group = data;
-	if (group->wlr_group->keyboard.repeat_info.rate <= 0)
+	if (locked || group->wlr_group->keyboard.repeat_info.rate <= 0)
 		return 0;
 
 	wl_event_source_timer_update(group->key_repeat_source,
don't send pointer events to clients while lockedsave196 · 2026-09-15 · b83881f
查看变更
dwl.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index 12f8c8f..15b0bb8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -211,6 +211,7 @@ struct Monitor {
 	struct wl_listener frame;
 	struct wl_listener destroy;
 	struct wl_listener request_state;
+	struct wl_listener commit_lock_surface;
 	struct wl_listener destroy_lock_surface;
 	struct wlr_session_lock_surface_v1 *lock_surface;
 	struct wlr_box m; /* monitor area, layout-relative */
@@ -276,6 +277,7 @@ static void cleanupmon(struct wl_listener *listener, void *data);
 static void cleanuplisteners(void);
 static void closemon(Monitor *m);
 static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
+static void commitlocksurface(struct wl_listener *listener, void *data);
 static void commitnotify(struct wl_listener *listener, void *data);
 static void commitpopup(struct wl_listener *listener, void *data);
 static void createdecoration(struct wl_listener *listener, void *data);
@@ -953,6 +955,20 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
 	arrangelayers(l->mon);
 }
 
+void
+commitlocksurface(struct wl_listener *listener, void *data)
+{
+	Monitor *m = wl_container_of(listener, m, commit_lock_surface);
+
+	if (!m->lock_surface->surface->mapped)
+		return;
+
+	wl_list_remove(&m->commit_lock_surface.link);
+	wl_list_init(&m->commit_lock_surface.link);
+
+	motionnotify(0, NULL, 0, 0, 0, 0);
+}
+
 void
 commitnotify(struct wl_listener *listener, void *data)
 {
@@ -1130,6 +1146,7 @@ createlocksurface(struct wl_listener *listener, void *data)
 	wlr_session_lock_surface_v1_configure(lock_surface, m->m.width, m->m.height);
 
 	LISTEN(&lock_surface->events.destroy, &m->destroy_lock_surface, destroylocksurface);
+	LISTEN(&lock_surface->surface->events.commit, &m->commit_lock_surface, commitlocksurface);
 
 	if (m == selmon)
 		client_notify_enter(lock_surface->surface, wlr_seat_get_keyboard(seat));
@@ -1411,6 +1428,7 @@ destroylocksurface(struct wl_listener *listener, void *data)
 
 	m->lock_surface = NULL;
 	wl_list_remove(&m->destroy_lock_surface.link);
+	wl_list_remove(&m->commit_lock_surface.link);
 
 	if (lock_surface->surface != seat->keyboard_state.focused_surface)
 		return;
@@ -1854,6 +1872,12 @@ locksession(struct wl_listener *listener, void *data)
 	cur_lock = lock->lock = session_lock;
 	locked = 1;
 
+	/* Cancel any interactive move/resize and take the pointer focus away
+	 * from the clients below the lock screen */
+	cursor_mode = CurNormal;
+	grabc = NULL;
+	motionnotify(0, NULL, 0, 0, 0, 0);
+
 	LISTEN(&session_lock->events.new_surface, &lock->new_surface, createlocksurface);
 	LISTEN(&session_lock->events.destroy, &lock->destroy, destroysessionlock);
 	LISTEN(&session_lock->events.unlock, &lock->unlock, unlocksession);
@@ -3223,7 +3247,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
 	struct wlr_surface *surface = NULL;
 	int layer;
 
-	for (layer = NUM_LAYERS - 1; !surface && layer >= 0; layer--) {
+	for (layer = NUM_LAYERS - 1; !surface && layer >= (locked ? LyrBlock : 0); layer--) {
 		if (layer == LyrIMPopup ||
 				!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny)))
 			continue;
don't run axis bindings when lockedsave196 · 2026-09-20 · fa400c5
查看变更
dwl.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/dwl.c b/dwl.c
index 4cfd0fd..12f8c8f 100644
--- a/dwl.c
+++ b/dwl.c
@@ -663,16 +663,18 @@ axisnotify(struct wl_listener *listener, void *data)
 
 	wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
 
-	if (event->orientation == WL_POINTER_AXIS_VERTICAL_SCROLL)
-		adir = event->delta > 0 ? AxisDown : AxisUp;
-	else
-		adir = event->delta > 0 ? AxisRight : AxisLeft;
-	keyboard = wlr_seat_get_keyboard(seat);
-	mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
-	for (a = axes; a < END(axes); a++) {
-		if (CLEANMASK(mods) == CLEANMASK(a->mod) && adir == a->dir && a->func) {
-			a->func(&a->arg);
-			return;
+	if (!locked) {
+		if (event->orientation == WL_POINTER_AXIS_VERTICAL_SCROLL)
+			adir = event->delta > 0 ? AxisDown : AxisUp;
+		else
+			adir = event->delta > 0 ? AxisRight : AxisLeft;
+		keyboard = wlr_seat_get_keyboard(seat);
+		mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
+		for (a = axes; a < END(axes); a++) {
+			if (CLEANMASK(mods) == CLEANMASK(a->mod) && adir == a->dir && a->func) {
+				a->func(&a->arg);
+				return;
+			}
 		}
 	}
 
bind axis to nothing by defaultsave196 · 2026-09-20 · 40b0ae7
查看变更
config.def.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/config.def.h b/config.def.h
index 13c5322..a4019d3 100644
--- a/config.def.h
+++ b/config.def.h
@@ -172,6 +172,9 @@ static const Button buttons[] = {
 };
 
 static const Axis axes[] = {
+	/* example of volume control:
 	{ MODKEY, AxisUp,   spawn, SHCMD("volume-up_EXAMPLE") },
-	{ MODKEY, AxisDown, spawn, SHCMD("volume-down_EXAMPLE") },
+	{ MODKEY, AxisDown, spawn, SHCMD("volume-down_EXAMPLE") }, */
+	{ 0, 0, NULL, {0} },
+	/* does nothing, but the array cannot be empty */
 };
don't use the xdg window geometry offset as a position
It is the offset of the visible bounds inside the surface, which is not zero for clients that pad their surface or place subsurfaces outside it, so floating windows were mapped offset by their client side decorations.
save196 · 2026-09-15 · 2a56719
查看变更
client.h | 1 +
 1 file changed, 1 insertion(+)
diff --git a/client.h b/client.h
index dc0615e..eb1bb47 100644
--- a/client.h
+++ b/client.h
@@ -189,6 +189,7 @@ client_get_geometry(Client *c, struct wlr_box *geom)
 	}
 #endif
 	*geom = c->surface.xdg->geometry;
+	geom->x = geom->y = 0;
 }
 
 static inline Client *
bump version to 0.10-devGuido Cella · 2026-09-20 · cc23250
查看变更
config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config.mk b/config.mk
index ab5a3fd..0da079c 100644
--- a/config.mk
+++ b/config.mk
@@ -1,4 +1,4 @@
-_VERSION = 0.9-dev
+_VERSION = 0.10-dev
 VERSION  = `git describe --tags --dirty 2>/dev/null || echo $(_VERSION)`
 
 PKG_CONFIG = pkg-config
add version 0.9 to the changelogGuido Cella · 2026-09-20 · 98bea2c
查看变更
CHANGELOG.md | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9626255..bace46b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,11 +1,96 @@
 # Changelog
 
+* [0.9](#0.9)
 * [0.8](#0.8)
 * [0.7](#0.7)
 * [0.6](#0.6)
 * [0.5](#0.5)
 
 
+## 0.9
+
+### Added
+
+* Add axis mouse bindings ([#652][652])
+* Add support for the ext-data-control protocol ([#1184][1184])
+* Add support for the ext-foreign-toplevel-list protocol ([#1223][1223])
+* Add support for the ext-image-copy-capture and ext-image-capture-source protocols (screensharing) ([#1218][1218], [#1223][1223], [#1224][1224])
+* Add support for version 4 of the layer shell protocol (on-demand keyboard interactivity) ([#674][674])
+* Add support for wlr-text-input and wlr-input-method protocols (IME) ([#1219][1219])
+* Snap windows to edges when moving or resizing them ([#608][608])
+
+[1184]: https://codeberg.org/dwl/dwl/pulls/1184
+[1218]: https://codeberg.org/dwl/dwl/pulls/1218
+[1219]: https://codeberg.org/dwl/dwl/pulls/1219
+[1223]: https://codeberg.org/dwl/dwl/pulls/1223
+[1224]: https://codeberg.org/dwl/dwl/pulls/1224
+[608]: https://codeberg.org/dwl/dwl/pulls/608
+[652]: https://codeberg.org/dwl/dwl/pulls/652
+[674]: https://codeberg.org/dwl/dwl/pulls/674
+
+
+### Changed
+
+* Update wlroots to version 0.20 ([#1218][1218])
+* Use modifier-independent key symbols in config.h keybindings ([#1075][1075])
+
+[1075]: https://codeberg.org/dwl/dwl/pulls/1075
+[1218]: https://codeberg.org/dwl/dwl/pulls/1218
+
+
+### Fixed
+
+* Apply a minimum window size of 1x1 ([#1231][1231])
+* Close Xwayland submenus when changing tag or focus ([#1233][1233])
+* Don't make Firefox draw rounded corners when it is opened ([#d1ebf3c][d1ebf3c])
+* Don't send key release events to the wrong client ([#1108][1108])
+* Fix a crash when closing mpv ([#1220][1220])
+* Fix a crash when destroying an idle-inhibitor ([#1214][1214])
+* Fix choppy resizing on newer wlroots ([#1280][1280])
+* Fix the position of certain sub-menus in Xwayland applications ([#1232][1232])
+* Keep the focused border color on the regular client when opening a layer shell surface like wmenu ([#6013835][6013835])
+* Let keybindings focus and tag monitors above and below ([#5fd19fe][5fd19fe])
+* Preserve asleep disabled outputs in output config ([#1198][1198])
+* Respect size hints ([#4de32d2][4de32d2])
+* Set seat capabilities for virtual keyboards and pointers when there is no other input device ([#99cdc9a][99cdc9a])
+* Show popups in fullscreen Xwayland applications ([#1fe1b4e][1fe1b4e])
+* Show the correct cursor after moving and resizing ([#8ad2c92][8ad2c92])
+
+[1108]: https://codeberg.org/dwl/dwl/pulls/1108
+[1198]: https://codeberg.org/dwl/dwl/pulls/1198
+[1214]: https://codeberg.org/dwl/dwl/pulls/1214
+[1220]: https://codeberg.org/dwl/dwl/pulls/1220
+[1231]: https://codeberg.org/dwl/dwl/pulls/1231
+[1232]: https://codeberg.org/dwl/dwl/pulls/1232
+[1233]: https://codeberg.org/dwl/dwl/pulls/1233
+[1280]: https://codeberg.org/dwl/dwl/pulls/1280
+[1fe1b4e]: https://codeberg.org/dwl/dwl/commit/1fe1b4e
+[4de32d2]: https://codeberg.org/dwl/dwl/commit/4de32d2
+[5fd19fe]: https://codeberg.org/dwl/dwl/commit/5fd19fe
+[6013835]: https://codeberg.org/dwl/dwl/commit/6013835
+[8ad2c92]: https://codeberg.org/dwl/dwl/commit/8ad2c92
+[99cdc9a]: https://codeberg.org/dwl/dwl/commit/99cdc9a
+[d1ebf3c]: https://codeberg.org/dwl/dwl/commit/d1ebf3c
+
+
+### Contributors
+
+
+* A Frederick Christensen
+* Alex Denes
+* Andrea Chiavazza
+* Diego Viola
+* Guido Cella
+* Leonardo Hernández Hernández
+* Peter Hofmann
+* Siva Mahadevan
+* julmajustus
+* klim
+* save196
+* sewn
+* thanatos
+
+
 ## 0.8
 
 ### Added
change unreleased to 0.8 and update itGuido Cella · 2026-09-20 · 49837e9
查看变更
CHANGELOG.md | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 07c9ee4..9626255 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,12 +1,13 @@
 # Changelog
 
-* [Unreleased](#unreleased)
+* [0.8](#0.8)
 * [0.7](#0.7)
 * [0.6](#0.6)
 * [0.5](#0.5)
 
 
-## Unreleased
+## 0.8
+
 ### Added
 
 * Support for the linux-drm-syncobj-v1 protocol ([wlroots!4715][wlroots!4715], [#685][685])
@@ -17,15 +18,12 @@
 [646]: https://codeberg.org/dwl/dwl/pulls/646
 
 
-### Changed
-### Deprecated
-### Removed
 ### Fixed
 
 * Crash when a client is created while all outputs are disabled.
 
-### Security
-### Contributors
+
+Most changes in this release are not listed. See the commits for details.
 
 
 ## 0.7
Fix input_method_relay double allocation
- input_method_relay is allocated inside input_method_relay_create(), which leads the extra allocation to leak memory.
julmajustus · 2026-09-18 · d16036e
查看变更
dwl.c | 1 -
 1 file changed, 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index dada453..4cfd0fd 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2814,7 +2814,6 @@ setup(void)
 
 	input_method_manager = wlr_input_method_manager_v2_create(dpy);
 	text_input_manager = wlr_text_input_manager_v3_create(dpy);
-	input_method_relay = ecalloc(1, sizeof(*input_method_relay));
 	input_method_relay = input_method_relay_create();
 
 	/* Make sure XWayland clients don't connect to the parent X server,
always apply a minimum size of 1x1
Resizing with the mouse can make the size negative, which makes dwl crash, and the minimum is 1 because 0 makes some X11 clients crash.
save196 · 2026-09-17 · 45054a3
查看变更
dwl.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/dwl.c b/dwl.c
index 0e90c8f..dada453 100644
--- a/dwl.c
+++ b/dwl.c
@@ -488,6 +488,10 @@ static struct wlr_xwayland *xwayland;
 void
 applybounds(Client *c, struct wlr_box *bbox)
 {
+	/* set minimum client size to 1 */
+	c->geom.width = MAX(1 + 2 * (int)c->bw, c->geom.width);
+	c->geom.height = MAX(1 + 2 * (int)c->bw, c->geom.height);
+
 	if (!c->isfullscreen) {
 		struct wlr_box min = {0}, max = {0};
 		client_get_size_hints(c, &max, &min);
let the focus leave an unmanaged surface
Unmanaged clients spawned by a parent window, like menus, would not close if the user changed workspace or focused another client while the menu was selected, because the parent was never told that it lost the focus. This remembers the last managed client and deactivates it on a focus change, so that it closes the menu itself. This also fixes a regression introduced by f6e3a28, where menus would close immediately after being opened.
save196 · 2026-09-15 · 669b26d
查看变更
dwl.c | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/dwl.c b/dwl.c
index c51e0d5..0e90c8f 100644
--- a/dwl.c
+++ b/dwl.c
@@ -377,6 +377,7 @@ static void zoom(const Arg *arg);
 static pid_t child_pid = -1;
 static int locked;
 static void *exclusive_focus;
+static Client *focused_client;
 static struct wl_display *dpy;
 static struct wl_event_loop *event_loop;
 static struct wlr_backend *backend;
@@ -1523,6 +1524,9 @@ focusclient(Client *c, int lift)
 			wlr_xdg_popup_destroy(popup);
 	}
 
+	if (old_c && old_c == exclusive_focus && client_wants_focus(old_c))
+		exclusive_focus = NULL;
+
 	/* Put the new client atop the focus stack and select its monitor */
 	if (c && !client_is_unmanaged(c)) {
 		wl_list_remove(&c->flink);
@@ -1536,24 +1540,23 @@ focusclient(Client *c, int lift)
 			client_set_border_color(c, focuscolor);
 	}
 
-	/* Deactivate old client if focus is changing */
-	if (old && (!c || client_surface(c) != old)) {
-		/* If an overlay is focused, don't focus or activate the client,
-		 * but only update its position in fstack to render its border with focuscolor
-		 * 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)
-				&& old_l->layer_surface->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP
-				&& old_l->layer_surface->current.keyboard_interactive == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE) {
-			return;
-		} else if (old_c && old_c == exclusive_focus && client_wants_focus(old_c)) {
-			return;
-		} else if (old_c && !client_is_unmanaged(old_c)) {
-			if (c && !client_is_unmanaged(c))
-				client_set_border_color(old_c, bordercolor);
+	/* If an overlay is focused, don't focus or activate the client,
+	 * but only update its position in fstack to render its border with focuscolor
+	 * and focus it after the overlay is closed. */
+	if (old && (!c || client_surface(c) != old)
+			&& old_client_type == LayerShell && wlr_scene_node_coords(
+				&old_l->scene->node, &unused_lx, &unused_ly)
+			&& old_l->layer_surface->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP
+			&& old_l->layer_surface->current.keyboard_interactive == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
+		return;
 
-			client_activate_surface(old, 0);
-		}
+	if (focused_client && focused_client != c && !(c && client_is_unmanaged(c))) {
+		struct wlr_surface *s = client_surface(focused_client);
+		if (c)
+			client_set_border_color(focused_client, bordercolor);
+		if (s && s->mapped)
+			client_activate_surface(s, 0);
+		focused_client = NULL;
 	}
 	printstatus();
 
@@ -1574,6 +1577,9 @@ focusclient(Client *c, int lift)
 
 	/* Activate the new client */
 	client_activate_surface(client_surface(c), 1);
+
+	if (!client_is_unmanaged(c))
+		focused_client = c;
 }
 
 void
@@ -2980,6 +2986,8 @@ unmapnotify(struct wl_listener *listener, void *data)
 		cursor_mode = CurNormal;
 		grabc = NULL;
 	}
+	if (c == focused_client)
+		focused_client = NULL;
 
 	if (client_is_unmanaged(c)) {
 		if (c == exclusive_focus) {
follow the geometry of unmanaged clients and fix formattingsave196 · 2026-09-15 · e451862
查看变更
dwl.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/dwl.c b/dwl.c
index 70c76a3..c51e0d5 100644
--- a/dwl.c
+++ b/dwl.c
@@ -153,6 +153,7 @@ typedef struct {
 	struct wl_listener associate;
 	struct wl_listener dissociate;
 	struct wl_listener configure;
+	struct wl_listener set_geometry;
 	struct wl_listener set_hints;
 #endif
 	unsigned int bw;
@@ -466,6 +467,7 @@ static void associatex11(struct wl_listener *listener, void *data);
 static void configurex11(struct wl_listener *listener, void *data);
 static void createnotifyx11(struct wl_listener *listener, void *data);
 static void dissociatex11(struct wl_listener *listener, void *data);
+static void setgeometryx11(struct wl_listener *listener, void *data);
 static void sethints(struct wl_listener *listener, void *data);
 static void xwaylandready(struct wl_listener *listener, void *data);
 static struct wl_listener new_xwayland_surface = {.notify = createnotifyx11};
@@ -549,9 +551,9 @@ arrange(Monitor *m)
 	wl_list_for_each(c, &clients, link) {
 		if (c->mon == m) {
 			wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m));
-			client_set_suspended(c, !VISIBLEON(c, m) &&
-					(!c->image_capture_source ||
-					wl_list_empty(&c->image_capture_source->resources)));
+			client_set_suspended(c, !VISIBLEON(c, m)
+					&& (!c->image_capture_source
+					|| wl_list_empty(&c->image_capture_source->resources)));
 		}
 	}
 
@@ -1430,6 +1432,7 @@ destroynotify(struct wl_listener *listener, void *data)
 		wl_list_remove(&c->associate.link);
 		wl_list_remove(&c->configure.link);
 		wl_list_remove(&c->dissociate.link);
+		wl_list_remove(&c->set_geometry.link);
 		wl_list_remove(&c->set_hints.link);
 	} else
 #endif
@@ -1876,7 +1879,6 @@ mapnotify(struct wl_listener *listener, void *data)
 		/* Unmanaged clients always are floating */
 		wlr_scene_node_reparent(&c->scene->node, layers[LyrUnmanaged]);
 		wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
-		client_set_size(c, c->geom.width, c->geom.height);
 		if (client_wants_focus(c)) {
 			focusclient(c, 1);
 			exclusive_focus = c;
@@ -3280,13 +3282,8 @@ configurex11(struct wl_listener *listener, void *data)
 {
 	Client *c = wl_container_of(listener, c, configure);
 	struct wlr_xwayland_surface_configure_event *event = data;
-	if (!client_surface(c) || !client_surface(c)->mapped) {
-		wlr_xwayland_surface_configure(c->surface.xwayland,
-				event->x, event->y, event->width, event->height);
-		return;
-	}
-	if (client_is_unmanaged(c)) {
-		wlr_scene_node_set_position(&c->scene->node, event->x, event->y);
+	if (!client_surface(c) || !client_surface(c)->mapped
+			|| client_is_unmanaged(c)) {
 		wlr_xwayland_surface_configure(c->surface.xwayland,
 				event->x, event->y, event->width, event->height);
 		return;
@@ -3319,6 +3316,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
 	LISTEN(&xsurface->events.request_activate, &c->activate, activatex11);
 	LISTEN(&xsurface->events.request_configure, &c->configure, configurex11);
 	LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify);
+	LISTEN(&xsurface->events.set_geometry, &c->set_geometry, setgeometryx11);
 	LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints);
 	LISTEN(&xsurface->events.set_title, &c->set_title, updatetitle);
 }
@@ -3331,6 +3329,19 @@ dissociatex11(struct wl_listener *listener, void *data)
 	wl_list_remove(&c->unmap.link);
 }
 
+void
+setgeometryx11(struct wl_listener *listener, void *data)
+{
+	Client *c = wl_container_of(listener, c, set_geometry);
+
+	if (!client_is_unmanaged(c) || !client_surface(c)
+			|| !client_surface(c)->mapped)
+		return;
+
+	client_get_geometry(c, &c->geom);
+	wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
+}
+
 void
 sethints(struct wl_listener *listener, void *data)
 {
fix capturing hidden toplevelssave196 · 2026-09-15 · b3223b1
查看变更
dwl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index f7bda0b..70c76a3 100644
--- a/dwl.c
+++ b/dwl.c
@@ -549,7 +549,9 @@ arrange(Monitor *m)
 	wl_list_for_each(c, &clients, link) {
 		if (c->mon == m) {
 			wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m));
-			client_set_suspended(c, !VISIBLEON(c, m));
+			client_set_suspended(c, !VISIBLEON(c, m) &&
+					(!c->image_capture_source ||
+					wl_list_empty(&c->image_capture_source->resources)));
 		}
 	}
 
@@ -749,6 +751,8 @@ capturerequest(struct wl_listener *listener, void *data)
 
 	wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept(
 		request, view->image_capture_source);
+
+	client_set_suspended(view, 0);
 }
 
 void
@@ -2998,6 +3002,8 @@ unmapnotify(struct wl_listener *listener, void *data)
 #endif
 
 	wlr_scene_node_destroy(&c->image_capture_scene->tree.node);
+	c->image_capture_scene = NULL;
+	c->image_capture_source = NULL;
 	wlr_scene_node_destroy(&c->scene->node);
 	client_surface(c)->data = NULL;
 	printstatus();
show popups in fullscreen Xwayland apps
The dialogs opened by clicking items in Xwyland applications' toolbars are unmanaged clients, so placing them in LyrFloat drew them below their source client in LyrFS when it is fullscreened. Add a new dedicated layer for unamanged clients to fix it. Don't put them in LyrFS to prevent the regular fullscreen client from hiding unmanaged ones, e.g. by opening dmenu and then clicking the regular client. Fixes https://codeberg.org/dwl/dwl/issues/556
Guido Cella · 2026-09-16 · 1fe1b4e
查看变更
dwl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dwl.c b/dwl.c
index 156660f..f7bda0b 100644
--- a/dwl.c
+++ b/dwl.c
@@ -88,7 +88,8 @@
 /* enums */
 enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
 enum { XDGShell, LayerShell, X11 }; /* client types */
-enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
+enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
+	LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
 enum { AxisUp, AxisRight, AxisDown, AxisLeft };
 
 typedef union {
@@ -1869,7 +1870,7 @@ mapnotify(struct wl_listener *listener, void *data)
 	/* Handle unmanaged clients first so we can return prior create borders */
 	if (client_is_unmanaged(c)) {
 		/* Unmanaged clients always are floating */
-		wlr_scene_node_reparent(&c->scene->node, layers[LyrFloat]);
+		wlr_scene_node_reparent(&c->scene->node, layers[LyrUnmanaged]);
 		wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
 		client_set_size(c, c->geom.width, c->geom.height);
 		if (client_wants_focus(c)) {
size hints can be -1Guido Cella · 2026-09-16 · 1dae5ba
查看变更
client.h | 4 ++--
 dwl.c    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/client.h b/client.h
index 5d76b13..dc0615e 100644
--- a/client.h
+++ b/client.h
@@ -248,12 +248,12 @@ client_is_float_type(Client *c)
 			return 1;
 		}
 
-		return min.width && min.height &&
+		return min.width > 0 && min.height > 0 &&
 			(min.width == max.width || min.height == max.height);
 	}
 #endif
 
-	return c->surface.xdg->toplevel->parent || (min.width && min.height &&
+	return c->surface.xdg->toplevel->parent || (min.width > 0 && min.height > 0 &&
 			(min.width == max.width || min.height == max.height));
 }
 
diff --git a/dwl.c b/dwl.c
index a2418d0..156660f 100644
--- a/dwl.c
+++ b/dwl.c
@@ -491,9 +491,9 @@ applybounds(Client *c, struct wlr_box *bbox)
 		c->geom.height = MAX(min.height + 2 * (int)c->bw, c->geom.height);
 		/* Some clients set their max size to INT_MAX, which does not violate the
 		 * protocol but it's unnecesary, as they can set their max size to zero. */
-		if (max.width && 2 * (int)c->bw <= INT_MAX - max.width) /* Checks for overflow */
+		if (max.width > 0 && 2 * (int)c->bw <= INT_MAX - max.width) /* Checks for overflow */
 			c->geom.width = MIN(max.width + 2 * (int)c->bw, c->geom.width);
-		if (max.height && 2 * (int)c->bw <= INT_MAX - max.height) /* Checks for overflow */
+		if (max.height > 0 && 2 * (int)c->bw <= INT_MAX - max.height) /* Checks for overflow */
 			c->geom.height = MIN(max.height + 2 * (int)c->bw, c->geom.height);
 	}
 
fix a use-after-free
Prevent a use-after-free when closing a nested dwl with Ctrl+c. It happened because cleanup() → input_method_relay_finish() frees input_method_relay, and then closemon() → focusclient() → input_method_relay_set_focus() uses relay->surface.
Guido Cella · 2026-09-15 · 433c325
查看变更
dwl.c | 1 +
 ime.h | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index 63996a2..a2418d0 100644
--- a/dwl.c
+++ b/dwl.c
@@ -792,6 +792,7 @@ cleanup(void)
 	destroykeyboardgroup(&kb_group->destroy, NULL);
 
 	input_method_relay_finish(input_method_relay);
+	input_method_relay = NULL;
 
 	/* 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 */
diff --git a/ime.h b/ime.h
index f537a2d..b9591f5 100644
--- a/ime.h
+++ b/ime.h
@@ -625,7 +625,7 @@ void
 input_method_relay_set_focus(struct input_method_relay *relay,
 		struct wlr_surface *surface)
 {
-	if (relay->focused_surface == surface)
+	if (!relay || relay->focused_surface == surface)
 		return;
 
 	if (relay->focused_surface)
keep the focused border color of the old client in certain cases
When focusing an unmanaged client (like dmenu) or a layer shell surface (like wmenu) keep the focused border color of the regular client, but still deactivate it. This is consistent with dwm and sway. This was already done for unmanaged clients but not for layer shell surfaces. This is not perfect because you can press MODKEY+j/k or move the cursor while a program like dmenu is focused and have 2 clients with focused border color after closing dmenu. But this doesn't work well even in sway where if you change focus while dmenu is open you can longer focus it, and after closing a layer shell surface with on-demand keyboard interactivity all toplevels have the focused border color, so this will do for now.
Guido Cella · 2026-09-15 · 6013835
查看变更
dwl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index 190235d..63996a2 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1540,7 +1540,8 @@ focusclient(Client *c, int lift)
 		} else if (old_c && old_c == exclusive_focus && client_wants_focus(old_c)) {
 			return;
 		} else if (old_c && !client_is_unmanaged(old_c)) {
-			client_set_border_color(old_c, bordercolor);
+			if (c && !client_is_unmanaged(c))
+				client_set_border_color(old_c, bordercolor);
 
 			client_activate_surface(old, 0);
 		}
deactivate the old client when the new one wants focus
I see no issue with winecfg after removing this condition, so I assume it was fixed upstream.
Guido Cella · 2026-09-15 · f6e3a28
查看变更
dwl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/dwl.c b/dwl.c
index 8dbb4a0..190235d 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1539,9 +1539,7 @@ focusclient(Client *c, int lift)
 			return;
 		} else if (old_c && old_c == exclusive_focus && client_wants_focus(old_c)) {
 			return;
-		/* 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))) {
+		} else if (old_c && !client_is_unmanaged(old_c)) {
 			client_set_border_color(old_c, bordercolor);
 
 			client_activate_surface(old, 0);
Reapply "use modifier-independent key symbols in keybindings"
This reverts commit 0f8630282d11e21b694dcd4716a3935a4ead6fa5.
Guido Cella · 2026-09-15 · aa0c165
查看变更
config.def.h | 35 +++++++++++++++++------------------
 dwl.c        | 44 ++++++++++++++++++--------------------------
 util.h       | 12 ++++++++++++
 3 files changed, 47 insertions(+), 44 deletions(-)
diff --git a/config.def.h b/config.def.h
index 7ba41e0..13c5322 100644
--- a/config.def.h
+++ b/config.def.h
@@ -106,11 +106,11 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
 /* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
 #define MODKEY WLR_MODIFIER_ALT
 
-#define TAGKEYS(KEY,SKEY,TAG) \
+#define TAGKEYS(KEY,TAG) \
 	{ MODKEY,                    KEY,            view,            {.ui = 1 << TAG} }, \
 	{ MODKEY|WLR_MODIFIER_CTRL,  KEY,            toggleview,      {.ui = 1 << TAG} }, \
-	{ MODKEY|WLR_MODIFIER_SHIFT, SKEY,           tag,             {.ui = 1 << TAG} }, \
-	{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }
+	{ MODKEY|WLR_MODIFIER_SHIFT, KEY,            tag,             {.ui = 1 << TAG} }, \
+	{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,KEY,toggletag,  {.ui = 1 << TAG} }
 
 /* helper for spawning shell commands in the pre dwm-5.0 fashion */
 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
@@ -120,7 +120,6 @@ static const char *termcmd[] = { "foot", NULL };
 static const char *menucmd[] = { "wmenu-run", NULL };
 
 static const Key keys[] = {
-	/* Note that Shift changes certain key codes: 2 -> at, etc. */
 	/* modifier                  key                  function          argument */
 	{ MODKEY,                    XKB_KEY_p,           spawn,            {.v = menucmd} },
 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return,      spawn,            {.v = termcmd} },
@@ -140,28 +139,28 @@ static const Key keys[] = {
 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space,       togglefloating,   {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|WLR_MODIFIER_SHIFT, XKB_KEY_0,           tag,              {.ui = ~0} },
 	{ MODKEY,                    XKB_KEY_comma,       focusmon,         {.i = WLR_DIRECTION_LEFT} },
 	{ 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} },
-	TAGKEYS(          XKB_KEY_1, XKB_KEY_exclam,                        0),
-	TAGKEYS(          XKB_KEY_2, XKB_KEY_at,                            1),
-	TAGKEYS(          XKB_KEY_3, XKB_KEY_numbersign,                    2),
-	TAGKEYS(          XKB_KEY_4, XKB_KEY_dollar,                        3),
-	TAGKEYS(          XKB_KEY_5, XKB_KEY_percent,                       4),
-	TAGKEYS(          XKB_KEY_6, XKB_KEY_asciicircum,                   5),
-	TAGKEYS(          XKB_KEY_7, XKB_KEY_ampersand,                     6),
-	TAGKEYS(          XKB_KEY_8, XKB_KEY_asterisk,                      7),
-	TAGKEYS(          XKB_KEY_9, XKB_KEY_parenleft,                     8),
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_comma,       tagmon,           {.i = WLR_DIRECTION_LEFT} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_period,      tagmon,           {.i = WLR_DIRECTION_RIGHT} },
+	TAGKEYS(                     XKB_KEY_1,           0),
+	TAGKEYS(                     XKB_KEY_2,           1),
+	TAGKEYS(                     XKB_KEY_3,           2),
+	TAGKEYS(                     XKB_KEY_4,           3),
+	TAGKEYS(                     XKB_KEY_5,           4),
+	TAGKEYS(                     XKB_KEY_6,           5),
+	TAGKEYS(                     XKB_KEY_7,           6),
+	TAGKEYS(                     XKB_KEY_8,           7),
+	TAGKEYS(                     XKB_KEY_9,           8),
 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_q,           quit,             {0} },
 
 	/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
-	{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
+	{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_BackSpace, quit, {0} },
 	/* Ctrl-Alt-Fx is used to switch to another VT, if you don't know what a VT is
 	 * do not remove them.
 	 */
-#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} }
+#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_F##n, chvt, {.ui = (n)} }
 	CHVT(1), CHVT(2), CHVT(3), CHVT(4), CHVT(5), CHVT(6),
 	CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12),
 };
diff --git a/dwl.c b/dwl.c
index d18d1f8..8dbb4a0 100644
--- a/dwl.c
+++ b/dwl.c
@@ -170,9 +170,8 @@ typedef struct {
 	struct wlr_keyboard_group *wlr_group;
 	struct wlr_keyboard *virtual_keyboard;
 
-	int nsyms;
-	const xkb_keysym_t *keysyms; /* invalid if nsyms == 0 */
-	uint32_t mods; /* invalid if nsyms == 0 */
+	xkb_keysym_t keysyms[2];
+	uint32_t mods;
 	struct wl_event_source *key_repeat_source;
 
 	struct wl_listener modifiers;
@@ -1711,11 +1710,8 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
 	 */
 	const Key *k;
 	for (k = keys; k < END(keys); k++) {
-		if (CLEANMASK(mods) == CLEANMASK(k->mod)
-				&& xkb_keysym_to_lower(sym) == xkb_keysym_to_lower(k->keysym)
-				&& k->func) {
+		if (CLEANMASK(mods) == CLEANMASK(k->mod) && sym == k->keysym && k->func)
 			return k;
-		}
 	}
 	return NULL;
 }
@@ -1723,28 +1719,30 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
 void
 keypress(struct wl_listener *listener, void *data)
 {
-	int i;
 	/* 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;
 
 	/* 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);
-
+	struct wlr_keyboard *kb = &group->wlr_group->keyboard;
+	xkb_layout_index_t layout = xkb_state_key_get_layout(kb->xkb_state, keycode);
 	int handled = 0;
-	uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
+
+	// Get the keysyms for level 0 (normal) and level 1 (shifted)
+	// Only one keysym for each level:
+	// multiple keysyms per keycode don't really exist in the real world
+	for (int i = 0; i < 2; i++)
+		group->keysyms[i] = keymap_get_one_sym_by_level(kb->keymap, keycode, layout, i);
+	group->mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
 
 	wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
 
 	/* On _press_ if there is no active screen locker,
 	 * attempt to process a compositor keybinding. */
 	if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
-		for (i = 0; i < nsyms; i++) {
-			const Key *key = keybinding(mods, syms[i]);
+		for (int i = 0; i < 2; i++) {
+			const Key *key = keybinding(group->mods, group->keysyms[i]);
 			if (key) {
 				consumed[event->keycode] = 1;
 				key->func(&key->arg);
@@ -1754,16 +1752,11 @@ keypress(struct wl_listener *listener, void *data)
 		}
 	}
 
-	if (handled && group->wlr_group->keyboard.repeat_info.delay > 0) {
-		group->mods = mods;
-		group->keysyms = syms;
-		group->nsyms = nsyms;
+	if (handled && group->wlr_group->keyboard.repeat_info.delay > 0)
 		wl_event_source_timer_update(group->key_repeat_source,
 				group->wlr_group->keyboard.repeat_info.delay);
-	} else {
-		group->nsyms = 0;
+	else
 		wl_event_source_timer_update(group->key_repeat_source, 0);
-	}
 
 	if (handled || input_method_keyboard_grab_forward_key(group, event))
 		return;
@@ -1799,14 +1792,13 @@ int
 keyrepeat(void *data)
 {
 	KeyboardGroup *group = data;
-	int i;
-	if (!group->nsyms || group->wlr_group->keyboard.repeat_info.rate <= 0)
+	if (group->wlr_group->keyboard.repeat_info.rate <= 0)
 		return 0;
 
 	wl_event_source_timer_update(group->key_repeat_source,
 			1000 / group->wlr_group->keyboard.repeat_info.rate);
 
-	for (i = 0; i < group->nsyms; i++) {
+	for (int i = 0; i < 2; i++) {
 		const Key *key = keybinding(group->mods, group->keysyms[i]);
 		if (key) {
 			key->func(&key->arg);
diff --git a/util.h b/util.h
index 40cfbe4..4aaf208 100644
--- a/util.h
+++ b/util.h
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
+#include <xkbcommon/xkbcommon.h>
 
 #define MAX(A, B)               ((A) > (B) ? (A) : (B))
 #define MIN(A, B)               ((A) < (B) ? (A) : (B))
@@ -13,6 +14,8 @@
 static void die(const char *fmt, ...);
 static void *ecalloc(size_t nmemb, size_t size);
 static int fd_set_nonblock(int fd);
+xkb_keysym_t keymap_get_one_sym_by_level(struct xkb_keymap *keymap,
+        xkb_keycode_t key, xkb_layout_index_t layout, xkb_level_index_t level);
 
 void
 die(const char *fmt, ...) {
@@ -56,3 +59,12 @@ fd_set_nonblock(int fd) {
 
 	return 0;
 }
+
+xkb_keysym_t
+keymap_get_one_sym_by_level(struct xkb_keymap *keymap, xkb_keycode_t key,
+        xkb_layout_index_t layout, xkb_level_index_t level)
+{
+    const xkb_keysym_t *syms;
+    int count = xkb_keymap_key_get_syms_by_level(keymap, key, layout, level, &syms);
+    return count ? syms[0] : XKB_KEY_NoSymbol;
+}
don't run keybindings twice when the shift keysym is the same
For keys like F1-F12 the keysym with the shift is the same as without. Avoid running keybindings bound to these keys twice.
Guido Cella · 2026-09-15 · bab3fda
查看变更
dwl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index 7994e41..d18d1f8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1749,6 +1749,7 @@ keypress(struct wl_listener *listener, void *data)
 				consumed[event->keycode] = 1;
 				key->func(&key->arg);
 				handled = 1;
+				break;
 			}
 		}
 	}
@@ -1807,8 +1808,10 @@ keyrepeat(void *data)
 
 	for (i = 0; i < group->nsyms; i++) {
 		const Key *key = keybinding(group->mods, group->keysyms[i]);
-		if (key)
+		if (key) {
 			key->func(&key->arg);
+			break;
+		}
 	}
 
 	return 0;
Revert "use modifier-independent key symbols in keybindings"
This reverts commit f9c644f0b07a408e3b6a1389b1ffbd90dcaf4285.
Guido Cella · 2026-09-15 · 0f86302
查看变更
config.def.h | 35 ++++++++++++++++++-----------------
 dwl.c        | 44 ++++++++++++++++++++++++++------------------
 util.h       | 12 ------------
 3 files changed, 44 insertions(+), 47 deletions(-)
diff --git a/config.def.h b/config.def.h
index 13c5322..7ba41e0 100644
--- a/config.def.h
+++ b/config.def.h
@@ -106,11 +106,11 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
 /* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
 #define MODKEY WLR_MODIFIER_ALT
 
-#define TAGKEYS(KEY,TAG) \
+#define TAGKEYS(KEY,SKEY,TAG) \
 	{ MODKEY,                    KEY,            view,            {.ui = 1 << TAG} }, \
 	{ MODKEY|WLR_MODIFIER_CTRL,  KEY,            toggleview,      {.ui = 1 << TAG} }, \
-	{ MODKEY|WLR_MODIFIER_SHIFT, KEY,            tag,             {.ui = 1 << TAG} }, \
-	{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,KEY,toggletag,  {.ui = 1 << TAG} }
+	{ MODKEY|WLR_MODIFIER_SHIFT, SKEY,           tag,             {.ui = 1 << TAG} }, \
+	{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }
 
 /* helper for spawning shell commands in the pre dwm-5.0 fashion */
 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
@@ -120,6 +120,7 @@ static const char *termcmd[] = { "foot", NULL };
 static const char *menucmd[] = { "wmenu-run", NULL };
 
 static const Key keys[] = {
+	/* Note that Shift changes certain key codes: 2 -> at, etc. */
 	/* modifier                  key                  function          argument */
 	{ MODKEY,                    XKB_KEY_p,           spawn,            {.v = menucmd} },
 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return,      spawn,            {.v = termcmd} },
@@ -139,28 +140,28 @@ static const Key keys[] = {
 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space,       togglefloating,   {0} },
 	{ MODKEY,                    XKB_KEY_e,           togglefullscreen, {0} },
 	{ MODKEY,                    XKB_KEY_0,           view,             {.ui = ~0} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_0,           tag,              {.ui = ~0} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright,  tag,              {.ui = ~0} },
 	{ MODKEY,                    XKB_KEY_comma,       focusmon,         {.i = WLR_DIRECTION_LEFT} },
 	{ MODKEY,                    XKB_KEY_period,      focusmon,         {.i = WLR_DIRECTION_RIGHT} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_comma,       tagmon,           {.i = WLR_DIRECTION_LEFT} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_period,      tagmon,           {.i = WLR_DIRECTION_RIGHT} },
-	TAGKEYS(                     XKB_KEY_1,           0),
-	TAGKEYS(                     XKB_KEY_2,           1),
-	TAGKEYS(                     XKB_KEY_3,           2),
-	TAGKEYS(                     XKB_KEY_4,           3),
-	TAGKEYS(                     XKB_KEY_5,           4),
-	TAGKEYS(                     XKB_KEY_6,           5),
-	TAGKEYS(                     XKB_KEY_7,           6),
-	TAGKEYS(                     XKB_KEY_8,           7),
-	TAGKEYS(                     XKB_KEY_9,           8),
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less,        tagmon,           {.i = WLR_DIRECTION_LEFT} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater,     tagmon,           {.i = WLR_DIRECTION_RIGHT} },
+	TAGKEYS(          XKB_KEY_1, XKB_KEY_exclam,                        0),
+	TAGKEYS(          XKB_KEY_2, XKB_KEY_at,                            1),
+	TAGKEYS(          XKB_KEY_3, XKB_KEY_numbersign,                    2),
+	TAGKEYS(          XKB_KEY_4, XKB_KEY_dollar,                        3),
+	TAGKEYS(          XKB_KEY_5, XKB_KEY_percent,                       4),
+	TAGKEYS(          XKB_KEY_6, XKB_KEY_asciicircum,                   5),
+	TAGKEYS(          XKB_KEY_7, XKB_KEY_ampersand,                     6),
+	TAGKEYS(          XKB_KEY_8, XKB_KEY_asterisk,                      7),
+	TAGKEYS(          XKB_KEY_9, XKB_KEY_parenleft,                     8),
 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_q,           quit,             {0} },
 
 	/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
-	{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_BackSpace, quit, {0} },
+	{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
 	/* Ctrl-Alt-Fx is used to switch to another VT, if you don't know what a VT is
 	 * do not remove them.
 	 */
-#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_F##n, chvt, {.ui = (n)} }
+#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} }
 	CHVT(1), CHVT(2), CHVT(3), CHVT(4), CHVT(5), CHVT(6),
 	CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12),
 };
diff --git a/dwl.c b/dwl.c
index f9ea272..7994e41 100644
--- a/dwl.c
+++ b/dwl.c
@@ -170,8 +170,9 @@ typedef struct {
 	struct wlr_keyboard_group *wlr_group;
 	struct wlr_keyboard *virtual_keyboard;
 
-	xkb_keysym_t keysyms[2];
-	uint32_t mods;
+	int nsyms;
+	const xkb_keysym_t *keysyms; /* invalid if nsyms == 0 */
+	uint32_t mods; /* invalid if nsyms == 0 */
 	struct wl_event_source *key_repeat_source;
 
 	struct wl_listener modifiers;
@@ -1710,8 +1711,11 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
 	 */
 	const Key *k;
 	for (k = keys; k < END(keys); k++) {
-		if (CLEANMASK(mods) == CLEANMASK(k->mod) && sym == k->keysym && k->func)
+		if (CLEANMASK(mods) == CLEANMASK(k->mod)
+				&& xkb_keysym_to_lower(sym) == xkb_keysym_to_lower(k->keysym)
+				&& k->func) {
 			return k;
+		}
 	}
 	return NULL;
 }
@@ -1719,30 +1723,28 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
 void
 keypress(struct wl_listener *listener, void *data)
 {
+	int i;
 	/* 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;
 
 	/* Translate libinput keycode -> xkbcommon */
 	uint32_t keycode = event->keycode + 8;
-	struct wlr_keyboard *kb = &group->wlr_group->keyboard;
-	xkb_layout_index_t layout = xkb_state_key_get_layout(kb->xkb_state, keycode);
-	int handled = 0;
+	/* 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);
 
-	// Get the keysyms for level 0 (normal) and level 1 (shifted)
-	// Only one keysym for each level:
-	// multiple keysyms per keycode don't really exist in the real world
-	for (int i = 0; i < 2; i++)
-		group->keysyms[i] = keymap_get_one_sym_by_level(kb->keymap, keycode, layout, i);
-	group->mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
+	int handled = 0;
+	uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
 
 	wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
 
 	/* On _press_ if there is no active screen locker,
 	 * attempt to process a compositor keybinding. */
 	if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
-		for (int i = 0; i < 2; i++) {
-			const Key *key = keybinding(group->mods, group->keysyms[i]);
+		for (i = 0; i < nsyms; i++) {
+			const Key *key = keybinding(mods, syms[i]);
 			if (key) {
 				consumed[event->keycode] = 1;
 				key->func(&key->arg);
@@ -1751,11 +1753,16 @@ keypress(struct wl_listener *listener, void *data)
 		}
 	}
 
-	if (handled && group->wlr_group->keyboard.repeat_info.delay > 0)
+	if (handled && group->wlr_group->keyboard.repeat_info.delay > 0) {
+		group->mods = mods;
+		group->keysyms = syms;
+		group->nsyms = nsyms;
 		wl_event_source_timer_update(group->key_repeat_source,
 				group->wlr_group->keyboard.repeat_info.delay);
-	else
+	} else {
+		group->nsyms = 0;
 		wl_event_source_timer_update(group->key_repeat_source, 0);
+	}
 
 	if (handled || input_method_keyboard_grab_forward_key(group, event))
 		return;
@@ -1791,13 +1798,14 @@ int
 keyrepeat(void *data)
 {
 	KeyboardGroup *group = data;
-	if (group->wlr_group->keyboard.repeat_info.rate <= 0)
+	int i;
+	if (!group->nsyms || group->wlr_group->keyboard.repeat_info.rate <= 0)
 		return 0;
 
 	wl_event_source_timer_update(group->key_repeat_source,
 			1000 / group->wlr_group->keyboard.repeat_info.rate);
 
-	for (int i = 0; i < 2; i++) {
+	for (i = 0; i < group->nsyms; i++) {
 		const Key *key = keybinding(group->mods, group->keysyms[i]);
 		if (key)
 			key->func(&key->arg);
diff --git a/util.h b/util.h
index 4aaf208..40cfbe4 100644
--- a/util.h
+++ b/util.h
@@ -4,7 +4,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
-#include <xkbcommon/xkbcommon.h>
 
 #define MAX(A, B)               ((A) > (B) ? (A) : (B))
 #define MIN(A, B)               ((A) < (B) ? (A) : (B))
@@ -14,8 +13,6 @@
 static void die(const char *fmt, ...);
 static void *ecalloc(size_t nmemb, size_t size);
 static int fd_set_nonblock(int fd);
-xkb_keysym_t keymap_get_one_sym_by_level(struct xkb_keymap *keymap,
-        xkb_keycode_t key, xkb_layout_index_t layout, xkb_level_index_t level);
 
 void
 die(const char *fmt, ...) {
@@ -59,12 +56,3 @@ fd_set_nonblock(int fd) {
 
 	return 0;
 }
-
-xkb_keysym_t
-keymap_get_one_sym_by_level(struct xkb_keymap *keymap, xkb_keycode_t key,
-        xkb_layout_index_t layout, xkb_level_index_t level)
-{
-    const xkb_keysym_t *syms;
-    int count = xkb_keymap_key_get_syms_by_level(keymap, key, layout, level, &syms);
-    return count ? syms[0] : XKB_KEY_NoSymbol;
-}
Reapply "respect size hints"
This reverts commit 31bf1cbaf6418a6fb39e41b21cadc5c20826a663. Fixes https://codeberg.org/dwl/dwl/issues/105 Fixes https://codeberg.org/dwl/dwl/issues/634 Fixes https://codeberg.org/dwl/dwl/issues/1171
Guido Cella · 2026-09-15 · 4de32d2
查看变更
client.h | 43 ++++++++++++++++++++++++++++++++-----------
 dwl.c    | 16 +++++++++++++---
 2 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/client.h b/client.h
index a915f98..5d76b13 100644
--- a/client.h
+++ b/client.h
@@ -15,6 +15,32 @@ client_is_x11(Client *c)
 	return 0;
 }
 
+static inline void
+client_get_size_hints(Client *c, struct wlr_box *max, struct wlr_box *min)
+{
+	struct wlr_xdg_toplevel_state *state;
+
+#ifdef XWAYLAND
+	if (client_is_x11(c)) {
+		xcb_size_hints_t *size_hints = c->surface.xwayland->size_hints;
+		if (size_hints) {
+			max->width = size_hints->max_width;
+			max->height = size_hints->max_height;
+			min->width = size_hints->min_width;
+			min->height = size_hints->min_height;
+		}
+		return;
+	}
+#endif
+
+	state = &c->surface.xdg->toplevel->current;
+	max->width = state->max_width;
+	max->height = state->max_height;
+	min->width = state->min_width;
+	min->height = state->min_height;
+}
+
+
 static inline struct wlr_surface *
 client_surface(Client *c)
 {
@@ -206,13 +232,12 @@ client_get_title(Client *c)
 static inline int
 client_is_float_type(Client *c)
 {
-	struct wlr_xdg_toplevel *toplevel;
-	struct wlr_xdg_toplevel_state state;
+	struct wlr_box min = {0}, max = {0};
+	client_get_size_hints(c, &max, &min);
 
 #ifdef XWAYLAND
 	if (client_is_x11(c)) {
 		struct wlr_xwayland_surface *surface = c->surface.xwayland;
-		xcb_size_hints_t *size_hints = surface->size_hints;
 		if (surface->modal)
 			return 1;
 
@@ -223,17 +248,13 @@ client_is_float_type(Client *c)
 			return 1;
 		}
 
-		return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0
-			&& (size_hints->max_width == size_hints->min_width
-				|| size_hints->max_height == size_hints->min_height);
+		return min.width && min.height &&
+			(min.width == max.width || min.height == max.height);
 	}
 #endif
 
-	toplevel = c->surface.xdg->toplevel;
-	state = toplevel->current;
-	return toplevel->parent || (state.min_width != 0 && state.min_height != 0
-		&& (state.min_width == state.max_width
-			|| state.min_height == state.max_height));
+	return c->surface.xdg->toplevel->parent || (min.width && min.height &&
+			(min.width == max.width || min.height == max.height));
 }
 
 static inline int
diff --git a/dwl.c b/dwl.c
index 6636a4d..f9ea272 100644
--- a/dwl.c
+++ b/dwl.c
@@ -3,6 +3,7 @@
  */
 #include <getopt.h>
 #include <libinput.h>
+#include <limits.h>
 #include <linux/input-event-codes.h>
 #include <math.h>
 #include <signal.h>
@@ -483,9 +484,18 @@ static struct wlr_xwayland *xwayland;
 void
 applybounds(Client *c, struct wlr_box *bbox)
 {
-	/* set minimum possible */
-	c->geom.width = MAX(1 + 2 * (int)c->bw, c->geom.width);
-	c->geom.height = MAX(1 + 2 * (int)c->bw, c->geom.height);
+	if (!c->isfullscreen) {
+		struct wlr_box min = {0}, max = {0};
+		client_get_size_hints(c, &max, &min);
+		c->geom.width = MAX(min.width + 2 * (int)c->bw, c->geom.width);
+		c->geom.height = MAX(min.height + 2 * (int)c->bw, c->geom.height);
+		/* Some clients set their max size to INT_MAX, which does not violate the
+		 * protocol but it's unnecesary, as they can set their max size to zero. */
+		if (max.width && 2 * (int)c->bw <= INT_MAX - max.width) /* Checks for overflow */
+			c->geom.width = MIN(max.width + 2 * (int)c->bw, c->geom.width);
+		if (max.height && 2 * (int)c->bw <= INT_MAX - max.height) /* Checks for overflow */
+			c->geom.height = MIN(max.height + 2 * (int)c->bw, c->geom.height);
+	}
 
 	if (c->geom.x >= bbox->x + bbox->width)
 		c->geom.x = bbox->x + bbox->width - c->geom.width;
Revert "don't resize on commit"
This reverts commit 498a0e605cb0260f3a1d9c1ffc092b3041337033. Without resizing on every commit the top left of firefox is cropped.
Guido Cella · 2026-09-15 · 36c80af
查看变更
dwl.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/dwl.c b/dwl.c
index 44d57ab..6636a4d 100644
--- a/dwl.c
+++ b/dwl.c
@@ -956,6 +956,8 @@ commitnotify(struct wl_listener *listener, void *data)
 					WLR_EDGE_RIGHT);
 		return;
 	}
+
+	resize(c, c->geom, (c->isfloating && !c->isfullscreen));
 }
 
 void
Revert "reduce nesting in commitnotify()"
This reverts commit c824886b8ce6a249c608e3a04bf251e4b32206c1.
Guido Cella · 2026-09-15 · 68c6319
查看变更
dwl.c | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/dwl.c b/dwl.c
index bb010d8..44d57ab 100644
--- a/dwl.c
+++ b/dwl.c
@@ -933,28 +933,29 @@ commitnotify(struct wl_listener *listener, void *data)
 {
 	Client *c = wl_container_of(listener, c, commit);
 
-	if (!c->surface.xdg->initial_commit)
+	if (c->surface.xdg->initial_commit) {
+		/*
+		 * Get the monitor this client will be rendered on
+		 * Note that if the user set a rule in which the client is placed on
+		 * a different monitor based on its title, this will likely select
+		 * a wrong monitor.
+		 */
+		applyrules(c);
+		if (c->mon) {
+			client_set_scale(client_surface(c), c->mon->wlr_output->scale);
+		}
+		setmon(c, NULL, 0); /* Make sure to reapply rules in mapnotify() */
+
+		wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel,
+				WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);
+		if (c->decoration)
+			requestdecorationmode(&c->set_decoration_mode, c->decoration);
+		wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, 0, 0);
+		if (!c->isfloating)
+			client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
+					WLR_EDGE_RIGHT);
 		return;
-
-	/*
-	 * Get the monitor this client will be rendered on
-	 * Note that if the user set a rule in which the client is placed on
-	 * a different monitor based on its title, this will likely select
-	 * a wrong monitor.
-	 */
-	applyrules(c);
-	if (c->mon)
-		client_set_scale(client_surface(c), c->mon->wlr_output->scale);
-	setmon(c, NULL, 0); /* Make sure to reapply rules in mapnotify() */
-
-	wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel,
-			WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);
-	if (c->decoration)
-		requestdecorationmode(&c->set_decoration_mode, c->decoration);
-	wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, 0, 0);
-	if (!c->isfloating)
-		client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
-				WLR_EDGE_RIGHT);
+	}
 }
 
 void
reduce nesting in commitnotify()Guido Cella · 2026-09-15 · c824886
查看变更
dwl.c | 43 +++++++++++++++++++++----------------------
 1 file changed, 21 insertions(+), 22 deletions(-)
diff --git a/dwl.c b/dwl.c
index 44d57ab..bb010d8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -933,29 +933,28 @@ commitnotify(struct wl_listener *listener, void *data)
 {
 	Client *c = wl_container_of(listener, c, commit);
 
-	if (c->surface.xdg->initial_commit) {
-		/*
-		 * Get the monitor this client will be rendered on
-		 * Note that if the user set a rule in which the client is placed on
-		 * a different monitor based on its title, this will likely select
-		 * a wrong monitor.
-		 */
-		applyrules(c);
-		if (c->mon) {
-			client_set_scale(client_surface(c), c->mon->wlr_output->scale);
-		}
-		setmon(c, NULL, 0); /* Make sure to reapply rules in mapnotify() */
-
-		wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel,
-				WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);
-		if (c->decoration)
-			requestdecorationmode(&c->set_decoration_mode, c->decoration);
-		wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, 0, 0);
-		if (!c->isfloating)
-			client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
-					WLR_EDGE_RIGHT);
+	if (!c->surface.xdg->initial_commit)
 		return;
-	}
+
+	/*
+	 * Get the monitor this client will be rendered on
+	 * Note that if the user set a rule in which the client is placed on
+	 * a different monitor based on its title, this will likely select
+	 * a wrong monitor.
+	 */
+	applyrules(c);
+	if (c->mon)
+		client_set_scale(client_surface(c), c->mon->wlr_output->scale);
+	setmon(c, NULL, 0); /* Make sure to reapply rules in mapnotify() */
+
+	wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel,
+			WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);
+	if (c->decoration)
+		requestdecorationmode(&c->set_decoration_mode, c->decoration);
+	wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, 0, 0);
+	if (!c->isfloating)
+		client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
+				WLR_EDGE_RIGHT);
 }
 
 void
don't resize on commit
Fixes https://codeberg.org/dwl/dwl/issues/1229 Reverts 32e66f4 This could be called only on the initial_commit, but it was added to fix https://github.com/djpohly/dwl/issues/515 which I can't reproduce after removing it, so let's try to remove it completely.
Guido Cella · 2026-09-15 · 498a0e6
查看变更
dwl.c | 2 --
 1 file changed, 2 deletions(-)
diff --git a/dwl.c b/dwl.c
index 6636a4d..44d57ab 100644
--- a/dwl.c
+++ b/dwl.c
@@ -956,8 +956,6 @@ commitnotify(struct wl_listener *listener, void *data)
 					WLR_EDGE_RIGHT);
 		return;
 	}
-
-	resize(c, c->geom, (c->isfloating && !c->isfullscreen));
 }
 
 void
make client_set_size() return void
The return value is unused since the previous commit.
Guido Cella · 2026-09-15 · fec0699
查看变更
client.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/client.h b/client.h
index 75f1c27..a915f98 100644
--- a/client.h
+++ b/client.h
@@ -344,20 +344,19 @@ client_set_scale(struct wlr_surface *s, float scale)
 	wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale));
 }
 
-static inline uint32_t
+static inline void
 client_set_size(Client *c, uint32_t width, uint32_t height)
 {
 #ifdef XWAYLAND
 	if (client_is_x11(c)) {
 		wlr_xwayland_surface_configure(c->surface.xwayland,
 				c->geom.x + c->bw, c->geom.y + c->bw, width, height);
-		return 0;
+		return;
 	}
 #endif
-	if ((int32_t)width == c->surface.xdg->toplevel->current.width
-			&& (int32_t)height == c->surface.xdg->toplevel->current.height)
-		return 0;
-	return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
+	if ((int32_t)width != c->surface.xdg->toplevel->current.width
+			|| (int32_t)height != c->surface.xdg->toplevel->current.height)
+		wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
 }
 
 static inline void
remove c->resize
Unused since 70c33c0.
Guido Cella · 2026-09-15 · e7f185e
查看变更
dwl.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/dwl.c b/dwl.c
index f3abcf8..6636a4d 100644
--- a/dwl.c
+++ b/dwl.c
@@ -156,7 +156,6 @@ typedef struct {
 	unsigned int bw;
 	uint32_t tags;
 	int isfloating, isurgent, isfullscreen;
-	uint32_t resize; /* configure serial of a pending resize */
 } Client;
 
 typedef struct {
@@ -959,10 +958,6 @@ commitnotify(struct wl_listener *listener, void *data)
 	}
 
 	resize(c, c->geom, (c->isfloating && !c->isfullscreen));
-
-	/* mark a pending resize as completed */
-	if (c->resize && c->resize <= c->surface.xdg->current.configure_serial)
-		c->resize = 0;
 }
 
 void
@@ -2362,9 +2357,7 @@ resize(Client *c, struct wlr_box geo, int interact)
 	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);
 
-	/* this is a no-op if size hasn't changed */
-	c->resize = client_set_size(c, c->geom.width - 2 * c->bw,
-			c->geom.height - 2 * c->bw);
+	client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw);
 	client_get_clip(c, &clip);
 	wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
 }
use modifier-independent key symbols in keybindings
Co-authored-by: Guido Cella <guido@guidocella.xyz>
Andrea Chiavazza · 2026-09-14 · f9c644f
查看变更
config.def.h | 35 +++++++++++++++++------------------
 dwl.c        | 44 ++++++++++++++++++--------------------------
 util.h       | 12 ++++++++++++
 3 files changed, 47 insertions(+), 44 deletions(-)
diff --git a/config.def.h b/config.def.h
index 7ba41e0..13c5322 100644
--- a/config.def.h
+++ b/config.def.h
@@ -106,11 +106,11 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
 /* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
 #define MODKEY WLR_MODIFIER_ALT
 
-#define TAGKEYS(KEY,SKEY,TAG) \
+#define TAGKEYS(KEY,TAG) \
 	{ MODKEY,                    KEY,            view,            {.ui = 1 << TAG} }, \
 	{ MODKEY|WLR_MODIFIER_CTRL,  KEY,            toggleview,      {.ui = 1 << TAG} }, \
-	{ MODKEY|WLR_MODIFIER_SHIFT, SKEY,           tag,             {.ui = 1 << TAG} }, \
-	{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }
+	{ MODKEY|WLR_MODIFIER_SHIFT, KEY,            tag,             {.ui = 1 << TAG} }, \
+	{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,KEY,toggletag,  {.ui = 1 << TAG} }
 
 /* helper for spawning shell commands in the pre dwm-5.0 fashion */
 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
@@ -120,7 +120,6 @@ static const char *termcmd[] = { "foot", NULL };
 static const char *menucmd[] = { "wmenu-run", NULL };
 
 static const Key keys[] = {
-	/* Note that Shift changes certain key codes: 2 -> at, etc. */
 	/* modifier                  key                  function          argument */
 	{ MODKEY,                    XKB_KEY_p,           spawn,            {.v = menucmd} },
 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return,      spawn,            {.v = termcmd} },
@@ -140,28 +139,28 @@ static const Key keys[] = {
 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space,       togglefloating,   {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|WLR_MODIFIER_SHIFT, XKB_KEY_0,           tag,              {.ui = ~0} },
 	{ MODKEY,                    XKB_KEY_comma,       focusmon,         {.i = WLR_DIRECTION_LEFT} },
 	{ 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} },
-	TAGKEYS(          XKB_KEY_1, XKB_KEY_exclam,                        0),
-	TAGKEYS(          XKB_KEY_2, XKB_KEY_at,                            1),
-	TAGKEYS(          XKB_KEY_3, XKB_KEY_numbersign,                    2),
-	TAGKEYS(          XKB_KEY_4, XKB_KEY_dollar,                        3),
-	TAGKEYS(          XKB_KEY_5, XKB_KEY_percent,                       4),
-	TAGKEYS(          XKB_KEY_6, XKB_KEY_asciicircum,                   5),
-	TAGKEYS(          XKB_KEY_7, XKB_KEY_ampersand,                     6),
-	TAGKEYS(          XKB_KEY_8, XKB_KEY_asterisk,                      7),
-	TAGKEYS(          XKB_KEY_9, XKB_KEY_parenleft,                     8),
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_comma,       tagmon,           {.i = WLR_DIRECTION_LEFT} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_period,      tagmon,           {.i = WLR_DIRECTION_RIGHT} },
+	TAGKEYS(                     XKB_KEY_1,           0),
+	TAGKEYS(                     XKB_KEY_2,           1),
+	TAGKEYS(                     XKB_KEY_3,           2),
+	TAGKEYS(                     XKB_KEY_4,           3),
+	TAGKEYS(                     XKB_KEY_5,           4),
+	TAGKEYS(                     XKB_KEY_6,           5),
+	TAGKEYS(                     XKB_KEY_7,           6),
+	TAGKEYS(                     XKB_KEY_8,           7),
+	TAGKEYS(                     XKB_KEY_9,           8),
 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_q,           quit,             {0} },
 
 	/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
-	{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
+	{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_BackSpace, quit, {0} },
 	/* Ctrl-Alt-Fx is used to switch to another VT, if you don't know what a VT is
 	 * do not remove them.
 	 */
-#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} }
+#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_F##n, chvt, {.ui = (n)} }
 	CHVT(1), CHVT(2), CHVT(3), CHVT(4), CHVT(5), CHVT(6),
 	CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12),
 };
diff --git a/dwl.c b/dwl.c
index aead8eb..f3abcf8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -170,9 +170,8 @@ typedef struct {
 	struct wlr_keyboard_group *wlr_group;
 	struct wlr_keyboard *virtual_keyboard;
 
-	int nsyms;
-	const xkb_keysym_t *keysyms; /* invalid if nsyms == 0 */
-	uint32_t mods; /* invalid if nsyms == 0 */
+	xkb_keysym_t keysyms[2];
+	uint32_t mods;
 	struct wl_event_source *key_repeat_source;
 
 	struct wl_listener modifiers;
@@ -1706,11 +1705,8 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
 	 */
 	const Key *k;
 	for (k = keys; k < END(keys); k++) {
-		if (CLEANMASK(mods) == CLEANMASK(k->mod)
-				&& xkb_keysym_to_lower(sym) == xkb_keysym_to_lower(k->keysym)
-				&& k->func) {
+		if (CLEANMASK(mods) == CLEANMASK(k->mod) && sym == k->keysym && k->func)
 			return k;
-		}
 	}
 	return NULL;
 }
@@ -1718,28 +1714,30 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
 void
 keypress(struct wl_listener *listener, void *data)
 {
-	int i;
 	/* 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;
 
 	/* 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);
-
+	struct wlr_keyboard *kb = &group->wlr_group->keyboard;
+	xkb_layout_index_t layout = xkb_state_key_get_layout(kb->xkb_state, keycode);
 	int handled = 0;
-	uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
+
+	// Get the keysyms for level 0 (normal) and level 1 (shifted)
+	// Only one keysym for each level:
+	// multiple keysyms per keycode don't really exist in the real world
+	for (int i = 0; i < 2; i++)
+		group->keysyms[i] = keymap_get_one_sym_by_level(kb->keymap, keycode, layout, i);
+	group->mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
 
 	wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
 
 	/* On _press_ if there is no active screen locker,
 	 * attempt to process a compositor keybinding. */
 	if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
-		for (i = 0; i < nsyms; i++) {
-			const Key *key = keybinding(mods, syms[i]);
+		for (int i = 0; i < 2; i++) {
+			const Key *key = keybinding(group->mods, group->keysyms[i]);
 			if (key) {
 				consumed[event->keycode] = 1;
 				key->func(&key->arg);
@@ -1748,16 +1746,11 @@ keypress(struct wl_listener *listener, void *data)
 		}
 	}
 
-	if (handled && group->wlr_group->keyboard.repeat_info.delay > 0) {
-		group->mods = mods;
-		group->keysyms = syms;
-		group->nsyms = nsyms;
+	if (handled && group->wlr_group->keyboard.repeat_info.delay > 0)
 		wl_event_source_timer_update(group->key_repeat_source,
 				group->wlr_group->keyboard.repeat_info.delay);
-	} else {
-		group->nsyms = 0;
+	else
 		wl_event_source_timer_update(group->key_repeat_source, 0);
-	}
 
 	if (handled || input_method_keyboard_grab_forward_key(group, event))
 		return;
@@ -1793,14 +1786,13 @@ int
 keyrepeat(void *data)
 {
 	KeyboardGroup *group = data;
-	int i;
-	if (!group->nsyms || group->wlr_group->keyboard.repeat_info.rate <= 0)
+	if (group->wlr_group->keyboard.repeat_info.rate <= 0)
 		return 0;
 
 	wl_event_source_timer_update(group->key_repeat_source,
 			1000 / group->wlr_group->keyboard.repeat_info.rate);
 
-	for (i = 0; i < group->nsyms; i++) {
+	for (int i = 0; i < 2; i++) {
 		const Key *key = keybinding(group->mods, group->keysyms[i]);
 		if (key)
 			key->func(&key->arg);
diff --git a/util.h b/util.h
index 40cfbe4..4aaf208 100644
--- a/util.h
+++ b/util.h
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
+#include <xkbcommon/xkbcommon.h>
 
 #define MAX(A, B)               ((A) > (B) ? (A) : (B))
 #define MIN(A, B)               ((A) < (B) ? (A) : (B))
@@ -13,6 +14,8 @@
 static void die(const char *fmt, ...);
 static void *ecalloc(size_t nmemb, size_t size);
 static int fd_set_nonblock(int fd);
+xkb_keysym_t keymap_get_one_sym_by_level(struct xkb_keymap *keymap,
+        xkb_keycode_t key, xkb_layout_index_t layout, xkb_level_index_t level);
 
 void
 die(const char *fmt, ...) {
@@ -56,3 +59,12 @@ fd_set_nonblock(int fd) {
 
 	return 0;
 }
+
+xkb_keysym_t
+keymap_get_one_sym_by_level(struct xkb_keymap *keymap, xkb_keycode_t key,
+        xkb_layout_index_t layout, xkb_level_index_t level)
+{
+    const xkb_keysym_t *syms;
+    int count = xkb_keymap_key_get_syms_by_level(keymap, key, layout, level, &syms);
+    return count ? syms[0] : XKB_KEY_NoSymbol;
+}
use the new output swapchain manager in outputmgrapplyortest()Leonardo Hernández Hernández · 2026-09-14 · dc9a860
查看变更
dwl.c | 68 +++++++++++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 41 insertions(+), 27 deletions(-)
diff --git a/dwl.c b/dwl.c
index c0c617b..aead8eb 100644
--- a/dwl.c
+++ b/dwl.c
@@ -15,6 +15,7 @@
 #include <wlr/backend.h>
 #include <wlr/backend/libinput.h>
 #include <wlr/render/allocator.h>
+#include <wlr/render/swapchain.h>
 #include <wlr/render/wlr_renderer.h>
 #include <wlr/types/wlr_alpha_modifier_v1.h>
 #include <wlr/types/wlr_compositor.h>
@@ -42,6 +43,7 @@
 #include <wlr/types/wlr_output_layout.h>
 #include <wlr/types/wlr_output_management_v1.h>
 #include <wlr/types/wlr_output_power_management_v1.h>
+#include <wlr/types/wlr_output_swapchain_manager.h>
 #include <wlr/types/wlr_pointer.h>
 #include <wlr/types/wlr_pointer_constraints_v1.h>
 #include <wlr/types/wlr_presentation_time.h>
@@ -2129,49 +2131,61 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test)
 	 * output_layout.change event, not here.
 	 */
 	struct wlr_output_configuration_head_v1 *config_head;
-	int ok = 1;
+	size_t states_len, i;
+	struct wlr_output_swapchain_manager swapchain_manager;
+	struct wlr_backend_output_state *states =
+		wlr_output_configuration_v1_build_state(config, &states_len);
+	int ok = 0;
+
+	if (!states) {
+		wlr_output_configuration_v1_send_failed(config);
+		return;
+	}
+
+	wlr_output_swapchain_manager_init(&swapchain_manager, backend);
+
+	ok = wlr_output_swapchain_manager_prepare(&swapchain_manager, states, states_len);
+	if (!ok || test)
+		goto out;
+
+	for (i = 0; i < states_len; i++) {
+		struct wlr_swapchain *swapchain = wlr_output_swapchain_manager_get_swapchain(
+				&swapchain_manager, states[i].output);
+		if (swapchain && !states[i].output->enabled)
+			wlr_output_state_set_buffer(&states[i].base, wlr_swapchain_acquire(swapchain));
+	}
+
+	if (!(ok = wlr_backend_commit(backend, states, states_len)))
+		goto out;
+
+	wlr_output_swapchain_manager_apply(&swapchain_manager);
 
 	wl_list_for_each(config_head, &config->heads, link) {
 		struct wlr_output *wlr_output = config_head->state.output;
 		Monitor *m = wlr_output->data;
-		struct wlr_output_state state;
 
 		/* Ensure displays previously disabled by wlr-output-power-management-v1
 		 * are properly handled*/
 		m->asleep = 0;
 
-		wlr_output_state_init(&state);
-		wlr_output_state_set_enabled(&state, config_head->state.enabled);
-		if (!config_head->state.enabled)
-			goto apply_or_test;
-
-		if (config_head->state.mode)
-			wlr_output_state_set_mode(&state, config_head->state.mode);
-		else
-			wlr_output_state_set_custom_mode(&state,
-					config_head->state.custom_mode.width,
-					config_head->state.custom_mode.height,
-					config_head->state.custom_mode.refresh);
-
-		wlr_output_state_set_transform(&state, config_head->state.transform);
-		wlr_output_state_set_scale(&state, config_head->state.scale);
-		wlr_output_state_set_adaptive_sync_enabled(&state,
-				config_head->state.adaptive_sync_enabled);
-
-apply_or_test:
-		ok &= test ? wlr_output_test_state(wlr_output, &state)
-				: wlr_output_commit_state(wlr_output, &state);
-
 		/* Don't move monitors if position wouldn't change. This avoids
 		 * wlroots marking the output as manually configured.
 		 * wlr_output_layout_add does not like disabled outputs */
-		if (!test && wlr_output->enabled && (m->m.x != config_head->state.x || m->m.y != config_head->state.y))
+		if (config_head->state.enabled
+				&& (m->m.x != config_head->state.x || m->m.y != config_head->state.y
+					|| !wlr_output_layout_get(output_layout, wlr_output))) {
 			wlr_output_layout_add(output_layout, wlr_output,
 					config_head->state.x, config_head->state.y);
-
-		wlr_output_state_finish(&state);
+		}
 	}
 
+out:
+	wlr_output_swapchain_manager_finish(&swapchain_manager);
+	for (i = 0; i < states_len; i++)
+		wlr_output_state_finish(&states[i].base);
+
+	free(states);
+
 	if (ok)
 		wlr_output_configuration_v1_send_succeeded(config);
 	else
fix firefox opening with rounded corners
Fixes https://codeberg.org/dwl/dwl/issues/1169 The c->isfloating check is needed to have the correct floating window size with e.g. alacritty -o window.dimensions.columns=15 window.dimensions.lines=10.
Guido Cella · 2026-09-14 · d1ebf3c
查看变更
dwl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index 23bb3f6..c0c617b 100644
--- a/dwl.c
+++ b/dwl.c
@@ -951,6 +951,9 @@ commitnotify(struct wl_listener *listener, void *data)
 		if (c->decoration)
 			requestdecorationmode(&c->set_decoration_mode, c->decoration);
 		wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, 0, 0);
+		if (!c->isfloating)
+			client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
+					WLR_EDGE_RIGHT);
 		return;
 	}
 
@@ -1881,7 +1884,6 @@ mapnotify(struct wl_listener *listener, void *data)
 	}
 
 	/* 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;
 	c->geom.height += 2 * c->bw;
 
replicate dwm behavior for snap resizesewn · 2024-04-01 · 8f52e96
查看变更
config.def.h |  1 +
 dwl.c        | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/config.def.h b/config.def.h
index 572984b..7ba41e0 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 unsigned int snap             = 32; /* snap pixel */
 static const float rootcolor[]             = COLOR(0x222222ff);
 static const float bordercolor[]           = COLOR(0x444444ff);
 static const float focuscolor[]            = COLOR(0x005577ff);
diff --git a/dwl.c b/dwl.c
index f902ace..23bb3f6 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1981,6 +1981,7 @@ void
 motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
 		double dx_unaccel, double dy_unaccel)
 {
+	int nx, ny;
 	double sx = 0, sy = 0, sx_confined, sy_confined;
 	Client *c = NULL, *w = NULL;
 	LayerSurface *l = NULL, *focusedl = NULL;
@@ -2038,7 +2039,17 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
 	/* If we are currently grabbing the mouse, handle and return */
 	if (cursor_mode == CurMove) {
 		/* Move the grabbed client to the new position. */
-		resize(grabc, (struct wlr_box){.x = (int)round(cursor->x) - grabcx, .y = (int)round(cursor->y) - grabcy,
+		nx = (int)round(cursor->x) - grabcx;
+		ny = (int)round(cursor->y) - grabcy;
+		if (abs(selmon->w.x - nx) < (int)snap)
+			nx = selmon->w.x;
+		else if (abs((selmon->w.x + selmon->w.width) - (nx + grabc->geom.width)) < (int)snap)
+			nx = selmon->w.x + selmon->w.width - grabc->geom.width;
+		if (abs(selmon->w.y - ny) < (int)snap)
+			ny = selmon->w.y;
+		else if (abs((selmon->w.y + selmon->w.height) - (ny + grabc->geom.height)) < (int)snap)
+			ny = selmon->w.y + selmon->w.height - grabc->geom.height;
+		resize(grabc, (struct wlr_box){.x = nx, .y = ny,
 			.width = grabc->geom.width, .height = grabc->geom.height}, 1);
 		return;
 	} else if (cursor_mode == CurResize) {
support monitors above and below in focusmon and tagmon
Fixes https://codeberg.org/dwl/dwl/issues/1105
Guido Cella · 2026-09-13 · 5fd19fe
查看变更
dwl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index 7bffb83..f902ace 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1474,7 +1474,8 @@ dirtomon(enum wlr_direction dir)
 			dir, selmon->wlr_output, selmon->m.x, selmon->m.y)))
 		return next->data;
 	if ((next = wlr_output_layout_farthest_output(output_layout,
-			dir ^ (WLR_DIRECTION_LEFT|WLR_DIRECTION_RIGHT),
+			dir ^ (WLR_DIRECTION_LEFT | WLR_DIRECTION_RIGHT |
+					WLR_DIRECTION_UP | WLR_DIRECTION_DOWN),
 			selmon->wlr_output, selmon->m.x, selmon->m.y)))
 		return next->data;
 	return selmon;
remove zero flickering lie
This isn't true since dwl switched to the scene API in 2021 (1b38801). The issue is tracked at https://codeberg.org/dwl/dwl/issues/552.
Guido Cella · 2026-09-13 · b1c1015
查看变更
README.md | 1 -
 1 file changed, 1 deletion(-)
diff --git a/README.md b/README.md
index b8cddb4..fd72785 100644
--- a/README.md
+++ b/README.md
@@ -153,7 +153,6 @@ given the base on which it is built. Implemented default features are:
 - Support screen lockers via ext-session-lock-v1 protocol
 - Various Wayland protocols
 - XWayland support as provided by wlroots (can be enabled in `config.mk`)
-- Zero flickering - Wayland users naturally expect that "every frame is perfect"
 - Layer shell popups (used by Waybar)
 - Damage tracking provided by scenegraph API
 
use the right cursor after move and resize
Fixes https://codeberg.org/dwl/dwl/issues/1162 Co-authored-by: DreamMaoMao <2523610504@qq.com>
Guido Cella · 2026-09-13 · 8ad2c92
查看变更
dwl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dwl.c b/dwl.c
index 9e293b8..7bffb83 100644
--- a/dwl.c
+++ b/dwl.c
@@ -703,10 +703,11 @@ buttonpress(struct wl_listener *listener, void *data)
 		break;
 	case WL_POINTER_BUTTON_STATE_RELEASED:
 		/* If you released any buttons, we exit interactive move/resize mode. */
-		/* TODO: should reset to the pointer focus's current setcursor */
 		if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) {
-			wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
 			cursor_mode = CurNormal;
+			/* Update the cursor */
+			wlr_seat_pointer_clear_focus(seat);
+			motionnotify(0, NULL, 0, 0, 0, 0);
 			/* Drop the window off on its new monitor */
 			selmon = xytomon(cursor->x, cursor->y);
 			setmon(grabc, selmon, 0);
implement Axis mouse bindings
Co-authored-by: Guido Cella <guido@guidocella.xyz>
Peter Hofmann · 2026-09-13 · e8bf70d
查看变更
config.def.h |  5 +++++
 dwl.c        | 29 +++++++++++++++++++++++++++--
 2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..572984b 100644
--- a/config.def.h
+++ b/config.def.h
@@ -170,3 +170,8 @@ static const Button buttons[] = {
 	{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
 	{ MODKEY, BTN_RIGHT,  moveresize,     {.ui = CurResize} },
 };
+
+static const Axis axes[] = {
+	{ MODKEY, AxisUp,   spawn, SHCMD("volume-up_EXAMPLE") },
+	{ MODKEY, AxisDown, spawn, SHCMD("volume-down_EXAMPLE") },
+};
diff --git a/dwl.c b/dwl.c
index 0f36e58..9e293b8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -86,6 +86,7 @@
 enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
 enum { XDGShell, LayerShell, X11 }; /* client types */
 enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
+enum { AxisUp, AxisRight, AxisDown, AxisLeft };
 
 typedef union {
 	int i;
@@ -94,6 +95,13 @@ typedef union {
 	const void *v;
 } Arg;
 
+typedef struct {
+	unsigned int mod;
+	unsigned int dir;
+	void (*func)(const Arg *);
+	const Arg arg;
+} Axis;
+
 typedef struct {
 	unsigned int mod;
 	unsigned int button;
@@ -628,9 +636,26 @@ axisnotify(struct wl_listener *listener, void *data)
 	/* This event is forwarded by the cursor when a pointer emits an axis event,
 	 * for example when you move the scroll wheel. */
 	struct wlr_pointer_axis_event *event = data;
+	const Axis *a;
+	unsigned int adir;
+	struct wlr_keyboard *keyboard;
+	uint32_t mods;
+
 	wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
-	/* TODO: allow usage of scroll wheel for mousebindings, it can be implemented
-	 * by checking the event's orientation and the delta of the event */
+
+	if (event->orientation == WL_POINTER_AXIS_VERTICAL_SCROLL)
+		adir = event->delta > 0 ? AxisDown : AxisUp;
+	else
+		adir = event->delta > 0 ? AxisRight : AxisLeft;
+	keyboard = wlr_seat_get_keyboard(seat);
+	mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
+	for (a = axes; a < END(axes); a++) {
+		if (CLEANMASK(mods) == CLEANMASK(a->mod) && adir == a->dir && a->func) {
+			a->func(&a->arg);
+			return;
+		}
+	}
+
 	/* Notify the client with pointer focus of the axis event. */
 	wlr_seat_pointer_notify_axis(seat,
 			event->time_msec, event->orientation, event->delta,
set seat capabilities for virtual keyboards and pointers
wlr_seat_set_capabilities was never called without a real input device. Fixes https://codeberg.org/dwl/dwl/issues/1155. Co-authored-by: brinkpw
Guido Cella · 2026-09-13 · 99cdc9a
查看变更
dwl.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/dwl.c b/dwl.c
index 8d32c08..0f36e58 100644
--- a/dwl.c
+++ b/dwl.c
@@ -3119,6 +3119,7 @@ virtualkeyboard(struct wl_listener *listener, void *data)
 
 	/* Add the new keyboard to the group */
 	wlr_keyboard_group_add_keyboard(group->wlr_group, &kb->keyboard);
+	wlr_seat_set_capabilities(seat, seat->capabilities | WL_SEAT_CAPABILITY_KEYBOARD);
 }
 
 void
@@ -3130,6 +3131,7 @@ virtualpointer(struct wl_listener *listener, void *data)
 	wlr_cursor_attach_input_device(cursor, device);
 	if (event->suggested_output)
 		wlr_cursor_map_input_to_output(cursor, device, event->suggested_output);
+	wlr_seat_set_capabilities(seat, seat->capabilities | WL_SEAT_CAPABILITY_POINTER);
 }
 
 Monitor *
don't crash when clicking an empty area
If l is not initialized, accessing l->layer_surface->current.keyboard_interactive causes a segmentation fault. This was hard to see because c above was never initialized but never caused a crash, and dwl also didn't crash building with ASan. Also initialize c to be safe. Fixes 4c54bd8. Fixes https://codeberg.org/dwl/dwl/issues/1225.
Guido Cella · 2026-09-13 · 7ba3350
查看变更
dwl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dwl.c b/dwl.c
index fa8c8ae..8d32c08 100644
--- a/dwl.c
+++ b/dwl.c
@@ -643,8 +643,8 @@ buttonpress(struct wl_listener *listener, void *data)
 	struct wlr_pointer_button_event *event = data;
 	struct wlr_keyboard *keyboard;
 	uint32_t mods;
-	Client *c;
-	LayerSurface *l;
+	Client *c = NULL;
+	LayerSurface *l = NULL;
 	const Button *b;
 
 	wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
support screenshare of single windows
Supersedes https://codeberg.org/dwl/dwl/pulls/1157. Co-authored-by: Zuki Air <zukirust@gmail.com>
Guido Cella · 2026-09-12 · fb4102b
查看变更
dwl.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
diff --git a/dwl.c b/dwl.c
index bbd5b98..fa8c8ae 100644
--- a/dwl.c
+++ b/dwl.c
@@ -121,6 +121,12 @@ typedef struct {
 	} surface;
 	struct wlr_xdg_toplevel_decoration_v1 *decoration;
 	struct wlr_ext_foreign_toplevel_handle_v1 *foreign_toplevel_handle;
+	struct wlr_scene *image_capture_scene;
+	struct wlr_ext_image_capture_source_v1 *image_capture_source;
+	union {
+		struct wlr_scene_tree *image_capture_tree;
+		struct wlr_scene_surface *image_capture_scene_surface;
+	} capture;
 	struct wl_listener commit;
 	struct wl_listener map;
 	struct wl_listener maximize;
@@ -251,6 +257,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 capturerequest(struct wl_listener *listener, void *data);
 static void chvt(const Arg *arg);
 static void checkidleinhibitor(struct wlr_surface *exclude);
 static void cleanup(void);
@@ -386,6 +393,7 @@ 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;
 static struct wlr_ext_foreign_toplevel_list_v1 *foreign_toplevel_list;
+static struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1 *ext_foreign_toplevel_image_capture_source_manager_v1;
 
 static struct wlr_pointer_constraints_v1 *pointer_constraints;
 static struct wlr_relative_pointer_manager_v1 *relative_pointer_mgr;
@@ -440,6 +448,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 new_foreign_toplevel_capture_request = {.notify = capturerequest};
 
 #ifdef XWAYLAND
 static void activatex11(struct wl_listener *listener, void *data);
@@ -688,6 +697,23 @@ buttonpress(struct wl_listener *listener, void *data)
 			event->time_msec, event->button, event->state);
 }
 
+void
+capturerequest(struct wl_listener *listener, void *data)
+{
+	struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request *request = data;
+	Client *view = request->toplevel_handle->data;
+
+	if (!view->image_capture_source) {
+		view->image_capture_source = wlr_ext_image_capture_source_v1_create_with_scene_node(
+				&view->image_capture_scene->tree.node, event_loop, alloc, drw);
+		if (!view->image_capture_source)
+			return;
+	}
+
+	wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept(
+		request, view->image_capture_source);
+}
+
 void
 chvt(const Arg *arg)
 {
@@ -800,6 +826,7 @@ cleanuplisteners(void)
 	wl_list_remove(&request_start_drag.link);
 	wl_list_remove(&start_drag.link);
 	wl_list_remove(&new_session_lock.link);
+	wl_list_remove(&new_foreign_toplevel_capture_request.link);
 #ifdef XWAYLAND
 	wl_list_remove(&new_xwayland_surface.link);
 	wl_list_remove(&xwayland_ready.link);
@@ -1838,6 +1865,14 @@ mapnotify(struct wl_listener *listener, void *data)
 	c->foreign_toplevel_handle = wlr_ext_foreign_toplevel_handle_v1_create(
 			foreign_toplevel_list, &foreign_toplevel_state);
 	c->foreign_toplevel_handle->data = c;
+	c->image_capture_scene = wlr_scene_create();
+	if (c->type == XDGShell)
+		c->capture.image_capture_tree = wlr_scene_xdg_surface_create(&c->image_capture_scene->tree, c->surface.xdg);
+#ifdef XWAYLAND
+	else
+		c->capture.image_capture_scene_surface = wlr_scene_surface_create(&c->image_capture_scene->tree, c->surface.xwayland->surface);
+#endif
+
 
 	/* Set initial monitor, tags, floating status, and focus:
 	 * we always consider floating, clients that have parent and thus
@@ -2630,6 +2665,10 @@ setup(void)
 	wlr_scene_node_set_enabled(&locked_bg->node, 0);
 
 	foreign_toplevel_list = wlr_ext_foreign_toplevel_list_v1_create(dpy,1);
+	ext_foreign_toplevel_image_capture_source_manager_v1 =
+            wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create(dpy, 1);
+	wl_signal_add(&ext_foreign_toplevel_image_capture_source_manager_v1->events.new_request,
+			&new_foreign_toplevel_capture_request);
 
 	/* Use decoration protocols to negotiate server-side decorations */
 	wlr_server_decoration_manager_set_default_mode(
@@ -2898,6 +2937,14 @@ unmapnotify(struct wl_listener *listener, void *data)
 		wlr_ext_foreign_toplevel_handle_v1_destroy(c->foreign_toplevel_handle);
 		c->foreign_toplevel_handle = NULL;
 	}
+#ifdef XWAYLAND
+	if (c->type != XDGShell && c->capture.image_capture_scene_surface) {
+		wlr_scene_node_destroy(&c->capture.image_capture_scene_surface->buffer->node);
+		c->capture.image_capture_scene_surface = NULL;
+	}
+#endif
+
+	wlr_scene_node_destroy(&c->image_capture_scene->tree.node);
 	wlr_scene_node_destroy(&c->scene->node);
 	client_surface(c)->data = NULL;
 	printstatus();
implement ext-foreign-toplevel-list
This is used by lswt which lists toplevel ids and titles. keyd-application-mapper will also support it hopefully. This will also be needed to support screenshare of single windows (https://codeberg.org/dwl/dwl/pulls/1157). Co-authored-by: Zuki Air <zukirust@gmail.com>
Guido Cella · 2026-09-11 · 721f70e
查看变更
dwl.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
diff --git a/dwl.c b/dwl.c
index 0d10a22..bbd5b98 100644
--- a/dwl.c
+++ b/dwl.c
@@ -27,6 +27,7 @@
 #include <wlr/types/wlr_ext_data_control_v1.h>
 #include <wlr/types/wlr_ext_image_capture_source_v1.h>
 #include <wlr/types/wlr_ext_image_copy_capture_v1.h>
+#include <wlr/types/wlr_ext_foreign_toplevel_list_v1.h>
 #include <wlr/types/wlr_fractional_scale_v1.h>
 #include <wlr/types/wlr_gamma_control_v1.h>
 #include <wlr/types/wlr_idle_inhibit_v1.h>
@@ -119,6 +120,7 @@ typedef struct {
 		struct wlr_xwayland_surface *xwayland;
 	} surface;
 	struct wlr_xdg_toplevel_decoration_v1 *decoration;
+	struct wlr_ext_foreign_toplevel_handle_v1 *foreign_toplevel_handle;
 	struct wl_listener commit;
 	struct wl_listener map;
 	struct wl_listener maximize;
@@ -383,6 +385,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;
+static struct wlr_ext_foreign_toplevel_list_v1 *foreign_toplevel_list;
 
 static struct wlr_pointer_constraints_v1 *pointer_constraints;
 static struct wlr_relative_pointer_manager_v1 *relative_pointer_mgr;
@@ -1788,6 +1791,11 @@ mapnotify(struct wl_listener *listener, void *data)
 	Monitor *m;
 	int i;
 
+	struct wlr_ext_foreign_toplevel_handle_v1_state foreign_toplevel_state = {
+		.app_id = client_get_appid(c),
+		.title = client_get_title(c),
+	};
+
 	/* Create scene tree for this client and its border */
 	c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]);
 	/* Enabled later by a call to arrange() */
@@ -1827,6 +1835,10 @@ mapnotify(struct wl_listener *listener, void *data)
 	wl_list_insert(&clients, &c->link);
 	wl_list_insert(&fstack, &c->flink);
 
+	c->foreign_toplevel_handle = wlr_ext_foreign_toplevel_handle_v1_create(
+			foreign_toplevel_list, &foreign_toplevel_state);
+	c->foreign_toplevel_handle->data = c;
+
 	/* Set initial monitor, tags, floating status, and focus:
 	 * we always consider floating, clients that have parent and thus
 	 * we set the same tags and monitor as its parent.
@@ -2617,6 +2629,8 @@ setup(void)
 			(float [4]){0.1f, 0.1f, 0.1f, 1.0f});
 	wlr_scene_node_set_enabled(&locked_bg->node, 0);
 
+	foreign_toplevel_list = wlr_ext_foreign_toplevel_list_v1_create(dpy,1);
+
 	/* Use decoration protocols to negotiate server-side decorations */
 	wlr_server_decoration_manager_set_default_mode(
 			wlr_server_decoration_manager_create(dpy),
@@ -2880,6 +2894,10 @@ unmapnotify(struct wl_listener *listener, void *data)
 		wl_list_remove(&c->flink);
 	}
 
+	if (c->foreign_toplevel_handle) {
+		wlr_ext_foreign_toplevel_handle_v1_destroy(c->foreign_toplevel_handle);
+		c->foreign_toplevel_handle = NULL;
+	}
 	wlr_scene_node_destroy(&c->scene->node);
 	client_surface(c)->data = NULL;
 	printstatus();
@@ -3001,6 +3019,15 @@ updatetitle(struct wl_listener *listener, void *data)
 	Client *c = wl_container_of(listener, c, set_title);
 	if (c == focustop(c->mon))
 		printstatus();
+
+	if (c->foreign_toplevel_handle) {
+		struct wlr_ext_foreign_toplevel_handle_v1_state foreign_toplevel_state = {
+			.app_id = client_get_appid(c),
+			.title = client_get_title(c),
+		};
+		wlr_ext_foreign_toplevel_handle_v1_update_state(c->foreign_toplevel_handle,
+				&foreign_toplevel_state);
+	}
 }
 
 void
add support for layer-shell on-demand keyboard interactivity
Supersedes https://codeberg.org/dwl/dwl/pulls/674 Co-authored-by: Leonardo Hernández Hernández <leohdz172@proton.me> Co-authored-by: MayOrMayNotBeACat <maybeacat804@gmail.com>
Guido Cella · 2026-09-12 · 0a6dc6d
查看变更
dwl.c | 56 ++++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 38 insertions(+), 18 deletions(-)
diff --git a/dwl.c b/dwl.c
index 7b8e55a..0d10a22 100644
--- a/dwl.c
+++ b/dwl.c
@@ -309,7 +309,7 @@ static void moveresize(const Arg *arg);
 static void outputmgrapply(struct wl_listener *listener, void *data);
 static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test);
 static void outputmgrtest(struct wl_listener *listener, void *data);
-static void pointerfocus(Client *c, struct wlr_surface *surface,
+static void pointerfocus(Client *c, LayerSurface* l, struct wlr_surface *surface,
 		double sx, double sy, uint32_t time);
 static void printstatus(void);
 static void powermgrsetmode(struct wl_listener *listener, void *data);
@@ -593,10 +593,13 @@ arrangelayers(Monitor *m)
 	for (i = 3; i >= 0; i--)
 		arrangelayer(m, &m->layers[i], &usable_area, 0);
 
-	/* Find topmost keyboard interactive layer, if such a layer exists */
+	/* Find topmost keyboard interactive layer that has indicated it wants
+	 * exclusive access to the keyboard, if such a layer exists */
 	for (i = 0; i < (int)LENGTH(layers_above_shell); i++) {
 		wl_list_for_each_reverse(l, &m->layers[layers_above_shell[i]], link) {
-			if (locked || !l->layer_surface->current.keyboard_interactive || !l->mapped)
+			if (locked ||
+					l->layer_surface->current.keyboard_interactive != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE ||
+					!l->mapped)
 				continue;
 			/* Deactivate the focused client. */
 			focusclient(NULL, 0);
@@ -629,6 +632,7 @@ buttonpress(struct wl_listener *listener, void *data)
 	struct wlr_keyboard *keyboard;
 	uint32_t mods;
 	Client *c;
+	LayerSurface *l;
 	const Button *b;
 
 	wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@@ -640,10 +644,15 @@ buttonpress(struct wl_listener *listener, void *data)
 		if (locked)
 			break;
 
-		/* Change focus if the button was _pressed_ over a client */
-		xytonode(cursor->x, cursor->y, NULL, &c, NULL, NULL, NULL);
-		if (c && (!client_is_unmanaged(c) || client_wants_focus(c)))
+		/* Change focus if the button was _pressed_ over a client
+		   or a layer surface with on-demand keyboard interactivity */
+		xytonode(cursor->x, cursor->y, NULL, &c, &l, NULL, NULL);
+		if (c && (!client_is_unmanaged(c) || client_wants_focus(c))) {
 			focusclient(c, 1);
+		} else if (l && l->layer_surface->current.keyboard_interactive) {
+			focusclient(NULL, 0);
+			client_notify_enter(l->layer_surface->surface, wlr_seat_get_keyboard(seat));
+		}
 
 		keyboard = wlr_seat_get_keyboard(seat);
 		mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
@@ -843,6 +852,11 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
 		return;
 	}
 
+	if (layer_surface == exclusive_focus
+			&& layer_surface->current.keyboard_interactive !=
+				ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
+		exclusive_focus = NULL;
+
 	if (layer_surface->current.committed == 0 && l->mapped == layer_surface->surface->mapped)
 		return;
 	l->mapped = layer_surface->surface->mapped;
@@ -1454,7 +1468,8 @@ focusclient(Client *c, int lift)
 		 * 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)
-				&& old_l->layer_surface->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
+				&& old_l->layer_surface->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP
+				&& old_l->layer_surface->current.keyboard_interactive == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE) {
 			return;
 		} else if (old_c && old_c == exclusive_focus && client_wants_focus(old_c)) {
 			return;
@@ -1894,20 +1909,20 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
 {
 	double sx = 0, sy = 0, sx_confined, sy_confined;
 	Client *c = NULL, *w = NULL;
-	LayerSurface *l = NULL;
+	LayerSurface *l = NULL, *focusedl = NULL;
 	struct wlr_surface *surface = NULL;
 	struct wlr_pointer_constraint_v1 *constraint;
 
 	/* Find the client under the pointer and send the event along. */
-	xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy);
+	xytonode(cursor->x, cursor->y, &surface, &c, &l, &sx, &sy);
 
 	if (cursor_mode == CurPressed && !seat->drag
 			&& surface != seat->pointer_state.focused_surface
-			&& toplevel_from_wlr_surface(seat->pointer_state.focused_surface, &w, &l) >= 0) {
+			&& toplevel_from_wlr_surface(seat->pointer_state.focused_surface, &w, &focusedl) >= 0) {
 		c = w;
 		surface = seat->pointer_state.focused_surface;
-		sx = cursor->x - (l ? l->scene->node.x : w->geom.x);
-		sy = cursor->y - (l ? l->scene->node.y : w->geom.y);
+		sx = cursor->x - (focusedl ? focusedl->scene->node.x : w->geom.x);
+		sy = cursor->y - (focusedl ? focusedl->scene->node.y : w->geom.y);
 	}
 
 	/* time is 0 in internal calls meant to restore pointer focus. */
@@ -1964,7 +1979,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
 	if (!surface && !seat->drag)
 		wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
 
-	pointerfocus(c, surface, sx, sy, time);
+	pointerfocus(c, l, surface, sx, sy, time);
 }
 
 void
@@ -2088,14 +2103,19 @@ outputmgrtest(struct wl_listener *listener, void *data)
 }
 
 void
-pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
+pointerfocus(Client *c, LayerSurface *l, struct wlr_surface *surface, double sx, double sy,
 		uint32_t time)
 {
 	struct timespec now;
 
-	if (surface != seat->pointer_state.focused_surface &&
-			sloppyfocus && time && c && !client_is_unmanaged(c))
-		focusclient(c, 0);
+	if (surface != seat->pointer_state.focused_surface && sloppyfocus && time) {
+		if (c && (!client_is_unmanaged(c) || client_wants_focus(c))) {
+			focusclient(c, 0);
+		} else if (l && l->layer_surface->current.keyboard_interactive) {
+			focusclient(NULL, 0);
+			client_notify_enter(l->layer_surface->surface, wlr_seat_get_keyboard(seat));
+		}
+	}
 
 	/* If surface is NULL, clear pointer focus */
 	if (!surface) {
@@ -2583,7 +2603,7 @@ setup(void)
 	wl_signal_add(&xdg_shell->events.new_toplevel, &new_xdg_toplevel);
 	wl_signal_add(&xdg_shell->events.new_popup, &new_xdg_popup);
 
-	layer_shell = wlr_layer_shell_v1_create(dpy, 3);
+	layer_shell = wlr_layer_shell_v1_create(dpy, 4);
 	wl_signal_add(&layer_shell->events.new_surface, &new_layer_surface);
 
 	idle_notifier = wlr_idle_notifier_v1_create(dpy);
implement xytonode() with toplevel_from_wlr_surface()
xytonode() does not return the layer surface under the cursor because pnode->data is always NULL. It was not noticed because it is not passed the LayerSurface argument anywhere. But it is noticeable after implementing layer shell on-demand keyboard interactivity because layer shell surfaces are never focused by sloppyfocus. Rather than figuring out how to fix it, just replace its implementation with toplevel_from_wlr_surface() which works and also reduces the SLOC.
Guido Cella · 2026-09-11 · 4c54bd8
查看变更
dwl.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/dwl.c b/dwl.c
index 1e7b9e9..7b8e55a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -3049,10 +3049,8 @@ void
 xytonode(double x, double y, struct wlr_surface **psurface,
 		Client **pc, LayerSurface **pl, double *nx, double *ny)
 {
-	struct wlr_scene_node *node, *pnode;
+	struct wlr_scene_node *node;
 	struct wlr_surface *surface = NULL;
-	Client *c = NULL;
-	LayerSurface *l = NULL;
 	int layer;
 
 	for (layer = NUM_LAYERS - 1; !surface && layer >= 0; layer--) {
@@ -3063,18 +3061,10 @@ xytonode(double x, double y, struct wlr_surface **psurface,
 		if (node->type == WLR_SCENE_NODE_BUFFER)
 			surface = wlr_scene_surface_try_from_buffer(
 					wlr_scene_buffer_from_node(node))->surface;
-		/* Walk the tree to find a node that knows the client */
-		for (pnode = node; pnode && !c; pnode = &pnode->parent->node)
-			c = pnode->data;
-		if (c && c->type == LayerShell) {
-			c = NULL;
-			l = pnode->data;
-		}
 	}
 
 	if (psurface) *psurface = surface;
-	if (pc) *pc = c;
-	if (pl) *pl = l;
+	toplevel_from_wlr_surface(surface, pc, pl);
 }
 
 void
add IME support
Based on mangowm, which is based on labwc, which is based on sway, so this should be covered by LICENSE.sway. Fixes https://codeberg.org/dwl/dwl/issues/6 Fixes https://codeberg.org/dwl/dwl/issues/710 Fixes https://codeberg.org/dwl/dwl/issues/1176 Fixes https://codeberg.org/dwl/dwl/issues/1185 Co-authored-by: DreamMaoMao <2523610504@qq.com>
Guido Cella · 2026-09-10 · 2f3fe06
查看变更
Makefile  |   4 +-
 README.md |   3 -
 dwl.c     |  24 +++++-
 ime.h     | 639 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 662 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index 599581a..8304245 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEV
 LDLIBS    = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
 
 all: dwl
-dwl: dwl.c client.h config.h util.h config.mk cursor-shape-v1-protocol.h \
+dwl: dwl.c client.h config.h ime.h util.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
@@ -56,7 +56,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.h dwl.desktop \
+		config.mk protocols dwl.1 dwl.c ime.h util.h dwl.desktop \
 		dwl-$(VERSION)
 	tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION)
 	rm -rf dwl-$(VERSION)
diff --git a/README.md b/README.md
index d811a40..b8cddb4 100644
--- a/README.md
+++ b/README.md
@@ -166,9 +166,6 @@ indiscriminately. We will try to keep the code as small as possible.
 Features under consideration (possibly as patches) are:
 
 - Protocols made trivial by wlroots
-- Implement the text-input and input-method protocols to support IME once ibus
-  implements input-method v2 (see https://github.com/ibus/ibus/pull/2256 and
-  https://codeberg.org/dwl/dwl/pulls/235)
 
 Feature *non-goals* for the main codebase include:
 
diff --git a/dwl.c b/dwl.c
index 9637d2e..1e7b9e9 100644
--- a/dwl.c
+++ b/dwl.c
@@ -84,7 +84,7 @@
 /* enums */
 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 */
+enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
 
 typedef union {
 	int i;
@@ -150,6 +150,7 @@ typedef struct {
 
 typedef struct {
 	struct wlr_keyboard_group *wlr_group;
+	struct wlr_keyboard *virtual_keyboard;
 
 	int nsyms;
 	const xkb_keysym_t *keysyms; /* invalid if nsyms == 0 */
@@ -456,6 +457,8 @@ static struct wlr_xwayland *xwayland;
 /* attempt to encapsulate suck into one file */
 #include "client.h"
 
+#include "ime.h"
+
 /* function implementations */
 void
 applybounds(Client *c, struct wlr_box *bbox)
@@ -714,6 +717,8 @@ cleanup(void)
 
 	destroykeyboardgroup(&kb_group->destroy, NULL);
 
+	input_method_relay_finish(input_method_relay);
+
 	/* 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 */
 	wlr_backend_destroy(backend);
@@ -1465,6 +1470,7 @@ focusclient(Client *c, int lift)
 
 	if (!c) {
 		/* With no client, all we have left is to clear focus */
+		input_method_relay_set_focus(input_method_relay, NULL);
 		wlr_seat_keyboard_notify_clear_focus(seat);
 		return;
 	}
@@ -1472,6 +1478,8 @@ focusclient(Client *c, int lift)
 	/* Change cursor surface */
 	motionnotify(0, NULL, 0, 0, 0, 0);
 
+	input_method_relay_set_focus(input_method_relay, client_surface(c));
+
 	/* Have a client, so focus its top-level wlr_surface */
 	client_notify_enter(client_surface(c), wlr_seat_get_keyboard(seat));
 
@@ -1674,7 +1682,7 @@ keypress(struct wl_listener *listener, void *data)
 		wl_event_source_timer_update(group->key_repeat_source, 0);
 	}
 
-	if (handled)
+	if (handled || input_method_keyboard_grab_forward_key(group, event))
 		return;
 
 	if (consumed[event->keycode]) {
@@ -1695,6 +1703,9 @@ keypressmod(struct wl_listener *listener, void *data)
 	 * pressed. We simply communicate this to the client. */
 	KeyboardGroup *group = wl_container_of(listener, group, modifiers);
 
+	if (input_method_keyboard_grab_forward_modifiers(group))
+		return;
+
 	wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
 	/* Send modifiers to the client. */
 	wlr_seat_keyboard_notify_modifiers(seat,
@@ -2659,6 +2670,11 @@ setup(void)
 	wl_signal_add(&output_mgr->events.apply, &output_mgr_apply);
 	wl_signal_add(&output_mgr->events.test, &output_mgr_test);
 
+	input_method_manager = wlr_input_method_manager_v2_create(dpy);
+	text_input_manager = wlr_text_input_manager_v3_create(dpy);
+	input_method_relay = ecalloc(1, sizeof(*input_method_relay));
+	input_method_relay = input_method_relay_create();
+
 	/* 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 */
@@ -3002,6 +3018,7 @@ virtualkeyboard(struct wl_listener *listener, void *data)
 	struct wlr_virtual_keyboard_v1 *kb = data;
 	/* virtual keyboards shouldn't share keyboard group */
 	KeyboardGroup *group = createkeyboardgroup();
+	group->virtual_keyboard = &kb->keyboard;
 	/* Set the keymap to match the group keymap */
 	wlr_keyboard_set_keymap(&kb->keyboard, group->wlr_group->keyboard.keymap);
 	LISTEN(&kb->keyboard.base.events.destroy, &group->destroy, destroykeyboardgroup);
@@ -3039,7 +3056,8 @@ xytonode(double x, double y, struct wlr_surface **psurface,
 	int layer;
 
 	for (layer = NUM_LAYERS - 1; !surface && layer >= 0; layer--) {
-		if (!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny)))
+		if (layer == LyrIMPopup ||
+				!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny)))
 			continue;
 
 		if (node->type == WLR_SCENE_NODE_BUFFER)
diff --git a/ime.h b/ime.h
new file mode 100644
index 0000000..f537a2d
--- /dev/null
+++ b/ime.h
@@ -0,0 +1,639 @@
+#include <wlr/types/wlr_input_method_v2.h>
+#include <wlr/types/wlr_text_input_v3.h>
+
+struct input_method_relay {
+	struct wl_list text_inputs; /* struct text_input.link */
+	struct wlr_input_method_v2 *input_method;
+
+	struct wlr_surface *focused_surface;
+	struct text_input *active_text_input;
+
+	struct wl_list popups; /* input_method_popup.link */
+	struct wlr_scene_tree *popup_tree;
+
+	struct wl_listener new_text_input;
+	struct wl_listener new_input_method;
+
+	struct wl_listener input_method_commit;
+	struct wl_listener input_method_grab_keyboard;
+	struct wl_listener input_method_destroy;
+	struct wl_listener input_method_new_popup_surface;
+
+	struct wl_listener keyboard_grab_destroy;
+	struct wl_listener focused_surface_destroy;
+};
+
+struct input_method_popup {
+	struct wlr_input_popup_surface_v2 *popup_surface;
+	struct wlr_scene_tree *tree;
+	struct wlr_scene_tree *scene_surface;
+	struct input_method_relay *relay;
+	struct wl_list link; /* input_method_relay.popups */
+
+	struct wl_listener destroy;
+	struct wl_listener commit;
+};
+
+struct text_input {
+	struct input_method_relay *relay;
+	struct wlr_text_input_v3 *input;
+	struct wl_list link;
+
+	struct wl_listener enable;
+	struct wl_listener commit;
+	struct wl_listener disable;
+	struct wl_listener destroy;
+};
+
+struct wlr_input_method_manager_v2 *input_method_manager;
+struct wlr_text_input_manager_v3 *text_input_manager;
+struct input_method_relay *input_method_relay;
+
+/* functions used in dwl.c */
+static int input_method_keyboard_grab_forward_key(
+		KeyboardGroup *keyboard, struct wlr_keyboard_key_event *event);
+static int input_method_keyboard_grab_forward_modifiers(KeyboardGroup *keyboard);
+static struct input_method_relay *input_method_relay_create(void);
+static void input_method_relay_finish(struct input_method_relay *relay);
+static void input_method_relay_set_focus(struct input_method_relay *relay,
+		struct wlr_surface *surface);
+
+/* internal functions */
+static struct text_input *get_active_text_input(struct input_method_relay *relay);
+static struct wlr_input_method_keyboard_grab_v2 *get_keyboard_grab(KeyboardGroup *keyboard);
+static int keyboard_is_emulated_by_input_method(struct wlr_keyboard *keyboard,
+		struct wlr_input_method_v2 *input_method);
+static void handle_focused_surface_destroy(struct wl_listener *listener, void *data);
+static void handle_input_method_commit(struct wl_listener *listener, void *data);
+static void handle_input_method_destroy(struct wl_listener *listener, void *data);
+static void handle_input_method_grab_keyboard(struct wl_listener *listener, void *data);
+static void handle_input_method_new_popup_surface(struct wl_listener *listener, void *data);
+static void handle_keyboard_grab_destroy(struct wl_listener *listener, void *data);
+static void handle_new_input_method(struct wl_listener *listener, void *data);
+static void handle_new_text_input(struct wl_listener *listener, void *data);
+static void handle_popup_surface_commit(struct wl_listener *listener, void *data);
+static void handle_popup_surface_destroy(struct wl_listener *listener, void *data);
+static void handle_text_input_commit(struct wl_listener *listener, void *data);
+static void handle_text_input_destroy(struct wl_listener *listener, void *data);
+static void handle_text_input_disable(struct wl_listener *listener, void *data);
+static void handle_text_input_enable(struct wl_listener *listener, void *data);
+static Monitor *output_from_wlr_output(struct wlr_output *wlr_output);
+static Monitor *output_nearest_to(int lx, int ly);
+static void send_state_to_input_method(struct input_method_relay *relay);
+static void update_active_text_input(struct input_method_relay *relay);
+static void update_popup_position(struct input_method_popup *popup);
+static void update_popups_position(struct input_method_relay *relay);
+static void update_text_inputs_focused_surface(struct input_method_relay *relay);
+
+Monitor *
+output_from_wlr_output(struct wlr_output *wlr_output)
+{
+	Monitor *m = NULL;
+	wl_list_for_each(m, &mons, link) {
+		if (m->wlr_output == wlr_output)
+			return m;
+	}
+	return NULL;
+}
+
+Monitor *
+output_nearest_to(int lx, int ly)
+{
+	double closest_x, closest_y;
+	wlr_output_layout_closest_point(output_layout, NULL, lx, ly, &closest_x,
+			&closest_y);
+
+	return output_from_wlr_output(
+			wlr_output_layout_output_at(output_layout, closest_x, closest_y));
+}
+
+int
+keyboard_is_emulated_by_input_method(struct wlr_keyboard *keyboard,
+		struct wlr_input_method_v2 *input_method)
+{
+	struct wlr_virtual_keyboard_v1 *virtual_keyboard;
+
+	if (!keyboard || !input_method)
+		return 0;
+
+	virtual_keyboard = wlr_input_device_get_virtual_keyboard(&keyboard->base);
+
+	return virtual_keyboard &&
+			wl_resource_get_client(virtual_keyboard->resource) ==
+				wl_resource_get_client(input_method->resource);
+}
+
+struct wlr_input_method_keyboard_grab_v2 *
+get_keyboard_grab(KeyboardGroup *keyboard)
+{
+	struct wlr_input_method_v2 *input_method = input_method_relay->input_method;
+
+	if (!input_method || !input_method->keyboard_grab || keyboard != kb_group ||
+			keyboard_is_emulated_by_input_method(keyboard->virtual_keyboard,
+				input_method))
+		return NULL;
+
+	return input_method->keyboard_grab;
+}
+
+int
+input_method_keyboard_grab_forward_modifiers(KeyboardGroup *keyboard)
+{
+	struct wlr_input_method_keyboard_grab_v2 *keyboard_grab =
+		get_keyboard_grab(keyboard);
+
+	struct wlr_keyboard_modifiers *modifiers =
+		&keyboard->wlr_group->keyboard.modifiers;
+
+	if (keyboard_grab) {
+		wlr_input_method_keyboard_grab_v2_set_keyboard(
+				keyboard_grab, &keyboard->wlr_group->keyboard);
+		wlr_input_method_keyboard_grab_v2_send_modifiers(keyboard_grab, modifiers);
+		return 1;
+	} else {
+		return 0;
+	}
+}
+
+int
+input_method_keyboard_grab_forward_key(
+		KeyboardGroup *keyboard, struct wlr_keyboard_key_event *event)
+{
+	struct wlr_input_method_keyboard_grab_v2 *keyboard_grab =
+		get_keyboard_grab(keyboard);
+	if (keyboard_grab) {
+		wlr_input_method_keyboard_grab_v2_set_keyboard(
+				keyboard_grab, &keyboard->wlr_group->keyboard);
+		wlr_input_method_keyboard_grab_v2_send_key(keyboard_grab, event->time_msec,
+				event->keycode, event->state);
+		return 1;
+	} else {
+		return 0;
+	}
+}
+
+struct text_input *
+get_active_text_input(struct input_method_relay *relay)
+{
+	struct text_input *text_input;
+
+	if (!relay->input_method)
+		return NULL;
+
+	wl_list_for_each(text_input, &relay->text_inputs, link) {
+		if (text_input->input->focused_surface &&
+				text_input->input->current_enabled)
+			return text_input;
+	}
+	return NULL;
+}
+
+void
+update_active_text_input(struct input_method_relay *relay)
+{
+	struct text_input *active_text_input = get_active_text_input(relay);
+
+	if (relay->input_method && relay->active_text_input != active_text_input) {
+		if (active_text_input)
+			wlr_input_method_v2_send_activate(relay->input_method);
+		else
+			wlr_input_method_v2_send_deactivate(relay->input_method);
+		wlr_input_method_v2_send_done(relay->input_method);
+	}
+
+	relay->active_text_input = active_text_input;
+}
+
+void
+update_text_inputs_focused_surface(struct input_method_relay *relay)
+{
+	struct text_input *text_input;
+	wl_list_for_each(text_input, &relay->text_inputs, link) {
+		struct wlr_text_input_v3 *input = text_input->input;
+
+		struct wlr_surface *new_focused_surface;
+		if (relay->input_method && relay->focused_surface &&
+			wl_resource_get_client(input->resource) ==
+				wl_resource_get_client(relay->focused_surface->resource)) {
+			new_focused_surface = relay->focused_surface;
+		} else {
+			new_focused_surface = NULL;
+		}
+
+		if (input->focused_surface == new_focused_surface)
+			continue;
+		if (input->focused_surface)
+			wlr_text_input_v3_send_leave(input);
+		if (new_focused_surface)
+			wlr_text_input_v3_send_enter(input, new_focused_surface);
+	}
+}
+
+void
+update_popup_position(struct input_method_popup *popup)
+{
+	struct input_method_relay *relay = popup->relay;
+	struct text_input *text_input = relay->active_text_input;
+	struct wlr_box cursor_rect;
+	struct wlr_xdg_surface *xdg_surface;
+	struct wlr_layer_surface_v1 *layer_surface;
+	struct wlr_scene_tree *tree;
+	int lx, ly;
+	Monitor *output;
+	struct wlr_box output_box;
+	struct wlr_xdg_positioner_rules positioner_rules;
+	struct wlr_box popup_box;
+
+	if (!text_input || !relay->focused_surface ||
+			!popup->popup_surface->surface->mapped)
+		return;
+
+	xdg_surface = wlr_xdg_surface_try_from_wlr_surface(relay->focused_surface);
+	layer_surface = wlr_layer_surface_v1_try_from_wlr_surface(relay->focused_surface);
+
+	if ((text_input->input->current.features &
+				WLR_TEXT_INPUT_V3_FEATURE_CURSOR_RECTANGLE) &&
+			(xdg_surface || layer_surface)) {
+		cursor_rect = text_input->input->current.cursor_rectangle;
+
+		tree = relay->focused_surface->data;
+		wlr_scene_node_coords(&tree->node, &lx, &ly);
+		cursor_rect.x += lx;
+		cursor_rect.y += ly;
+
+		if (xdg_surface) {
+			cursor_rect.x -= xdg_surface->geometry.x;
+			cursor_rect.y -= xdg_surface->geometry.y;
+		}
+	} else {
+		cursor_rect = (struct wlr_box){0};
+	}
+
+	output = output_nearest_to(cursor_rect.x, cursor_rect.y);
+	if (!output || !output->wlr_output->enabled)
+		return;
+
+	wlr_output_layout_get_box(output_layout, output->wlr_output, &output_box);
+
+	positioner_rules = (struct wlr_xdg_positioner_rules) {
+		.anchor_rect = cursor_rect,
+		.anchor = XDG_POSITIONER_ANCHOR_BOTTOM_LEFT,
+		.gravity = XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT,
+		.size =
+		{
+			.width = popup->popup_surface->surface->current.width,
+			.height = popup->popup_surface->surface->current.height,
+		},
+		.constraint_adjustment = XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y |
+			XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X,
+	};
+
+	wlr_xdg_positioner_rules_get_geometry(&positioner_rules, &popup_box);
+	wlr_xdg_positioner_rules_unconstrain_box(&positioner_rules, &output_box, &popup_box);
+
+	wlr_scene_node_set_position(&popup->tree->node, popup_box.x, popup_box.y);
+	wlr_scene_node_raise_to_top(&relay->popup_tree->node);
+
+	wlr_input_popup_surface_v2_send_text_input_rectangle(
+			popup->popup_surface, &(struct wlr_box){
+			.x = cursor_rect.x - popup_box.x,
+			.y = cursor_rect.y - popup_box.y,
+			.width = cursor_rect.width,
+			.height = cursor_rect.height,
+			});
+}
+
+void
+update_popups_position(struct input_method_relay *relay)
+{
+	struct input_method_popup *popup;
+	wl_list_for_each(popup, &relay->popups, link) {
+		update_popup_position(popup);
+	}
+}
+
+void
+handle_input_method_commit(struct wl_listener *listener,
+		void *data)
+{
+	struct input_method_relay *relay =
+		wl_container_of(listener, relay, input_method_commit);
+	struct wlr_input_method_v2 *input_method = relay->input_method;
+	struct text_input *text_input = relay->active_text_input;
+
+	if (!text_input)
+		return;
+
+	if (input_method->current.preedit.text) {
+		wlr_text_input_v3_send_preedit_string(text_input->input,
+				input_method->current.preedit.text,
+				input_method->current.preedit.cursor_begin,
+				input_method->current.preedit.cursor_end);
+	}
+	if (input_method->current.commit_text) {
+		wlr_text_input_v3_send_commit_string(text_input->input,
+				input_method->current.commit_text);
+	}
+	if (input_method->current.delete.before_length ||
+			input_method->current.delete.after_length) {
+		wlr_text_input_v3_send_delete_surrounding_text(text_input->input,
+				input_method->current.delete.before_length,
+				input_method->current.delete.after_length);
+	}
+	wlr_text_input_v3_send_done(text_input->input);
+}
+
+void
+handle_keyboard_grab_destroy(struct wl_listener *listener,
+		void *data)
+{
+	struct input_method_relay *relay =
+		wl_container_of(listener, relay, keyboard_grab_destroy);
+	struct wlr_input_method_keyboard_grab_v2 *keyboard_grab =
+		relay->input_method->keyboard_grab;
+	wl_list_remove(&relay->keyboard_grab_destroy.link);
+
+	if (keyboard_grab->keyboard) {
+		/* Send modifier state to original client */
+		wlr_seat_keyboard_notify_modifiers(keyboard_grab->input_method->seat,
+				&keyboard_grab->keyboard->modifiers);
+	}
+}
+
+void
+handle_input_method_grab_keyboard(struct wl_listener *listener,
+		void *data)
+{
+	struct input_method_relay *relay =
+		wl_container_of(listener, relay, input_method_grab_keyboard);
+	struct wlr_input_method_keyboard_grab_v2 *keyboard_grab = data;
+
+	struct wlr_keyboard *active_keyboard = &kb_group->wlr_group->keyboard;
+
+	if (!keyboard_is_emulated_by_input_method(active_keyboard,
+				relay->input_method)) {
+		/* Send modifier state to grab */
+		wlr_input_method_keyboard_grab_v2_set_keyboard(keyboard_grab,
+				active_keyboard);
+	}
+
+	relay->keyboard_grab_destroy.notify = handle_keyboard_grab_destroy;
+	wl_signal_add(&keyboard_grab->events.destroy, &relay->keyboard_grab_destroy);
+}
+
+void
+handle_input_method_destroy(struct wl_listener *listener,
+		void *data)
+{
+	struct input_method_relay *relay =
+		wl_container_of(listener, relay, input_method_destroy);
+	wl_list_remove(&relay->input_method_commit.link);
+	wl_list_remove(&relay->input_method_grab_keyboard.link);
+	wl_list_remove(&relay->input_method_new_popup_surface.link);
+	wl_list_remove(&relay->input_method_destroy.link);
+	relay->input_method = NULL;
+
+	update_text_inputs_focused_surface(relay);
+	update_active_text_input(relay);
+}
+
+void
+handle_popup_surface_destroy(struct wl_listener *listener,
+		void *data)
+{
+	struct input_method_popup *popup = wl_container_of(listener, popup, destroy);
+	wlr_scene_node_destroy(&popup->tree->node);
+	wl_list_remove(&popup->destroy.link);
+	wl_list_remove(&popup->commit.link);
+	wl_list_remove(&popup->link);
+	free(popup);
+}
+
+void
+handle_popup_surface_commit(struct wl_listener *listener,
+		void *data)
+{
+	struct input_method_popup *popup = wl_container_of(listener, popup, commit);
+	update_popup_position(popup);
+}
+
+void
+handle_input_method_new_popup_surface(struct wl_listener *listener,
+		void *data)
+{
+	struct input_method_relay *relay =
+		wl_container_of(listener, relay, input_method_new_popup_surface);
+
+	struct input_method_popup *popup = ecalloc(1, sizeof(*popup));
+	popup->popup_surface = data;
+	popup->relay = relay;
+
+	popup->destroy.notify = handle_popup_surface_destroy;
+	wl_signal_add(&popup->popup_surface->events.destroy, &popup->destroy);
+
+	popup->commit.notify = handle_popup_surface_commit;
+	wl_signal_add(&popup->popup_surface->surface->events.commit, &popup->commit);
+
+	popup->tree = wlr_scene_tree_create(layers[LyrIMPopup]);
+	popup->scene_surface = wlr_scene_subsurface_tree_create(
+			popup->tree, popup->popup_surface->surface);
+	popup->scene_surface->node.data = popup;
+
+	wl_list_insert(&relay->popups, &popup->link);
+
+	update_popup_position(popup);
+}
+
+void
+handle_new_input_method(struct wl_listener *listener, void *data)
+{
+	struct input_method_relay *relay =
+		wl_container_of(listener, relay, new_input_method);
+	struct wlr_input_method_v2 *input_method = data;
+	if (seat != input_method->seat)
+		return;
+
+	if (relay->input_method) {
+		wlr_input_method_v2_send_unavailable(input_method);
+		return;
+	}
+
+	relay->input_method = input_method;
+
+	relay->input_method_commit.notify = handle_input_method_commit;
+	wl_signal_add(&relay->input_method->events.commit,
+			&relay->input_method_commit);
+
+	relay->input_method_grab_keyboard.notify = handle_input_method_grab_keyboard;
+	wl_signal_add(&relay->input_method->events.grab_keyboard,
+			&relay->input_method_grab_keyboard);
+
+	relay->input_method_destroy.notify = handle_input_method_destroy;
+	wl_signal_add(&relay->input_method->events.destroy,
+			&relay->input_method_destroy);
+
+	relay->input_method_new_popup_surface.notify =
+		handle_input_method_new_popup_surface;
+	wl_signal_add(&relay->input_method->events.new_popup_surface,
+			&relay->input_method_new_popup_surface);
+
+	update_text_inputs_focused_surface(relay);
+	update_active_text_input(relay);
+}
+
+void
+send_state_to_input_method(struct input_method_relay *relay)
+{
+	struct wlr_input_method_v2 *input_method = relay->input_method;
+	struct wlr_text_input_v3 *input = relay->active_text_input->input;
+
+	if (input->active_features & WLR_TEXT_INPUT_V3_FEATURE_SURROUNDING_TEXT) {
+		wlr_input_method_v2_send_surrounding_text(input_method,
+				input->current.surrounding.text,
+				input->current.surrounding.cursor,
+				input->current.surrounding.anchor);
+	}
+	wlr_input_method_v2_send_text_change_cause(input_method,
+			input->current.text_change_cause);
+	if (input->active_features & WLR_TEXT_INPUT_V3_FEATURE_CONTENT_TYPE) {
+		wlr_input_method_v2_send_content_type(input_method,
+				input->current.content_type.hint,
+				input->current.content_type.purpose);
+	}
+	wlr_input_method_v2_send_done(input_method);
+}
+
+void
+handle_text_input_enable(struct wl_listener *listener, void *data)
+{
+	struct text_input *text_input = wl_container_of(listener, text_input, enable);
+	struct input_method_relay *relay = text_input->relay;
+
+	update_active_text_input(relay);
+	if (relay->active_text_input == text_input) {
+		update_popups_position(relay);
+		send_state_to_input_method(relay);
+	}
+	wlr_text_input_v3_send_done(text_input->input);
+}
+
+void
+handle_text_input_disable(struct wl_listener *listener,
+		void *data)
+{
+	struct text_input *text_input =
+		wl_container_of(listener, text_input, disable);
+	update_active_text_input(text_input->relay);
+}
+
+void
+handle_text_input_commit(struct wl_listener *listener, void *data)
+{
+	struct text_input *text_input = wl_container_of(listener, text_input, commit);
+	struct input_method_relay *relay = text_input->relay;
+
+	if (relay->active_text_input == text_input) {
+		update_popups_position(relay);
+		send_state_to_input_method(relay);
+	}
+}
+
+void
+handle_text_input_destroy(struct wl_listener *listener,
+		void *data)
+{
+	struct text_input *text_input =
+		wl_container_of(listener, text_input, destroy);
+	wl_list_remove(&text_input->enable.link);
+	wl_list_remove(&text_input->disable.link);
+	wl_list_remove(&text_input->commit.link);
+	wl_list_remove(&text_input->destroy.link);
+	wl_list_remove(&text_input->link);
+	update_active_text_input(text_input->relay);
+	free(text_input);
+}
+
+void
+handle_new_text_input(struct wl_listener *listener, void *data)
+{
+	struct input_method_relay *relay =
+		wl_container_of(listener, relay, new_text_input);
+	struct wlr_text_input_v3 *wlr_text_input = data;
+	struct text_input *text_input;
+
+	if (seat != wlr_text_input->seat)
+		return;
+
+	text_input = ecalloc(1, sizeof(*text_input));
+	text_input->input = wlr_text_input;
+	text_input->relay = relay;
+	wl_list_insert(&relay->text_inputs, &text_input->link);
+
+	text_input->enable.notify = handle_text_input_enable;
+	wl_signal_add(&text_input->input->events.enable, &text_input->enable);
+
+	text_input->disable.notify = handle_text_input_disable;
+	wl_signal_add(&text_input->input->events.disable, &text_input->disable);
+
+	text_input->commit.notify = handle_text_input_commit;
+	wl_signal_add(&text_input->input->events.commit, &text_input->commit);
+
+	text_input->destroy.notify = handle_text_input_destroy;
+	wl_signal_add(&text_input->input->events.destroy, &text_input->destroy);
+
+	update_text_inputs_focused_surface(relay);
+}
+
+void
+handle_focused_surface_destroy(struct wl_listener *listener,
+		void *data)
+{
+	struct input_method_relay *relay =
+		wl_container_of(listener, relay, focused_surface_destroy);
+	input_method_relay_set_focus(relay, NULL);
+}
+
+struct input_method_relay *
+input_method_relay_create()
+{
+	struct input_method_relay *relay = ecalloc(1, sizeof(*relay));
+	wl_list_init(&relay->text_inputs);
+	wl_list_init(&relay->popups);
+	relay->popup_tree = wlr_scene_tree_create(&scene->tree);
+
+	relay->new_text_input.notify = handle_new_text_input;
+	wl_signal_add(&text_input_manager->events.new_text_input, &relay->new_text_input);
+
+	relay->new_input_method.notify = handle_new_input_method;
+	wl_signal_add(&input_method_manager->events.new_input_method,
+			&relay->new_input_method);
+
+	relay->focused_surface_destroy.notify = handle_focused_surface_destroy;
+
+	return relay;
+}
+
+void
+input_method_relay_finish(struct input_method_relay *relay)
+{
+	wl_list_remove(&relay->new_text_input.link);
+	wl_list_remove(&relay->new_input_method.link);
+	free(relay);
+}
+
+void
+input_method_relay_set_focus(struct input_method_relay *relay,
+		struct wlr_surface *surface)
+{
+	if (relay->focused_surface == surface)
+		return;
+
+	if (relay->focused_surface)
+		wl_list_remove(&relay->focused_surface_destroy.link);
+	relay->focused_surface = surface;
+	if (surface)
+		wl_signal_add(&surface->events.destroy, &relay->focused_surface_destroy);
+
+	update_text_inputs_focused_surface(relay);
+	update_active_text_input(relay);
+}
fix some key binding events being passed to clientsAndrea Chiavazza · 2025-05-08 · f6800e9
查看变更
client.h | 15 +++++++++++----
 dwl.c    | 32 +++++++++++++++++++++++---------
 2 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/client.h b/client.h
index d9f90bb..75f1c27 100644
--- a/client.h
+++ b/client.h
@@ -291,11 +291,18 @@ client_is_unmanaged(Client *c)
 static inline void
 client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb)
 {
-	if (kb)
-		wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes,
-				kb->num_keycodes, &kb->modifiers);
-	else
+	uint32_t filtered[WLR_KEYBOARD_KEYS_CAP];
+	size_t size = 0;
+	if (!kb) {
 		wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
+		return;
+	}
+	for (size_t i = 0; i < kb->num_keycodes; i++) {
+		uint32_t key = kb->keycodes[i];
+		if (!consumed[key])
+			filtered[size++] = key;
+	}
+	wlr_seat_keyboard_notify_enter(seat, s, filtered, size, &kb->modifiers);
 }
 
 static inline void
diff --git a/dwl.c b/dwl.c
index 29961dc..9637d2e 100644
--- a/dwl.c
+++ b/dwl.c
@@ -291,7 +291,7 @@ static void gpureset(struct wl_listener *listener, void *data);
 static void handlesig(int signo);
 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);
+static const Key *keybinding(uint32_t mods, xkb_keysym_t sym);
 static void keypress(struct wl_listener *listener, void *data);
 static void keypressmod(struct wl_listener *listener, void *data);
 static int keyrepeat(void *data);
@@ -405,6 +405,7 @@ static struct wlr_output_layout *output_layout;
 static struct wlr_box sgeom;
 static struct wl_list mons;
 static Monitor *selmon;
+static int consumed[KEY_MAX + 1];
 
 /* global event handlers */
 static struct wl_listener cursor_axis = {.notify = axisnotify};
@@ -1610,7 +1611,7 @@ inputdevice(struct wl_listener *listener, void *data)
 	wlr_seat_set_capabilities(seat, caps);
 }
 
-int
+const Key *
 keybinding(uint32_t mods, xkb_keysym_t sym)
 {
 	/*
@@ -1623,11 +1624,10 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
 		if (CLEANMASK(mods) == CLEANMASK(k->mod)
 				&& xkb_keysym_to_lower(sym) == xkb_keysym_to_lower(k->keysym)
 				&& k->func) {
-			k->func(&k->arg);
-			return 1;
+			return k;
 		}
 	}
-	return 0;
+	return NULL;
 }
 
 void
@@ -1653,8 +1653,14 @@ keypress(struct wl_listener *listener, void *data)
 	/* On _press_ if there is no active screen locker,
 	 * attempt to process a compositor keybinding. */
 	if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
-		for (i = 0; i < nsyms; i++)
-			handled = keybinding(mods, syms[i]) || handled;
+		for (i = 0; i < nsyms; i++) {
+			const Key *key = keybinding(mods, syms[i]);
+			if (key) {
+				consumed[event->keycode] = 1;
+				key->func(&key->arg);
+				handled = 1;
+			}
+		}
 	}
 
 	if (handled && group->wlr_group->keyboard.repeat_info.delay > 0) {
@@ -1671,6 +1677,11 @@ keypress(struct wl_listener *listener, void *data)
 	if (handled)
 		return;
 
+	if (consumed[event->keycode]) {
+		if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED)
+			consumed[event->keycode] = 0;
+		return; /* Don't pass to the client the release event of a handled key-press */
+	}
 	wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
 	/* Pass unhandled keycodes along to the client. */
 	wlr_seat_keyboard_notify_key(seat, event->time_msec,
@@ -1701,8 +1712,11 @@ keyrepeat(void *data)
 	wl_event_source_timer_update(group->key_repeat_source,
 			1000 / group->wlr_group->keyboard.repeat_info.rate);
 
-	for (i = 0; i < group->nsyms; i++)
-		keybinding(group->mods, group->keysyms[i]);
+	for (i = 0; i < group->nsyms; i++) {
+		const Key *key = keybinding(group->mods, group->keysyms[i]);
+		if (key)
+			key->func(&key->arg);
+	}
 
 	return 0;
 }
move util.c to util.h
This allows single-source compilation and whole-program optimization using something like: make CFLAGS='-flto -ffunction-sections -fdata-sections -Wl,--gc-sections' Furthermore, move more compositor-agnostic utility functions/macros to util.h, similar to the original dwm sources.
Siva Mahadevan · 2026-02-28 · 7fb2024
查看变更
Makefile  | 14 ++++----------
 README.md |  2 +-
 dwl.c     |  4 ----
 util.c    | 51 ---------------------------------------------------
 util.h    | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 5 files changed, 61 insertions(+), 69 deletions(-)
diff --git a/Makefile b/Makefile
index 3981fbb..599581a 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ include config.mk
 
 # flags for compiling
 DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \
-	-DVERSION=\"$(VERSION)\" $(XWAYLAND)
+	-DVERSION=\"$(VERSION)\" $(XWAYLAND) $(CPPFLAGS)
 DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
 	-Wno-unused-parameter -Wshadow -Wunused-macros -Werror=strict-prototypes \
 	-Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types \
@@ -17,13 +17,11 @@ DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEV
 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.c client.h config.h util.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
-util.o: util.c util.h
+	$(CC) dwl.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
 
 # wayland-scanner is a tool which generates C headers and rigging for Wayland
 # protocols, which are specified in XML. wlroots requires you to rig these up
@@ -58,7 +56,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 util.h dwl.desktop \
 		dwl-$(VERSION)
 	tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION)
 	rm -rf dwl-$(VERSION)
@@ -77,7 +75,3 @@ install: dwl
 uninstall:
 	rm -f $(DESTDIR)$(PREFIX)/bin/dwl $(DESTDIR)$(MANDIR)/man1/dwl.1 \
 		$(DESTDIR)$(DATADIR)/wayland-sessions/dwl.desktop
-
-.SUFFIXES: .c .o
-.c.o:
-	$(CC) $(CPPFLAGS) $(DWLCFLAGS) -o $@ -c $<
diff --git a/README.md b/README.md
index 6c372c1..d811a40 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ primarily in terms of functionality, and secondarily in terms of
 philosophy. Like [dwm], dwl is:
 
 - Easy to understand, hack on, and extend with patches
-- One C source file (or a very small number) configurable via `config.h`
+- One C source file configurable via `config.h`
 - Tied to as few external dependencies as possible
 
 ## Getting Started:
diff --git a/dwl.c b/dwl.c
index 9808ef9..29961dc 100644
--- a/dwl.c
+++ b/dwl.c
@@ -75,12 +75,8 @@
 #include "util.h"
 
 /* macros */
-#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 LENGTH(X)               (sizeof X / sizeof X[0])
-#define END(A)                  ((A) + LENGTH(A))
 #define TAGMASK                 ((1u << TAGCOUNT) - 1)
 #define LISTEN(E, L, H)         wl_signal_add((E), ((L)->notify = (H), (L)))
 #define LISTEN_STATIC(E, H)     do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0)
diff --git a/util.c b/util.c
deleted file mode 100644
index b925987..0000000
--- a/util.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* See LICENSE.dwm file for copyright and license details. */
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-
-#include "util.h"
-
-void
-die(const char *fmt, ...) {
-	va_list ap;
-
-	va_start(ap, fmt);
-	vfprintf(stderr, fmt, ap);
-	va_end(ap);
-
-	if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
-		fputc(' ', stderr);
-		perror(NULL);
-	} else {
-		fputc('\n', stderr);
-	}
-
-	exit(1);
-}
-
-void *
-ecalloc(size_t nmemb, size_t size)
-{
-	void *p;
-
-	if (!(p = calloc(nmemb, size)))
-		die("calloc:");
-	return p;
-}
-
-int
-fd_set_nonblock(int fd) {
-	int flags = fcntl(fd, F_GETFL);
-	if (flags < 0) {
-		perror("fcntl(F_GETFL):");
-		return -1;
-	}
-	if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
-		perror("fcntl(F_SETFL):");
-		return -1;
-	}
-
-	return 0;
-}
diff --git a/util.h b/util.h
index 226980d..40cfbe4 100644
--- a/util.h
+++ b/util.h
@@ -1,5 +1,58 @@
 /* See LICENSE.dwm file for copyright and license details. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
 
-void die(const char *fmt, ...);
-void *ecalloc(size_t nmemb, size_t size);
-int fd_set_nonblock(int fd);
+#define MAX(A, B)               ((A) > (B) ? (A) : (B))
+#define MIN(A, B)               ((A) < (B) ? (A) : (B))
+#define LENGTH(X)               (sizeof X / sizeof X[0])
+#define END(A)                  ((A) + LENGTH(A))
+
+static void die(const char *fmt, ...);
+static void *ecalloc(size_t nmemb, size_t size);
+static int fd_set_nonblock(int fd);
+
+void
+die(const char *fmt, ...) {
+	va_list ap;
+
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+
+	if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
+		fputc(' ', stderr);
+		perror(NULL);
+	} else {
+		fputc('\n', stderr);
+	}
+
+	exit(1);
+}
+
+void *
+ecalloc(size_t nmemb, size_t size)
+{
+	void *p;
+
+	if (!(p = calloc(nmemb, size)))
+		die("calloc:");
+	return p;
+}
+
+int
+fd_set_nonblock(int fd) {
+	int flags = fcntl(fd, F_GETFL);
+	if (flags < 0) {
+		perror("fcntl(F_GETFL):");
+		return -1;
+	}
+	if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
+		perror("fcntl(F_SETFL):");
+		return -1;
+	}
+
+	return 0;
+}
Formally not lead developers in README
User @guidocella joins dwl as a lead developer
A Frederick Christensen · 2026-09-08 · 21be76a
查看变更
README.md | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/README.md b/README.md
index 3a3b9bd..6c372c1 100644
--- a/README.md
+++ b/README.md
@@ -193,6 +193,10 @@ inspiration, and to the various contributors to the project, including:
   and for helping to keep the project running
 - Stivvo for output management and fullscreen support, and patch maintenance
 
+Also, thanks to our current lead developers:
+
+- @thanatos
+- @guidocella
 
 [wlroots]: https://gitlab.freedesktop.org/wlroots
 [dwm]: https://dwm.suckless.org/
Remove rendermon pending resize frame skip
This is no longer needed as wlroots => 0.19 handles this internally via scene-level surface state tracking and linux-drm-syncobj explicit sync. The manual commit skip now causes the c->resize to be stuck on non-zero state which leads to choppy resizing experience.
julmajustus · 2026-05-23 · 70c33c0
查看变更
dwl.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/dwl.c b/dwl.c
index e3b1175..9808ef9 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2162,24 +2162,15 @@ rendermon(struct wl_listener *listener, void *data)
 	/* This function is called every time an output is ready to display a frame,
 	 * generally at the output's refresh rate (e.g. 60Hz). */
 	Monitor *m = wl_container_of(listener, m, frame);
-	Client *c;
-	struct wlr_output_state pending = {0};
 	struct timespec now;
 
-	/* Render if no XDG clients have an outstanding resize and are visible on
-	 * this monitor. */
-	wl_list_for_each(c, &clients, link) {
-		if (c->resize && !c->isfloating && client_is_rendered_on_mon(c, m) && !client_is_stopped(c))
-			goto skip;
+	if (!wlr_scene_output_needs_frame(m->scene_output)) {
+		return;
 	}
 
 	wlr_scene_output_commit(m->scene_output, NULL);
-
-skip:
-	/* Let clients know a frame has been rendered */
 	clock_gettime(CLOCK_MONOTONIC, &now);
 	wlr_scene_output_send_frame_done(m->scene_output, &now);
-	wlr_output_state_finish(&pending);
 }
 
 void
update wlroots version in commented variablesGuido Cella · 2026-09-08 · ee788f0
查看变更
config.mk | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/config.mk b/config.mk
index b1d782a..ab5a3fd 100644
--- a/config.mk
+++ b/config.mk
@@ -17,12 +17,12 @@ WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.20`
 #WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
 #	-I$(PWD)/wlroots/include
 # Set -rpath to avoid using the wrong library.
-#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/build -L$(PWD)/wlroots/build -lwlroots-0.19
+#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/build -L$(PWD)/wlroots/build -lwlroots-0.20
 
-# Assuming you ran "meson setup --prefix ${PWD}/0.19 build && ninja -C build install"
+# Assuming you ran "meson setup --prefix ${PWD}/0.20 build && ninja -C build install"
 #WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
-#	-I$(PWD)/wlroots/0.19/include/wlroots-0.19
-#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/0.19/lib64 -L$(PWD)/wlroots/0.19/lib64 -lwlroots-0.19
+#	-I$(PWD)/wlroots/0.20/include/wlroots-0.20
+#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/0.20/lib64 -L$(PWD)/wlroots/0.20/lib64 -lwlroots-0.20
 
 XWAYLAND =
 XLIBS =
add support for ext-image-copy-capture-v1 and ext-image-capture-source-v1 (wlroots!4545)A Frederick Christensen · 2026-02-22 · 132606e
查看变更
Makefile | 4 ++++
 dwl.c    | 4 ++++
 2 files changed, 8 insertions(+)
diff --git a/Makefile b/Makefile
index 578194f..3981fbb 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,7 @@ 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 \
+	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
 util.o: util.c util.h
@@ -33,6 +34,9 @@ WAYLAND_PROTOCOLS = `$(PKG_CONFIG) --variable=pkgdatadir wayland-protocols`
 cursor-shape-v1-protocol.h:
 	$(WAYLAND_SCANNER) enum-header \
 		$(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@
+ext-image-copy-capture-v1-protocol.h:
+	$(WAYLAND_SCANNER) enum-header \
+		$(WAYLAND_PROTOCOLS)/staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml $@
 pointer-constraints-unstable-v1-protocol.h:
 	$(WAYLAND_SCANNER) enum-header \
 		$(WAYLAND_PROTOCOLS)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml $@
diff --git a/dwl.c b/dwl.c
index 60e1e89..e3b1175 100644
--- a/dwl.c
+++ b/dwl.c
@@ -25,6 +25,8 @@
 #include <wlr/types/wlr_drm.h>
 #include <wlr/types/wlr_export_dmabuf_v1.h>
 #include <wlr/types/wlr_ext_data_control_v1.h>
+#include <wlr/types/wlr_ext_image_capture_source_v1.h>
+#include <wlr/types/wlr_ext_image_copy_capture_v1.h>
 #include <wlr/types/wlr_fractional_scale_v1.h>
 #include <wlr/types/wlr_gamma_control_v1.h>
 #include <wlr/types/wlr_idle_inhibit_v1.h>
@@ -2524,6 +2526,8 @@ setup(void)
 	wlr_data_device_manager_create(dpy);
 	wlr_export_dmabuf_manager_v1_create(dpy);
 	wlr_screencopy_manager_v1_create(dpy);
+	wlr_ext_image_copy_capture_manager_v1_create(dpy, 1);
+	wlr_ext_output_image_capture_source_manager_v1_create(dpy, 1);
 	wlr_data_control_manager_v1_create(dpy);
 	wlr_ext_data_control_manager_v1_create(dpy, 1);
 	wlr_primary_selection_v1_device_manager_create(dpy);
Bumped to 0.9 for wlroots-0.20.0. Updated cursor image buffer handling for xwaylandThanatos · 2026-01-15 · 49ca434
查看变更
config.mk | 6 +++---
 dwl.c     | 5 ++---
 2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/config.mk b/config.mk
index eb08a05..b1d782a 100644
--- a/config.mk
+++ b/config.mk
@@ -1,4 +1,4 @@
-_VERSION = 0.8-dev
+_VERSION = 0.9-dev
 VERSION  = `git describe --tags --dirty 2>/dev/null || echo $(_VERSION)`
 
 PKG_CONFIG = pkg-config
@@ -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 f0aa4cf..60e1e89 100644
--- a/dwl.c
+++ b/dwl.c
@@ -69,6 +69,7 @@
 #include <xcb/xcb_icccm.h>
 #endif
 
+#include "xdg-shell-protocol.h"
 #include "util.h"
 
 /* macros */
@@ -3187,9 +3188,7 @@ xwaylandready(struct wl_listener *listener, void *data)
 
 	/* Set the default XWayland cursor to match the rest of dwl. */
 	if ((xcursor = wlr_xcursor_manager_get_xcursor(cursor_mgr, "default", 1)))
-		wlr_xwayland_set_cursor(xwayland,
-				xcursor->images[0]->buffer, xcursor->images[0]->width * 4,
-				xcursor->images[0]->width, xcursor->images[0]->height,
+		wlr_xwayland_set_cursor(xwayland, wlr_xcursor_image_get_buffer(xcursor->images[0]),
 				xcursor->images[0]->hotspot_x, xcursor->images[0]->hotspot_y);
 }
 #endif
Preserve asleep disabled outputs in output configsave196 · 2026-04-04 · babccfe
查看变更
dwl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index 2e63c8c..f0aa4cf 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2862,10 +2862,13 @@ updatemons(struct wl_listener *listener, void *data)
 
 	/* First remove from the layout the disabled monitors */
 	wl_list_for_each(m, &mons, link) {
-		if (m->wlr_output->enabled || m->asleep)
+		if (m->wlr_output->enabled)
 			continue;
 		config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
 		config_head->state.enabled = 0;
+		if (m->asleep)
+			continue;
+
 		/* Remove this output from the layout to avoid cursor enter inside it */
 		wlr_output_layout_remove(output_layout, m->wlr_output);
 		closemon(m);
Clear surface->data on unmap to fix idle-inhibitor use-after-free
mapnotify() stores the client's scene tree in client_surface(c)->data; checkidleinhibitor() later reads it back as a wlr_scene_tree and calls wlr_scene_node_coords() on it. unmapnotify() frees the scene tree with wlr_scene_node_destroy() but leaves surface->data dangling, so the next arrange() -> checkidleinhibitor() dereferences freed memory and crashes (SIGSEGV) whenever an idle inhibitor outlives the unmap. Reset the pointer to NULL on unmap so the existing !tree guard handles it.
klim · 2026-07-20 · 4847f97
查看变更
dwl.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/dwl.c b/dwl.c
index df9b2ba..2e63c8c 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2839,6 +2839,7 @@ unmapnotify(struct wl_listener *listener, void *data)
 	}
 
 	wlr_scene_node_destroy(&c->scene->node);
+	client_surface(c)->data = NULL;
 	printstatus();
 	motionnotify(0, NULL, 0, 0, 0, 0);
 }
Remove decoration event listeners on destroynotify
When destroynotify doesn't clean up these listeners it causes a crash once the cleanup of the decoration is triggered Thanks to kennylevinsen - https://codeberg.org/dwl/dwl/issues/1205#issuecomment-22424401
Alex Denes · 2026-09-06 · 04279f2
查看变更
dwl.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/dwl.c b/dwl.c
index bf3e58c..df9b2ba 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1348,6 +1348,10 @@ destroynotify(struct wl_listener *listener, void *data)
 		wl_list_remove(&c->map.link);
 		wl_list_remove(&c->unmap.link);
 		wl_list_remove(&c->maximize.link);
+		if (c->decoration) {
+			wl_list_remove(&c->set_decoration_mode.link);
+			wl_list_remove(&c->destroy_decoration.link);
+		}
 	}
 	free(c);
 }
NULL out decoration on destroyAlex Denes · 2026-04-10 · f4dfdab
查看变更
dwl.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/dwl.c b/dwl.c
index 101a45f..bf3e58c 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1242,6 +1242,7 @@ void
 destroydecoration(struct wl_listener *listener, void *data)
 {
 	Client *c = wl_container_of(listener, c, destroy_decoration);
+	c->decoration = NULL;
 
 	wl_list_remove(&c->destroy_decoration.link);
 	wl_list_remove(&c->set_decoration_mode.link);
Remove trailing whitespace from READMEDiego Viola · 2026-02-25 · a2d03cf
查看变更
README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index c81efd0..3a3b9bd 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,7 @@ depend on functionality that is not in the current release of `wlroots`.
 The `wlroots-next` branch is built against the git version of [wlroots], which
 is unstable and changes frequently. PRs requiring functionality from the git
 version of `wlroots` should target this branch.
-  
+
 ### Building dwl
 dwl has the following dependencies:
 - libinput
@@ -213,4 +213,4 @@ inspiration, and to the various contributors to the project, including:
 [wiki]: https://codeberg.org/dwl/dwl/wiki/Home#compatible-status-bars
 [Discord server]: https://discord.gg/jJxZnrGPWN
 [Wayland]: https://wayland.freedesktop.org/
-[#dwl-official:matrix.org]: https://matrix.to/#/#dwl-official:matrix.org
\ No newline at end of file
+[#dwl-official:matrix.org]: https://matrix.to/#/#dwl-official:matrix.org
Fix typosDiego Viola · 2026-02-25 · cb4cc3a
查看变更
dwl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dwl.c b/dwl.c
index 320910d..101a45f 100644
--- a/dwl.c
+++ b/dwl.c
@@ -586,7 +586,7 @@ arrangelayers(Monitor *m)
 		arrange(m);
 	}
 
-	/* Arrange non-exlusive surfaces from top->bottom */
+	/* Arrange non-exclusive surfaces from top->bottom */
 	for (i = 3; i >= 0; i--)
 		arrangelayer(m, &m->layers[i], &usable_area, 0);
 
@@ -2134,7 +2134,7 @@ powermgrsetmode(struct wl_listener *listener, void *data)
 	if (!m)
 		return;
 
-	m->gamma_lut_changed = 1; /* Reapply gamma LUT when re-enabling the ouput */
+	m->gamma_lut_changed = 1; /* Reapply gamma LUT when re-enabling the output */
 	wlr_output_state_set_enabled(&state, event->mode);
 	wlr_output_commit_state(m->wlr_output, &state);
 
@@ -2456,7 +2456,7 @@ setup(void)
 	wlr_log_init(log_level, NULL);
 
 	/* The Wayland display is managed by libwayland. It handles accepting
-	 * clients from the Unix socket, manging Wayland globals, and so on. */
+	 * clients from the Unix socket, managing Wayland globals, and so on. */
 	dpy = wl_display_create();
 	event_loop = wl_display_get_event_loop(dpy);
 
Updated README to clarify branch roles
This change effectively reverts DWL to the prior development model, where development of DWL itself happens against the current wlroots release, and changes in anticipation of the next wlroots release are made on a separate branch.
thanatos · 2026-02-21 · 9b76ee8
查看变更
README.md | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index d5f2098..c81efd0 100644
--- a/README.md
+++ b/README.md
@@ -24,11 +24,13 @@ with each release on the [release] page
 
 ### Development branch [main]
 Active development progresses on the `main` branch. The `main` branch is built
-against a late (and often changing) git commit of wlroots. While the adventurous
-are welcome to use `main`, it is a rocky road. Using `main` requires that the
-user be willing to chase git commits of wlroots. Testing development pull
-requests may involve merging unmerged pull requests in [wlroots]' git repository
-and/or git commits of wayland.
+against the latest release of [wlroots]. PRs should target this branch unless they
+depend on functionality that is not in the current release of `wlroots`.
+
+### Preview branch [wlroots-next]
+The `wlroots-next` branch is built against the git version of [wlroots], which
+is unstable and changes frequently. PRs requiring functionality from the git
+version of `wlroots` should target this branch.
   
 ### Building dwl
 dwl has the following dependencies:
@@ -203,6 +205,7 @@ inspiration, and to the various contributors to the project, including:
 [dwl-patches]: https://codeberg.org/dwl/dwl-patches
 [list of useful resources on our wiki]: https://codeberg.org/dwl/dwl/wiki/Home#migrating-from-x
 [main]: https://codeberg.org/dwl/dwl/src/branch/main
+[wlroots-next]: https://codeberg.org/dwl/dwl/src/branch/wlroots-next
 [release]: https://codeberg.org/dwl/dwl/releases
 [runit]: http://smarden.org/runit/faq.html#userservices
 [s6]: https://skarnet.org/software/s6/
Corrected READMEthanatos · 2026-02-21 · 908a73d
查看变更
README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 30ffea3..d5f2098 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 # dwl - dwm for Wayland
 
-Join us on our [Discord server]
-Or Matrix: [#dwl-official:matrix.org]
+Join us on our [Discord server]  
+Or Matrix: [#dwl-official:matrix.org]  
 Or on our IRC channel: [#dwl on Libera Chat]
 
 dwl is a compact, hackable compositor for [Wayland] based on [wlroots]. It is
Added Matrix to READMEthanatos · 2026-02-21 · 227cdf0
查看变更
README.md | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 390788d..30ffea3 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
 # dwl - dwm for Wayland
 
-Join us on our IRC channel: [#dwl on Libera Chat]  
-Or on the community-maintained [Discord server].
+Join us on our [Discord server]
+Or Matrix: [#dwl-official:matrix.org]
+Or on our IRC channel: [#dwl on Libera Chat]
 
 dwl is a compact, hackable compositor for [Wayland] based on [wlroots]. It is
 intended to fill the same space in the Wayland world that [dwm] does in X11,
@@ -209,3 +210,4 @@ inspiration, and to the various contributors to the project, including:
 [wiki]: https://codeberg.org/dwl/dwl/wiki/Home#compatible-status-bars
 [Discord server]: https://discord.gg/jJxZnrGPWN
 [Wayland]: https://wayland.freedesktop.org/
+[#dwl-official:matrix.org]: https://matrix.to/#/#dwl-official:matrix.org
\ No newline at end of file
add support for the data control protocol
Enables the protocol documented at https://wayland.app/protocols/ext-data-control-v1 It is the upstreamed version of the old wlr_data_control. It is used e.g. by mpv to read and write the clipboard.
Guido Cella · 2026-02-03 · ca41230
查看变更
dwl.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/dwl.c b/dwl.c
index 44f3ad9..320910d 100644
--- a/dwl.c
+++ b/dwl.c
@@ -24,6 +24,7 @@
 #include <wlr/types/wlr_data_device.h>
 #include <wlr/types/wlr_drm.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>
 #include <wlr/types/wlr_gamma_control_v1.h>
 #include <wlr/types/wlr_idle_inhibit_v1.h>
@@ -2518,6 +2519,7 @@ setup(void)
 	wlr_export_dmabuf_manager_v1_create(dpy);
 	wlr_screencopy_manager_v1_create(dpy);
 	wlr_data_control_manager_v1_create(dpy);
+	wlr_ext_data_control_manager_v1_create(dpy, 1);
 	wlr_primary_selection_v1_device_manager_create(dpy);
 	wlr_viewporter_create(dpy);
 	wlr_single_pixel_buffer_manager_v1_create(dpy);
Remove "unmaintained" notice from README
User @thanatos has offered to take on the lead developer role for dwl.
fauxmight · 2026-02-09 · a891522
查看变更
README.md | 8 --------
 1 file changed, 8 deletions(-)
diff --git a/README.md b/README.md
index 38211c4..390788d 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,5 @@
 # dwl - dwm for Wayland
 
-2025-08-16:  
-dwl IS CURRENTLY UN-MAINTAINED.  
-AT THE PRESENT TIME, I (@fauxmight) DO NOT HAVE  
-THE TIME OR CAPACITY TO KEEP UP WITH [wlroots] CHANGES.  
-IF YOU ARE INTERESTED IN TAKING ON LEAD DEVELOPER RESPONSIBILITIES,  
-SEE ISSUE [#1166](https://codeberg.org/dwl/dwl/issues/1166).
----
-
 Join us on our IRC channel: [#dwl on Libera Chat]  
 Or on the community-maintained [Discord server].
 
config.def.h clarify Rule and MonitorRule comments closes #660A Frederick Christensen · 2025-12-27 · 9b11a49
查看变更
config.def.h | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/config.def.h b/config.def.h
index bcaa8a0..8a6eda0 100644
--- a/config.def.h
+++ b/config.def.h
@@ -20,12 +20,11 @@ static const float fullscreen_bg[]         = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
 /* logging */
 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" */
+    /* default/example rule: can be changed but cannot be eliminated; at least one rule must exist */
 };
 
 /* layout(s) */
@@ -38,17 +37,14 @@ static const Layout layouts[] = {
 
 /* 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
- * https://gitlab.freedesktop.org/xorg/xserver/-/issues/899
-*/
-/* NOTE: ALWAYS add a fallback rule, even if you are completely sure it won't be used */
+ * WARNING: negative values other than (-1, -1) cause problems with Xwayland clients due to
+ * https://gitlab.freedesktop.org/xorg/xserver/-/issues/899 */
 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 },
-	*/
-	/* defaults */
+   /* 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 }, */
 	{ NULL,       0.55f, 1,      1,    &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL,   -1,  -1 },
+	/* default monitor rule: can be changed but cannot be eliminated; at least one monitor rule must exist */
 };
 
 /* keyboard */
config.def.h whitespace cleanupA Frederick Christensen · 2025-12-27 · 53e3e60
查看变更
config.def.h | 68 ++++++++++++++++++++++++++++++++++----------------------------------
 1 file changed, 34 insertions(+), 34 deletions(-)
diff --git a/config.def.h b/config.def.h
index 804a5cb..bcaa8a0 100644
--- a/config.def.h
+++ b/config.def.h
@@ -124,40 +124,40 @@ static const char *menucmd[] = { "wmenu-run", NULL };
 
 static const Key keys[] = {
 	/* Note that Shift changes certain key codes: 2 -> at, etc. */
-	/* modifier                  key                 function        argument */
-	{ MODKEY,                    XKB_KEY_p,          spawn,          {.v = menucmd} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return,     spawn,          {.v = termcmd} },
-	{ MODKEY,                    XKB_KEY_j,          focusstack,     {.i = +1} },
-	{ MODKEY,                    XKB_KEY_k,          focusstack,     {.i = -1} },
-	{ MODKEY,                    XKB_KEY_i,          incnmaster,     {.i = +1} },
-	{ MODKEY,                    XKB_KEY_d,          incnmaster,     {.i = -1} },
-	{ MODKEY,                    XKB_KEY_h,          setmfact,       {.f = -0.05f} },
-	{ MODKEY,                    XKB_KEY_l,          setmfact,       {.f = +0.05f} },
-	{ MODKEY,                    XKB_KEY_Return,     zoom,           {0} },
-	{ MODKEY,                    XKB_KEY_Tab,        view,           {0} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_c,          killclient,     {0} },
-	{ MODKEY,                    XKB_KEY_t,          setlayout,      {.v = &layouts[0]} },
-	{ MODKEY,                    XKB_KEY_f,          setlayout,      {.v = &layouts[1]} },
-	{ MODKEY,                    XKB_KEY_m,          setlayout,      {.v = &layouts[2]} },
-	{ MODKEY,                    XKB_KEY_space,      setlayout,      {0} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space,      togglefloating, {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} },
-	{ 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} },
-	TAGKEYS(          XKB_KEY_1, XKB_KEY_exclam,                     0),
-	TAGKEYS(          XKB_KEY_2, XKB_KEY_at,                         1),
-	TAGKEYS(          XKB_KEY_3, XKB_KEY_numbersign,                 2),
-	TAGKEYS(          XKB_KEY_4, XKB_KEY_dollar,                     3),
-	TAGKEYS(          XKB_KEY_5, XKB_KEY_percent,                    4),
-	TAGKEYS(          XKB_KEY_6, XKB_KEY_asciicircum,                5),
-	TAGKEYS(          XKB_KEY_7, XKB_KEY_ampersand,                  6),
-	TAGKEYS(          XKB_KEY_8, XKB_KEY_asterisk,                   7),
-	TAGKEYS(          XKB_KEY_9, XKB_KEY_parenleft,                  8),
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_q,          quit,           {0} },
+	/* modifier                  key                  function          argument */
+	{ MODKEY,                    XKB_KEY_p,           spawn,            {.v = menucmd} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return,      spawn,            {.v = termcmd} },
+	{ MODKEY,                    XKB_KEY_j,           focusstack,       {.i = +1} },
+	{ MODKEY,                    XKB_KEY_k,           focusstack,       {.i = -1} },
+	{ MODKEY,                    XKB_KEY_i,           incnmaster,       {.i = +1} },
+	{ MODKEY,                    XKB_KEY_d,           incnmaster,       {.i = -1} },
+	{ MODKEY,                    XKB_KEY_h,           setmfact,         {.f = -0.05f} },
+	{ MODKEY,                    XKB_KEY_l,           setmfact,         {.f = +0.05f} },
+	{ MODKEY,                    XKB_KEY_Return,      zoom,             {0} },
+	{ MODKEY,                    XKB_KEY_Tab,         view,             {0} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_c,           killclient,       {0} },
+	{ MODKEY,                    XKB_KEY_t,           setlayout,        {.v = &layouts[0]} },
+	{ MODKEY,                    XKB_KEY_f,           setlayout,        {.v = &layouts[1]} },
+	{ MODKEY,                    XKB_KEY_m,           setlayout,        {.v = &layouts[2]} },
+	{ MODKEY,                    XKB_KEY_space,       setlayout,        {0} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space,       togglefloating,   {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} },
+	{ 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} },
+	TAGKEYS(          XKB_KEY_1, XKB_KEY_exclam,                        0),
+	TAGKEYS(          XKB_KEY_2, XKB_KEY_at,                            1),
+	TAGKEYS(          XKB_KEY_3, XKB_KEY_numbersign,                    2),
+	TAGKEYS(          XKB_KEY_4, XKB_KEY_dollar,                        3),
+	TAGKEYS(          XKB_KEY_5, XKB_KEY_percent,                       4),
+	TAGKEYS(          XKB_KEY_6, XKB_KEY_asciicircum,                   5),
+	TAGKEYS(          XKB_KEY_7, XKB_KEY_ampersand,                     6),
+	TAGKEYS(          XKB_KEY_8, XKB_KEY_asterisk,                      7),
+	TAGKEYS(          XKB_KEY_9, XKB_KEY_parenleft,                     8),
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_q,           quit,             {0} },
 
 	/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
 	{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
fix: ignore case of keysyms in `keybindings`jackinfurs · 2025-12-27 · 9837ea5
查看变更
config.def.h | 6 +++---
 dwl.c        | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/config.def.h b/config.def.h
index 95c2afa..804a5cb 100644
--- a/config.def.h
+++ b/config.def.h
@@ -123,7 +123,7 @@ static const char *termcmd[] = { "foot", NULL };
 static const char *menucmd[] = { "wmenu-run", NULL };
 
 static const Key keys[] = {
-	/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
+	/* Note that Shift changes certain key codes: 2 -> at, etc. */
 	/* modifier                  key                 function        argument */
 	{ MODKEY,                    XKB_KEY_p,          spawn,          {.v = menucmd} },
 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return,     spawn,          {.v = termcmd} },
@@ -135,7 +135,7 @@ static const Key keys[] = {
 	{ MODKEY,                    XKB_KEY_l,          setmfact,       {.f = +0.05f} },
 	{ MODKEY,                    XKB_KEY_Return,     zoom,           {0} },
 	{ MODKEY,                    XKB_KEY_Tab,        view,           {0} },
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C,          killclient,     {0} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_c,          killclient,     {0} },
 	{ MODKEY,                    XKB_KEY_t,          setlayout,      {.v = &layouts[0]} },
 	{ MODKEY,                    XKB_KEY_f,          setlayout,      {.v = &layouts[1]} },
 	{ MODKEY,                    XKB_KEY_m,          setlayout,      {.v = &layouts[2]} },
@@ -157,7 +157,7 @@ static const Key keys[] = {
 	TAGKEYS(          XKB_KEY_7, XKB_KEY_ampersand,                  6),
 	TAGKEYS(          XKB_KEY_8, XKB_KEY_asterisk,                   7),
 	TAGKEYS(          XKB_KEY_9, XKB_KEY_parenleft,                  8),
-	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q,          quit,           {0} },
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_q,          quit,           {0} },
 
 	/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
 	{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
diff --git a/dwl.c b/dwl.c
index 12f441e..44f3ad9 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1616,7 +1616,8 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
 	const Key *k;
 	for (k = keys; k < END(keys); k++) {
 		if (CLEANMASK(mods) == CLEANMASK(k->mod)
-				&& sym == k->keysym && k->func) {
+				&& xkb_keysym_to_lower(sym) == xkb_keysym_to_lower(k->keysym)
+				&& k->func) {
 			k->func(&k->arg);
 			return 1;
 		}
Update README.mdfauxmight · 2025-12-19 · 9ba7461
查看变更
README.md | 1 -
 1 file changed, 1 deletion(-)
diff --git a/README.md b/README.md
index 4a56b7e..38211c4 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,5 @@
 # dwl - dwm for Wayland
 
----
 2025-08-16:  
 dwl IS CURRENTLY UN-MAINTAINED.  
 AT THE PRESENT TIME, I (@fauxmight) DO NOT HAVE  
Note unmaintained status in READMEfauxmight · 2025-12-19 · aca6173
查看变更
README.md | 9 +++++++++
 1 file changed, 9 insertions(+)
diff --git a/README.md b/README.md
index 390788d..4a56b7e 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,14 @@
 # dwl - dwm for Wayland
 
+---
+2025-08-16:  
+dwl IS CURRENTLY UN-MAINTAINED.  
+AT THE PRESENT TIME, I (@fauxmight) DO NOT HAVE  
+THE TIME OR CAPACITY TO KEEP UP WITH [wlroots] CHANGES.  
+IF YOU ARE INTERESTED IN TAKING ON LEAD DEVELOPER RESPONSIBILITIES,  
+SEE ISSUE [#1166](https://codeberg.org/dwl/dwl/issues/1166).
+---
+
 Join us on our IRC channel: [#dwl on Libera Chat]  
 Or on the community-maintained [Discord server].
 
Update README.md
Document Java nonreparenting WM issue Closes #722
fauxmight · 2025-09-29 · 6cd2656
查看变更
README.md | 9 +++++++++
 1 file changed, 9 insertions(+)
diff --git a/README.md b/README.md
index d131bb0..390788d 100644
--- a/README.md
+++ b/README.md
@@ -118,6 +118,15 @@ script with the line
 
 To get a list of status bars that work with dwl consult our [wiki].
 
+### (Known) Java nonreparenting WM issue
+Certain IDEs don't display correctly unless an environmental variable for Java AWT
+indicates that the WM is nonreparenting.
+
+For some Java AWT-based IDEs, such as Xilinx Vivado and Microchip MPLAB X, the
+following environment variable needs to be set before running the IDE or dwl:
+
+    export _JAVA_AWT_WM_NONREPARENTING=1
+
 ## Replacements for X applications
 
 You can find a [list of useful resources on our wiki].
Update README.md
Make "dwl" references in README.md links to dwm main site. Closes #1168
fauxmight · 2025-09-29 · ed2e1ef
查看变更
README.md | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 364e3ca..d131bb0 100644
--- a/README.md
+++ b/README.md
@@ -4,9 +4,9 @@ Join us on our IRC channel: [#dwl on Libera Chat]
 Or on the community-maintained [Discord server].
 
 dwl is a compact, hackable compositor for [Wayland] based on [wlroots]. It is
-intended to fill the same space in the Wayland world that dwm does in X11,
+intended to fill the same space in the Wayland world that [dwm] does in X11,
 primarily in terms of functionality, and secondarily in terms of
-philosophy. Like dwm, dwl is:
+philosophy. Like [dwm], dwl is:
 
 - Easy to understand, hack on, and extend with patches
 - One C source file (or a very small number) configurable via `config.h`
@@ -55,11 +55,11 @@ To enable XWayland, you should uncomment its flags in `config.mk`.
 ## Configuration
 
 All configuration is done by editing `config.h` and recompiling, in the same
-manner as dwm. There is no way to separately restart the window manager in
+manner as [dwm]. There is no way to separately restart the window manager in
 Wayland without restarting the entire display server, so any changes will take
 effect the next time dwl is executed.
 
-As in the dwm community, we encourage users to share patches they have
+As in the [dwm] community, we encourage users to share patches they have
 created. Check out the [dwl-patches] repository!
 
 ## Running dwl
@@ -124,11 +124,11 @@ You can find a [list of useful resources on our wiki].
 
 ## Background
 
-dwl is not meant to provide every feature under the sun. Instead, like dwm, it
+dwl is not meant to provide every feature under the sun. Instead, like [dwm], it
 sticks to features which are necessary, simple, and straightforward to implement
 given the base on which it is built. Implemented default features are:
 
-- Any features provided by dwm/Xlib: simple window borders, tags, keybindings,
+- Any features provided by [dwm]/Xlib: simple window borders, tags, keybindings,
   client rules, mouse move/resize. Providing a built-in status bar is an
   exception to this goal, to avoid dependencies on font rendering and/or drawing
   libraries when an external bar could work well.
@@ -145,10 +145,10 @@ given the base on which it is built. Implemented default features are:
 - Layer shell popups (used by Waybar)
 - Damage tracking provided by scenegraph API
 
-Given the Wayland architecture, dwl has to implement features from dwm **and**
+Given the Wayland architecture, dwl has to implement features from [dwm] **and**
 the xorg-server. Because of this, it is impossible to maintain the original
 project goal of 2000 SLOC and have a reasonably complete compositor with
-features comparable to dwm. However, this does not mean that the code will grow
+features comparable to [dwm]. However, this does not mean that the code will grow
 indiscriminately. We will try to keep the code as small as possible.
 
 Features under consideration (possibly as patches) are:
@@ -172,7 +172,7 @@ developers. This was made possible in many cases by looking at how sway
 accomplished something, then trying to do the same in as suckless a way as
 possible.
 
-Many thanks to suckless.org and the dwm developers and community for the
+Many thanks to suckless.org and the [dwm] developers and community for the
 inspiration, and to the various contributors to the project, including:
 
 - **Devin J. Pohly for creating and nurturing the fledgling project**
@@ -183,6 +183,7 @@ inspiration, and to the various contributors to the project, including:
 
 
 [wlroots]: https://gitlab.freedesktop.org/wlroots
+[dwm]: https://dwm.suckless.org/
 [`systemd --user`]: https://wiki.archlinux.org/title/Systemd/User
 [#dwl on Libera Chat]: https://web.libera.chat/?channels=#dwl
 [0.7-rc1]: https://codeberg.org/dwl/dwl/releases/tag/v0.7-rc1
Revert "add support for ext-image-copy-capture-v1 and ext-image-capture-source-v1 (wlroots!4545)"
This reverts commit b28674e0ca4a9ecc92cb0607498e3db2df3d4c00. This PR is not yet finalized. (Screen freezes).
A Frederick Christensen · 2025-08-04 · ab4cb6e
查看变更
Makefile | 4 ----
 dwl.c    | 4 ----
 2 files changed, 8 deletions(-)
diff --git a/Makefile b/Makefile
index 3981fbb..578194f 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,6 @@ 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 \
-	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
 util.o: util.c util.h
@@ -34,9 +33,6 @@ WAYLAND_PROTOCOLS = `$(PKG_CONFIG) --variable=pkgdatadir wayland-protocols`
 cursor-shape-v1-protocol.h:
 	$(WAYLAND_SCANNER) enum-header \
 		$(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@
-ext-image-copy-capture-v1-protocol.h:
-	$(WAYLAND_SCANNER) enum-header \
-		$(WAYLAND_PROTOCOLS)/staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml $@
 pointer-constraints-unstable-v1-protocol.h:
 	$(WAYLAND_SCANNER) enum-header \
 		$(WAYLAND_PROTOCOLS)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml $@
diff --git a/dwl.c b/dwl.c
index 1dad6ac..12f441e 100644
--- a/dwl.c
+++ b/dwl.c
@@ -24,8 +24,6 @@
 #include <wlr/types/wlr_data_device.h>
 #include <wlr/types/wlr_drm.h>
 #include <wlr/types/wlr_export_dmabuf_v1.h>
-#include <wlr/types/wlr_ext_image_capture_source_v1.h>
-#include <wlr/types/wlr_ext_image_copy_capture_v1.h>
 #include <wlr/types/wlr_fractional_scale_v1.h>
 #include <wlr/types/wlr_gamma_control_v1.h>
 #include <wlr/types/wlr_idle_inhibit_v1.h>
@@ -2518,8 +2516,6 @@ setup(void)
 	wlr_data_device_manager_create(dpy);
 	wlr_export_dmabuf_manager_v1_create(dpy);
 	wlr_screencopy_manager_v1_create(dpy);
-	wlr_ext_image_copy_capture_manager_v1_create(dpy, 1);
-	wlr_ext_output_image_capture_source_manager_v1_create(dpy, 1);
 	wlr_data_control_manager_v1_create(dpy);
 	wlr_primary_selection_v1_device_manager_create(dpy);
 	wlr_viewporter_create(dpy);
add support for ext-image-copy-capture-v1 and ext-image-capture-source-v1 (wlroots!4545)
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4545
Leonardo Hernández Hernández · 2025-01-14 · b28674e
查看变更
Makefile | 4 ++++
 dwl.c    | 4 ++++
 2 files changed, 8 insertions(+)
diff --git a/Makefile b/Makefile
index 578194f..3981fbb 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,7 @@ 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 \
+	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
 util.o: util.c util.h
@@ -33,6 +34,9 @@ WAYLAND_PROTOCOLS = `$(PKG_CONFIG) --variable=pkgdatadir wayland-protocols`
 cursor-shape-v1-protocol.h:
 	$(WAYLAND_SCANNER) enum-header \
 		$(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@
+ext-image-copy-capture-v1-protocol.h:
+	$(WAYLAND_SCANNER) enum-header \
+		$(WAYLAND_PROTOCOLS)/staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml $@
 pointer-constraints-unstable-v1-protocol.h:
 	$(WAYLAND_SCANNER) enum-header \
 		$(WAYLAND_PROTOCOLS)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml $@
diff --git a/dwl.c b/dwl.c
index 12f441e..1dad6ac 100644
--- a/dwl.c
+++ b/dwl.c
@@ -24,6 +24,8 @@
 #include <wlr/types/wlr_data_device.h>
 #include <wlr/types/wlr_drm.h>
 #include <wlr/types/wlr_export_dmabuf_v1.h>
+#include <wlr/types/wlr_ext_image_capture_source_v1.h>
+#include <wlr/types/wlr_ext_image_copy_capture_v1.h>
 #include <wlr/types/wlr_fractional_scale_v1.h>
 #include <wlr/types/wlr_gamma_control_v1.h>
 #include <wlr/types/wlr_idle_inhibit_v1.h>
@@ -2516,6 +2518,8 @@ setup(void)
 	wlr_data_device_manager_create(dpy);
 	wlr_export_dmabuf_manager_v1_create(dpy);
 	wlr_screencopy_manager_v1_create(dpy);
+	wlr_ext_image_copy_capture_manager_v1_create(dpy, 1);
+	wlr_ext_output_image_capture_source_manager_v1_create(dpy, 1);
 	wlr_data_control_manager_v1_create(dpy);
 	wlr_primary_selection_v1_device_manager_create(dpy);
 	wlr_viewporter_create(dpy);
fullscreen_bg defaults to black
Per conversation at PR #1147 with @kilpilainen
A Frederick Christensen · 2025-06-18 · 15bfffd
查看变更
config.def.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config.def.h b/config.def.h
index 22d2171..95c2afa 100644
--- a/config.def.h
+++ b/config.def.h
@@ -12,7 +12,7 @@ static const float bordercolor[]           = COLOR(0x444444ff);
 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 float fullscreen_bg[]         = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
 
 /* tagging - TAGCOUNT must be no greater than 31 */
 #define TAGCOUNT (9)
Update README.md
Correct description of default background color
fauxmight · 2025-06-18 · 90b8371
查看变更
README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index b876fdb..364e3ca 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,7 @@ seatd daemon.
 When dwl is run with no arguments, it will launch the server and begin handling
 any shortcuts configured in `config.h`. There is no status bar or other
 decoration initially; these are instead clients that can be run within the
-Wayland session. Do note that the default background color is black. This can be
+Wayland session. Do note that the default background color is grey. This can be
 modified in `config.h`.
 
 If you would like to run a script or command automatically at startup, you can
float sub-windows matching a rule
Currently when a rule that doesn't make windows floating matches, even sub-windows of float type get tiled rather than just the main window. This is inconsistent with dwm and other compositors. Fix this by making these windows floating after applying rules. Fixes #1142.
Guido Cella · 2025-06-14 · ea263a0
查看变更
dwl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dwl.c b/dwl.c
index 76b7755..12f441e 100644
--- a/dwl.c
+++ b/dwl.c
@@ -483,7 +483,6 @@ applyrules(Client *c)
 	const Rule *r;
 	Monitor *mon = selmon, *m;
 
-	c->isfloating = client_is_float_type(c);
 	appid = client_get_appid(c);
 	title = client_get_title(c);
 
@@ -499,6 +498,8 @@ applyrules(Client *c)
 			}
 		}
 	}
+
+	c->isfloating |= client_is_float_type(c);
 	setmon(c, mon, newtags);
 }
 
document status outputLeonardo Hernández Hernández · 2024-12-26 · 67ff29e
查看变更
README.md |   2 +-
 dwl.1     | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 102 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index b8e3a3a..b876fdb 100644
--- a/README.md
+++ b/README.md
@@ -103,7 +103,7 @@ automatically, you will need to configure it prior to launching `dwl`, e.g.:
 
 Information about selected layouts, current window title, app-id, and
 selected/occupied/urgent tags is written to the stdin of the `-s` command (see
-the `printstatus()` function for details).  This information can be used to
+the `STATUS INFORMATION` section in `_dwl_(1)`).  This information can be used to
 populate an external status bar with a script that parses the
 information. Failing to read this information will cause dwl to block, so if you
 do want to run a startup command that does not consume the status information,
diff --git a/dwl.1 b/dwl.1
index fccf569..7fee870 100644
--- a/dwl.1
+++ b/dwl.1
@@ -37,7 +37,7 @@ starts a shell process running
 when starting.
 When stopping, it sends
 .Dv SIGTERM
-to the child process and waits for it to exit.
+to the child process group and waits for it to exit.
 .Pp
 Users are encouraged to customize
 .Nm
@@ -55,10 +55,10 @@ Move window to a single tag.
 Toggle tag for window.
 .It Mod-p
 Spawn
-.Nm wmenu-run .
+.Xr wmenu-run 1 .
 .It Mod-Shift-Return
 Spawn
-.Nm foot .
+.Xr foot 1 .
 .It Mod-[jk]
 Move focus down/up the stack.
 .It Mod-[id]
@@ -111,6 +111,103 @@ Toggle focused window between floating and tiled state.
 Resize focused window while dragging.
 Tiled windows will be toggled to the floating state.
 .El
+.Sh STATUS INFORMATION
+.Nm
+writes its status information to standard output.
+If the
+.Fl s
+option is given, the status information is written to the standard input of the
+child process instead.
+.Pp
+Said information has the following format:
+.Bd -ragged -offset indent
+.Ar <monitor>
+.Ar <component>
+.Ar <data>
+.Ed
+.Pp
+.Bl -tag -width 11n -offset 0 -compact
+.It Ar <monitor>
+is the name given to the output.
+.It Ar <component>
+is one of (in order)
+.Em title ,
+.Em appid ,
+.Em fullscreen ,
+.Em floating ,
+.Em selmon ,
+.Em tags ,
+.Em layout .
+.It Ar <data>
+changes depending on
+.Ar <component> .
+.Bl -tag -width 10n -compact
+.It Em title
+The title of the focused window on
+.Ar <monitor>
+or nothing if there is no focused window.
+.It Em appid
+The app_id of the focused window on
+.Ar <monitor>
+or nothing if there is no focused window.
+.It Em fullscreen
+Prints 1 if the focused window on
+.Ar <monitor>
+is in fullscreen state, otherwise prints 0. If there is no focused
+window it prints nothing.
+.It Em floating
+Prints 1 if the focused window on
+.Ar <monitor>
+is in floating state, otherwise prints 0. If there is no focused
+window it prints nothing.
+.It Em selmon
+Prints 1 if
+.Ar <monitor>
+is the selected monitor, otherwise prints 0.
+.It Em tags
+Prints four bitmasks in the following order:
+.Bl -bullet -width 2n -compact
+.It
+Occupied tags of
+.Ar <monitor> .
+.It
+Selected tags of
+.Ar <monitor> .
+.It
+Tags of the focused window on
+.Ar <monitor> .
+.It
+Tags where a window on
+.Ar <monitor>
+requested activation or has urgency hints.
+.El
+The bitmasks are 32-bit unsigned decimal integers.
+.It Em layout
+Prints the symbol of the current layout.
+.El
+.El
+.Ss Examples
+When there is a selected window:
+.Bd -literal -offset indent
+HDMI\-A\-1 title \(ti/source/repos/dwl > man \-l dwl.1
+HDMI\-A\-1 appid footclient
+HDMI\-A\-1 fullscreen 0
+HDMI\-A\-1 floating 0
+HDMI\-A\-1 selmon 1
+HDMI\-A\-1 tags 271 4 4 0
+HDMI\-A\-1 layout [T]
+.Ed
+.Pp
+When there is no selected window:
+.Bd -literal -offset indent
+HDMI\-A\-1 title
+HDMI\-A\-1 appid
+HDMI\-A\-1 fullscreen
+HDMI\-A\-1 floating
+HDMI\-A\-1 selmon 1
+HDMI\-A\-1 tags 271 512 0 0
+HDMI\-A\-1 layout [T]
+.Ed
 .Sh ENVIRONMENT
 These environment variables are used by
 .Nm :
@@ -153,9 +250,9 @@ Start
 with s6 in the background:
 .Dl dwl \-s \(aqs6\-svscan <&\-\(aq
 .Sh SEE ALSO
+.Xr dwm 1 ,
 .Xr foot 1 ,
 .Xr wmenu 1 ,
-.Xr dwm 1 ,
 .Xr xkeyboard-config 7
 .Sh BUGS
 All of them.
Use a subsection for mouse commands
also add missing ".El", s/Toggles/Toggle/ in second command and add newlines after a full stop
Leonardo Hernández Hernández · 2024-09-27 · 661e1ee
查看变更
dwl.1 | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/dwl.1 b/dwl.1
index 65648f4..fccf569 100644
--- a/dwl.1
+++ b/dwl.1
@@ -100,16 +100,17 @@ Quit
 .Nm .
 .El
 These might differ depending on your keyboard layout.
-.Sh Mouse commands
+.Ss Mouse commands
 .Bl -tag -width 20n -offset indent -compact
 .It Mod-Button1
-Move focused window while dragging. Tiled windows will be toggled to the floating state.
+Move focused window while dragging.
+Tiled windows will be toggled to the floating state.
 .It Mod-Button2
-Toggles focused window between floating and tiled state.
+Toggle focused window between floating and tiled state.
 .It Mod-Button3
-Resize focused window while dragging. Tiled windows will be toggled to
-the
-floating state.
+Resize focused window while dragging.
+Tiled windows will be toggled to the floating state.
+.El
 .Sh ENVIRONMENT
 These environment variables are used by
 .Nm :