Compare commits

..
36 Commits
Author SHA1 Message Date
Guido Cella 28f91b0326 foreign-toplevel-management: update 2026-11-03 01:20:08 +01:00
julmajustus 3360d3acf7 btrtile: update patches for main
- Refactored the resizing logic to work with the changes in main
   branch.
 - Replaced the fixed resize_interval_ms throttle with a pending flag
   set from motionnotify() and applied once per output frame from
   rendermon(), so the resize update rate follows the display refresh rate.
2026-10-29 20:11:47 +02:00
Guido Cella 730f15e95e scenefx: update 2026-10-29 18:15:34 +01:00
André Desgualdo Pereira 9e89b5823f Fix swapfocus README 2026-10-25 13:55:47 -03:00
iglt 78e632455b swapfocus: fix readme 2026-10-25 12:35:52 +01:00
iglt ae0fe9e212 swapfocus: minor update 2026-10-25 12:32:30 +01:00
Guido Cella 8a28588683 switchtotag: update 2026-10-20 21:28:18 +02:00
Guido Cella c71551b288 center-terminal: remove this
This is too obscure. I haven't used it in forever and I doubt anyone
uses it.
2026-10-19 18:04:12 +02:00
Dhruva Sambrani 4dbca64379 extrabar: fix stale bar on monitor removal/disable 2026-10-14 13:05:51 +02:00
killertofus 7b42b1ab4d squashed 2026-10-10 01:48:56 +02:00
Guido CellaandKaon 20598d28dc unclutter: fix a rare crash when last_cursor points to freed memory
I couldn't reproduce this, but this is also what mangowm does.

Fixes https://codeberg.org/dwl/dwl-patches/issues/675

Co-authored-by: Kaon <uriel@tuta.com>
2026-10-04 22:51:24 +02:00
atourist de72d2bb3c refactor chainkeys patch 2026-10-02 11:06:30 -07:00
pi66 f974a35dab fix: animation glitches and zoom logic 2026-09-30 00:07:51 +01:00
pi66 1be70745cc focusdir: update for dwl v0.9 and wlroots-next-4fd683c 2026-09-29 12:24:56 +01:00
pi66 3f5c2329b4 touch-input: update README for wlroots-next-4fd683c 2026-09-29 12:00:44 +01:00
pi66 d69efde56f touch-input: update for wlroots-next-4fd683c 2026-09-29 11:50:56 +01:00
pi66 e142fc1e5e add: zoom and bezier animation support 2026-09-29 11:28:47 +01:00
atourist 06112ab17a Add blur patch 2026-09-28 21:47:38 +02:00
André Desgualdo Pereira 08c7e3b6fb update focusonurgent patch to current dwl modifications on focusclient 2026-09-28 08:18:50 -03:00
pi66 93435f5ced touch-input: update for 0.9 and for wlroots-next-f1675a4 2026-09-27 20:12:08 +02:00
Dhruva Sambrani a733201614 winview: rebase to latest main 2026-09-27 17:11:40 +02:00
Dhruva Sambrani 3ff8f1731f [gaplessgrid] bring in kanas updates to latest patch 2026-09-27 17:10:57 +02:00
Dhruva Sambrani 1725192f63 dim-unfocused: rebase to latest main 2026-09-27 17:03:15 +02:00
Dhruva Sambrani eca40ea3ed skipfocus: rebase to latest main 2026-09-27 17:02:36 +02:00
Dhruva Sambrani ef95baef73 gaplessgrid: rebase to latest main 2026-09-27 17:01:52 +02:00
Guido Cella ac60875541 unclutter: update 2026-09-26 12:30:27 +02:00
Palanix 3940eaa6a4 Update dragmfact to v0.9 2026-09-25 18:25:18 +02:00
Palanix 2c342cc0b4 Update monitorconfig to 0.9 2026-09-25 18:21:11 +02:00
julmajustus fd5e06a50d ipc: update for v0.9 2026-09-21 21:49:55 +03:00
julmajustus 701d0756a1 btrtile: update 2026-09-21 21:31:58 +03:00
julmajustus 40da88b1ee fullscreenadaptivesync: update 2026-09-21 21:05:28 +03:00
julmajustus 85cc52630c simple_scratchpad: update 2026-09-21 20:57:11 +03:00
julmajustus 77bc50859c fullscreenadaptivesync: update
- Updated to current main
2026-09-20 03:30:30 +03:00
julmajustus d5bbf841c2 simple_scratchpad: update
- Updated to current main
2026-09-20 03:27:16 +03:00
julmajustus 0d41b75737 btrtile: update and minor changes
- Updated to current main
 - Added more user toggles to control the behaviour of btrtile into
   config.h
 - Simplified the btrtile gapps logic
 - Simplified the changes to dwl.c
 - Added two keybind functions to swap and toggle splits
 - Minor code cleanups
 - Added functionality to respect the client size hints
2026-09-20 03:18:11 +03:00
julmajustus 161586e355 ipc: update patch
- Revived ipc patch from stale-patches
 - Update to match the current dwl main branch
 - Protocol feature addition: extended dwl-ipc protocol with
   focused_geometry which allows passing the client geometry details
   trough the ipc
 - Cleaned the README.md
 - Pointed dwlmsg to updated fork
2026-09-20 02:50:18 +03:00
71 changed files with 9087 additions and 3442 deletions
+9
View File
@@ -0,0 +1,9 @@
## Description
Choose multiple/one floating window to be always-on-top - this prevents other floating windows from being raised above it. Useful for playing films, etc.
this builds against tag 0.9 and also against commit 1dae5ba3ed.
### Download
- [2026-09-17](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/ontop/ontop.patch)
### Author
- [killertofus](https://codeberg.org/killertofus)
killertofus irc/matrix
with help from kana
+99
View File
@@ -0,0 +1,99 @@
diff --git a/config.def.h b/config.def.h
index 13c5322..0af77b2 100644
--- a/config.def.h
+++ b/config.def.h
@@ -137,6 +137,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
+ { MODKEY|WLR_MODIFIER_ALT, XKB_KEY_space, togglealwaysontop, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_0, tag, {.ui = ~0} },
diff --git a/dwl.c b/dwl.c
index c51e0d5..a6c9a05 100644
--- a/dwl.c
+++ b/dwl.c
@@ -88,7 +88,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, LyrTile, LyrFloat, LyrAlwaysTop, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
enum { AxisUp, AxisRight, AxisDown, AxisLeft };
@@ -158,7 +158,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, isalwaysontop;
} Client;
typedef struct {
@@ -355,6 +355,7 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
+static void togglealwaysontop(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -565,7 +566,7 @@ arrange(Monitor *m)
/* We move all clients (except fullscreen and unmanaged) to LyrTile while
* in floating layout to avoid "real" floating clients be always on top */
wl_list_for_each(c, &clients, link) {
- if (c->mon != m || c->scene->node.parent == layers[LyrFS])
+ if (c->mon != m || c->scene->node.parent == layers[LyrFS] || c->isalwaysontop)
continue;
wlr_scene_node_reparent(&c->scene->node,
@@ -2487,7 +2488,8 @@ setfloating(Client *c, int floating)
return;
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ||
(p && p->isfullscreen) ? LyrFS
- : c->isfloating ? LyrFloat : LyrTile]);
+ : c->isfloating ? (c->isalwaysontop ? LyrAlwaysTop : LyrFloat) : LyrTile]);
+
arrange(c->mon);
printstatus();
}
@@ -2501,7 +2503,8 @@ setfullscreen(Client *c, int fullscreen)
c->bw = fullscreen ? 0 : borderpx;
client_set_fullscreen(c, fullscreen);
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
- ? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
+ ? LyrFS : c->isfloating ? (c->isalwaysontop ? LyrAlwaysTop : LyrFloat) : LyrTile]);
+
if (fullscreen) {
c->prev = c->geom;
@@ -2515,6 +2518,27 @@ setfullscreen(Client *c, int fullscreen)
printstatus();
}
+void
+togglealwaysontop(const Arg *arg)
+{
+ Client *sel = focustop(selmon);
+ if (!sel)
+ return;
+
+ if (sel->isfullscreen)
+ return;
+
+ if (sel->isalwaysontop) {
+ wlr_scene_node_reparent(&sel->scene->node, layers[sel->isalwaysontop]);
+ sel->isalwaysontop = 0;
+ } else {
+ sel->isalwaysontop = sel->isfullscreen ? LyrFS : LyrTile;
+ wlr_scene_node_reparent(&sel->scene->node, layers[LyrAlwaysTop]);
+ }
+ arrange(selmon);
+}
+
+
void
setlayout(const Arg *arg)
{
+10
View File
@@ -0,0 +1,10 @@
### Description
Add simple animation support with a [cubic-bezier](https://en.wikipedia.org/wiki/B%C3%A9zier_curve) curve.
### Download
- [git branch](/pi66/dwl-patches/src/branch/animation)
- [animation-0.9.patch](/dwl/dwl-patches/raw/branch/main/patches/animation/animation-0.9.patch)
- [animation-e203845.patch](/dwl/dwl-patches/raw/branch/main/patches/animation/animation-e203845.patch)
### Authors
- [Pi66](https://codeberg.org/pi66)
+307
View File
@@ -0,0 +1,307 @@
From 302ace232def0685dfccefe5d48570996263619d Mon Sep 17 00:00:00 2001
From: pi66 <pixel2176@proton.me>
Date: Wed, 30 Sep 2026 00:05:37 +0100
Subject: [PATCH] fix: animation glitches and zoom logic
---
client.h | 9 +--
config.def.h | 4 ++
dwl.c | 155 ++++++++++++++++++++++++++++++++++++++++++++-------
3 files changed, 144 insertions(+), 24 deletions(-)
diff --git a/client.h b/client.h
index dc0615e..9300417 100644
--- a/client.h
+++ b/client.h
@@ -365,7 +365,7 @@ client_set_scale(struct wlr_surface *s, float scale)
wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale));
}
-static inline void
+static inline uint32_t
client_set_size(Client *c, uint32_t width, uint32_t height)
{
#ifdef XWAYLAND
@@ -375,9 +375,10 @@ 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);
+ 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);
}
static inline void
diff --git a/config.def.h b/config.def.h
index 13c5322..b0c17e8 100644
--- a/config.def.h
+++ b/config.def.h
@@ -15,6 +15,10 @@ 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 */
+/* animation */
+static const unsigned int animation_duration = 300; /* ms */
+static const float animation_curve[4] = {0.0f, 0.85f, 0.2f, 1.0f}; /* cubic-bezier x1, y1, x2, y2 */
+
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
diff --git a/dwl.c b/dwl.c
index 4cfd0fd..81f157d 100644
--- a/dwl.c
+++ b/dwl.c
@@ -86,6 +86,7 @@
#define LISTEN_STATIC(E, H) do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0)
/* enums */
+enum { CliNormal, CliClosing, CliOpening }; /* client events */
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
enum { XDGShell, LayerShell, X11 }; /* client types */
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
@@ -159,6 +160,11 @@ typedef struct {
unsigned int bw;
uint32_t tags;
int isfloating, isurgent, isfullscreen;
+
+ /* Animation */
+ struct wlr_box anim_from, anim_to, anim_cur;
+ uint32_t anim_start, serial;
+ int animating, status;
} Client;
typedef struct {
@@ -260,6 +266,10 @@ typedef struct {
} SessionLock;
/* function declarations */
+static uint32_t animation_now_ms(void);
+static float animation_bezier(float t);
+static int animation_tick(void *data);
+static void animation_apply(Client *c, struct wlr_box g);
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
static void arrange(Monitor *m);
@@ -374,6 +384,7 @@ static void xytonode(double x, double y, struct wlr_surface **psurface,
static void zoom(const Arg *arg);
/* variables */
+static struct wl_event_source *animation_timer;
static pid_t child_pid = -1;
static int locked;
static void *exclusive_focus;
@@ -485,6 +496,86 @@ static struct wlr_xwayland *xwayland;
#include "ime.h"
/* function implementations */
+uint32_t
+animation_now_ms(void)
+{
+ struct timespec t;
+
+ clock_gettime(CLOCK_MONOTONIC, &t);
+ return t.tv_sec * 1000 + t.tv_nsec / 1000000;
+}
+
+float
+animation_bezier(float t)
+{
+ float x1 = animation_curve[0], y1 = animation_curve[1];
+ float x2 = animation_curve[2], y2 = animation_curve[3];
+ float lo = 0, hi = 1, s = t, x;
+ int i;
+
+ for (i = 0; i < 20; i++) {
+ x = 3*(1-s)*(1-s)*s*x1 + 3*(1-s)*s*s*x2 + s*s*s;
+ if (x < t)
+ lo = s;
+ else
+ hi = s;
+ s = (lo + hi) / 2;
+ }
+ return 3*(1-s)*(1-s)*s*y1 + 3*(1-s)*s*s*y2 + s*s*s;
+}
+
+int
+animation_tick(void *data)
+{
+ Client *c;
+ float t, p;
+ int more = 0;
+
+ wl_list_for_each(c, &clients, link) {
+ if (!c->animating)
+ continue;
+ t = (animation_now_ms() - c->anim_start) / (float)animation_duration;
+ if (t >= 1) {
+ t = 1;
+ c->animating = 0;
+ }
+ p = animation_bezier(t);
+ c->anim_cur.x = (int)(c->anim_from.x + (c->anim_to.x - c->anim_from.x) * p);
+ c->anim_cur.y = (int)(c->anim_from.y + (c->anim_to.y - c->anim_from.y) * p);
+ c->anim_cur.width = (int)(c->anim_from.width + (c->anim_to.width - c->anim_from.width) * p);
+ c->anim_cur.height = (int)(c->anim_from.height + (c->anim_to.height - c->anim_from.height) * p);
+
+ animation_apply(c, c->anim_cur);
+ more |= c->animating;
+ }
+ if (more)
+ wl_event_source_timer_update(animation_timer, 16);
+ return 0;
+}
+
+void
+animation_apply(Client *c, struct wlr_box g)
+{
+ struct wlr_box clip, save = c->geom;
+
+ c->geom = g;
+
+ 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);
+ 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);
+
+ client_get_clip(c, &clip);
+ wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
+
+ c->geom = save;
+}
+
void
applybounds(Client *c, struct wlr_box *bbox)
{
@@ -1873,6 +1964,7 @@ mapnotify(struct wl_listener *listener, void *data)
.title = client_get_title(c),
};
+ c->status = CliOpening;
/* 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() */
@@ -2322,12 +2414,17 @@ rendermon(struct wl_listener *listener, void *data)
* generally at the output's refresh rate (e.g. 60Hz). */
Monitor *m = wl_container_of(listener, m, frame);
struct timespec now;
+ Client *c;
if (!wlr_scene_output_needs_frame(m->scene_output)) {
return;
}
+ wl_list_for_each(c, &clients, link)
+ if (c->serial && !c->isfloating && client_is_rendered_on_mon(c, m) && !client_is_stopped(c))
+ goto skip;
wlr_scene_output_commit(m->scene_output, NULL);
+skip:
clock_gettime(CLOCK_MONOTONIC, &now);
wlr_scene_output_send_frame_done(m->scene_output, &now);
}
@@ -2365,7 +2462,6 @@ void
resize(Client *c, struct wlr_box geo, int interact)
{
struct wlr_box *bbox;
- struct wlr_box clip;
if (!c->mon || !client_surface(c)->mapped)
return;
@@ -2375,21 +2471,27 @@ resize(Client *c, struct wlr_box geo, int interact)
client_set_bounds(c, geo.width, geo.height);
c->geom = geo;
applybounds(c, bbox);
+ c->serial = client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw);
- /* 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);
- 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);
+ if (interact) {
+ c->animating = 0;
+ c->anim_cur = c->geom;
+ animation_apply(c, c->geom);
+ return;
+ }
- 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);
+ if (!c->animating && c->anim_cur.width == 0) {
+ c->anim_cur.width = c->geom.width / 2;
+ c->anim_cur.height = c->geom.height / 2;
+ c->anim_cur.x = c->geom.x + (c->geom.width - c->anim_cur.width) / 2;
+ c->anim_cur.y = c->geom.y + (c->geom.height - c->anim_cur.height) / 2;
+ }
+
+ c->anim_from = c->anim_cur;
+ c->anim_to = c->geom;
+ c->anim_start = animation_now_ms();
+ c->animating = 1;
+ wl_event_source_timer_update(animation_timer, 1);
}
void
@@ -2615,6 +2717,7 @@ setup(void)
* clients from the Unix socket, managing Wayland globals, and so on. */
dpy = wl_display_create();
event_loop = wl_display_get_event_loop(dpy);
+ animation_timer = wl_event_loop_add_timer(event_loop, animation_tick, NULL);
/* The backend is a wlroots feature which abstracts the underlying input and
* output hardware. The autocreate option will choose the most suitable
@@ -2896,19 +2999,31 @@ tile(Monitor *m)
mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
else
mw = m->w.width;
+
i = my = ty = 0;
wl_list_for_each(c, &clients, link) {
+ struct wlr_box geo;
+
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;
+ geo = (struct wlr_box){m->w.x, m->w.y + my, mw,
+ (m->w.height - my) / (MIN(n, m->nmaster) - i)};
+ my += geo.height;
} 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;
+ geo = (struct wlr_box){m->w.x + mw, m->w.y + ty, m->w.width - mw,
+ (m->w.height - ty) / (n - i)};
+ ty += geo.height;
+ }
+
+ if (c->status == CliOpening) {
+ c->anim_cur = (struct wlr_box){geo.x + geo.width / 4, geo.y + geo.height / 4,
+ geo.width / 2, geo.height / 2};
+ c->anim_from = c->anim_cur;
+ c->status = CliNormal;
}
+ resize(c, geo, 0);
i++;
}
}
--
2.55.0
+307
View File
@@ -0,0 +1,307 @@
From e8f65d36d788cfb0a02984ecaf979d639388913c Mon Sep 17 00:00:00 2001
From: pi66 <pixel2176@proton.me>
Date: Wed, 30 Sep 2026 00:03:31 +0100
Subject: [PATCH] fix: animation glitches and zoom logic
---
client.h | 9 +--
config.def.h | 4 ++
dwl.c | 155 ++++++++++++++++++++++++++++++++++++++++++++-------
3 files changed, 144 insertions(+), 24 deletions(-)
diff --git a/client.h b/client.h
index eb1bb47..a271446 100644
--- a/client.h
+++ b/client.h
@@ -366,7 +366,7 @@ client_set_scale(struct wlr_surface *s, float scale)
wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale));
}
-static inline void
+static inline uint32_t
client_set_size(Client *c, uint32_t width, uint32_t height)
{
#ifdef XWAYLAND
@@ -376,9 +376,10 @@ 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);
+ 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);
}
static inline void
diff --git a/config.def.h b/config.def.h
index a4019d3..d37aa10 100644
--- a/config.def.h
+++ b/config.def.h
@@ -15,6 +15,10 @@ 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 */
+/* animation */
+static const unsigned int animation_duration = 300; /* ms */
+static const float animation_curve[4] = {0.0f, 0.85f, 0.2f, 1.0f}; /* cubic-bezier x1, y1, x2, y2 */
+
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
diff --git a/dwl.c b/dwl.c
index 216deb5..50e1687 100644
--- a/dwl.c
+++ b/dwl.c
@@ -86,6 +86,7 @@
#define LISTEN_STATIC(E, H) do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0)
/* enums */
+enum { CliNormal, CliClosing, CliOpening }; /* client events */
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
enum { XDGShell, LayerShell, X11 }; /* client types */
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
@@ -159,6 +160,11 @@ typedef struct {
unsigned int bw;
uint32_t tags;
int isfloating, isurgent, isfullscreen;
+
+ /* Animation */
+ struct wlr_box anim_from, anim_to, anim_cur;
+ uint32_t anim_start, serial;
+ int animating, status;
} Client;
typedef struct {
@@ -261,6 +267,10 @@ typedef struct {
} SessionLock;
/* function declarations */
+static uint32_t animation_now_ms(void);
+static float animation_bezier(float t);
+static int animation_tick(void *data);
+static void animation_apply(Client *c, struct wlr_box g);
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
static void arrange(Monitor *m);
@@ -376,6 +386,7 @@ static void xytonode(double x, double y, struct wlr_surface **psurface,
static void zoom(const Arg *arg);
/* variables */
+static struct wl_event_source *animation_timer;
static pid_t child_pid = -1;
static int locked;
static Client *focused_client;
@@ -486,6 +497,86 @@ static struct wlr_xwayland *xwayland;
#include "ime.h"
/* function implementations */
+uint32_t
+animation_now_ms(void)
+{
+ struct timespec t;
+
+ clock_gettime(CLOCK_MONOTONIC, &t);
+ return t.tv_sec * 1000 + t.tv_nsec / 1000000;
+}
+
+float
+animation_bezier(float t)
+{
+ float x1 = animation_curve[0], y1 = animation_curve[1];
+ float x2 = animation_curve[2], y2 = animation_curve[3];
+ float lo = 0, hi = 1, s = t, x;
+ int i;
+
+ for (i = 0; i < 20; i++) {
+ x = 3*(1-s)*(1-s)*s*x1 + 3*(1-s)*s*s*x2 + s*s*s;
+ if (x < t)
+ lo = s;
+ else
+ hi = s;
+ s = (lo + hi) / 2;
+ }
+ return 3*(1-s)*(1-s)*s*y1 + 3*(1-s)*s*s*y2 + s*s*s;
+}
+
+int
+animation_tick(void *data)
+{
+ Client *c;
+ float t, p;
+ int more = 0;
+
+ wl_list_for_each(c, &clients, link) {
+ if (!c->animating)
+ continue;
+ t = (animation_now_ms() - c->anim_start) / (float)animation_duration;
+ if (t >= 1) {
+ t = 1;
+ c->animating = 0;
+ }
+ p = animation_bezier(t);
+ c->anim_cur.x = (int)(c->anim_from.x + (c->anim_to.x - c->anim_from.x) * p);
+ c->anim_cur.y = (int)(c->anim_from.y + (c->anim_to.y - c->anim_from.y) * p);
+ c->anim_cur.width = (int)(c->anim_from.width + (c->anim_to.width - c->anim_from.width) * p);
+ c->anim_cur.height = (int)(c->anim_from.height + (c->anim_to.height - c->anim_from.height) * p);
+
+ animation_apply(c, c->anim_cur);
+ more |= c->animating;
+ }
+ if (more)
+ wl_event_source_timer_update(animation_timer, 16);
+ return 0;
+}
+
+void
+animation_apply(Client *c, struct wlr_box g)
+{
+ struct wlr_box clip, save = c->geom;
+
+ c->geom = g;
+
+ 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);
+ 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);
+
+ client_get_clip(c, &clip);
+ wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
+
+ c->geom = save;
+}
+
void
applybounds(Client *c, struct wlr_box *bbox)
{
@@ -1887,6 +1978,7 @@ mapnotify(struct wl_listener *listener, void *data)
.title = client_get_title(c),
};
+ c->status = CliOpening;
/* 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() */
@@ -2340,12 +2432,17 @@ rendermon(struct wl_listener *listener, void *data)
* generally at the output's refresh rate (e.g. 60Hz). */
Monitor *m = wl_container_of(listener, m, frame);
struct timespec now;
+ Client *c;
if (!wlr_scene_output_needs_frame(m->scene_output)) {
return;
}
+ wl_list_for_each(c, &clients, link)
+ if (c->serial && !c->isfloating && client_is_rendered_on_mon(c, m) && !client_is_stopped(c))
+ goto skip;
wlr_scene_output_commit(m->scene_output, NULL);
+skip:
clock_gettime(CLOCK_MONOTONIC, &now);
wlr_scene_output_send_frame_done(m->scene_output, &now);
}
@@ -2383,7 +2480,6 @@ void
resize(Client *c, struct wlr_box geo, int interact)
{
struct wlr_box *bbox;
- struct wlr_box clip;
if (!c->mon || !client_surface(c)->mapped)
return;
@@ -2393,21 +2489,27 @@ resize(Client *c, struct wlr_box geo, int interact)
client_set_bounds(c, geo.width, geo.height);
c->geom = geo;
applybounds(c, bbox);
+ c->serial = client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw);
- /* 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);
- 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);
+ if (interact) {
+ c->animating = 0;
+ c->anim_cur = c->geom;
+ animation_apply(c, c->geom);
+ return;
+ }
- 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);
+ if (!c->animating && c->anim_cur.width == 0) {
+ c->anim_cur.width = c->geom.width / 2;
+ c->anim_cur.height = c->geom.height / 2;
+ c->anim_cur.x = c->geom.x + (c->geom.width - c->anim_cur.width) / 2;
+ c->anim_cur.y = c->geom.y + (c->geom.height - c->anim_cur.height) / 2;
+ }
+
+ c->anim_from = c->anim_cur;
+ c->anim_to = c->geom;
+ c->anim_start = animation_now_ms();
+ c->animating = 1;
+ wl_event_source_timer_update(animation_timer, 1);
}
void
@@ -2633,6 +2735,7 @@ setup(void)
* clients from the Unix socket, managing Wayland globals, and so on. */
dpy = wl_display_create();
event_loop = wl_display_get_event_loop(dpy);
+ animation_timer = wl_event_loop_add_timer(event_loop, animation_tick, NULL);
/* The backend is a wlroots feature which abstracts the underlying input and
* output hardware. The autocreate option will choose the most suitable
@@ -2914,19 +3017,31 @@ tile(Monitor *m)
mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
else
mw = m->w.width;
+
i = my = ty = 0;
wl_list_for_each(c, &clients, link) {
+ struct wlr_box geo;
+
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;
+ geo = (struct wlr_box){m->w.x, m->w.y + my, mw,
+ (m->w.height - my) / (MIN(n, m->nmaster) - i)};
+ my += geo.height;
} 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;
+ geo = (struct wlr_box){m->w.x + mw, m->w.y + ty, m->w.width - mw,
+ (m->w.height - ty) / (n - i)};
+ ty += geo.height;
+ }
+
+ if (c->status == CliOpening) {
+ c->anim_cur = (struct wlr_box){geo.x + geo.width / 4, geo.y + geo.height / 4,
+ geo.width / 2, geo.height / 2};
+ c->anim_from = c->anim_cur;
+ c->status = CliNormal;
}
+ resize(c, geo, 0);
i++;
}
}
--
2.55.0
+70
View File
@@ -0,0 +1,70 @@
### Description
Blur implemented using scenefx
Implemented keybinds:
- dynamically toggle blur globally:
```c
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_B, toggleblur, {0} },
```
- toggle blur for focused window:
```c
{ MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_b, toggleblurfocused,{0} },
```
Options in config.def.h:
```c
#define blur_params 2, 2, 0, 0.703125, 0.4375, 0.875 // passes, radius, noise, brightness, contrast, saturation
static int blur_enabled = 1;
```
Requires [scenefx](https://github.com/wlrfx/scenefx) version 0.5 (which is currently the latest version). Some information about installation instructions is provided at the bottom.
I have only implemented the xray version of blur, where blur skips past contents of other windows underneath a window and directly shows the background, because this way the background blur is cached, which helps to significantly reduce the gpu usage.
Tested blur.patch on main branch commit dwl/dwl@f1675a4800
As of commit fd5e06a50d the bar patch does not apply cleanly to dwl/dwl@f1675a4800, therefore the blur_bar.patch would also need to be manually applied. I will update it after the bar patch gets updated.
### Download
- [blur.patch](/dwl/dwl-patches/raw/branch/main/patches/blur/blur.patch) : for application to base dwl, does not apply blur to the bar
- [blur_bar.patch](/dwl/dwl-patches/raw/branch/main/patches/blur/blur_bar.patch) : for use with the bar patch, this version applies blur to the bar too, but to actually see the blur effect the bar background color would need to be changed to a transparent or translucent value, for example:
```c
static uint32_t colors[][3] = {
/* fg bg border */
[SchemeNorm] = { 0x777777ff, 0x00000000, 0x00000000 },
[SchemeSel] = { 0x00ffffff, 0x00000000, 0x00ffffff },
[SchemeUrg] = { 0xff00ffff, 0x00000000, 0xff00ffff },
};
```
### Authors
- [atourist](https://codeberg.org/atourist)
---
Installing [scenefx](https://github.com/wlrfx/scenefx) version 0.5
The recommended way to install scenefx is through your linux distro's package manager, if the scenefx version in your distro's official repositories is 0.5. The scenefx github page has a [list](https://github.com/wlrfx/scenefx#Installation) with the version info on some common distros. For vanilla Arch Linux users, scenefx is not available in the official repositories, but it can be installed via the AUR instead, either using yay or paru or some other AUR helper, or manually by following the steps listed on the [Arch wiki for AUR](https://wiki.archlinux.org/title/Arch_User_Repository). Some derivative Arch distros like CachyOS provide scenefx through their official repositories.
If you install scenefx via your package manager or through AUR, **no further steps are needed**.
But if you compile from source using the instructions provided in the [scenefx github repository](https://github.com/wlrfx/scenefx), depending on where you install scenefx, you might need to ensure that the `PKG_CONFIG` specified in dwl's `config.mk` is able to locate the header files for scenefx. By default, it uses pkg-config, so to check, use the following terminal command:
```sh
pkg-config --cflags scenefx-0.5
```
If this returns a path to the scenefx header files, **no further steps are needed**.
**Otherwise** the path to the header files needs to be manually provided following these steps:
1. Apply the blur patch
2. In `Makefile` in the dwl source code, remove `scenefx-0.5` from `PKGS = `
3. In `Makefile` add `-I/path/to/scenefx_headers` with the correct path to `DWLCFLAGS =` such that it is placed before all other options, so it should look something like this:
```Makefile
DWLCFLAGS = -I/path/to/scenefx_headers `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
```
4. In `Makefile` add `-lscenefx-0.5` to `LDLIBS =` such that it is placed before all other options, so it should look something like this:
```Makefile
LDLIBS = -lscenefx-0.5 `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
```
+196
View File
@@ -0,0 +1,196 @@
diff --git a/Makefile b/Makefile
index 8304245..f55e2f9 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
-Wfloat-conversion
# CFLAGS / LDFLAGS
-PKGS = wayland-server xkbcommon libinput $(XLIBS)
+PKGS = scenefx-0.5 wayland-server xkbcommon libinput $(XLIBS)
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
diff --git a/config.def.h b/config.def.h
index a4019d3..88029d9 100644
--- a/config.def.h
+++ b/config.def.h
@@ -18,6 +18,9 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
+#define blur_params 2, 2, 0, 0.703125, 0.4375, 0.875 // passes, radius, noise, brightness, contrast, saturation
+static int blur_enabled = 1;
+
/* logging */
static int log_level = WLR_ERROR;
@@ -123,6 +126,8 @@ 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|WLR_MODIFIER_SHIFT, XKB_KEY_B, toggleblur, {0} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_b, toggleblurfocused,{0} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
diff --git a/dwl.c b/dwl.c
index ca97c30..af50458 100644
--- a/dwl.c
+++ b/dwl.c
@@ -11,6 +11,8 @@
#include <stdlib.h>
#include <sys/wait.h>
#include <time.h>
+#include <scenefx/render/fx_renderer/fx_renderer.h>
+#include <scenefx/types/wlr_scene.h>
#include <unistd.h>
#include <wayland-server-core.h>
#include <wlr/backend.h>
@@ -51,7 +53,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,8 +89,7 @@
/* enums */
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
enum { XDGShell, LayerShell, X11 }; /* client types */
-enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
- LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
+enum { LyrBg, LyrBlur, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay, LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
enum { AxisUp, AxisRight, AxisDown, AxisLeft };
typedef union {
@@ -159,6 +159,7 @@ typedef struct {
unsigned int bw;
uint32_t tags;
int isfloating, isurgent, isfullscreen;
+ struct wlr_scene_blur *blur;
} Client;
typedef struct {
@@ -226,6 +227,7 @@ struct Monitor {
int nmaster;
char ltsymbol[16];
int asleep;
+ struct wlr_scene_optimized_blur *blur;
};
typedef struct {
@@ -357,6 +359,8 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
+static void toggleblur(const Arg *arg);
+static void toggleblurfocused(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -841,6 +845,8 @@ cleanupmon(struct wl_listener *listener, void *data)
closemon(m);
wlr_scene_node_destroy(&m->fullscreen_bg->node);
+ wlr_scene_node_destroy(&m->blur->node);
+ m->blur = NULL;
free(m);
}
@@ -944,6 +950,7 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
}
arrangelayers(l->mon);
+ if ((layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) && (l->mon)) wlr_scene_optimized_blur_mark_dirty(l->mon->blur);
}
void
@@ -990,6 +997,7 @@ commitnotify(struct wl_listener *listener, void *data)
}
resize(c, c->geom, (c->isfloating && !c->isfullscreen));
+ wlr_scene_blur_set_size(c->blur, c->geom.width, c->geom.height);
}
void
@@ -1211,6 +1219,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);
+ m->blur = wlr_scene_optimized_blur_create(&scene->tree, m->m.width, m->m.height);
+ wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y);
+ wlr_scene_node_reparent(&m->blur->node, layers[LyrBlur]);
+ wlr_scene_node_set_enabled(&m->blur->node, blur_enabled);
+
/* Adds this to the output layout in the order it was configured.
*
* The output layout utility automatically adds a wl_output global to the
@@ -1955,6 +1968,11 @@ mapnotify(struct wl_listener *listener, void *data)
}
printstatus();
+ c->blur = wlr_scene_blur_create(c->scene, c->geom.width, c->geom.height);
+ wlr_scene_node_lower_to_bottom(&c->blur->node);
+ wlr_scene_blur_set_should_only_blur_bottom_layer(c->blur, true);
+ wlr_scene_node_set_enabled(&c->blur->node, blur_enabled);
+
unset_fullscreen:
m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
wl_list_for_each(w, &clients, link) {
@@ -2651,11 +2669,13 @@ setup(void)
drag_icon = wlr_scene_tree_create(&scene->tree);
wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
+ wlr_scene_set_blur_data(scene, blur_params);
+
/* 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);
@@ -2933,6 +2953,21 @@ tile(Monitor *m)
}
}
+void toggleblur(const Arg *arg) {
+ Client *c;
+ Monitor *m = NULL;
+ blur_enabled = !blur_enabled;
+ wl_list_for_each(m, &mons, link) {
+ wlr_scene_node_set_enabled(&m->blur->node, blur_enabled);
+ }
+ wl_list_for_each(c, &clients, link) wlr_scene_node_set_enabled(&c->blur->node, blur_enabled);
+}
+
+void toggleblurfocused(const Arg *arg) {
+ Client *sel = focustop(selmon);
+ if (sel && sel->blur) wlr_scene_node_set_enabled(&sel->blur->node, !sel->blur->node.enabled);
+}
+
void
togglefloating(const Arg *arg)
{
@@ -2995,6 +3030,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
arrangelayers(l->mon);
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
focusclient(focustop(selmon), NULL, 1);
+ if ((l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) && (l->mon)) wlr_scene_optimized_blur_mark_dirty(l->mon->blur);
motionnotify(0, NULL, 0, 0, 0, 0);
}
@@ -3098,6 +3134,9 @@ updatemons(struct wl_listener *listener, void *data)
wlr_scene_node_set_position(&m->fullscreen_bg->node, m->m.x, m->m.y);
wlr_scene_rect_set_size(m->fullscreen_bg, m->m.width, m->m.height);
+ wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y);
+ wlr_scene_optimized_blur_set_size(m->blur, m->m.width, m->m.height);
+
if (m->lock_surface) {
struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data;
wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);
+209
View File
@@ -0,0 +1,209 @@
diff --git a/Makefile b/Makefile
index 09ae285..02e7e13 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
-Wfloat-conversion
# CFLAGS / LDFLAGS
-PKGS = wayland-server xkbcommon libinput pixman-1 fcft $(XLIBS)
+PKGS = scenefx-0.5 wayland-server xkbcommon libinput pixman-1 fcft $(XLIBS)
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
diff --git a/config.def.h b/config.def.h
index 1c50fc5..90e17d6 100644
--- a/config.def.h
+++ b/config.def.h
@@ -20,6 +20,9 @@ static uint32_t colors[][3] = {
[SchemeUrg] = { 0, 0, 0x770000ff },
};
+#define blur_params 2, 2, 0, 0.703125, 0.4375, 0.875 // passes, radius, noise, brightness, contrast, saturation
+static int blur_enabled = 1;
+
/* tagging */
static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
@@ -130,6 +133,8 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
{ MODKEY, XKB_KEY_b, togglebar, {0} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_B, toggleblur, {0} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_b, toggleblurfocused,{0} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
diff --git a/dwl.c b/dwl.c
index 2afec86..9bec152 100644
--- a/dwl.c
+++ b/dwl.c
@@ -12,6 +12,8 @@
#include <stdlib.h>
#include <sys/wait.h>
#include <time.h>
+#include <scenefx/render/fx_renderer/fx_renderer.h>
+#include <scenefx/types/wlr_scene.h>
#include <unistd.h>
#include <wayland-server-core.h>
#include <wlr/backend.h>
@@ -50,7 +52,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>
@@ -91,7 +92,7 @@
enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */
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, LyrBlur, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
enum { AxisUp, AxisRight, AxisDown, AxisLeft };
enum { ClkTagBar, ClkLtSymbol, ClkStatus, ClkTitle, ClkClient, ClkRoot }; /* clicks */
@@ -163,6 +164,7 @@ typedef struct {
uint32_t tags;
int isfloating, isurgent, isfullscreen;
uint32_t resize; /* configure serial of a pending resize */
+ struct wlr_scene_blur *blur;
} Client;
typedef struct {
@@ -221,6 +223,7 @@ struct Monitor {
struct wlr_output *wlr_output;
struct wlr_scene_output *scene_output;
struct wlr_scene_buffer *scene_buffer; /* bar buffer */
+ struct wlr_scene_blur *bar_blur;
struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
struct wl_listener frame;
struct wl_listener destroy;
@@ -247,6 +250,7 @@ struct Monitor {
Drwl *drw;
Buffer *pool[2];
int lrpad;
+ struct wlr_scene_optimized_blur *blur;
};
typedef struct {
@@ -387,6 +391,8 @@ static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglebar(const Arg *arg);
+static void toggleblur(const Arg *arg);
+static void toggleblurfocused(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -979,6 +985,8 @@ cleanupmon(struct wl_listener *listener, void *data)
closemon(m);
wlr_scene_node_destroy(&m->fullscreen_bg->node);
wlr_scene_node_destroy(&m->scene_buffer->node);
+ wlr_scene_node_destroy(&m->blur->node);
+ m->blur = NULL;
free(m);
}
@@ -1087,6 +1095,7 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
}
arrangelayers(l->mon);
+ if ((layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) && (l->mon)) wlr_scene_optimized_blur_mark_dirty(l->mon->blur);
}
void
@@ -1120,6 +1129,7 @@ commitnotify(struct wl_listener *listener, void *data)
/* mark a pending resize as completed */
if (c->resize && c->resize <= c->surface.xdg->current.configure_serial)
c->resize = 0;
+ wlr_scene_blur_set_size(c->blur, c->geom.width, c->geom.height);
}
void
@@ -1347,6 +1357,16 @@ 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);
+ m->blur = wlr_scene_optimized_blur_create(&scene->tree, m->m.width, m->m.height);
+ wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y);
+ wlr_scene_node_reparent(&m->blur->node, layers[LyrBlur]);
+ wlr_scene_node_set_enabled(&m->blur->node, blur_enabled);
+ m->bar_blur = wlr_scene_blur_create(layers[LyrBottom], m->b.real_width, m->b.real_height);
+ wlr_scene_node_set_position(&m->bar_blur->node, m->m.x, m->m.y);
+ wlr_scene_node_lower_to_bottom(&m->bar_blur->node);
+ wlr_scene_blur_set_should_only_blur_bottom_layer(m->bar_blur, true);
+ wlr_scene_node_set_enabled(&m->bar_blur->node, blur_enabled);
+
/* Adds this to the output layout in the order it was configured.
*
* The output layout utility automatically adds a wl_output global to the
@@ -2154,6 +2174,11 @@ mapnotify(struct wl_listener *listener, void *data)
}
drawbars();
+ c->blur = wlr_scene_blur_create(c->scene, c->geom.width, c->geom.height);
+ wlr_scene_node_lower_to_bottom(&c->blur->node);
+ wlr_scene_blur_set_should_only_blur_bottom_layer(c->blur, true);
+ wlr_scene_node_set_enabled(&c->blur->node, blur_enabled);
+
unset_fullscreen:
m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
wl_list_for_each(w, &clients, link) {
@@ -2785,11 +2810,13 @@ setup(void)
drag_icon = wlr_scene_tree_create(&scene->tree);
wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
+ wlr_scene_set_blur_data(scene, blur_params);
+
/* 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);
@@ -3108,6 +3135,22 @@ togglebar(const Arg *arg)
drawbars();
}
+void toggleblur(const Arg *arg) {
+ Client *c;
+ Monitor *m = NULL;
+ blur_enabled = !blur_enabled;
+ wl_list_for_each(m, &mons, link) {
+ wlr_scene_node_set_enabled(&m->blur->node, blur_enabled);
+ wlr_scene_node_set_enabled(&m->bar_blur->node, blur_enabled);
+ }
+ wl_list_for_each(c, &clients, link) wlr_scene_node_set_enabled(&c->blur->node, blur_enabled);
+}
+
+void toggleblurfocused(const Arg *arg) {
+ Client *sel = focustop(selmon);
+ if (sel && sel->blur) wlr_scene_node_set_enabled(&sel->blur->node, !sel->blur->node.enabled);
+}
+
void
togglefloating(const Arg *arg)
{
@@ -3172,6 +3215,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
arrangelayers(l->mon);
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
focusclient(focustop(selmon), 1);
+ if ((l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) && (l->mon)) wlr_scene_optimized_blur_mark_dirty(l->mon->blur);
motionnotify(0, NULL, 0, 0, 0, 0);
}
@@ -3274,6 +3318,9 @@ updatemons(struct wl_listener *listener, void *data)
wlr_scene_node_set_position(&m->fullscreen_bg->node, m->m.x, m->m.y);
wlr_scene_rect_set_size(m->fullscreen_bg, m->m.width, m->m.height);
+ wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y);
+ wlr_scene_optimized_blur_set_size(m->blur, m->m.width, m->m.height);
+
if (m->lock_surface) {
struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data;
wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);
+34 -55
View File
@@ -1,6 +1,6 @@
### Description
# btrtile — A Focus-Driven Tiling Layout
# btrtile - A Focus-Driven Tiling Layout
It provides a focus-driven, mouse- and keyboard-friendly tiling layout that grants you granular control over how clients are placed and resized.
@@ -14,39 +14,35 @@ While dwl’s patches folder is full of different layouts, I couldn't find suita
---
# Features
- **Combined Tiling and Management**
Combines tiling layout and management of clients under one patchset.
- **Focus-Driven Splits**
When you add a new client, btrtile checks where your pointer is relative to the focused client’s geometry.
- If the pointer is on the left half (for a horizontally large client), the new client spawns on the left side, and vice versa.
- By default, new splits are 50/50.
- **Adaptive Splitting**
- If the area to be split is wider than its height, btrtile does a vertical split.
- Otherwise, it does a horizontal split.
- **Keyboard and Mouse Driven**
- Supports keyboard-based commands for quick ratio adjustments and client swapping.
- Mouse-based resizing and moving are integrated for more intuitive manipulation.
---
# How It Works
btrtile organizes clients using a binary tree data structure that represents splits either vertically or horizontally.
When a new client appears:
1. **Focused Client Detection**
btrtile checks your pointer location to find which client (if any) you’re interacting with.
2. **Split Creation**
- If there’s a focused client, btrtile creates a split node around it, placing the new client on the side where your pointer is.
3. **Ratio Management**
Each split node has a `split_ratio` (defaulting to 0.5). This ratio defines how much space is allocated to each child node. You can adjust this ratio using keyboard or mouse actions.
# How it works
Clients live in a binary tree, every split has a ratio (50/50 by default).
When a new client opens, it splits the client you last focused. The pointer decides which side it lands on: left half of the client puts it on the left, and so on. If the area is wider than it is tall the split is vertical, otherwise horizontal. When several clients open at once, each one splits the previous one, so you get a nice spiral instead of a pile in one corner.
- **Mouse**
Drag a tiled client with `MODKEY` + left button to float it, drop it on another tiled client to place it next to it.
`MODKEY` + right button resizes the divider next to the client you grabbed, it follows the pointer 1:1.
- **Keyboard**
`setratio_h` / `setratio_v` move a divider, `swapclients` swaps a client with its neighbour in a direction,
`togglesplit` flips the direction of the split you're in (and keeps it that way),
`swapsplit` mirrors the split.
**config.h:**
```c
use_active_for_splits = 1; /* 1: split the last focused client, 0: the one under the pointer */
force_split = 0; /* 0: new client on the pointer's side, 1: always left/top, 2: always right/bottom */
preserve_split = 0; /* 1: splits keep their direction, 0: direction follows the shape of the area */
split_width_multiplier = 1.0f; /* split side by side when width >= height * this */
resize_interval_ms = 16; /* limits mouse resize updates, 16ms is ~60 per second */
```
`force_split = 2` gives you a predictable spiral if you don't want the pointer to matter.
`split_width_multiplier` is handy on wide monitors, where windows tend to stay wider than tall for a long time.
Smoother mouse resizing costs some cpu, so tune `resize_interval_ms` to your refresh rate.
If resizing feels sluggish, try compiling dwl with -O2/-O3.
---
# What It Doesn’t Handle
@@ -56,23 +52,6 @@ When a new client appears:
---
# Configuring btrtile
btrtile adds couple variables to config.h to fine tune the mouse resizing of tiled clients.
1. **resize_factor**
- A multiplier to transfer pointer movement to client weight ratio. Depends heavily on mouse sensitivity.
Defaults to 0.0002f.
2. **resize_interval_ms**
- A time based resize call limiter. Depends on framerate and screen refresh rate.
Defaults to 16ms. (~60 resize updates per second)
Fine tune these values to find the best values for your setup, smoother resizing can significally increase cpu overhead.
If mouse resizing feels sluggish, you can try compiling dwl with more aggressive optimization flags like -O2/-O3.
---
# Patch recommendations
1. **Patches that I use with my btrtile**
@@ -95,11 +74,11 @@ If mouse resizing feels sluggish, you can try compiling dwl with more aggressive
---
### Download
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/btrtile-dev)
- [0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-v0.8.patch)
- [0.8 WITH gaps](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-v0.8-gaps.patch)
- [wlroots-next](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-wlroots-next-d41ecb7.patch)
- [wlroots-next WITH gaps](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-wlroots-next-d41ecb7-gaps.patch)
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/btrtile-0.9)
- [btrtile-0.9](/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-v0.9.patch)
- [btrtile-0.9 WITH gaps](/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-gaps-v0.9.patch)
- [btrtile-0.8](/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-v0.8.patch)
- [btrtile-0.8 WITH gaps](/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-v0.8-gaps.patch)
### Authors
- [julmajustus](https://codeberg.org/julmajustus)
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,922 +0,0 @@
From efb796ce92e7212aa392141705c7322fedc45dba Mon Sep 17 00:00:00 2001
From: julmajustus <julmajustus@tutanota.com>
Date: Mon, 22 Jun 2026 22:46:19 +0300
Subject: [PATCH] btrtile: bug fixes and readability improvement
- Removed client old_geom caching for simplicity fixes: https://codeberg.org/dwl/dwl-patches/issues/647
- Improved readability of the client sanitization loop inside btrtile function
- Removed fullscreened client's from the sanitization loop to retain simple_scratchpad: Spring update scratchpad V2
- Added support for multiple scratchpads their geometry
---
btrtile.c | 575 +++++++++++++++++++++++++++++++++++++++++++++++++++
config.def.h | 12 ++
dwl.c | 151 +++++++++++---
3 files changed, 711 insertions(+), 27 deletions(-)
create mode 100644 btrtile.c
diff --git a/btrtile.c b/btrtile.c
new file mode 100644
index 0000000..645b741
--- /dev/null
+++ b/btrtile.c
@@ -0,0 +1,575 @@
+/* ************************************************************************** */
+/* @@@ @@@@@@@@ */
+/* @@@ @@@@@@@@@@ */
+/* @@! @@! @@@@ */
+/* !@! !@! @!@!@ */
+/* btrtile.c @!! @!@ @! !@! */
+/* !!! !@!!! !!! */
+/* By: julmajustus <julmajustus@tutanota.com> !!: !!:! !!! */
+/* ::! :!: !:! */
+/* Created: 2024/12/15 00:26:07 by julmajustus :: ::::::: :: */
+/* Updated: 2026/06/22 22:34:11 by julmajustus : : : : : : */
+/* */
+/* ************************************************************************** */
+
+typedef struct LayoutNode {
+ unsigned int is_client_node;
+ unsigned int is_split_vertically;
+ float split_ratio;
+ struct LayoutNode *left;
+ struct LayoutNode *right;
+ struct LayoutNode *split_node;
+ Client *client;
+} LayoutNode;
+
+static void apply_layout(Monitor *m, LayoutNode *node,
+ struct wlr_box area, unsigned int is_root);
+static void btrtile(Monitor *m);
+static LayoutNode *create_client_node(Client *c);
+static LayoutNode *create_split_node(unsigned int is_split_vertically,
+ LayoutNode *left, LayoutNode *right);
+static void destroy_node(LayoutNode *node);
+static void destroy_tree(Monitor *m);
+static LayoutNode *find_client_node(LayoutNode *node, Client *c);
+static LayoutNode *find_suitable_split(Monitor *m, LayoutNode *start,
+ unsigned int need_vertical, int focused_on_left);
+static void init_tree(Monitor *m);
+static void insert_client(Monitor *m, Client *focused_client, Client *new_client);
+static LayoutNode *remove_client_node(LayoutNode *node, Client *c);
+static void remove_client(Monitor *m, Client *c);
+static void setratio_h(const Arg *arg);
+static void setratio_v(const Arg *arg);
+static void swapclients(const Arg *arg);
+static unsigned int visible_count(LayoutNode *node, Monitor *m);
+static Client *xytoclient(double x, double y);
+
+static double resize_last_update_x, resize_last_update_y;
+static uint32_t last_resize_time = 0;
+
+void
+apply_layout(Monitor *m, LayoutNode *node,
+ struct wlr_box area, unsigned int is_root)
+{
+ Client *c;
+ float ratio;
+ unsigned int left_count, right_count, mid, e = m->gaps;
+ struct wlr_box left_area, right_area;
+
+ if (!node)
+ return;
+
+ if (is_root && e) {
+ area.x += gappx;
+ area.y += gappx;
+ area.width -= 2 * gappx;
+ area.height -= 2 * gappx;
+ }
+
+ /* If this node is a client node, check if it is visible. */
+ if (node->is_client_node) {
+ c = node->client;
+ if (!c || !VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ return;
+ resize(c, area, 0);
+ return;
+ }
+
+ /* For a split node, we see how many visible children are on each side: */
+ left_count = visible_count(node->left, m);
+ right_count = visible_count(node->right, m);
+
+ if (left_count == 0 && right_count == 0) {
+ return;
+ } else if (left_count > 0 && right_count == 0) {
+ apply_layout(m, node->left, area, 0);
+ return;
+ } else if (left_count == 0 && right_count > 0) {
+ apply_layout(m, node->right, area, 0);
+ return;
+ }
+
+ /* If we’re here, we have visible clients in both subtrees. */
+ ratio = node->split_ratio;
+ if (ratio < 0.05f)
+ ratio = 0.05f;
+ if (ratio > 0.95f)
+ ratio = 0.95f;
+
+ memset(&left_area, 0, sizeof(left_area));
+ memset(&right_area, 0, sizeof(right_area));
+
+ if (node->is_split_vertically) {
+ mid = (unsigned int)(area.width * ratio);
+ left_area.x = area.x;
+ left_area.y = area.y;
+ left_area.width = mid;
+ left_area.height = area.height;
+
+ right_area.x = area.x + mid;
+ right_area.y = area.y;
+ right_area.width = area.width - mid;
+ right_area.height = area.height;
+
+ if (e) {
+ left_area.width -= gappx / 2;
+ right_area.x += gappx / 2;
+ right_area.width -= gappx / 2;
+ }
+ } else {
+ /* horizontal split */
+ mid = (unsigned int)(area.height * ratio);
+ left_area.x = area.x;
+ left_area.y = area.y;
+ left_area.width = area.width;
+ left_area.height = mid;
+
+ right_area.x = area.x;
+ right_area.y = area.y + mid;
+ right_area.width = area.width;
+ right_area.height= area.height - mid;
+
+ if (e) {
+ left_area.height -= gappx / 2;
+ right_area.y += gappx / 2;
+ right_area.height -= gappx / 2;
+ }
+ }
+
+ apply_layout(m, node->left, left_area, 0);
+ apply_layout(m, node->right, right_area, 0);
+}
+
+void
+btrtile(Monitor *m)
+{
+ Client *c, *focused = NULL;
+ int n = 0;
+ LayoutNode *found;
+ struct wlr_box full_area;
+
+ if (!m)
+ return;
+
+ /* Remove floating and moved clients */
+ wl_list_for_each(c, &clients, link) {
+ if (c->mon != m || c->isfloating)
+ remove_client(m, c);
+ }
+
+ /* If no client is found under cursor, fallback to focustop(m) */
+ if (!(focused = xytoclient(cursor->x, cursor->y)))
+ focused = focustop(m);
+
+ /* Insert visible clients that are not part of the tree. */
+ wl_list_for_each(c, &clients, link) {
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen && c->mon == m) {
+ found = find_client_node(m->root, c);
+ if (!found) {
+ insert_client(m, focused, c);
+ }
+ n++;
+ }
+ }
+
+ if (n == 0)
+ return;
+
+ full_area = m->w;
+ apply_layout(m, m->root, full_area, 1);
+}
+
+LayoutNode *
+create_client_node(Client *c)
+{
+ LayoutNode *node = calloc(1, sizeof(LayoutNode));
+
+ if (!node)
+ return NULL;
+ node->is_client_node = 1;
+ node->split_ratio = 0.5f;
+ node->client = c;
+ return node;
+}
+
+LayoutNode *
+create_split_node(unsigned int is_split_vertically,
+ LayoutNode *left, LayoutNode *right)
+{
+ LayoutNode *node = calloc(1, sizeof(LayoutNode));
+
+ if (!node)
+ return NULL;
+ node->is_client_node = 0;
+ node->split_ratio = 0.5f;
+ node->is_split_vertically = is_split_vertically;
+ node->left = left;
+ node->right = right;
+ if (left)
+ left->split_node = node;
+ if (right)
+ right->split_node = node;
+ return node;
+}
+
+void
+destroy_node(LayoutNode *node)
+{
+ if (!node)
+ return;
+ if (!node->is_client_node) {
+ destroy_node(node->left);
+ destroy_node(node->right);
+ }
+ free(node);
+}
+
+void
+destroy_tree(Monitor *m)
+{
+ if (!m || !m->root)
+ return;
+ destroy_node(m->root);
+ m->root = NULL;
+}
+
+LayoutNode *
+find_client_node(LayoutNode *node, Client *c)
+{
+ LayoutNode *res;
+
+ if (!node || !c)
+ return NULL;
+ if (node->is_client_node) {
+ return (node->client == c) ? node : NULL;
+ }
+ res = find_client_node(node->left, c);
+ return res ? res : find_client_node(node->right, c);
+}
+
+LayoutNode *
+find_suitable_split(Monitor *m, LayoutNode *start_node,
+ unsigned int need_vertical, int focused_on_left)
+{
+ LayoutNode *n = start_node, *child = NULL;
+
+ if (!m)
+ return NULL;
+
+ if (n && n->is_client_node) {
+ child = n;
+ n = n->split_node;
+ }
+
+ while (n) {
+ if (!n->is_client_node && n->is_split_vertically == need_vertical
+ && visible_count(n->left, m) > 0
+ && visible_count(n->right, m) > 0) {
+ if ((focused_on_left && n->left == child) ||
+ (!focused_on_left && n->right == child))
+ return n;
+ }
+ child = n;
+ n = n->split_node;
+ }
+ return NULL;
+}
+void
+init_tree(Monitor *m)
+{
+ if (m)
+ m->root = NULL;
+}
+
+void
+insert_client(Monitor *m, Client *focused_client, Client *new_client)
+{
+ Client *old_client;
+ LayoutNode **root = &m->root, *old_root,
+ *focused_node, *new_client_node, *old_client_node;
+ unsigned int wider, mid_x, mid_y;
+
+ /* If no root , new client becomes the root. */
+ if (!*root) {
+ *root = create_client_node(new_client);
+ return;
+ }
+
+ /* Find the focused_client node,
+ * if not found split the root. */
+ focused_node = focused_client ?
+ find_client_node(*root, focused_client) : NULL;
+ if (!focused_node) {
+ old_root = *root;
+ new_client_node = create_client_node(new_client);
+ *root = create_split_node(1, old_root, new_client_node);
+ return;
+ }
+
+ /* Turn focused node from a client node into a split node,
+ * and attach old_client + new_client. */
+ old_client = focused_node->client;
+ old_client_node = create_client_node(old_client);
+ new_client_node = create_client_node(new_client);
+
+ /* Decide split direction. */
+ wider = (focused_client->geom.width >= focused_client->geom.height);
+ focused_node->is_client_node = 0;
+ focused_node->client = NULL;
+ focused_node->is_split_vertically = (wider ? 1 : 0);
+
+ /* Pick new_client side depending on the cursor position. */
+ mid_x = focused_client->geom.x + focused_client->geom.width / 2;
+ mid_y = focused_client->geom.y + focused_client->geom.height / 2;
+
+ if (wider) {
+ /* vertical split => left vs right */
+ if (cursor->x <= mid_x) {
+ focused_node->left = new_client_node;
+ focused_node->right = old_client_node;
+ } else {
+ focused_node->left = old_client_node;
+ focused_node->right = new_client_node;
+ }
+ } else {
+ /* horizontal split => top vs bottom */
+ if (cursor->y <= mid_y) {
+ focused_node->left = new_client_node;
+ focused_node->right = old_client_node;
+ } else {
+ focused_node->left = old_client_node;
+ focused_node->right = new_client_node;
+ }
+ }
+ old_client_node->split_node = focused_node;
+ new_client_node->split_node = focused_node;
+ focused_node->split_ratio = 0.5f;
+}
+
+LayoutNode *
+remove_client_node(LayoutNode *node, Client *c)
+{
+ LayoutNode *tmp;
+ if (!node)
+ return NULL;
+ if (node->is_client_node) {
+ /* If this client_node is the client we're removing,
+ * return NULL to remove it */
+ if (node->client == c) {
+ free(node);
+ return NULL;
+ }
+ return node;
+ }
+
+ node->left = remove_client_node(node->left, c);
+ node->right = remove_client_node(node->right, c);
+
+ /* If one of the client node is NULL after removal and the other is not,
+ * we "lift" the other client node up to replace this split node. */
+ if (!node->left && node->right) {
+ tmp = node->right;
+
+ /* Save pointer to split node */
+ if (tmp)
+ tmp->split_node = node->split_node;
+
+ free(node);
+ return tmp;
+ }
+
+ if (!node->right && node->left) {
+ tmp = node->left;
+
+ /* Save pointer to split node */
+ if (tmp)
+ tmp->split_node = node->split_node;
+
+ free(node);
+ return tmp;
+ }
+
+ /* If both children exist or both are NULL (empty tree),
+ * return node as is. */
+ return node;
+}
+
+void
+remove_client(Monitor *m, Client *c)
+{
+ if (!m->root || !c)
+ return;
+ m->root = remove_client_node(m->root, c);
+}
+
+static void
+setratio(unsigned int need_vertical, const Arg *arg)
+{
+ Client *sel;
+ LayoutNode *client_node, *split_node;
+ float new_ratio;
+ int focused_on_left;
+
+ if (!selmon || !selmon->lt[selmon->sellt]->arrange)
+ return;
+
+ sel = focustop(selmon);
+ if (!sel)
+ return;
+
+ client_node = find_client_node(selmon->root, sel);
+ if (!client_node)
+ return;
+
+ focused_on_left = (arg->f >= 0.0f);
+
+ split_node = find_suitable_split(selmon, client_node, need_vertical, focused_on_left);
+
+ if (!split_node)
+ split_node = find_suitable_split(selmon, client_node, need_vertical, !focused_on_left);
+ if (!split_node)
+ return;
+
+ new_ratio = (arg->f != 0.0f) ? (split_node->split_ratio + arg->f) : 0.5f;
+ if (new_ratio < 0.05f)
+ new_ratio = 0.05f;
+ if (new_ratio > 0.95f)
+ new_ratio = 0.95f;
+ split_node->split_ratio = new_ratio;
+
+ apply_layout(selmon, selmon->root, selmon->w, 1);
+}
+
+void
+setratio_h(const Arg *arg)
+{
+ setratio(1, arg);
+}
+
+void
+setratio_v(const Arg *arg)
+{
+ setratio(0, arg);
+}
+
+void swapclients(const Arg *arg) {
+ Client *c, *tmp, *target = NULL, *sel = focustop(selmon);
+ LayoutNode *sel_node, *target_node;
+ int closest_dist = INT_MAX, dist, sel_center_x, sel_center_y,
+ cand_center_x, cand_center_y;
+
+ if (!sel || sel->isfullscreen ||
+ !selmon->root || !selmon->lt[selmon->sellt]->arrange)
+ return;
+
+
+ /* Get the center coordinates of the selected client */
+ sel_center_x = sel->geom.x + sel->geom.width / 2;
+ sel_center_y = sel->geom.y + sel->geom.height / 2;
+
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen || c == sel)
+ continue;
+
+ /* Get the center of candidate client */
+ cand_center_x = c->geom.x + c->geom.width / 2;
+ cand_center_y = c->geom.y + c->geom.height / 2;
+
+ /* Check that the candidate lies in the requested direction. */
+ switch (arg->ui) {
+ case 0:
+ if (cand_center_x >= sel_center_x)
+ continue;
+ break;
+ case 1:
+ if (cand_center_x <= sel_center_x)
+ continue;
+ break;
+ case 2:
+ if (cand_center_y >= sel_center_y)
+ continue;
+ break;
+ case 3:
+ if (cand_center_y <= sel_center_y)
+ continue;
+ break;
+ default:
+ continue;
+ }
+
+ /* Get distance between the centers */
+ dist = abs(sel_center_x - cand_center_x) + abs(sel_center_y - cand_center_y);
+ if (dist < closest_dist) {
+ closest_dist = dist;
+ target = c;
+ }
+ }
+
+ /* If target is found, swap the two clients’ positions in the layout tree */
+ if (target) {
+ sel_node = find_client_node(selmon->root, sel);
+ target_node = find_client_node(selmon->root, target);
+ if (sel_node && target_node) {
+ tmp = sel_node->client;
+ sel_node->client = target_node->client;
+ target_node->client = tmp;
+ arrange(selmon);
+ }
+ }
+}
+
+unsigned int
+visible_count(LayoutNode *node, Monitor *m)
+{
+ Client *c;
+
+ if (!node)
+ return 0;
+ /* Check if this client is visible. */
+ if (node->is_client_node) {
+ c = node->client;
+ if (c && VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
+ return 1;
+ return 0;
+ }
+ /* Else it’s a split node. */
+ return visible_count(node->left, m) + visible_count(node->right, m);
+}
+
+Client *
+xytoclient(double x, double y) {
+ Monitor *m = xytomon(x, y);
+ Client *c, *closest = NULL;
+ double dist, mindist = INT_MAX, dx, dy;
+
+ wl_list_for_each_reverse(c, &clients, link) {
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen &&
+ x >= c->geom.x && x <= (c->geom.x + c->geom.width) &&
+ y >= c->geom.y && y <= (c->geom.y + c->geom.height)){
+ return c;
+ }
+ }
+
+ /* If no client was found at cursor position fallback to closest. */
+ wl_list_for_each_reverse(c, &clients, link) {
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) {
+ dx = 0, dy = 0;
+
+ if (x < c->geom.x)
+ dx = c->geom.x - x;
+ else if (x > (c->geom.x + c->geom.width))
+ dx = x - (c->geom.x + c->geom.width);
+
+ if (y < c->geom.y)
+ dy = c->geom.y - y;
+ else if (y > (c->geom.y + c->geom.height))
+ dy = y - (c->geom.y + c->geom.height);
+
+ dist = dx * dx + dy * dy;
+ if (dist < mindist) {
+ mindist = dist;
+ closest = c;
+ }
+ }
+ }
+ return closest;
+}
diff --git a/config.def.h b/config.def.h
index 8a6eda0..bc04e3f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,7 +13,10 @@ static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
+static const float resize_factor = 0.0002f; /* Resize multiplier for mouse resizing, depends on mouse sensivity. */
+static const uint32_t resize_interval_ms = 16; /* Resize interval depends on framerate and screen refresh rate. */
+enum Direction { DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN };
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
@@ -30,6 +33,7 @@ static const Rule rules[] = {
/* layout(s) */
static const Layout layouts[] = {
/* symbol arrange function */
+ { "|w|", btrtile },
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
@@ -144,6 +148,14 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up, swapclients, {.i = DIR_UP} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, swapclients, {.i = DIR_DOWN} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, swapclients, {.i = DIR_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, swapclients, {.i = DIR_LEFT} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Right, setratio_h, {.f = +0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Left, setratio_h, {.f = -0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Up, setratio_v, {.f = -0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Down, setratio_v, {.f = +0.025f} },
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
diff --git a/dwl.c b/dwl.c
index 8101ffa..7abf390 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1,6 +1,7 @@
/*
* See LICENSE file for copyright and license details.
*/
+#include <limits.h>
#include <getopt.h>
#include <libinput.h>
#include <linux/input-event-codes.h>
@@ -104,6 +105,7 @@ typedef struct {
const Arg arg;
} Button;
+typedef struct LayoutNode LayoutNode;
typedef struct Monitor Monitor;
typedef struct {
/* Must keep this field first */
@@ -141,7 +143,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, was_tiled;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -209,6 +211,7 @@ struct Monitor {
int nmaster;
char ltsymbol[16];
int asleep;
+ LayoutNode *root;
};
typedef struct {
@@ -251,6 +254,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m);
static void axisnotify(struct wl_listener *listener, void *data);
+static void btrtile(Monitor *m);
static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
static void checkidleinhibitor(struct wlr_surface *exclude);
@@ -333,6 +337,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
+static void setratio_h(const Arg *arg);
+static void setratio_v(const Arg *arg);
+static void swapclients(const Arg *arg);
static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
@@ -458,6 +465,7 @@ static struct wlr_xwayland *xwayland;
/* attempt to encapsulate suck into one file */
#include "client.h"
+#include "btrtile.c"
/* function implementations */
void
@@ -628,7 +636,7 @@ buttonpress(struct wl_listener *listener, void *data)
struct wlr_pointer_button_event *event = data;
struct wlr_keyboard *keyboard;
uint32_t mods;
- Client *c;
+ Client *c, *target = NULL;
const Button *b;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@@ -649,7 +657,7 @@ buttonpress(struct wl_listener *listener, void *data)
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
for (b = buttons; b < END(buttons); b++) {
if (CLEANMASK(mods) == CLEANMASK(b->mod) &&
- event->button == b->button && b->func) {
+ event->button == b->button && b->func) {
b->func(&b->arg);
return;
}
@@ -659,6 +667,21 @@ buttonpress(struct wl_listener *listener, void *data)
/* If you released any buttons, we exit interactive move/resize mode. */
/* TODO: should reset to the pointer focus's current setcursor */
if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) {
+ c = grabc;
+ if (c && c->was_tiled && !strcmp(selmon->ltsymbol, "|w|")) {
+ if (cursor_mode == CurMove && c->isfloating) {
+ target = xytoclient(cursor->x, cursor->y);
+
+ if (target && !target->isfloating && !target->isfullscreen)
+ insert_client(selmon, target, c);
+ else
+ selmon->root = create_client_node(c);
+
+ setfloating(c, 0);
+ apply_layout(selmon, selmon->root, selmon->w, 1);
+ }
+ }
+ /* Default behaviour */
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
cursor_mode = CurNormal;
/* Drop the window off on its new monitor */
@@ -750,6 +773,7 @@ cleanupmon(struct wl_listener *listener, void *data)
wlr_output_layout_remove(output_layout, m->wlr_output);
wlr_scene_output_destroy(m->scene_output);
+ destroy_tree(m);
closemon(m);
wlr_scene_node_destroy(&m->fullscreen_bg->node);
free(m);
@@ -1094,6 +1118,7 @@ createmon(struct wl_listener *listener, void *data)
wl_list_insert(&mons, &m->link);
printstatus();
+ init_tree(m);
/* The xdg-protocol specifies:
*
@@ -1332,10 +1357,18 @@ void
destroynotify(struct wl_listener *listener, void *data)
{
/* Called when the xdg_toplevel is destroyed. */
+ Monitor *mon;
Client *c = wl_container_of(listener, c, destroy);
wl_list_remove(&c->destroy.link);
wl_list_remove(&c->set_title.link);
wl_list_remove(&c->fullscreen.link);
+ /* We check if the destroyed client was part of any tiled_list, to catch
+ * client removals even if they would not be currently managed by btrtile */
+ wl_list_for_each(mon, &mons, link) {
+ if (mon->root) {
+ remove_client(mon, c);
+ }
+ }
#ifdef XWAYLAND
if (c->type != XDGShell) {
wl_list_remove(&c->activate.link);
@@ -1866,7 +1899,8 @@ void
motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
double dx_unaccel, double dy_unaccel)
{
- double sx = 0, sy = 0, sx_confined, sy_confined;
+ int tiled = 0;
+ double sx = 0, sy = 0, sx_confined, sy_confined, dx_total, dy_total;
Client *c = NULL, *w = NULL;
LayerSurface *l = NULL;
struct wlr_surface *surface = NULL;
@@ -1920,18 +1954,55 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
/* Update drag icon's position */
wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x), (int)round(cursor->y));
- /* If we are currently grabbing the mouse, handle and return */
+ /* Skip if internal call */
+ if (time == 0)
+ goto focus;
+
+ tiled = grabc && !grabc->isfloating && !grabc->isfullscreen;
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,
- .width = grabc->geom.width, .height = grabc->geom.height}, 1);
- return;
+ if (grabc && grabc->isfloating) {
+ resize(grabc, (struct wlr_box){
+ .x = (int)round(cursor->x) - grabcx,
+ .y = (int)round(cursor->y) - grabcy,
+ .width = grabc->geom.width,
+ .height = grabc->geom.height
+ }, 1);
+ return;
+ }
} else if (cursor_mode == CurResize) {
- resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
- .width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
- return;
+ if (tiled) {
+ dx_total = cursor->x - resize_last_update_x;
+ dy_total = cursor->y - resize_last_update_y;
+
+ if (time - last_resize_time >= resize_interval_ms) {
+ Arg a = {0};
+ if (fabs(dx_total) > fabs(dy_total)) {
+ a.f = (float)(dx_total * resize_factor);
+ setratio_h(&a);
+ } else {
+ a.f = (float)(dy_total * resize_factor);
+ setratio_v(&a);
+ }
+
+ last_resize_time = time;
+ resize_last_update_x = cursor->x;
+ resize_last_update_y = cursor->y;
+ }
+
+ } else if (grabc && grabc->isfloating) {
+ /* Floating resize as original */
+ resize(grabc, (struct wlr_box){
+ .x = grabc->geom.x,
+ .y = grabc->geom.y,
+ .width = (int)round(cursor->x) - grabc->geom.x,
+ .height = (int)round(cursor->y) - grabc->geom.y
+ }, 1);
+ return;
+ }
}
+focus:
/* If there's no client surface under the cursor, set the cursor image to a
* default. This is what makes the cursor image appear when you move it
* off of a client or over its border. */
@@ -1965,22 +2036,40 @@ moveresize(const Arg *arg)
if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen)
return;
- /* Float the window and tell motionnotify to grab it */
- setfloating(grabc, 1);
- switch (cursor_mode = arg->ui) {
- case CurMove:
- grabcx = (int)round(cursor->x) - grabc->geom.x;
- grabcy = (int)round(cursor->y) - grabc->geom.y;
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "all-scroll");
- break;
- case CurResize:
- /* Doesn't work for X11 output - the next absolute motion event
- * returns the cursor to where it started */
- wlr_cursor_warp_closest(cursor, NULL,
- grabc->geom.x + grabc->geom.width,
- grabc->geom.y + grabc->geom.height);
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
- break;
+ cursor_mode = arg->ui;
+ grabc->was_tiled = (!grabc->isfloating && !grabc->isfullscreen);
+
+ if (grabc->was_tiled) {
+ switch (cursor_mode) {
+ case CurMove:
+ setfloating(grabc, 1);
+ grabcx = (int)round(cursor->x) - grabc->geom.x;
+ grabcy = (int)round(cursor->y) - grabc->geom.y;
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur");
+ break;
+ case CurResize:
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
+ resize_last_update_x = cursor->x;
+ resize_last_update_y = cursor->y;
+ break;
+ }
+ } else {
+ /* Default floating logic */
+ /* Float the window and tell motionnotify to grab it */
+ setfloating(grabc, 1);
+ switch (cursor_mode) {
+ case CurMove:
+ grabcx = (int)round(cursor->x) - grabc->geom.x;
+ grabcy = (int)round(cursor->y) - grabc->geom.y;
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur");
+ break;
+ case CurResize:
+ wlr_cursor_warp_closest(cursor, NULL,
+ grabc->geom.x + grabc->geom.width,
+ grabc->geom.y + grabc->geom.height);
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
+ break;
+ }
}
}
@@ -2833,6 +2922,14 @@ unmapnotify(struct wl_listener *listener, void *data)
focusclient(focustop(selmon), 1);
}
} else {
+ /* btrtile remove clients for each monitor */
+ Monitor *mon;
+ wl_list_for_each(mon, &mons, link) {
+ if (mon->root) {
+ remove_client(mon, c);
+ }
+ }
+
wl_list_remove(&c->link);
setmon(c, NULL, 0);
wl_list_remove(&c->flink);
--
2.53.0
@@ -1,900 +0,0 @@
From 3500e732fc34aa849cd3babeff7d2545a0230fa9 Mon Sep 17 00:00:00 2001
From: julmajustus <julmajustus@tutanota.com>
Date: Mon, 22 Jun 2026 22:33:17 +0300
Subject: [PATCH] btrtile: bug fixes and readability improvement
- Removed client old_geom caching for simplicity fixes: https://codeberg.org/dwl/dwl-patches/issues/647
- Improved readability of the client sanitization loop inside btrtile function
- Removed fullscreened client's from the sanitization loop to retain their geometry
---
btrtile.c | 556 +++++++++++++++++++++++++++++++++++++++++++++++++++
config.def.h | 12 ++
dwl.c | 151 +++++++++++---
3 files changed, 692 insertions(+), 27 deletions(-)
create mode 100644 btrtile.c
diff --git a/btrtile.c b/btrtile.c
new file mode 100644
index 0000000..b4f6f43
--- /dev/null
+++ b/btrtile.c
@@ -0,0 +1,556 @@
+/* ************************************************************************** */
+/* @@@ @@@@@@@@ */
+/* @@@ @@@@@@@@@@ */
+/* @@! @@! @@@@ */
+/* !@! !@! @!@!@ */
+/* btrtile.c @!! @!@ @! !@! */
+/* !!! !@!!! !!! */
+/* By: julmajustus <julmajustus@tutanota.com> !!: !!:! !!! */
+/* ::! :!: !:! */
+/* Created: 2024/12/15 00:26:07 by julmajustus :: ::::::: :: */
+/* Updated: 2026/06/22 22:30:19 by julmajustus : : : : : : */
+/* */
+/* ************************************************************************** */
+
+typedef struct LayoutNode {
+ unsigned int is_client_node;
+ unsigned int is_split_vertically;
+ float split_ratio;
+ struct LayoutNode *left;
+ struct LayoutNode *right;
+ struct LayoutNode *split_node;
+ Client *client;
+} LayoutNode;
+
+static void apply_layout(Monitor *m, LayoutNode *node,
+ struct wlr_box area, unsigned int is_root);
+static void btrtile(Monitor *m);
+static LayoutNode *create_client_node(Client *c);
+static LayoutNode *create_split_node(unsigned int is_split_vertically,
+ LayoutNode *left, LayoutNode *right);
+static void destroy_node(LayoutNode *node);
+static void destroy_tree(Monitor *m);
+static LayoutNode *find_client_node(LayoutNode *node, Client *c);
+static LayoutNode *find_suitable_split(Monitor *m, LayoutNode *start,
+ unsigned int need_vertical, int focused_on_left);
+static void init_tree(Monitor *m);
+static void insert_client(Monitor *m, Client *focused_client, Client *new_client);
+static LayoutNode *remove_client_node(LayoutNode *node, Client *c);
+static void remove_client(Monitor *m, Client *c);
+static void setratio_h(const Arg *arg);
+static void setratio_v(const Arg *arg);
+static void swapclients(const Arg *arg);
+static unsigned int visible_count(LayoutNode *node, Monitor *m);
+static Client *xytoclient(double x, double y);
+
+static double resize_last_update_x, resize_last_update_y;
+static uint32_t last_resize_time = 0;
+
+void
+apply_layout(Monitor *m, LayoutNode *node,
+ struct wlr_box area, unsigned int is_root)
+{
+ Client *c;
+ float ratio;
+ unsigned int left_count, right_count, mid;
+ struct wlr_box left_area, right_area;
+
+ if (!node)
+ return;
+
+ /* If this node is a client node, check if it is visible. */
+ if (node->is_client_node) {
+ c = node->client;
+ if (!c || !VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ return;
+ resize(c, area, 0);
+ return;
+ }
+
+ /* For a split node, we see how many visible children are on each side: */
+ left_count = visible_count(node->left, m);
+ right_count = visible_count(node->right, m);
+
+ if (left_count == 0 && right_count == 0) {
+ return;
+ } else if (left_count > 0 && right_count == 0) {
+ apply_layout(m, node->left, area, 0);
+ return;
+ } else if (left_count == 0 && right_count > 0) {
+ apply_layout(m, node->right, area, 0);
+ return;
+ }
+
+ /* If we’re here, we have visible clients in both subtrees. */
+ ratio = node->split_ratio;
+ if (ratio < 0.05f)
+ ratio = 0.05f;
+ if (ratio > 0.95f)
+ ratio = 0.95f;
+
+ memset(&left_area, 0, sizeof(left_area));
+ memset(&right_area, 0, sizeof(right_area));
+
+ if (node->is_split_vertically) {
+ mid = (unsigned int)(area.width * ratio);
+ left_area.x = area.x;
+ left_area.y = area.y;
+ left_area.width = mid;
+ left_area.height = area.height;
+
+ right_area.x = area.x + mid;
+ right_area.y = area.y;
+ right_area.width = area.width - mid;
+ right_area.height = area.height;
+ } else {
+ /* horizontal split */
+ mid = (unsigned int)(area.height * ratio);
+ left_area.x = area.x;
+ left_area.y = area.y;
+ left_area.width = area.width;
+ left_area.height = mid;
+
+ right_area.x = area.x;
+ right_area.y = area.y + mid;
+ right_area.width = area.width;
+ right_area.height= area.height - mid;
+ }
+
+ apply_layout(m, node->left, left_area, 0);
+ apply_layout(m, node->right, right_area, 0);
+}
+
+void
+btrtile(Monitor *m)
+{
+ Client *c, *focused = NULL;
+ int n = 0;
+ LayoutNode *found;
+ struct wlr_box full_area;
+
+ if (!m)
+ return;
+
+ /* Remove floating and moved clients */
+ wl_list_for_each(c, &clients, link) {
+ if (c->mon != m || c->isfloating)
+ remove_client(m, c);
+ }
+
+ /* If no client is found under cursor, fallback to focustop(m) */
+ if (!(focused = xytoclient(cursor->x, cursor->y)))
+ focused = focustop(m);
+
+ /* Insert visible clients that are not part of the tree. */
+ wl_list_for_each(c, &clients, link) {
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen && c->mon == m) {
+ found = find_client_node(m->root, c);
+ if (!found) {
+ insert_client(m, focused, c);
+ }
+ n++;
+ }
+ }
+
+ if (n == 0)
+ return;
+
+ full_area = m->w;
+ apply_layout(m, m->root, full_area, 1);
+}
+
+LayoutNode *
+create_client_node(Client *c)
+{
+ LayoutNode *node = calloc(1, sizeof(LayoutNode));
+
+ if (!node)
+ return NULL;
+ node->is_client_node = 1;
+ node->split_ratio = 0.5f;
+ node->client = c;
+ return node;
+}
+
+LayoutNode *
+create_split_node(unsigned int is_split_vertically,
+ LayoutNode *left, LayoutNode *right)
+{
+ LayoutNode *node = calloc(1, sizeof(LayoutNode));
+
+ if (!node)
+ return NULL;
+ node->is_client_node = 0;
+ node->split_ratio = 0.5f;
+ node->is_split_vertically = is_split_vertically;
+ node->left = left;
+ node->right = right;
+ if (left)
+ left->split_node = node;
+ if (right)
+ right->split_node = node;
+ return node;
+}
+
+void
+destroy_node(LayoutNode *node)
+{
+ if (!node)
+ return;
+ if (!node->is_client_node) {
+ destroy_node(node->left);
+ destroy_node(node->right);
+ }
+ free(node);
+}
+
+void
+destroy_tree(Monitor *m)
+{
+ if (!m || !m->root)
+ return;
+ destroy_node(m->root);
+ m->root = NULL;
+}
+
+LayoutNode *
+find_client_node(LayoutNode *node, Client *c)
+{
+ LayoutNode *res;
+
+ if (!node || !c)
+ return NULL;
+ if (node->is_client_node) {
+ return (node->client == c) ? node : NULL;
+ }
+ res = find_client_node(node->left, c);
+ return res ? res : find_client_node(node->right, c);
+}
+
+LayoutNode *
+find_suitable_split(Monitor *m, LayoutNode *start_node,
+ unsigned int need_vertical, int focused_on_left)
+{
+ LayoutNode *n = start_node, *child = NULL;
+
+ if (!m)
+ return NULL;
+
+ if (n && n->is_client_node) {
+ child = n;
+ n = n->split_node;
+ }
+
+ while (n) {
+ if (!n->is_client_node && n->is_split_vertically == need_vertical
+ && visible_count(n->left, m) > 0
+ && visible_count(n->right, m) > 0) {
+ if ((focused_on_left && n->left == child) ||
+ (!focused_on_left && n->right == child))
+ return n;
+ }
+ child = n;
+ n = n->split_node;
+ }
+ return NULL;
+}
+void
+init_tree(Monitor *m)
+{
+ if (m)
+ m->root = NULL;
+}
+
+void
+insert_client(Monitor *m, Client *focused_client, Client *new_client)
+{
+ Client *old_client;
+ LayoutNode **root = &m->root, *old_root,
+ *focused_node, *new_client_node, *old_client_node;
+ unsigned int wider, mid_x, mid_y;
+
+ /* If no root , new client becomes the root. */
+ if (!*root) {
+ *root = create_client_node(new_client);
+ return;
+ }
+
+ /* Find the focused_client node,
+ * if not found split the root. */
+ focused_node = focused_client ?
+ find_client_node(*root, focused_client) : NULL;
+ if (!focused_node) {
+ old_root = *root;
+ new_client_node = create_client_node(new_client);
+ *root = create_split_node(1, old_root, new_client_node);
+ return;
+ }
+
+ /* Turn focused node from a client node into a split node,
+ * and attach old_client + new_client. */
+ old_client = focused_node->client;
+ old_client_node = create_client_node(old_client);
+ new_client_node = create_client_node(new_client);
+
+ /* Decide split direction. */
+ wider = (focused_client->geom.width >= focused_client->geom.height);
+ focused_node->is_client_node = 0;
+ focused_node->client = NULL;
+ focused_node->is_split_vertically = (wider ? 1 : 0);
+
+ /* Pick new_client side depending on the cursor position. */
+ mid_x = focused_client->geom.x + focused_client->geom.width / 2;
+ mid_y = focused_client->geom.y + focused_client->geom.height / 2;
+
+ if (wider) {
+ /* vertical split => left vs right */
+ if (cursor->x <= mid_x) {
+ focused_node->left = new_client_node;
+ focused_node->right = old_client_node;
+ } else {
+ focused_node->left = old_client_node;
+ focused_node->right = new_client_node;
+ }
+ } else {
+ /* horizontal split => top vs bottom */
+ if (cursor->y <= mid_y) {
+ focused_node->left = new_client_node;
+ focused_node->right = old_client_node;
+ } else {
+ focused_node->left = old_client_node;
+ focused_node->right = new_client_node;
+ }
+ }
+ old_client_node->split_node = focused_node;
+ new_client_node->split_node = focused_node;
+ focused_node->split_ratio = 0.5f;
+}
+
+LayoutNode *
+remove_client_node(LayoutNode *node, Client *c)
+{
+ LayoutNode *tmp;
+ if (!node)
+ return NULL;
+ if (node->is_client_node) {
+ /* If this client_node is the client we're removing,
+ * return NULL to remove it */
+ if (node->client == c) {
+ free(node);
+ return NULL;
+ }
+ return node;
+ }
+
+ node->left = remove_client_node(node->left, c);
+ node->right = remove_client_node(node->right, c);
+
+ /* If one of the client node is NULL after removal and the other is not,
+ * we "lift" the other client node up to replace this split node. */
+ if (!node->left && node->right) {
+ tmp = node->right;
+
+ /* Save pointer to split node */
+ if (tmp)
+ tmp->split_node = node->split_node;
+
+ free(node);
+ return tmp;
+ }
+
+ if (!node->right && node->left) {
+ tmp = node->left;
+
+ /* Save pointer to split node */
+ if (tmp)
+ tmp->split_node = node->split_node;
+
+ free(node);
+ return tmp;
+ }
+
+ /* If both children exist or both are NULL (empty tree),
+ * return node as is. */
+ return node;
+}
+
+void
+remove_client(Monitor *m, Client *c)
+{
+ if (!m->root || !c)
+ return;
+ m->root = remove_client_node(m->root, c);
+}
+
+static void
+setratio(unsigned int need_vertical, const Arg *arg)
+{
+ Client *sel;
+ LayoutNode *client_node, *split_node;
+ float new_ratio;
+ int focused_on_left;
+
+ if (!selmon || !selmon->lt[selmon->sellt]->arrange)
+ return;
+
+ sel = focustop(selmon);
+ if (!sel)
+ return;
+
+ client_node = find_client_node(selmon->root, sel);
+ if (!client_node)
+ return;
+
+ focused_on_left = (arg->f >= 0.0f);
+
+ split_node = find_suitable_split(selmon, client_node, need_vertical, focused_on_left);
+
+ if (!split_node)
+ split_node = find_suitable_split(selmon, client_node, need_vertical, !focused_on_left);
+ if (!split_node)
+ return;
+
+ new_ratio = (arg->f != 0.0f) ? (split_node->split_ratio + arg->f) : 0.5f;
+ if (new_ratio < 0.05f)
+ new_ratio = 0.05f;
+ if (new_ratio > 0.95f)
+ new_ratio = 0.95f;
+ split_node->split_ratio = new_ratio;
+
+ apply_layout(selmon, selmon->root, selmon->w, 1);
+}
+
+void
+setratio_h(const Arg *arg)
+{
+ setratio(1, arg);
+}
+
+void
+setratio_v(const Arg *arg)
+{
+ setratio(0, arg);
+}
+
+void swapclients(const Arg *arg) {
+ Client *c, *tmp, *target = NULL, *sel = focustop(selmon);
+ LayoutNode *sel_node, *target_node;
+ int closest_dist = INT_MAX, dist, sel_center_x, sel_center_y,
+ cand_center_x, cand_center_y;
+
+ if (!sel || sel->isfullscreen ||
+ !selmon->root || !selmon->lt[selmon->sellt]->arrange)
+ return;
+
+
+ /* Get the center coordinates of the selected client */
+ sel_center_x = sel->geom.x + sel->geom.width / 2;
+ sel_center_y = sel->geom.y + sel->geom.height / 2;
+
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen || c == sel)
+ continue;
+
+ /* Get the center of candidate client */
+ cand_center_x = c->geom.x + c->geom.width / 2;
+ cand_center_y = c->geom.y + c->geom.height / 2;
+
+ /* Check that the candidate lies in the requested direction. */
+ switch (arg->ui) {
+ case 0:
+ if (cand_center_x >= sel_center_x)
+ continue;
+ break;
+ case 1:
+ if (cand_center_x <= sel_center_x)
+ continue;
+ break;
+ case 2:
+ if (cand_center_y >= sel_center_y)
+ continue;
+ break;
+ case 3:
+ if (cand_center_y <= sel_center_y)
+ continue;
+ break;
+ default:
+ continue;
+ }
+
+ /* Get distance between the centers */
+ dist = abs(sel_center_x - cand_center_x) + abs(sel_center_y - cand_center_y);
+ if (dist < closest_dist) {
+ closest_dist = dist;
+ target = c;
+ }
+ }
+
+ /* If target is found, swap the two clients’ positions in the layout tree */
+ if (target) {
+ sel_node = find_client_node(selmon->root, sel);
+ target_node = find_client_node(selmon->root, target);
+ if (sel_node && target_node) {
+ tmp = sel_node->client;
+ sel_node->client = target_node->client;
+ target_node->client = tmp;
+ arrange(selmon);
+ }
+ }
+}
+
+unsigned int
+visible_count(LayoutNode *node, Monitor *m)
+{
+ Client *c;
+
+ if (!node)
+ return 0;
+ /* Check if this client is visible. */
+ if (node->is_client_node) {
+ c = node->client;
+ if (c && VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
+ return 1;
+ return 0;
+ }
+ /* Else it’s a split node. */
+ return visible_count(node->left, m) + visible_count(node->right, m);
+}
+
+Client *
+xytoclient(double x, double y) {
+ Monitor *m = xytomon(x, y);
+ Client *c, *closest = NULL;
+ double dist, mindist = INT_MAX, dx, dy;
+
+ wl_list_for_each_reverse(c, &clients, link) {
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen &&
+ x >= c->geom.x && x <= (c->geom.x + c->geom.width) &&
+ y >= c->geom.y && y <= (c->geom.y + c->geom.height)){
+ return c;
+ }
+ }
+
+ /* If no client was found at cursor position fallback to closest. */
+ wl_list_for_each_reverse(c, &clients, link) {
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) {
+ dx = 0, dy = 0;
+
+ if (x < c->geom.x)
+ dx = c->geom.x - x;
+ else if (x > (c->geom.x + c->geom.width))
+ dx = x - (c->geom.x + c->geom.width);
+
+ if (y < c->geom.y)
+ dy = c->geom.y - y;
+ else if (y > (c->geom.y + c->geom.height))
+ dy = y - (c->geom.y + c->geom.height);
+
+ dist = dx * dx + dy * dy;
+ if (dist < mindist) {
+ mindist = dist;
+ closest = c;
+ }
+ }
+ }
+ return closest;
+}
diff --git a/config.def.h b/config.def.h
index 8a6eda0..bc04e3f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,7 +13,10 @@ static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
+static const float resize_factor = 0.0002f; /* Resize multiplier for mouse resizing, depends on mouse sensivity. */
+static const uint32_t resize_interval_ms = 16; /* Resize interval depends on framerate and screen refresh rate. */
+enum Direction { DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN };
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
@@ -30,6 +33,7 @@ static const Rule rules[] = {
/* layout(s) */
static const Layout layouts[] = {
/* symbol arrange function */
+ { "|w|", btrtile },
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
@@ -144,6 +148,14 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up, swapclients, {.i = DIR_UP} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, swapclients, {.i = DIR_DOWN} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, swapclients, {.i = DIR_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, swapclients, {.i = DIR_LEFT} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Right, setratio_h, {.f = +0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Left, setratio_h, {.f = -0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Up, setratio_v, {.f = -0.025f} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Down, setratio_v, {.f = +0.025f} },
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
diff --git a/dwl.c b/dwl.c
index 8101ffa..31446ed 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1,6 +1,7 @@
/*
* See LICENSE file for copyright and license details.
*/
+#include <limits.h>
#include <getopt.h>
#include <libinput.h>
#include <linux/input-event-codes.h>
@@ -104,6 +105,7 @@ typedef struct {
const Arg arg;
} Button;
+typedef struct LayoutNode LayoutNode;
typedef struct Monitor Monitor;
typedef struct {
/* Must keep this field first */
@@ -141,7 +143,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, was_tiled;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -209,6 +211,7 @@ struct Monitor {
int nmaster;
char ltsymbol[16];
int asleep;
+ LayoutNode *root;
};
typedef struct {
@@ -251,6 +254,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m);
static void axisnotify(struct wl_listener *listener, void *data);
+static void btrtile(Monitor *m);
static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
static void checkidleinhibitor(struct wlr_surface *exclude);
@@ -333,6 +337,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
+static void setratio_h(const Arg *arg);
+static void setratio_v(const Arg *arg);
+static void swapclients(const Arg *arg);
static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
@@ -458,6 +465,7 @@ static struct wlr_xwayland *xwayland;
/* attempt to encapsulate suck into one file */
#include "client.h"
+#include "btrtile.c"
/* function implementations */
void
@@ -628,7 +636,7 @@ buttonpress(struct wl_listener *listener, void *data)
struct wlr_pointer_button_event *event = data;
struct wlr_keyboard *keyboard;
uint32_t mods;
- Client *c;
+ Client *c, *target = NULL;
const Button *b;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@@ -649,7 +657,7 @@ buttonpress(struct wl_listener *listener, void *data)
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
for (b = buttons; b < END(buttons); b++) {
if (CLEANMASK(mods) == CLEANMASK(b->mod) &&
- event->button == b->button && b->func) {
+ event->button == b->button && b->func) {
b->func(&b->arg);
return;
}
@@ -659,6 +667,21 @@ buttonpress(struct wl_listener *listener, void *data)
/* If you released any buttons, we exit interactive move/resize mode. */
/* TODO: should reset to the pointer focus's current setcursor */
if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) {
+ c = grabc;
+ if (c && c->was_tiled && !strcmp(selmon->ltsymbol, "|w|")) {
+ if (cursor_mode == CurMove && c->isfloating) {
+ target = xytoclient(cursor->x, cursor->y);
+
+ if (target && !target->isfloating && !target->isfullscreen)
+ insert_client(selmon, target, c);
+ else
+ selmon->root = create_client_node(c);
+
+ setfloating(c, 0);
+ apply_layout(selmon, selmon->root, selmon->w, 1);
+ }
+ }
+ /* Default behaviour */
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
cursor_mode = CurNormal;
/* Drop the window off on its new monitor */
@@ -750,6 +773,7 @@ cleanupmon(struct wl_listener *listener, void *data)
wlr_output_layout_remove(output_layout, m->wlr_output);
wlr_scene_output_destroy(m->scene_output);
+ destroy_tree(m);
closemon(m);
wlr_scene_node_destroy(&m->fullscreen_bg->node);
free(m);
@@ -1094,6 +1118,7 @@ createmon(struct wl_listener *listener, void *data)
wl_list_insert(&mons, &m->link);
printstatus();
+ init_tree(m);
/* The xdg-protocol specifies:
*
@@ -1333,9 +1358,17 @@ destroynotify(struct wl_listener *listener, void *data)
{
/* Called when the xdg_toplevel is destroyed. */
Client *c = wl_container_of(listener, c, destroy);
+ Monitor *mon;
wl_list_remove(&c->destroy.link);
wl_list_remove(&c->set_title.link);
wl_list_remove(&c->fullscreen.link);
+ /* We check if the destroyed client was part of any tiled_list, to catch
+ * client removals even if they would not be currently managed by btrtile */
+ wl_list_for_each(mon, &mons, link) {
+ if (mon->root) {
+ remove_client(mon, c);
+ }
+ }
#ifdef XWAYLAND
if (c->type != XDGShell) {
wl_list_remove(&c->activate.link);
@@ -1866,7 +1899,8 @@ void
motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
double dx_unaccel, double dy_unaccel)
{
- double sx = 0, sy = 0, sx_confined, sy_confined;
+ int tiled = 0;
+ double sx = 0, sy = 0, sx_confined, sy_confined, dx_total, dy_total;
Client *c = NULL, *w = NULL;
LayerSurface *l = NULL;
struct wlr_surface *surface = NULL;
@@ -1920,18 +1954,55 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
/* Update drag icon's position */
wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x), (int)round(cursor->y));
- /* If we are currently grabbing the mouse, handle and return */
+ /* Skip if internal call */
+ if (time == 0)
+ goto focus;
+
+ tiled = grabc && !grabc->isfloating && !grabc->isfullscreen;
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,
- .width = grabc->geom.width, .height = grabc->geom.height}, 1);
- return;
+ if (grabc && grabc->isfloating) {
+ resize(grabc, (struct wlr_box){
+ .x = (int)round(cursor->x) - grabcx,
+ .y = (int)round(cursor->y) - grabcy,
+ .width = grabc->geom.width,
+ .height = grabc->geom.height
+ }, 1);
+ return;
+ }
} else if (cursor_mode == CurResize) {
- resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
- .width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
- return;
+ if (tiled) {
+ dx_total = cursor->x - resize_last_update_x;
+ dy_total = cursor->y - resize_last_update_y;
+
+ if (time - last_resize_time >= resize_interval_ms) {
+ Arg a = {0};
+ if (fabs(dx_total) > fabs(dy_total)) {
+ a.f = (float)(dx_total * resize_factor);
+ setratio_h(&a);
+ } else {
+ a.f = (float)(dy_total * resize_factor);
+ setratio_v(&a);
+ }
+
+ last_resize_time = time;
+ resize_last_update_x = cursor->x;
+ resize_last_update_y = cursor->y;
+ }
+
+ } else if (grabc && grabc->isfloating) {
+ /* Floating resize as original */
+ resize(grabc, (struct wlr_box){
+ .x = grabc->geom.x,
+ .y = grabc->geom.y,
+ .width = (int)round(cursor->x) - grabc->geom.x,
+ .height = (int)round(cursor->y) - grabc->geom.y
+ }, 1);
+ return;
+ }
}
+focus:
/* If there's no client surface under the cursor, set the cursor image to a
* default. This is what makes the cursor image appear when you move it
* off of a client or over its border. */
@@ -1965,22 +2036,40 @@ moveresize(const Arg *arg)
if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen)
return;
- /* Float the window and tell motionnotify to grab it */
- setfloating(grabc, 1);
- switch (cursor_mode = arg->ui) {
- case CurMove:
- grabcx = (int)round(cursor->x) - grabc->geom.x;
- grabcy = (int)round(cursor->y) - grabc->geom.y;
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "all-scroll");
- break;
- case CurResize:
- /* Doesn't work for X11 output - the next absolute motion event
- * returns the cursor to where it started */
- wlr_cursor_warp_closest(cursor, NULL,
- grabc->geom.x + grabc->geom.width,
- grabc->geom.y + grabc->geom.height);
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
- break;
+ cursor_mode = arg->ui;
+ grabc->was_tiled = (!grabc->isfloating && !grabc->isfullscreen);
+
+ if (grabc->was_tiled) {
+ switch (cursor_mode) {
+ case CurMove:
+ setfloating(grabc, 1);
+ grabcx = (int)round(cursor->x) - grabc->geom.x;
+ grabcy = (int)round(cursor->y) - grabc->geom.y;
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur");
+ break;
+ case CurResize:
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
+ resize_last_update_x = cursor->x;
+ resize_last_update_y = cursor->y;
+ break;
+ }
+ } else {
+ /* Default floating logic */
+ /* Float the window and tell motionnotify to grab it */
+ setfloating(grabc, 1);
+ switch (cursor_mode) {
+ case CurMove:
+ grabcx = (int)round(cursor->x) - grabc->geom.x;
+ grabcy = (int)round(cursor->y) - grabc->geom.y;
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur");
+ break;
+ case CurResize:
+ wlr_cursor_warp_closest(cursor, NULL,
+ grabc->geom.x + grabc->geom.width,
+ grabc->geom.y + grabc->geom.height);
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
+ break;
+ }
}
}
@@ -2833,6 +2922,14 @@ unmapnotify(struct wl_listener *listener, void *data)
focusclient(focustop(selmon), 1);
}
} else {
+ /* btrtile remove clients for each monitor */
+ Monitor *mon;
+ wl_list_for_each(mon, &mons, link) {
+ if (mon->root) {
+ remove_client(mon, c);
+ }
+ }
+
wl_list_remove(&c->link);
setmon(c, NULL, 0);
wl_list_remove(&c->flink);
--
2.53.0
-13
View File
@@ -1,13 +0,0 @@
### Description
Add a keybinding that toggles centering the terminally horizontally when
it's the only window, while still tiling multiple windows.
This limits the width of long text making it easier to read, and avoids
covering the wallpaper more than necessary.
### Download
- [git branch](https://codeberg.org/guidocella/dwl/src/branch/center-terminal)
- [2026-09-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/center-terminal/center-terminal.patch)
### Authors
- [Guido Cella](https://codeberg.org/guidocella)
@@ -1,103 +0,0 @@
From 974db1c4a01a38e2c2af9460e4d9c5f48e7974f7 Mon Sep 17 00:00:00 2001
From: Guido Cella <guido@guidocella.xyz>
Date: Mon, 9 Feb 2026 10:21:33 +0100
Subject: [PATCH] add a keybinding to center the terminal
Add a keybinding that toggles centering the terminally horizontally when
it's the only window, while still tiling multiple windows.
This limits the width of long text making it easier to read, and avoids
covering the wallpaper more than necessary.
---
config.def.h | 1 +
dwl.c | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/config.def.h b/config.def.h
index 13c5322..aef03cb 100644
--- a/config.def.h
+++ b/config.def.h
@@ -138,6 +138,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_v, togglecenter, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_0, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
diff --git a/dwl.c b/dwl.c
index f7bda0b..cfdd4d1 100644
--- a/dwl.c
+++ b/dwl.c
@@ -9,6 +9,7 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include <strings.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
@@ -158,6 +159,7 @@ typedef struct {
unsigned int bw;
uint32_t tags;
int isfloating, isurgent, isfullscreen;
+ bool centered;
} Client;
typedef struct {
@@ -354,6 +356,7 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
+static void togglecenter(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -460,6 +463,8 @@ static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener new_session_lock = {.notify = locksession};
static struct wl_listener new_foreign_toplevel_capture_request = {.notify = capturerequest};
+static bool center;
+
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -534,6 +539,9 @@ applyrules(Client *c)
}
}
+ if (!strcasecmp(appid, termcmd[0]))
+ c->centered = true;
+
c->isfloating |= client_is_float_type(c);
setmon(c, mon, newtags);
}
@@ -2886,6 +2894,11 @@ tile(Monitor *m)
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
if (i < m->nmaster) {
+ if (n == 1 && center && c->centered) {
+ resize(c, (struct wlr_box){.x = m->w.width / 4, .y = m->w.y,
+ .width = m->w.width / 2, .height = m->w.height - 2 * c->bw}, 0);
+ return;
+ }
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
my += c->geom.height;
@@ -2898,6 +2911,13 @@ tile(Monitor *m)
}
}
+void
+togglecenter(const Arg *arg)
+{
+ center = !center;
+ tile(selmon);
+}
+
void
togglefloating(const Arg *arg)
{
--
2.55.0
+11 -2
View File
@@ -7,9 +7,18 @@ Mod+chain is pressed. A subsequent keypress will be matched against bindings
for that chain key. If it is configured the action will be triggered, otherwise
the keypress will be ignored.
To use chainkeys, append the key after the argument in the keybindings. Example usage:
```c
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_s, setmfact, {.f = -0.05f}, XKB_KEY_h },
{ MODKEY, XKB_KEY_s, setmfact, {.f = +0.05f}, XKB_KEY_l },
```
Here, `MODKEY+i` triggers incnmaster to decrease nmaster, while `MODKEY+s` triggers a chain. After triggering the chain, pressing `h` or `l` changes the monitor's mfact and resets the chain.
### Download
- [git branch](https://codeberg.org/bencc/dwl/src/branch/chainkeys)
- [2024-05-20](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/chainkeys/chainkeys.patch)
- [chainkeys.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/chainkeys/chainkeys.patch) Latest version, applies to main branch, tested on commit dwl/dwl@e2038450f2
- [chainkeys_2024-05-20.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/chainkeys/chainkeys_2024-05-20.patch) Legacy version from 2024-05-20
### Authors
- [atourist](https://codeberg.org/atourist)
- [Ben Collerson](https://codeberg.org/bencc)
+60 -143
View File
@@ -1,157 +1,74 @@
From 226e204ec7fb6d6840a984ef8e8ec1d2514e985f Mon Sep 17 00:00:00 2001
From: Ben Collerson <benc@benc.cc>
Date: Tue, 2 Jan 2024 10:33:59 +1000
Subject: [PATCH] chainkeys
---
config.def.h | 62 ++++++++++++++++++++++++++--------------------------
dwl.c | 23 ++++++++++++++++++-
2 files changed, 53 insertions(+), 32 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8f498d2f..1c182547 100644
--- a/config.def.h
+++ b/config.def.h
@@ -105,10 +105,10 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
#define MODKEY WLR_MODIFIER_ALT
diff --git a/Makefile b/Makefile
index 8304245..836cb87 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \
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 \
- -Wfloat-conversion
+ -Wfloat-conversion -Wno-missing-field-initializers
#define TAGKEYS(KEY,SKEY,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, -1, KEY, view, {.ui = 1 << TAG} }, \
+ { MODKEY|WLR_MODIFIER_CTRL, -1, KEY, toggleview, {.ui = 1 << TAG} }, \
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, SKEY, tag, {.ui = 1 << TAG} }, \
+ { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,-1,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 } }
@@ -119,30 +119,30 @@ static const char *menucmd[] = { "wmenu-run", NULL };
static const Key keys[] = {
/* Note that Shift changes certain key codes: c -> C, 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} },
+ /* modifier chain, key function argument */
+ { MODKEY, -1, XKB_KEY_p, spawn, {.v = menucmd} },
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_Return, spawn, {.v = termcmd} },
+ { MODKEY, -1, XKB_KEY_j, focusstack, {.i = +1} },
+ { MODKEY, -1, XKB_KEY_k, focusstack, {.i = -1} },
+ { MODKEY, -1, XKB_KEY_i, incnmaster, {.i = +1} },
+ { MODKEY, -1, XKB_KEY_d, incnmaster, {.i = -1} },
+ { MODKEY, -1, XKB_KEY_h, setmfact, {.f = -0.05f} },
+ { MODKEY, -1, XKB_KEY_l, setmfact, {.f = +0.05f} },
+ { MODKEY, -1, XKB_KEY_Return, zoom, {0} },
+ { MODKEY, -1, XKB_KEY_Tab, view, {0} },
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_C, killclient, {0} },
+ { MODKEY, -1, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, -1, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
+ { MODKEY, -1, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, -1, XKB_KEY_space, setlayout, {0} },
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_space, togglefloating, {0} },
+ { MODKEY, -1, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, -1, XKB_KEY_0, view, {.ui = ~0} },
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_parenright, tag, {.ui = ~0} },
+ { MODKEY, -1, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
+ { MODKEY, -1, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, 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),
@@ -152,14 +152,14 @@ 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, -1, 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,-1,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_XF86Switch_VT_##n, chvt, {.ui = (n)} }
+#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,-1,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),
};
# CFLAGS / LDFLAGS
PKGS = wayland-server xkbcommon libinput $(XLIBS)
diff --git a/dwl.c b/dwl.c
index bf763dfc..05e667f8 100644
index 216deb5..af011ea 100644
--- a/dwl.c
+++ b/dwl.c
@@ -143,6 +143,7 @@ typedef struct {
typedef struct {
uint32_t mod;
+ int chain;
@@ -166,6 +166,7 @@ typedef struct {
xkb_keysym_t keysym;
void (*func)(const Arg *);
const Arg arg;
@@ -353,6 +354,7 @@ static const char broken[] = "broken";
+ xkb_keysym_t chain;
} Key;
typedef struct {
@@ -378,6 +379,7 @@ static void zoom(const Arg *arg);
/* variables */
static pid_t child_pid = -1;
static int locked;
static void *exclusive_focus;
+static int chainkey = -1;
+static xkb_keysym_t chainkey = 0;
static Client *focused_client;
static struct wl_display *dpy;
static struct wlr_backend *backend;
static struct wlr_scene *scene;
@@ -1438,11 +1440,30 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
static struct wl_event_loop *event_loop;
@@ -1735,9 +1737,21 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
* processing.
*/
const Key *k;
+ if (chainkey) {
+ for (k = keys; k < END(keys); k++) {
+ if (chainkey == k->keysym && sym == k->chain) {
+ chainkey = 0;
+ return k;
+ }
+ }
+ chainkey = 0;
+ return NULL;
+ }
for (k = keys; k < END(keys); k++) {
if (CLEANMASK(mods) == CLEANMASK(k->mod)
- && sym == k->keysym && k->func) {
+ && sym == k->keysym
+ && chainkey == -1
+ && k->chain == -1
+ && k->func) {
k->func(&k->arg);
return 1;
}
+ else if (sym == k->keysym
+ && chainkey != -1
+ && k->chain == chainkey
+ && k->func) {
+ k->func(&k->arg);
+ chainkey = -1;
+ return 1;
+ }
+ else if (CLEANMASK(mods) == CLEANMASK(k->mod)
+ && k->chain == (int)sym
+ && chainkey == -1
+ && k->func) {
+ chainkey = sym;
+ return 1;
+ }
- if (CLEANMASK(mods) == CLEANMASK(k->mod) && sym == k->keysym && k->func)
+ if (CLEANMASK(mods) == CLEANMASK(k->mod) && sym == k->keysym && k->func) {
+ if (k->chain) chainkey = k->keysym;
return k;
+ }
}
+ chainkey = -1;
return 0;
return NULL;
}
--
2.43.0
@@ -1771,7 +1785,7 @@ keypress(struct wl_listener *listener, void *data)
const Key *key = keybinding(group->mods, group->keysyms[i]);
if (key) {
consumed[event->keycode] = 1;
- key->func(&key->arg);
+ if (!chainkey) key->func(&key->arg);
handled = 1;
break;
}
@@ -1827,7 +1841,7 @@ keyrepeat(void *data)
for (int i = 0; i < 2; i++) {
const Key *key = keybinding(group->mods, group->keysyms[i]);
if (key) {
- key->func(&key->arg);
+ if (!chainkey) key->func(&key->arg);
break;
}
}
@@ -0,0 +1,157 @@
From 226e204ec7fb6d6840a984ef8e8ec1d2514e985f Mon Sep 17 00:00:00 2001
From: Ben Collerson <benc@benc.cc>
Date: Tue, 2 Jan 2024 10:33:59 +1000
Subject: [PATCH] chainkeys
---
config.def.h | 62 ++++++++++++++++++++++++++--------------------------
dwl.c | 23 ++++++++++++++++++-
2 files changed, 53 insertions(+), 32 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8f498d2f..1c182547 100644
--- a/config.def.h
+++ b/config.def.h
@@ -105,10 +105,10 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
#define MODKEY WLR_MODIFIER_ALT
#define TAGKEYS(KEY,SKEY,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, -1, KEY, view, {.ui = 1 << TAG} }, \
+ { MODKEY|WLR_MODIFIER_CTRL, -1, KEY, toggleview, {.ui = 1 << TAG} }, \
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, SKEY, tag, {.ui = 1 << TAG} }, \
+ { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,-1,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 } }
@@ -119,30 +119,30 @@ static const char *menucmd[] = { "wmenu-run", NULL };
static const Key keys[] = {
/* Note that Shift changes certain key codes: c -> C, 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} },
+ /* modifier chain, key function argument */
+ { MODKEY, -1, XKB_KEY_p, spawn, {.v = menucmd} },
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_Return, spawn, {.v = termcmd} },
+ { MODKEY, -1, XKB_KEY_j, focusstack, {.i = +1} },
+ { MODKEY, -1, XKB_KEY_k, focusstack, {.i = -1} },
+ { MODKEY, -1, XKB_KEY_i, incnmaster, {.i = +1} },
+ { MODKEY, -1, XKB_KEY_d, incnmaster, {.i = -1} },
+ { MODKEY, -1, XKB_KEY_h, setmfact, {.f = -0.05f} },
+ { MODKEY, -1, XKB_KEY_l, setmfact, {.f = +0.05f} },
+ { MODKEY, -1, XKB_KEY_Return, zoom, {0} },
+ { MODKEY, -1, XKB_KEY_Tab, view, {0} },
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_C, killclient, {0} },
+ { MODKEY, -1, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, -1, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
+ { MODKEY, -1, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, -1, XKB_KEY_space, setlayout, {0} },
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_space, togglefloating, {0} },
+ { MODKEY, -1, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, -1, XKB_KEY_0, view, {.ui = ~0} },
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_parenright, tag, {.ui = ~0} },
+ { MODKEY, -1, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
+ { MODKEY, -1, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, 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),
@@ -152,14 +152,14 @@ 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, -1, 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,-1,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_XF86Switch_VT_##n, chvt, {.ui = (n)} }
+#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,-1,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 bf763dfc..05e667f8 100644
--- a/dwl.c
+++ b/dwl.c
@@ -143,6 +143,7 @@ typedef struct {
typedef struct {
uint32_t mod;
+ int chain;
xkb_keysym_t keysym;
void (*func)(const Arg *);
const Arg arg;
@@ -353,6 +354,7 @@ static const char broken[] = "broken";
static pid_t child_pid = -1;
static int locked;
static void *exclusive_focus;
+static int chainkey = -1;
static struct wl_display *dpy;
static struct wlr_backend *backend;
static struct wlr_scene *scene;
@@ -1438,11 +1440,30 @@ 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) {
+ && sym == k->keysym
+ && chainkey == -1
+ && k->chain == -1
+ && k->func) {
k->func(&k->arg);
return 1;
}
+ else if (sym == k->keysym
+ && chainkey != -1
+ && k->chain == chainkey
+ && k->func) {
+ k->func(&k->arg);
+ chainkey = -1;
+ return 1;
+ }
+ else if (CLEANMASK(mods) == CLEANMASK(k->mod)
+ && k->chain == (int)sym
+ && chainkey == -1
+ && k->func) {
+ chainkey = sym;
+ return 1;
+ }
}
+ chainkey = -1;
return 0;
}
--
2.43.0
+2 -1
View File
@@ -8,7 +8,8 @@ There are also two functions that can be bound to a `Key` or `Button`,
2. `toggledimmingclient`: Which toggles dimming for the focused window, as if the client had `neverdim` applied to it. This overwrites an applied `Rule`.
### Download
- [2026-03-10](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused.patch)
- [2026-09-27](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20260927.patch)
- [2026-03-10](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20260310.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240918.patch)
- [2024-09-03](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240903.patch)
- [2024-07-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240714.patch)
@@ -0,0 +1,221 @@
diff --git a/client.h b/client.h
index d9f90bb..7a7792d 100644
--- a/client.h
+++ b/client.h
@@ -318,6 +318,12 @@ client_set_border_color(Client *c, const float color[static 4])
wlr_scene_rect_set_color(c->border[i], color);
}
+static inline void
+client_set_dimmer_state(Client *c, const int dim)
+{
+ wlr_scene_node_set_enabled(&c->dimmer->node, DIMOPT && !c->neverdim && dim);
+}
+
static inline void
client_set_fullscreen(Client *c, int fullscreen)
{
diff --git a/config.def.h b/config.def.h
index 8a6eda0..96a020a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -10,6 +10,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
+static const float unfocuseddim[] = COLOR(0x00000088);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
@@ -168,5 +169,6 @@ static const Key keys[] = {
static const Button buttons[] = {
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
+ { MODKEY|ShiftMask, BTN_MIDDLE, toggledimmingclient, {0} },
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
};
diff --git a/dwl.c b/dwl.c
index 101a45f..d6b129a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -109,6 +109,7 @@ typedef struct {
Monitor *mon;
struct wlr_scene_tree *scene;
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
+ struct wlr_scene_rect *dimmer;
struct wlr_scene_tree *scene_surface;
struct wl_list link;
struct wl_list flink;
@@ -138,7 +139,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, neverdim;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -228,6 +229,7 @@ typedef struct {
const char *title;
uint32_t tags;
int isfloating;
+ int neverdim;
int monitor;
} Rule;
@@ -335,6 +337,8 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
+static void toggledimming(const Arg *arg);
+static void toggledimmingclient(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -406,6 +410,7 @@ static struct wlr_output_layout *output_layout;
static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static int DIMOPT = 1;
/* global event handlers */
static struct wl_listener cursor_axis = {.notify = axisnotify};
@@ -491,6 +496,7 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
+ c->neverdim = r-> neverdim;
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -1433,8 +1439,10 @@ focusclient(Client *c, int lift)
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
- if (!exclusive_focus && !seat->drag)
+ if (!exclusive_focus && !seat->drag) {
client_set_border_color(c, focuscolor);
+ client_set_dimmer_state(c, 0);
+ }
}
/* Deactivate old client if focus is changing */
@@ -1452,7 +1460,7 @@ focusclient(Client *c, int lift)
* and probably other clients */
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
client_set_border_color(old_c, bordercolor);
-
+ client_set_dimmer_state(old_c, 1);
client_activate_surface(old, 0);
}
}
@@ -1739,8 +1747,7 @@ void
mapnotify(struct wl_listener *listener, void *data)
{
/* Called when the surface is mapped, or ready to display on-screen. */
- Client *p = NULL;
- Client *w, *c = wl_container_of(listener, c, map);
+ Client *p, *w, *d, *c = wl_container_of(listener, c, map);
Monitor *m;
int i;
@@ -1774,6 +1781,10 @@ mapnotify(struct wl_listener *listener, void *data)
c->border[i]->node.data = c;
}
+ c->dimmer = wlr_scene_rect_create(c->scene, 0, 0, unfocuseddim);
+ c->dimmer->node.data = c;
+ client_set_dimmer_state(c, 1);
+
/* Initialize client geometry with room for border */
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT);
c->geom.width += 2 * c->bw;
@@ -1792,6 +1803,10 @@ mapnotify(struct wl_listener *listener, void *data)
setmon(c, p->mon, p->tags);
} else {
applyrules(c);
+ d = focustop(selmon);
+ if (d) {
+ client_set_dimmer_state(d, 0);
+ }
}
printstatus();
@@ -2218,7 +2233,7 @@ resize(Client *c, struct wlr_box geo, int interact)
c->geom = geo;
applybounds(c, bbox);
- /* Update scene-graph, including borders */
+ /* Update scene-graph, including borders and dimmer*/
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
@@ -2228,6 +2243,8 @@ resize(Client *c, struct wlr_box geo, int interact)
wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw);
wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
+ wlr_scene_rect_set_size(c->dimmer, c->geom.width - 2*c->bw, c-> geom.height - 2*c->bw);
+ wlr_scene_node_set_position(&c->dimmer->node, c->bw, c->bw);
/* this is a no-op if size hasn't changed */
c->resize = client_set_size(c, c->geom.width - 2 * c->bw,
@@ -2745,6 +2762,27 @@ tile(Monitor *m)
}
}
+void toggledimming(const Arg *arg)
+{
+ Client *c;
+ DIMOPT ^= 1;
+ wl_list_for_each(c, &clients, link)
+ {
+ client_set_dimmer_state(c, 1);
+ }
+ c = focustop(selmon);
+ if (c)
+ client_set_dimmer_state(c, 0);
+}
+
+void
+toggledimmingclient(const Arg *arg)
+{
+ Client *sel = focustop(selmon);
+ if (sel)
+ sel -> neverdim ^= 1;
+}
+
void
togglefloating(const Arg *arg)
{
@@ -3022,9 +3060,29 @@ xytonode(double x, double y, struct wlr_surface **psurface,
Client *c = NULL;
LayerSurface *l = NULL;
int layer;
-
+ struct wlr_scene_node *hidden_dimmers[32];
+ int hidden_count = 0;
for (layer = NUM_LAYERS - 1; !surface && layer >= 0; layer--) {
- if (!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny)))
+ node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny);
+
+ while (node && node->type == WLR_SCENE_NODE_RECT && node->data) {
+ Client *hit_c = node->data;
+ /* Verify the node is actually a client's dimmer */
+ if (hit_c->type != LayerShell && hit_c->dimmer && &hit_c->dimmer->node == node) {
+ if (hidden_count < 32) {
+ wlr_scene_node_set_enabled(node, 0);
+ hidden_dimmers[hidden_count++] = node;
+ node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny);
+ continue;
+ }
+ }
+ break;
+ }
+
+ for(int i=0; i<hidden_count; i++)
+ wlr_scene_node_set_enabled(hidden_dimmers[i], 1);
+
+ if (!node)
continue;
if (node->type == WLR_SCENE_NODE_BUFFER)
@@ -0,0 +1,227 @@
diff --git a/client.h b/client.h
index eb1bb47..c41e287 100644
--- a/client.h
+++ b/client.h
@@ -347,6 +347,12 @@ client_set_border_color(Client *c, const float color[static 4])
wlr_scene_rect_set_color(c->border[i], color);
}
+static inline void
+client_set_dimmer_state(Client *c, const int dim)
+{
+ wlr_scene_node_set_enabled(&c->dimmer->node, DIMOPT && !c->neverdim && dim);
+}
+
static inline void
client_set_fullscreen(Client *c, int fullscreen)
{
diff --git a/config.def.h b/config.def.h
index a4019d3..bf829c6 100644
--- a/config.def.h
+++ b/config.def.h
@@ -11,6 +11,7 @@ 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);
+static const float unfocuseddim[] = COLOR(0x00000088);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
@@ -168,6 +169,7 @@ static const Key keys[] = {
static const Button buttons[] = {
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
+ { MODKEY|ShiftMask, BTN_MIDDLE, toggledimmingclient, {0} },
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
};
diff --git a/dwl.c b/dwl.c
index cca1ea4..af6371b 100644
--- a/dwl.c
+++ b/dwl.c
@@ -121,6 +121,7 @@ typedef struct {
Monitor *mon;
struct wlr_scene_tree *scene;
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
+ struct wlr_scene_rect *dimmer;
struct wlr_scene_tree *scene_surface;
struct wl_list link;
struct wl_list flink;
@@ -158,7 +159,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, neverdim;
} Client;
typedef struct {
@@ -248,6 +249,7 @@ typedef struct {
const char *title;
uint32_t tags;
int isfloating;
+ int neverdim;
int monitor;
} Rule;
@@ -357,6 +359,8 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
+static void toggledimming(const Arg *arg);
+static void toggledimmingclient(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -431,6 +435,7 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
static int consumed[KEY_MAX + 1];
+static int DIMOPT = 1;
/* global event handlers */
static struct wl_listener cursor_axis = {.notify = axisnotify};
@@ -533,6 +538,7 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
+ c->neverdim = r-> neverdim;
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -1550,8 +1556,10 @@ focusclient(Client *c, LayerSurface *l, int lift)
* handling a drag operation */
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)
+ && !seat->drag) {
client_set_border_color(c, focuscolor);
+ client_set_dimmer_state(c, 0);
+ }
}
/* If an overlay is focused, don't focus or activate the client,
@@ -1566,8 +1574,10 @@ focusclient(Client *c, LayerSurface *l, int lift)
if (focused_client && focused_client != c && !(c && client_is_unmanaged(c))) {
struct wlr_surface *s = client_surface(focused_client);
- if (c)
+ if (c) {
client_set_border_color(focused_client, bordercolor);
+ client_set_dimmer_state(focused_client, 1);
+ }
if (s && s->mapped)
client_activate_surface(s, 0);
focused_client = NULL;
@@ -1887,7 +1897,7 @@ mapnotify(struct wl_listener *listener, void *data)
{
/* Called when the surface is mapped, or ready to display on-screen. */
Client *p = NULL;
- Client *w, *c = wl_container_of(listener, c, map);
+ Client *w, *d, *c = wl_container_of(listener, c, map);
Monitor *m;
int i;
@@ -1923,6 +1933,10 @@ mapnotify(struct wl_listener *listener, void *data)
c->border[i]->node.data = c;
}
+ c->dimmer = wlr_scene_rect_create(c->scene, 0, 0, unfocuseddim);
+ c->dimmer->node.data = c;
+ client_set_dimmer_state(c, 1);
+
/* Initialize client geometry with room for border */
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
WLR_EDGE_RIGHT);
@@ -1954,6 +1968,10 @@ mapnotify(struct wl_listener *listener, void *data)
setmon(c, p->mon, p->tags);
} else {
applyrules(c);
+ d = focustop(selmon);
+ if (d) {
+ client_set_dimmer_state(d, 0);
+ }
}
printstatus();
@@ -2398,7 +2416,7 @@ resize(Client *c, struct wlr_box geo, int interact)
c->geom = geo;
applybounds(c, bbox);
- /* Update scene-graph, including borders */
+ /* Update scene-graph, including borders and dimmer*/
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
@@ -2408,6 +2426,8 @@ resize(Client *c, struct wlr_box geo, int interact)
wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw);
wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
+ wlr_scene_rect_set_size(c->dimmer, c->geom.width - 2*c->bw, c-> geom.height - 2*c->bw);
+ wlr_scene_node_set_position(&c->dimmer->node, c->bw, c->bw);
client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw);
client_get_clip(c, &clip);
@@ -2935,6 +2955,27 @@ tile(Monitor *m)
}
}
+void toggledimming(const Arg *arg)
+{
+ Client *c;
+ DIMOPT ^= 1;
+ wl_list_for_each(c, &clients, link)
+ {
+ client_set_dimmer_state(c, 1);
+ }
+ c = focustop(selmon);
+ if (c)
+ client_set_dimmer_state(c, 0);
+}
+
+void
+toggledimmingclient(const Arg *arg)
+{
+ Client *sel = focustop(selmon);
+ if (sel)
+ sel -> neverdim ^= 1;
+}
+
void
togglefloating(const Arg *arg)
{
@@ -3237,10 +3278,32 @@ xytonode(double x, double y, struct wlr_surface **psurface,
struct wlr_scene_node *node;
struct wlr_surface *surface = NULL;
int layer;
+ struct wlr_scene_node *hidden_dimmers[32];
+ int hidden_count = 0;
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)))
+ if (layer == LyrIMPopup)
+ continue;
+ node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny);
+
+ while (node && node->type == WLR_SCENE_NODE_RECT && node->data) {
+ Client *hit_c = node->data;
+ /* Verify the node is actually a client's dimmer */
+ if (hit_c->type != LayerShell && hit_c->dimmer && &hit_c->dimmer->node == node) {
+ if (hidden_count < 32) {
+ wlr_scene_node_set_enabled(node, 0);
+ hidden_dimmers[hidden_count++] = node;
+ node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny);
+ continue;
+ }
+ }
+ break;
+ }
+
+ for(int i=0; i<hidden_count; i++)
+ wlr_scene_node_set_enabled(hidden_dimmers[i], 1);
+
+ if (!node)
continue;
if (node->type == WLR_SCENE_NODE_BUFFER)
@@ -1 +0,0 @@
09
+1
View File
@@ -3,6 +3,7 @@ Change mfact by dragging the mouse.
### Download
- [git branch](https://codeberg.org/Palanix/dwl/src/branch/dragmfact)
- [v0.9](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dragmfact/dragmfact-v0.9.patch)
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dragmfact/dragmfact-v0.7.patch)
- [v0.6](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dragmfact/dragmfact-v0.6.patch)
- [2024-02-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dragmfact/dragmfact.patch)
+60
View File
@@ -0,0 +1,60 @@
From e0bec95eb6527dc5b87244ba025b28d2eaac94fe Mon Sep 17 00:00:00 2001
From: Palanix <palanixyt@gmail.com>
Date: Fri, 25 Mar 2022 23:45:10 +0100
Subject: [PATCH] Change mfact using Middle mouse
---
config.def.h | 2 +-
dwl.c | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
index 13c5322..ddce20b 100644
--- a/config.def.h
+++ b/config.def.h
@@ -167,7 +167,7 @@ static const Key keys[] = {
static const Button buttons[] = {
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
- { MODKEY, BTN_MIDDLE, togglefloating, {0} },
+ { MODKEY, BTN_MIDDLE, moveresize, {.ui = Curmfact} },
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
};
diff --git a/dwl.c b/dwl.c
index 4cfd0fd..1eb98c2 100644
--- a/dwl.c
+++ b/dwl.c
@@ -86,7 +86,7 @@
#define LISTEN_STATIC(E, H) do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0)
/* enums */
-enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
+enum { CurNormal, CurPressed, CurMove, CurResize, Curmfact }; /* cursor */
enum { XDGShell, LayerShell, X11 }; /* client types */
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
@@ -2077,6 +2077,9 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
.width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
return;
+ } else if (cursor_mode == Curmfact && time) {
+ selmon->mfact = (float) (cursor->x / selmon->m.width);
+ arrange(selmon);
}
/* If there's no client surface under the cursor, set the cursor image to a
@@ -2128,6 +2131,10 @@ moveresize(const Arg *arg)
grabc->geom.y + grabc->geom.height);
wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
break;
+ case Curmfact:
+ setfloating(grabc, 0);
+ selmon->mfact = (float) (cursor->x / selmon->m.width);
+ arrange(selmon);
}
}
--
2.55.0
+5
View File
@@ -12,6 +12,11 @@ then `status1` is set as the status of the primary bar,
`status2` is set as the left status of extrabar,
`status3` is set as the right status of extrabar.
### Download
- [2026-10-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/extrabar/extrabar-20261014.patch)
- [2026-03-13](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/extrabar/extrabar-20260313.patch)
### Author
[dhruva_sambrani](/dhruva_sambrani)
+227
View File
@@ -0,0 +1,227 @@
diff --git a/dwl.c b/dwl.c
index 7fe9468..1c4d5ba 100644
--- a/dwl.c
+++ b/dwl.c
@@ -205,6 +205,7 @@ struct Monitor {
struct wlr_output *wlr_output;
struct wlr_scene_output *scene_output;
struct wlr_scene_buffer *scene_buffer; /* bar buffer */
+ struct wlr_scene_buffer *extra_scene_buffer; /* bar buffer */
struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
struct wl_listener frame;
struct wl_listener destroy;
@@ -230,6 +231,7 @@ struct Monitor {
int asleep;
Drwl *drw;
Buffer *pool[2];
+ Buffer *extra_pool[2];
int lrpad;
};
@@ -278,7 +280,7 @@ static void bufdestroy(struct wlr_buffer *buffer);
static bool bufdatabegin(struct wlr_buffer *buffer, uint32_t flags,
void **data, uint32_t *format, size_t *stride);
static void bufdataend(struct wlr_buffer *buffer);
-static Buffer *bufmon(Monitor *m);
+static Buffer *bufmon(Monitor *m, Buffer **pool);
static void bufrelease(struct wl_listener *listener, void *data);
static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
@@ -444,6 +446,8 @@ static struct wl_list mons;
static Monitor *selmon;
static char stext[256];
+static char stext2[256];
+static char stext3[256];
static struct wl_event_source *status_event_source;
static const struct wlr_buffer_impl buffer_impl = {
@@ -627,6 +631,11 @@ arrangelayers(Monitor *m)
usable_area.y += topbar ? m->b.real_height : 0;
}
+ if (m->extra_scene_buffer->node.enabled) {
+ usable_area.height -= m->b.real_height;
+ usable_area.y += topbar ? 0 : m->b.real_height;
+ }
+
/* Arrange exclusive surfaces from top->bottom */
for (i = 3; i >= 0; i--)
arrangelayer(m, &m->layers[i], &usable_area, 1);
@@ -706,23 +715,23 @@ bufdataend(struct wlr_buffer *wlr_buffer)
}
Buffer *
-bufmon(Monitor *m)
+bufmon(Monitor *m, Buffer **pool)
{
size_t i;
Buffer *buf = NULL;
for (i = 0; i < LENGTH(m->pool); i++) {
- if (m->pool[i]) {
- if (m->pool[i]->busy)
+ if (pool[i]) {
+ if (pool[i]->busy)
continue;
- buf = m->pool[i];
+ buf = pool[i];
break;
}
buf = ecalloc(1, sizeof(Buffer) + (m->b.width * 4 * m->b.height));
buf->image = drwl_image_create(NULL, m->b.width, m->b.height, buf->data);
wlr_buffer_init(&buf->base, &buffer_impl, m->b.width, m->b.height);
- m->pool[i] = buf;
+ pool[i] = buf;
break;
}
if (!buf)
@@ -894,6 +903,9 @@ cleanupmon(struct wl_listener *listener, void *data)
for (i = 0; i < LENGTH(m->pool); i++)
wlr_buffer_drop(&m->pool[i]->base);
+ for (i = 0; i < LENGTH(m->extra_pool); i++)
+ wlr_buffer_drop(&m->extra_pool[i]->base);
+
drwl_setimage(m->drw, NULL);
drwl_destroy(m->drw);
@@ -910,6 +922,7 @@ cleanupmon(struct wl_listener *listener, void *data)
closemon(m);
wlr_scene_node_destroy(&m->fullscreen_bg->node);
wlr_scene_node_destroy(&m->scene_buffer->node);
+ wlr_scene_node_destroy(&m->extra_scene_buffer->node);
free(m);
}
@@ -1255,6 +1268,8 @@ createmon(struct wl_listener *listener, void *data)
m->scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL);
m->scene_buffer->point_accepts_input = baracceptsinput;
+ m->extra_scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL);
+ m->extra_scene_buffer->point_accepts_input = baracceptsinput;
updatebar(m);
wl_list_insert(&mons, &m->link);
@@ -1580,7 +1595,7 @@ drawbar(Monitor *m)
if (!m->scene_buffer->node.enabled)
return;
- if (!(buf = bufmon(m)))
+ if (!(buf = bufmon(m, m->pool)))
return;
/* draw status first so it can be overdrawn by tags later */
@@ -1633,13 +1648,47 @@ drawbar(Monitor *m)
wlr_buffer_unlock(&buf->base);
}
+void
+extrabar(Monitor *m)
+{
+ int tw = 0;
+ Buffer *buf = NULL;
+
+ /* Skip if the extra bar scene buffer is not initialized/enabled */
+ if (!m->extra_scene_buffer || !m->extra_scene_buffer->node.enabled)
+ return;
+
+ /* Inline bufmon logic for the extra pool to keep changes contained */
+ if (!(buf = bufmon(m, m->extra_pool)))
+ return;
+
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ drwl_rect(m->drw, 0, 0, m->b.width, m->b.height, 1, 1);
+
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
+ tw = TEXTW(m, stext2) - m->lrpad + 2; /* 2px right padding */
+ drwl_text(m->drw, 2, 0, tw, m->b.height, 0, stext2, 0);
+
+ tw = TEXTW(m, stext3) - m->lrpad + 2; /* 2px right padding */
+ drwl_text(m->drw, m->b.width - tw - 4, 0, tw, m->b.height, 0, stext3, 0);
+
+ wlr_scene_buffer_set_dest_size(m->extra_scene_buffer, m->b.real_width, m->b.real_height);
+ wlr_scene_node_set_position(&m->extra_scene_buffer->node, m->m.x,
+ m->m.y + (topbar ? m->m.height - m->b.real_height : 0));
+
+ wlr_scene_buffer_set_buffer(m->extra_scene_buffer, &buf->base);
+ wlr_buffer_unlock(&buf->base);
+}
+
void
drawbars(void)
{
Monitor *m = NULL;
- wl_list_for_each(m, &mons, link)
+ wl_list_for_each(m, &mons, link) {
drawbar(m);
+ extrabar(m);
+ }
}
void
@@ -2896,7 +2945,7 @@ startdrag(struct wl_listener *listener, void *data)
int
statusin(int fd, unsigned int mask, void *data)
{
- char status[256];
+ char status[3*256];
ssize_t n;
if (mask & WL_EVENT_ERROR)
@@ -2911,7 +2960,18 @@ statusin(int fd, unsigned int mask, void *data)
status[n] = '\0';
status[strcspn(status, "\n")] = '\0';
- strncpy(stext, status, sizeof(stext));
+ char *l1 = strchr(status, ';');
+ if (l1) {
+ *l1 = '\0';
+ char *l2 = strchr(++l1, ';');
+ if (l2) {
+ *l2 = '\0';
+ strncpy(stext3, ++l2, sizeof(stext3));
+ }
+ strncpy(stext2, l1, sizeof(stext2));
+ }
+ strncpy(stext, status, sizeof(stext));
+
drawbars();
return 0;
@@ -3172,10 +3232,9 @@ updatemons(struct wl_listener *listener, void *data)
if (stext[0] == '\0')
strncpy(stext, "dwl-"VERSION, sizeof(stext));
- wl_list_for_each(m, &mons, link) {
+ wl_list_for_each(m, &mons, link)
updatebar(m);
- drawbar(m);
- }
+ drawbars();
/* FIXME: figure out why the cursor image is at 0,0 after turning all
* the monitors on.
@@ -3199,6 +3258,7 @@ updatebar(Monitor *m)
m->b.real_width = (int)((float)m->b.width / m->wlr_output->scale);
wlr_scene_node_set_enabled(&m->scene_buffer->node, m->wlr_output->enabled ? showbar : 0);
+ wlr_scene_node_set_enabled(&m->extra_scene_buffer->node, m->wlr_output->enabled ? showbar : 0);
for (i = 0; i < LENGTH(m->pool); i++)
if (m->pool[i]) {
@@ -3206,6 +3266,12 @@ updatebar(Monitor *m)
m->pool[i] = NULL;
}
+ for (i = 0; i < LENGTH(m->extra_pool); i++)
+ if (m->extra_pool[i]) {
+ wlr_buffer_drop(&m->extra_pool[i]->base);
+ m->extra_pool[i] = NULL;
+ }
+
if (m->b.scale == m->wlr_output->scale && m->drw)
return;
+3 -2
View File
@@ -2,8 +2,9 @@
Focus the window to the left, right, above or below the current focused window
### Download
- [git branch](https://codeberg.org/ldev105/dwl/src/branch/focusdir)
- [2023-01-22](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusdir/focusdir.patch)
- [0.9](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusdir/focusdir-0.9.patch.patch)
- [main 2026-09-29](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusdir/focusdir-wlroots-next-4fd683c.patch)
### Authors
- [pi66](https://codeberg.org/pi66)
- [ldev105](https://codeberg.org/ldev105)
@@ -1,7 +1,7 @@
From a0e71a687b7fcaebdaf1da80c09bf5563bff46b1 Mon Sep 17 00:00:00 2001
From: ldev <ldev@ldev.eu.org>
Date: Mon, 12 Feb 2024 21:50:24 +0100
Subject: [PATCH] focusdir
From 2b10cf7ae87f119627260ec5a17147593697b734 Mon Sep 17 00:00:00 2001
From: pi66 <pixel2176@proton.me>
Date: Tue, 29 Sep 2026 12:15:43 +0100
Subject: [PATCH] focusdir: update for dwl v0.9 and wlroots-next-4fd683c
---
config.def.h | 4 ++++
@@ -9,22 +9,22 @@ Subject: [PATCH] focusdir
2 files changed, 49 insertions(+)
diff --git a/config.def.h b/config.def.h
index 9009517..2a1a82e 100644
index 13c5322..d81f9cd 100644
--- a/config.def.h
+++ b/config.def.h
@@ -124,6 +124,10 @@ static const Key keys[] = {
{ 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|WLR_MODIFIER_CTRL, XKB_KEY_h, focusdir, {.ui = 0} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_l, focusdir, {.ui = 1} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_k, focusdir, {.ui = 2} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_j, focusdir, {.ui = 3} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
@@ -125,6 +125,10 @@ static const Key keys[] = {
{ 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|WLR_MODIFIER_CTRL, XKB_KEY_h, focusdir, {.ui = 0} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_l, focusdir, {.ui = 1} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_k, focusdir, {.ui = 2} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_j, focusdir, {.ui = 3} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
diff --git a/dwl.c b/dwl.c
index bf02a6d..64d5de7 100644
index 4cfd0fd..acab367 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1,6 +1,7 @@
@@ -34,29 +34,30 @@ index bf02a6d..64d5de7 100644
+#include <limits.h>
#include <getopt.h>
#include <libinput.h>
#include <linux/input-event-codes.h>
@@ -268,6 +269,7 @@ static Monitor *dirtomon(enum wlr_direction dir);
#include <limits.h>
@@ -306,6 +307,7 @@ static Monitor *dirtomon(enum wlr_direction dir);
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
+static void focusdir(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void handlesig(int signo);
@@ -1271,6 +1273,49 @@ focusstack(const Arg *arg)
static void gpureset(struct wl_listener *listener, void *data);
@@ -1624,6 +1626,49 @@ focusstack(const Arg *arg)
focusclient(c, 1);
}
+void focusdir(const Arg *arg)
+{
+ /* Focus the left, right, up, down client relative to the current focused client on selmon */
+ Client *c, *sel = focustop(selmon);
+ if (!sel || sel->isfullscreen)
+ return;
+
+ int dist=INT_MAX;
+ Client *c, *sel = focustop(selmon);
+ Client *newsel = NULL;
+ int newdist=INT_MAX;
+
+ if (!sel || sel->isfullscreen)
+ return;
+
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, selmon))
+ continue; /* skip non visible windows */
@@ -89,10 +90,9 @@ index bf02a6d..64d5de7 100644
+ }
+}
+
+
/* We probably should change the name of this, it sounds like
/* We probably should change the name of this: it sounds like it
* will focus the topmost client of this mon, when actually will
* only return that client */
--
2.43.0
2.55.0
@@ -0,0 +1,98 @@
From 552608256fdd2fcc0a0654651b5ee345b6fb9718 Mon Sep 17 00:00:00 2001
From: pi66 <pixel2176@proton.me>
Date: Tue, 29 Sep 2026 12:09:59 +0100
Subject: [PATCH] focusdir: update for dwl v0.9 and wlroots-next-4fd683c
---
config.def.h | 4 ++++
dwl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/config.def.h b/config.def.h
index a4019d3..c36bd6e 100644
--- a/config.def.h
+++ b/config.def.h
@@ -125,6 +125,10 @@ static const Key keys[] = {
{ 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|WLR_MODIFIER_CTRL, XKB_KEY_h, focusdir, {.ui = 0} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_l, focusdir, {.ui = 1} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_k, focusdir, {.ui = 2} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_j, focusdir, {.ui = 3} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
diff --git a/dwl.c b/dwl.c
index 26fb3a0..4f66a63 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1,6 +1,7 @@
/*
* See LICENSE file for copyright and license details.
*/
+#include <limits.h>
#include <getopt.h>
#include <libinput.h>
#include <limits.h>
@@ -308,6 +309,7 @@ static Monitor *dirtomon(enum wlr_direction dir);
static void focusclient(Client *c, LayerSurface *l, int lift);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
+static void focusdir(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);
@@ -1632,6 +1634,49 @@ focusstack(const Arg *arg)
focusclient(c, NULL, 1);
}
+void focusdir(const Arg *arg)
+{
+ /* Focus the left, right, up, down client relative to the current focused client on selmon */
+ int dist=INT_MAX;
+ Client *c, *sel = focustop(selmon);
+ Client *newsel = NULL;
+ int newdist=INT_MAX;
+
+ if (!sel || sel->isfullscreen)
+ return;
+
+ wl_list_for_each(c, &clients, link) {
+ if (!VISIBLEON(c, selmon))
+ continue; /* skip non visible windows */
+
+ if (arg->ui == 0 && sel->geom.x <= c->geom.x) {
+ /* Client isn't on our left */
+ continue;
+ }
+ if (arg->ui == 1 && sel->geom.x >= c->geom.x) {
+ /* Client isn't on our right */
+ continue;
+ }
+ if (arg->ui == 2 && sel->geom.y <= c->geom.y) {
+ /* Client isn't above us */
+ continue;
+ }
+ if (arg->ui == 3 && sel->geom.y >= c->geom.y) {
+ /* Client isn't below us */
+ continue;
+ }
+
+ dist=abs(sel->geom.x-c->geom.x)+abs(sel->geom.y-c->geom.y);
+ if (dist < newdist){
+ newdist = dist;
+ newsel=c;
+ }
+ }
+ if (newsel != NULL){
+ focusclient(newsel, NULL, 1);
+ }
+}
+
/* We probably should change the name of this: it sounds like it
* will focus the topmost client of this mon, when actually will
* only return that client */
--
2.55.0
+2 -1
View File
@@ -7,7 +7,8 @@ This is the approximately the equivalent of the focusonactive patch of dwm.
If you want a more controlled behavior, for example setting which clients can focus, check [activation-rule patch](https://codeberg.org/sevz/dwl-patches/src/branch/activation-rules).
### Download
- [main dwl 0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusonurgent/focusonurgent.patch)
- [dwl 0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusonurgent/focusonurgent_08.patch)
- [dwl current 2026/09/28](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusonurgent/focusonurgent_current.patch)
### Authors
- [André Desgualdo Pereira](https://codeberg.org/Kana)
@@ -0,0 +1,19 @@
diff --git a/dwl.c b/dwl.c
index 3e94fa2..364debd 100644
--- a/dwl.c
+++ b/dwl.c
@@ -2286,9 +2286,11 @@ printstatus(void)
wl_list_for_each(c, &clients, link) {
if (c->mon != m)
continue;
- occ |= c->tags;
- if (c->isurgent)
- urg |= c->tags;
+ if (c->isurgent) {
+ view(&((Arg){ .ui = c->tags }));
+ focusclient(c, NULL, 1);
+ }
+
}
if ((c = focustop(m))) {
printf("%s title %s\n", m->wlr_output->name, client_get_title(c));
@@ -2,8 +2,10 @@
Implement `foreign-toplevel-management`, it add handlers for activate, close, fullscreen and destroy request events, it's missing minimize and maximize request handlers.
### Download
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.6-a/foreign-toplevel-management)
- [git branch](https://codeberg.org/guidocella/dwl/src/branch/foreign-toplevel-management)
- [2026-10-20](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/foreign-toplevel-management/foreign-toplevel-management.patch)
- [2024-05-02](https://codeberg.org/dwl/dwl-patches/raw/commit/e58c3ec41a39df934d2998161d7187ac965ea77a/foreign-toplevel-management/foreign-toplevel-management.patch)
### Authors
- [wochap](https://codeberg.org/wochap)
- [wochap](https://codeberg.org/wochap)
- [Guido Cella](https://codeberg.org/guidocella)
@@ -1,29 +1,29 @@
From dc63d64cd69f515013464b3feb8acb411f5a348f Mon Sep 17 00:00:00 2001
From 7820c6ca511de2fc41ab5bcf74dc0a5e0803d33f Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com>
Date: Thu, 2 May 2024 17:25:45 -0500
Date: Thu, 17 Sep 2026 08:22:59 +0200
Subject: [PATCH] implement foreign toplevel management
---
Makefile | 5 +-
dwl.c | 93 +++++-
dwl.c | 95 +++++-
...oreign-toplevel-management-unstable-v1.xml | 270 ++++++++++++++++++
3 files changed, 366 insertions(+), 2 deletions(-)
3 files changed, 367 insertions(+), 3 deletions(-)
create mode 100644 protocols/wlr-foreign-toplevel-management-unstable-v1.xml
diff --git a/Makefile b/Makefile
index a67fdd3..e0e1260 100644
index 8304245..cfbc0e0 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS)
all: dwl
dwl: dwl.o util.o
$(CC) dwl.o util.o $(LDLIBS) $(LDFLAGS) $(DWLCFLAGS) -o $@
-dwl.o: dwl.c config.mk config.h client.h cursor-shape-v1-protocol.h pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h xdg-shell-protocol.h
+dwl.o: dwl.c config.mk config.h client.h cursor-shape-v1-protocol.h pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h xdg-shell-protocol.h wlr-foreign-toplevel-management-unstable-v1-protocol.h
util.o: util.c util.h
@@ -20,7 +20,7 @@ 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 \
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
- wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
+ wlr-foreign-toplevel-management-unstable-v1-protocol.h wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
$(CC) dwl.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
# wayland-scanner is a tool which generates C headers and rigging for Wayland
@@ -37,6 +37,9 @@ wlr-layer-shell-unstable-v1-protocol.h:
@@ -47,6 +47,9 @@ wlr-output-power-management-unstable-v1-protocol.h:
xdg-shell-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
@@ -34,18 +34,18 @@ index a67fdd3..e0e1260 100644
config.h:
cp config.def.h $@
diff --git a/dwl.c b/dwl.c
index bf763df..648616d 100644
index 89e8caf..006c615 100644
--- a/dwl.c
+++ b/dwl.c
@@ -22,6 +22,7 @@
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_drm.h>
#include <wlr/types/wlr_export_dmabuf_v1.h>
@@ -30,6 +30,7 @@
#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_foreign_toplevel_management_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>
@@ -126,6 +127,11 @@ typedef struct {
@@ -151,6 +152,11 @@ typedef struct {
struct wl_listener fullscreen;
struct wl_listener set_decoration_mode;
struct wl_listener destroy_decoration;
@@ -54,10 +54,10 @@ index bf763df..648616d 100644
+ struct wl_listener fclose;
+ struct wl_listener ffullscreen;
+ struct wl_listener fdestroy;
struct wlr_box prev; /* layout-relative, includes border */
struct wlr_box bounds;
#ifdef XWAYLAND
@@ -347,6 +353,11 @@ static Monitor *xytomon(double x, double y);
struct wl_listener activate;
struct wl_listener associate;
@@ -387,8 +393,14 @@ static Monitor *xytomon(double x, double y);
static void xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, double *nx, double *ny);
static void zoom(const Arg *arg);
@@ -68,19 +68,22 @@ index bf763df..648616d 100644
+static void ffullscreennotify(struct wl_listener *listener, void *data);
/* variables */
static const char broken[] = "broken";
@@ -392,6 +403,8 @@ static struct wlr_scene_rect *locked_bg;
+static const char broken[] = "broken";
static pid_t child_pid = -1;
static int locked;
static Client *focused_client;
@@ -433,6 +445,8 @@ static struct wlr_session_lock_manager_v1 *session_lock_mgr;
static struct wlr_scene_rect *locked_bg;
static struct wlr_session_lock_v1 *cur_lock;
static struct wl_listener lock_listener = {.notify = locksession};
+static struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_mgr;
+
static struct wlr_seat *seat;
static KeyboardGroup kb_group = {0};
static KeyboardGroup vkb_group = {0};
@@ -458,6 +471,11 @@ applyrules(Client *c)
if (!(title = client_get_title(c)))
title = broken;
static KeyboardGroup *kb_group;
static unsigned int cursor_mode;
@@ -588,6 +602,11 @@ applyrules(Client *c)
appid = client_get_appid(c);
title = client_get_title(c);
+ if (c->foreign_toplevel) {
+ wlr_foreign_toplevel_handle_v1_set_app_id(c->foreign_toplevel, appid);
@@ -90,34 +93,35 @@ index bf763df..648616d 100644
for (r = rules; r < END(rules); r++) {
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
@@ -1288,6 +1306,8 @@ focusclient(Client *c, int lift)
client_set_border_color(old_c, bordercolor);
client_activate_surface(old, 0);
+ if (old_c->foreign_toplevel)
+ wlr_foreign_toplevel_handle_v1_set_activated(old_c->foreign_toplevel, 0);
}
@@ -1631,6 +1650,8 @@ focusclient(Client *c, LayerSurface *l, int lift)
if (s && s->mapped)
client_activate_surface(s, 0);
focused_client = NULL;
+ if (old_c && old_c->foreign_toplevel)
+ wlr_foreign_toplevel_handle_v1_set_activated(old_c->foreign_toplevel, 0);
}
printstatus();
@@ -1306,6 +1326,8 @@ focusclient(Client *c, int lift)
/* Activate the new client */
client_activate_surface(client_surface(c), 1);
@@ -1653,6 +1674,9 @@ focusclient(Client *c, LayerSurface *l, int lift)
if (!client_is_unmanaged(c))
focused_client = c;
+
+ if (c->foreign_toplevel)
+ wlr_foreign_toplevel_handle_v1_set_activated(c->foreign_toplevel, 1);
}
void
@@ -1599,6 +1621,8 @@ mapnotify(struct wl_listener *listener, void *data)
@@ -1975,6 +1999,8 @@ mapnotify(struct wl_listener *listener, void *data)
c->border[i]->node.data = c;
}
+ createforeigntoplevel(c);
+
/* 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;
@@ -2232,12 +2256,17 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
WLR_EDGE_RIGHT);
@@ -2661,12 +2687,17 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
c->prev = c->geom;
/* Scene graph sends surface leave/enter events on move and resize */
@@ -136,29 +140,28 @@ index bf763df..648616d 100644
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
setfloating(c, c->isfloating);
}
@@ -2351,6 +2380,9 @@ setup(void)
gamma_control_mgr = wlr_gamma_control_manager_v1_create(dpy);
LISTEN_STATIC(&gamma_control_mgr->events.set_gamma, setgamma);
@@ -2806,7 +2837,10 @@ setup(void)
power_mgr = wlr_output_power_manager_v1_create(dpy);
wl_signal_add(&power_mgr->events.set_mode, &output_power_mgr_set_mode);
- /* Creates an output layout, which is a wlroots utility for working with an
+ /* Initializes foreign toplevel management */
+ foreign_toplevel_mgr = wlr_foreign_toplevel_manager_v1_create(dpy);
+
/* Creates an output layout, which a wlroots utility for working with an
+ /* Creates an output layout, which a wlroots utility for working with an
* arrangement of screens in a physical layout. */
output_layout = wlr_output_layout_create();
@@ -2691,6 +2723,11 @@ unmapnotify(struct wl_listener *listener, void *data)
wl_list_remove(&c->flink);
output_layout = wlr_output_layout_create(dpy);
wl_signal_add(&output_layout->events.change, &layout_change);
@@ -3261,6 +3295,8 @@ unmapnotify(struct wl_listener *listener, void *data)
wlr_ext_foreign_toplevel_handle_v1_destroy(c->foreign_toplevel_handle);
c->foreign_toplevel_handle = NULL;
}
+ if (c->foreign_toplevel) {
+ if (c->foreign_toplevel)
+ wlr_foreign_toplevel_handle_v1_destroy(c->foreign_toplevel);
+ c->foreign_toplevel = NULL;
+ }
+
wlr_scene_node_destroy(&c->scene->node);
printstatus();
motionnotify(0, NULL, 0, 0, 0, 0);
@@ -2802,6 +2839,12 @@ void
#ifdef XWAYLAND
if (c->type != XDGShell && c->capture.image_capture_scene_surface) {
wlr_scene_node_destroy(&c->capture.image_capture_scene_surface->buffer->node);
@@ -3393,6 +3429,12 @@ void
updatetitle(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, set_title);
@@ -170,8 +173,8 @@ index bf763df..648616d 100644
+ }
if (c == focustop(c->mon))
printstatus();
}
@@ -2929,6 +2972,54 @@ zoom(const Arg *arg)
@@ -3531,6 +3573,55 @@ zoom(const Arg *arg)
arrange(selmon);
}
@@ -195,7 +198,7 @@ index bf763df..648616d 100644
+ } else {
+ setmon(c, selmon, 0);
+ }
+ focusclient(c, 1);
+ focusclient(c, NULL, 1);
+ arrange(c->mon);
+}
+
@@ -221,6 +224,7 @@ index bf763df..648616d 100644
+ wl_list_remove(&c->fclose.link);
+ wl_list_remove(&c->ffullscreen.link);
+ wl_list_remove(&c->fdestroy.link);
+ c->foreign_toplevel = NULL;
+}
+
#ifdef XWAYLAND
@@ -503,5 +507,5 @@ index 0000000..44505bb
+ </interface>
+</protocol>
--
2.43.2
2.56.0
+6 -6
View File
@@ -1,9 +1,9 @@
### Description
# fullscreenadaptivesync — Enables adaptive sync/VRR when a client is fullscreen.
# fullscreenadaptivesync - Enables adaptive sync/VRR when a client is fullscreen.
Adds a function that automatically enables adaptive sync/VRR when a fullscreen client is detected, and disables it once the client exits fullscreen.
---
1. **Why**
@@ -18,13 +18,13 @@ Adds a function that automatically enables adaptive sync/VRR when a fullscreen c
- When the client exits fullscreen, adaptive sync is disabled again.
4. **togglefullscreenadaptivesync**
- Adds a switch to enable or disable the fullscreenadaptivesync behavior.
- Adds a switch to enable or disable the fullscreenadaptivesync behavior.
- Enabled by default.
### Download
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/fullscreenadaptivesync-wlroots-next)
- [0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/fullscreenadaptivesync/fullscreenadaptivesync-v0.8.patch)
- [wlroots-next-d41ecb7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/fullscreenadaptivesync/fullscreenadaptivesync-wlroots-next-d41ecb7.patch)
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/fullscreenadaptivesync-0.9)
- [fullscreenadaptivesync-v0.9](/dwl/dwl-patches/raw/branch/main/patches/fullscreenadaptivesync/fullscreenadaptivesync-v0.9.patch)
- [fullscreenadaptivesync-v0.8](/dwl/dwl-patches/raw/branch/main/patches/fullscreenadaptivesync/fullscreenadaptivesync-v0.8.patch)
### Authors
- [julmajustus](https://codeberg.org/julmajustus)
@@ -1,18 +1,15 @@
From 5d475f7afe7ba7cee389a5c5ed4fa676b408fee5 Mon Sep 17 00:00:00 2001
From 860793b4ff7b03c0fe4be03f2086ae5f25876293 Mon Sep 17 00:00:00 2001
From: julmajustus <julmajustus@tutanota.com>
Date: Mon, 22 Jun 2026 23:02:25 +0300
Subject: [PATCH] fullscreen_adaptive_sync: Minor bug fixes
Date: Sun, 20 Sep 2026 02:32:01 +0300
Subject: [PATCH] fullscreenadaptivesync refactor for d16036e
- Fixed logic error inside unmapnotify
- Added no-op guards inside set_adaptive_sync
- Added extra check for the config commit success
---
config.def.h | 1 +
dwl.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..06b3153 100644
index 13c5322..262e3f3 100644
--- a/config.def.h
+++ b/config.def.h
@@ -138,6 +138,7 @@ static const Key keys[] = {
@@ -21,13 +18,13 @@ index 8a6eda0..06b3153 100644
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_F5, togglefullscreenadaptivesync, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_0, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
diff --git a/dwl.c b/dwl.c
index 8101ffa..aabd882 100644
index 4cfd0fd..c3ab2ba 100644
--- a/dwl.c
+++ b/dwl.c
@@ -323,6 +323,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
@@ -340,6 +340,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
static void requestmonstate(struct wl_listener *listener, void *data);
static void resize(Client *c, struct wlr_box geo, int interact);
static void run(char *startup_cmd);
@@ -35,7 +32,7 @@ index 8101ffa..aabd882 100644
static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating);
@@ -340,6 +341,7 @@ static void tagmon(const Arg *arg);
@@ -357,6 +358,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
@@ -43,16 +40,16 @@ index 8101ffa..aabd882 100644
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);
@@ -440,6 +442,8 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
static struct wl_listener start_drag = {.notify = startdrag};
@@ -462,6 +464,8 @@ static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener new_session_lock = {.notify = locksession};
static struct wl_listener new_foreign_toplevel_capture_request = {.notify = capturerequest};
+static int fullscreen_adaptive_sync_enabled = 1;
+
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -2300,6 +2304,43 @@ run(char *startup_cmd)
@@ -2453,6 +2457,43 @@ run(char *startup_cmd)
wl_display_run(dpy);
}
@@ -96,7 +93,7 @@ index 8101ffa..aabd882 100644
void
setcursor(struct wl_listener *listener, void *data)
{
@@ -2363,10 +2404,12 @@ setfullscreen(Client *c, int fullscreen)
@@ -2516,10 +2557,12 @@ setfullscreen(Client *c, int fullscreen)
if (fullscreen) {
c->prev = c->geom;
resize(c, c->mon->m, 0);
@@ -109,7 +106,7 @@ index 8101ffa..aabd882 100644
}
arrange(c->mon);
printstatus();
@@ -2546,7 +2589,7 @@ setup(void)
@@ -2699,7 +2742,7 @@ setup(void)
output_layout = wlr_output_layout_create(dpy);
wl_signal_add(&output_layout->events.change, &layout_change);
@@ -118,7 +115,7 @@ index 8101ffa..aabd882 100644
/* Configure a listener to be notified when new outputs are available on the
* backend. */
@@ -2636,8 +2679,8 @@ setup(void)
@@ -2795,8 +2838,8 @@ setup(void)
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
&new_virtual_keyboard);
virtual_pointer_mgr = wlr_virtual_pointer_manager_v1_create(dpy);
@@ -129,7 +126,7 @@ index 8101ffa..aabd882 100644
seat = wlr_seat_create(dpy, "seat0");
wl_signal_add(&seat->events.request_set_cursor, &request_cursor);
@@ -2767,6 +2810,12 @@ togglefullscreen(const Arg *arg)
@@ -2930,6 +2973,12 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen);
}
@@ -142,7 +139,7 @@ index 8101ffa..aabd882 100644
void
toggletag(const Arg *arg)
{
@@ -2822,6 +2871,7 @@ unmapnotify(struct wl_listener *listener, void *data)
@@ -2985,6 +3034,7 @@ unmapnotify(struct wl_listener *listener, void *data)
{
/* Called when the surface is unmapped, and should no longer be shown. */
Client *c = wl_container_of(listener, c, unmap);
@@ -150,7 +147,7 @@ index 8101ffa..aabd882 100644
if (c == grabc) {
cursor_mode = CurNormal;
grabc = NULL;
@@ -2837,6 +2887,9 @@ unmapnotify(struct wl_listener *listener, void *data)
@@ -3002,6 +3052,9 @@ unmapnotify(struct wl_listener *listener, void *data)
setmon(c, NULL, 0);
wl_list_remove(&c->flink);
}
@@ -158,8 +155,8 @@ index 8101ffa..aabd882 100644
+ if (c->isfullscreen)
+ set_adaptive_sync(lastmon, 0);
wlr_scene_node_destroy(&c->scene->node);
printstatus();
if (c->foreign_toplevel_handle) {
wlr_ext_foreign_toplevel_handle_v1_destroy(c->foreign_toplevel_handle);
--
2.53.0
2.55.0
+2 -1
View File
@@ -4,7 +4,8 @@ Arranges windows in a grid. Except it adjusts the number of windows in the first
On widescreens (w > 2*h), it splits to three columns before splitting rows.
### Download
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid.patch)
- [2026-09-27](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20260927.patch)
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20260228.patch)
- [2025-10-31](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20251031.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20240918.patch)
- [2024-07-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20240714.patch)
@@ -0,0 +1,89 @@
diff --git a/config.def.h b/config.def.h
index a4019d3..d596f0c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -34,6 +34,7 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "###", gaplessgrid },
};
/* monitors */
@@ -135,6 +136,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XKB_KEY_g, setlayout, {.v = &layouts[3]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index cca1ea4..43ab340 100644
--- a/dwl.c
+++ b/dwl.c
@@ -311,6 +311,7 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
+static void gaplessgrid(Monitor *m);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@@ -1696,6 +1697,56 @@ handlesig(int signo)
quit(NULL);
}
+void
+gaplessgrid(Monitor *m)
+{
+ int n = 0, i = 0, ch, cw, cn, rn, rows, cols;
+ Client *c;
+
+ wl_list_for_each(c, &clients, link)
+ if (VISIBLEON(c, m) && !c->isfloating)
+ n++;
+ if (n == 0)
+ return;
+
+ /* grid dimensions */
+ for (cols = 0; cols <= (n / 2); cols++)
+ if ((cols * cols) >= n)
+ break;
+
+ if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
+ cols = 2;
+
+ /* widescreen is better if 3 columns */
+ if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1)
+ cols = 3;
+
+ rows = n / cols;
+
+ /* window geometries */
+ cw = cols ? m->w.width / cols : m->w.width;
+ cn = 0; /* current column number */
+ rn = 0; /* current row number */
+ wl_list_for_each(c, &clients, link) {
+ unsigned int cx, cy;
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+
+ if ((i / rows + 1) > (cols - n % cols))
+ rows = n / cols + 1;
+ ch = rows ? m->w.height / rows : m->w.height;
+ cx = m->w.x + cn * cw;
+ cy = m->w.y + rn * ch;
+ resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0);
+ rn++;
+ if (rn >= rows) {
+ rn = 0;
+ cn++;
+ }
+ i++;
+ }
+}
+
void
incnmaster(const Arg *arg)
{
+17
View File
@@ -0,0 +1,17 @@
### Description
Largely based on [raphi](https://sr.ht/~raphi/)'s [somebar](https://sr.ht/~raphi/somebar/), this patch provides an ipc for wayland clients to get and set dwl state. The ipc is intended for status bars, but can also be scripted with tools like [dwlmsg](https://codeberg.org/julmajustus/dwlmsg).
Status information to stdout is currently disabled as dwl tends to freeze. For now, `dwlmsg -w` should act as a drop-in replacement.
Note to [pertag](../pertag/) users: apply [this](./ipcpertag.patch) for ipc tagsetting to work as expected
### Download
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/ipc-0.9)
- [v0.9](/dwl/dwl-patches/raw/branch/main/patches/ipc/ipc.patch)
### Authors
- [MadcowOG](https://github.com/MadcowOG)
- [fbushstone](https://github.com/fbushstone)
- [notchoc](https://codeberg.org/notchoc)
- [snuk](https://codeberg.org/snuk)
- [julmajustus](https://codeberg.org/julmajustus)
+24
View File
@@ -0,0 +1,24 @@
From e3b5143bbc21a13cf55b843d8a0f7f042f299595 Mon Sep 17 00:00:00 2001
From: julmajustus <julmajustus@tutanota.com>
Date: Mon, 21 Sep 2026 21:43:44 +0300
Subject: [PATCH] ipc: update focus-tagset-output patch for v0.9
---
dwl.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/dwl.c b/dwl.c
index d24fcb3..6c52e78 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1707,6 +1707,7 @@ dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource,
if (!ipc_output)
return;
monitor = ipc_output->mon;
+ selmon = monitor;
if (!newtags || newtags == monitor->tagset[monitor->seltags])
return;
--
2.55.0
@@ -1,40 +1,33 @@
From 6c6d655b68770ce82a24fde9b58c4d97b672553a Mon Sep 17 00:00:00 2001
From: choc <notchoc@proton.me>
Date: Mon, 23 Oct 2023 10:35:17 +0800
Subject: [PATCH] implement dwl-ipc-unstable-v2
https://codeberg.org/dwl/dwl-patches/wiki/ipc
From 14ba1bbe5c64e58e6dc1194a8269c7e83c072195 Mon Sep 17 00:00:00 2001
From: julmajustus <julmajustus@tutanota.com>
Date: Mon, 21 Sep 2026 21:39:40 +0300
Subject: [PATCH] ipc: update for v0.9
---
Makefile | 14 +-
Makefile | 13 +-
config.def.h | 1 +
dwl.c | 257 ++++++++++++++++++++++++++----
protocols/dwl-ipc-unstable-v2.xml | 181 +++++++++++++++++++++
4 files changed, 419 insertions(+), 34 deletions(-)
dwl.c | 266 ++++++++++++++++++++++++++----
protocols/dwl-ipc-unstable-v2.xml | 191 +++++++++++++++++++++
4 files changed, 437 insertions(+), 34 deletions(-)
create mode 100644 protocols/dwl-ipc-unstable-v2.xml
diff --git a/Makefile b/Makefile
index 8db7409..a79a080 100644
index 8304245..b71571f 100644
--- a/Makefile
+++ b/Makefile
@@ -17,12 +17,14 @@ 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: dwl.o util.o dwl-ipc-unstable-v2-protocol.o
+ $(CC) dwl.o util.o dwl-ipc-unstable-v2-protocol.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \
@@ -20,8 +20,9 @@ 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 \
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 $@
+ wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h \
+ dwl-ipc-unstable-v2-protocol.h
util.o: util.c util.h
+dwl-ipc-unstable-v2-protocol.o: dwl-ipc-unstable-v2-protocol.c dwl-ipc-unstable-v2-protocol.h
+ dwl-ipc-unstable-v2-protocol.h dwl-ipc-unstable-v2-protocol.c
+ $(CC) dwl.c dwl-ipc-unstable-v2-protocol.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
@@ -45,6 +47,12 @@ wlr-output-power-management-unstable-v1-protocol.h:
@@ -47,11 +48,17 @@ wlr-output-power-management-unstable-v1-protocol.h:
xdg-shell-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
@@ -43,36 +36,42 @@ index 8db7409..a79a080 100644
+ protocols/dwl-ipc-unstable-v2.xml $@
+dwl-ipc-unstable-v2-protocol.c:
+ $(WAYLAND_SCANNER) private-code \
+ protocols/dwl-ipc-unstable-v2.xml $@
+ protocols/dwl-ipc-unstable-v2.xml $@
config.h:
cp config.def.h $@
clean:
- rm -f dwl *.o *-protocol.h
+ rm -f dwl *.o *-protocol.h *-protocol.c
dist: clean
mkdir -p dwl-$(VERSION)
diff --git a/config.def.h b/config.def.h
index 22d2171..1593033 100644
index 13c5322..998c715 100644
--- a/config.def.h
+++ b/config.def.h
@@ -127,6 +127,7 @@ static const Key keys[] = {
/* modifier key function argument */
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
+ { MODKEY, XKB_KEY_b, togglebar, {0} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
@@ -123,6 +123,7 @@ static const Key keys[] = {
/* modifier key function argument */
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
+ { MODKEY, XKB_KEY_b, togglebar, {0} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
diff --git a/dwl.c b/dwl.c
index 8a587d1..7a4949b 100644
index 4cfd0fd..d24fcb3 100644
--- a/dwl.c
+++ b/dwl.c
@@ -68,6 +68,7 @@
#include <xcb/xcb_icccm.h>
@@ -76,6 +76,7 @@
#endif
#include "xdg-shell-protocol.h"
+#include "dwl-ipc-unstable-v2-protocol.h"
#include "util.h"
/* macros */
@@ -144,6 +145,12 @@ typedef struct {
uint32_t resize; /* configure serial of a pending resize */
@@ -161,6 +162,12 @@ typedef struct {
int isfloating, isurgent, isfullscreen;
} Client;
+typedef struct {
@@ -84,7 +83,7 @@ index 8a587d1..7a4949b 100644
typedef struct {
uint32_t mod;
xkb_keysym_t keysym;
@@ -189,6 +196,7 @@ typedef struct {
@@ -205,6 +212,7 @@ typedef struct {
struct Monitor {
struct wl_list link;
@@ -92,8 +91,8 @@ index 8a587d1..7a4949b 100644
struct wlr_output *wlr_output;
struct wlr_scene_output *scene_output;
struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
@@ -286,6 +294,17 @@ static void destroysessionlock(struct wl_listener *listener, void *data);
static void destroysessionmgr(struct wl_listener *listener, void *data);
@@ -303,6 +311,17 @@ 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 dwl_ipc_manager_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id);
@@ -110,7 +109,7 @@ index 8a587d1..7a4949b 100644
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
@@ -338,6 +357,7 @@ static void startdrag(struct wl_listener *listener, void *data);
@@ -355,6 +374,7 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
@@ -118,9 +117,9 @@ index 8a587d1..7a4949b 100644
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -411,6 +431,9 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
@@ -462,6 +482,9 @@ static struct wl_listener start_drag = {.notify = startdrag};
static struct wl_listener new_session_lock = {.notify = locksession};
static struct wl_listener new_foreign_toplevel_capture_request = {.notify = capturerequest};
+static struct zdwl_ipc_manager_v2_interface dwl_manager_implementation = {.release = dwl_ipc_manager_release, .get_output = dwl_ipc_manager_get_output};
+static struct zdwl_ipc_output_v2_interface dwl_output_implementation = {.release = dwl_ipc_output_release, .set_tags = dwl_ipc_output_set_tags, .set_layout = dwl_ipc_output_set_layout, .set_client_tags = dwl_ipc_output_set_client_tags};
@@ -128,7 +127,7 @@ index 8a587d1..7a4949b 100644
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -703,6 +726,10 @@ cleanupmon(struct wl_listener *listener, void *data)
@@ -823,6 +846,10 @@ cleanupmon(struct wl_listener *listener, void *data)
LayerSurface *l, *tmp;
size_t i;
@@ -139,7 +138,7 @@ index 8a587d1..7a4949b 100644
/* m->layers[i] are intentionally not unlinked */
for (i = 0; i < LENGTH(m->layers); i++) {
wl_list_for_each_safe(l, tmp, &m->layers[i], link)
@@ -983,6 +1010,8 @@ createmon(struct wl_listener *listener, void *data)
@@ -1150,6 +1177,8 @@ createmon(struct wl_listener *listener, void *data)
m = wlr_output->data = ecalloc(1, sizeof(*m));
m->wlr_output = wlr_output;
@@ -148,7 +147,7 @@ index 8a587d1..7a4949b 100644
for (i = 0; i < LENGTH(m->layers); i++)
wl_list_init(&m->layers[i]);
@@ -1334,6 +1363,192 @@ dirtomon(enum wlr_direction dir)
@@ -1504,6 +1533,199 @@ dirtomon(enum wlr_direction dir)
return selmon;
}
@@ -218,13 +217,13 @@ index 8a587d1..7a4949b 100644
+{
+ Monitor *monitor = ipc_output->mon;
+ Client *c, *focused;
+ int tagmask, state, numclients, focused_client, tag;
+ int tagmask, state, numclients, is_focused_client, tag;
+ const char *title, *appid;
+ focused = focustop(monitor);
+ zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon);
+
+ for (tag = 0 ; tag < TAGCOUNT; tag++) {
+ numclients = state = focused_client = 0;
+ numclients = state = is_focused_client = 0;
+ tagmask = 1 << tag;
+ if ((tagmask & monitor->tagset[monitor->seltags]) != 0)
+ state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE;
@@ -235,13 +234,13 @@ index 8a587d1..7a4949b 100644
+ if (!(c->tags & tagmask))
+ continue;
+ if (c == focused)
+ focused_client = 1;
+ is_focused_client = 1;
+ if (c->isurgent)
+ state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_URGENT;
+
+ numclients++;
+ }
+ zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state, numclients, focused_client);
+ zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state, numclients, is_focused_client);
+ }
+ title = focused ? client_get_title(focused) : "";
+ appid = focused ? client_get_appid(focused) : "";
@@ -256,6 +255,13 @@ index 8a587d1..7a4949b 100644
+ if (wl_resource_get_version(ipc_output->resource) >= ZDWL_IPC_OUTPUT_V2_FLOATING_SINCE_VERSION) {
+ zdwl_ipc_output_v2_send_floating(ipc_output->resource, focused ? focused->isfloating : 0);
+ }
+ if (wl_resource_get_version(ipc_output->resource) >= ZDWL_IPC_OUTPUT_V2_FULLSCREEN_SINCE_VERSION) {
+ zdwl_ipc_output_v2_send_focused_geometry(ipc_output->resource,
+ focused ? focused->geom.x : 0,
+ focused ? focused->geom.y : 0,
+ focused ? focused->geom.width : 0,
+ focused ? focused->geom.height : 0);
+ }
+ zdwl_ipc_output_v2_send_frame(ipc_output->resource);
+}
+
@@ -341,13 +347,13 @@ index 8a587d1..7a4949b 100644
void
focusclient(Client *c, int lift)
{
@@ -2033,38 +2248,9 @@ void
@@ -2257,38 +2479,9 @@ void
printstatus(void)
{
Monitor *m = NULL;
- Client *c;
- uint32_t occ, urg, sel;
-
- wl_list_for_each(m, &mons, link) {
- occ = urg = 0;
- wl_list_for_each(c, &clients, link) {
@@ -370,7 +376,7 @@ index 8a587d1..7a4949b 100644
- printf("%s floating \n", m->wlr_output->name);
- sel = 0;
- }
-
- printf("%s selmon %u\n", m->wlr_output->name, m == selmon);
- printf("%s tags %"PRIu32" %"PRIu32" %"PRIu32" %"PRIu32"\n",
- m->wlr_output->name, occ, m->tagset[m->seltags], sel, urg);
@@ -382,16 +388,18 @@ index 8a587d1..7a4949b 100644
}
void
@@ -2584,6 +2770,8 @@ setup(void)
LISTEN_STATIC(&output_mgr->events.apply, outputmgrapply);
LISTEN_STATIC(&output_mgr->events.test, outputmgrtest);
@@ -2816,6 +3009,10 @@ setup(void)
text_input_manager = wlr_text_input_manager_v3_create(dpy);
input_method_relay = input_method_relay_create();
+ wl_global_create(dpy, &zdwl_ipc_manager_v2_interface, 2, NULL, dwl_ipc_manager_bind);
+
+ wl_global_create(dpy, &zdwl_ipc_manager_v2_interface, 2, NULL, dwl_ipc_manager_bind);
+
/* 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 */
@@ -2681,6 +2869,13 @@ tile(Monitor *m)
@@ -2913,6 +3110,13 @@ tile(Monitor *m)
}
}
@@ -407,10 +415,10 @@ index 8a587d1..7a4949b 100644
{
diff --git a/protocols/dwl-ipc-unstable-v2.xml b/protocols/dwl-ipc-unstable-v2.xml
new file mode 100644
index 0000000..0a6e7e5
index 0000000..07cc1c2
--- /dev/null
+++ b/protocols/dwl-ipc-unstable-v2.xml
@@ -0,0 +1,181 @@
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+This is largely ripped from somebar's ipc patchset; just with some personal modifications.
@@ -437,7 +445,7 @@ index 0000000..0a6e7e5
+ This interface is exposed as a global in wl_registry.
+
+ Clients can use this interface to get a dwl_ipc_output.
+ After binding the client will receive the dwl_ipc_manager.tags and dwl_ipc_manager.layout events.
+ After binding the client will recieve the dwl_ipc_manager.tags and dwl_ipc_manager.layout events.
+ The dwl_ipc_manager.tags and dwl_ipc_manager.layout events expose tags and layouts to the client.
+ </description>
+
@@ -459,7 +467,7 @@ index 0000000..0a6e7e5
+ <event name="tags">
+ <description summary="Announces tag amount">
+ This event is sent after binding.
+ A roundtrip after binding guarantees the client received all tags.
+ A roundtrip after binding guarantees the client recieved all tags.
+ </description>
+ <arg name="amount" type="uint"/>
+ </event>
@@ -467,7 +475,7 @@ index 0000000..0a6e7e5
+ <event name="layout">
+ <description summary="Announces a layout">
+ This event is sent after binding.
+ A roundtrip after binding guarantees the client received all layouts.
+ A roundtrip after binding guarantees the client recieved all layouts.
+ </description>
+ <arg name="name" type="string"/>
+ </event>
@@ -573,7 +581,7 @@ index 0000000..0a6e7e5
+
+ <request name="set_layout">
+ <description summary="Set the layout of this output"/>
+ <arg name="index" type="uint" summary="index of a layout received by dwl_ipc_manager.layout"/>
+ <arg name="index" type="uint" summary="index of a layout recieved by dwl_ipc_manager.layout"/>
+ </request>
+
+ <!-- Version 2 -->
@@ -590,8 +598,18 @@ index 0000000..0a6e7e5
+ </description>
+ <arg name="is_floating" type="uint" summary="If the selected client is floating. Nonzero is valid, zero invalid"/>
+ </event>
+
+ <event name="focused_geometry" since="2">
+ <description summary="Send focused client geometry">
+ Sends the focused client's geometry (x, y, width, and height) to the client.
+ </description>
+ <arg name="x" type="int" summary="X coordinate of the focused client"/>
+ <arg name="y" type="int" summary="Y coordinate of the focused client"/>
+ <arg name="width" type="int" summary="Width of the focused client"/>
+ <arg name="height" type="int" summary="Height of the focused client"/>
+ </event>
+ </interface>
+</protocol>
--
2.43.0
2.55.0
@@ -1,17 +1,17 @@
From c7d77ff4dec1da5a68b4da8aa42d4ed78dc41a00 Mon Sep 17 00:00:00 2001
From: choc <notchoc@proton.me>
Date: Thu, 14 Mar 2024 11:18:37 +0800
Subject: [PATCH] fix ipc to work with pertag
From cfcff31000041511b97c928645f2daef3127ba09 Mon Sep 17 00:00:00 2001
From: julmajustus <julmajustus@tutanota.com>
Date: Mon, 21 Sep 2026 21:41:48 +0300
Subject: [PATCH] ipc: update ipcpertag for v0.9
---
dwl.c | 50 +++++++++++++++++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 15 deletions(-)
diff --git a/dwl.c b/dwl.c
index a1a7809..d86e6e2 100644
index d24fcb3..b43843e 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1526,28 +1526,37 @@ void
@@ -1679,28 +1679,37 @@ void
dwl_ipc_output_set_layout(struct wl_client *client, struct wl_resource *resource, uint32_t index)
{
DwlIpcOutput *ipc_output;
@@ -57,7 +57,7 @@ index a1a7809..d86e6e2 100644
unsigned int newtags = tagmask & TAGMASK;
ipc_output = wl_resource_get_user_data(resource);
@@ -1555,16 +1564,27 @@ dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource,
@@ -1708,16 +1717,27 @@ dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource,
return;
monitor = ipc_output->mon;
@@ -93,5 +93,5 @@ index a1a7809..d86e6e2 100644
void
--
2.43.0
2.55.0
+1
View File
@@ -4,6 +4,7 @@ Allows more monitor configuration in config.h
### Download
- [git branch](https://codeberg.org/Palanix/dwl/src/branch/monitorconfig)
- [wlroots-next-f4249db](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/monitorconfig/monitorconfig-wlroots-next-f4249db.patch)
- [0.9](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/monitorconfig/monitorconfig-0.9.patch)
- [0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/monitorconfig/monitorconfig-0.8.patch)
### Authors
@@ -0,0 +1,94 @@
From 55494409072aad907aea0c02c796d56a9e925459 Mon Sep 17 00:00:00 2001
From: Palanix <palanixyt@gmail.com>
Date: Mon, 4 Apr 2022 16:08:29 +0200
Subject: [PATCH] Updated patch now allowing setting x and y
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Leonardo Hernández Hernández <leohdz172@proton.me>
---
config.def.h | 12 ++++++++----
dwl.c | 25 +++++++++++++++++++------
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/config.def.h b/config.def.h
index 13c5322..2d1fcb5 100644
--- a/config.def.h
+++ b/config.def.h
@@ -41,10 +41,14 @@ static const Layout layouts[] = {
* 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 }, */
- { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
+ /* name mfact nmaster scale layout rotate/reflect x y resx resy rate mode adaptive*/
+ /* example of a HiDPI laptop monitor at 120Hz: { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0, 0, 0, 120.000f, 1, 1}, */
+ /*
+ * mode let's the user decide on how dwl should implement the modes:
+ * -1 Sets a custom mode following the users choice
+ * All other number's set the mode at the index n, 0 is the standard mode; see wlr-randr
+ */
+ { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, 0, 0, 0.0f, 0 ,1},
/* default monitor rule: can be changed but cannot be eliminated; at least one monitor rule must exist */
};
diff --git a/dwl.c b/dwl.c
index 4cfd0fd..755a826 100644
--- a/dwl.c
+++ b/dwl.c
@@ -235,6 +235,11 @@ typedef struct {
const Layout *lt;
enum wl_output_transform rr;
int x, y;
+ int resx;
+ int resy;
+ float rate;
+ int mode;
+ int adaptive;
} MonitorRule;
typedef struct {
@@ -1139,6 +1144,7 @@ createmon(struct wl_listener *listener, void *data)
/* This event is raised by the backend when a new output (aka a display or
* monitor) becomes available. */
struct wlr_output *wlr_output = data;
+ struct wlr_output_mode *mode = wl_container_of(wlr_output->modes.next, mode, link);
const MonitorRule *r;
size_t i;
struct wlr_output_state state;
@@ -1167,16 +1173,23 @@ createmon(struct wl_listener *listener, void *data)
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
wlr_output_state_set_scale(&state, r->scale);
wlr_output_state_set_transform(&state, r->rr);
+
+ wlr_output_state_set_adaptive_sync_enabled(&state, r->adaptive);
+
+ if(r->mode == -1)
+ wlr_output_state_set_custom_mode(&state, r->resx, r->resy,
+ (int) (r->rate > 0 ? r->rate * 1000 : 0));
+ else if (!wl_list_empty(&wlr_output->modes)) {
+ for (int j = 0; j < r->mode; j++) {
+ mode = wl_container_of(mode->link.next, mode, link);
+ }
+ wlr_output_state_set_mode(&state, mode);
+ }
+
break;
}
}
- /* 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));
-
/* Set up event listeners */
LISTEN(&wlr_output->events.frame, &m->frame, rendermon);
LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon);
--
2.55.0
+12
View File
@@ -0,0 +1,12 @@
### Description
Implement rounded corners, shadows and blur with [scenefx](https://github.com/wlrfx/scenefx) 0.5.
- [git branch](https://codeberg.org/guidocella/dwl/src/branch/scenefx)
- [2026-10-29](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/scenefx/scenefx.patch)
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/7a5c3420822074c544fa102e030b7c30aa6b6be8/scenefx/scenefx.patch)
### Authors
- [wochap](https://codeberg.org/wochap)
- [Guido Cella](https://codeberg.org/guidocella)
+425
View File
@@ -0,0 +1,425 @@
From 10d093f65881d49ff5e919168451ab75f16adce0 Mon Sep 17 00:00:00 2001
From: Guido Cella <guido@guidocella.xyz>
Date: Thu, 29 Oct 2026 18:06:25 +0100
Subject: [PATCH] integrate scenefx
Add rounded corners, shadows and blur with scenefx.
The border is now a single rectangle with a hole for the window contents,
so its corners can be rounded concentrically with them. Buffers are rounded
when their corners coincide with the window's, which includes subsurfaces
covering it.
Tiled windows show the cached blur of the background layer, which is
redrawn only when it changes, while floating windows blur what's behind
them. Fullscreen windows have no effects so that fullscreen_bg keeps
hiding what's behind them.
scenefx has to be linked before wlroots so that its wlr_scene functions
override wlroots' ones, including those called by wlroots' scene surface
helpers, which scenefx doesn't reimplement.
---
Makefile | 4 +-
client.h | 4 +-
config.def.h | 8 +++
config.mk | 5 ++
dwl.c | 144 +++++++++++++++++++++++++++++++++++++++++++--------
5 files changed, 137 insertions(+), 28 deletions(-)
diff --git a/Makefile b/Makefile
index 8304245..aad87ba 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)` $(WLR_INCS) $(FX_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
+LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(FX_LIBS) $(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/client.h b/client.h
index ebe665b..d3f8091 100644
--- a/client.h
+++ b/client.h
@@ -300,9 +300,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 4901e7a..71ffa98 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,6 +13,14 @@ static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
+/* rounded corners, shadows and blur, see scenefx */
+static const int corner_radius = 8; /* radius of the corners of window contents, 0 disables them */
+static const int corner_radius_only_floating = 0; /* 1 means only floating windows have rounded corners */
+static const int shadow_sigma = 20; /* blur sigma and size of window shadows, 0 disables them */
+static const float shadow_color[] = COLOR(0x00000080);
+/* blur behind translucent windows. Set num_passes to 0 to disable it */
+static const struct blur_data blur_data = { .num_passes = 3, .radius = 5, .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..9293d5e 100644
--- a/config.mk
+++ b/config.mk
@@ -24,6 +24,11 @@ WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.20`
# -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
+# scenefx's headers are included with -isystem to hide their -Wpedantic warnings,
+# and after WLR_INCS so they don't override an alternative wlroots installation.
+FX_INCS = -isystem `$(PKG_CONFIG) --variable=includedir scenefx-0.5`/scenefx-0.5
+FX_LIBS = `$(PKG_CONFIG) --libs scenefx-0.5`
+
XWAYLAND =
XLIBS =
# Uncomment to build XWayland support
diff --git a/dwl.c b/dwl.c
index 89e8caf..1a702c9 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/clipped_region.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>
@@ -120,7 +122,9 @@ typedef struct {
Monitor *mon;
struct wlr_scene_tree *scene;
- struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
+ struct wlr_scene_rect *border;
+ struct wlr_scene_shadow *shadow;
+ struct wlr_scene_blur *blur;
struct wlr_scene_tree *scene_surface;
struct wl_list link;
struct wl_list flink;
@@ -211,6 +215,7 @@ 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_optimized_blur *blur;
struct wl_listener frame;
struct wl_listener destroy;
struct wl_listener request_state;
@@ -284,6 +289,7 @@ 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 int cornerradius(Client *c);
static void createdecoration(struct wl_listener *listener, void *data);
static void createidleinhibitor(struct wl_listener *listener, void *data);
static void createkeyboard(struct wlr_keyboard *keyboard);
@@ -346,6 +352,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);
@@ -545,6 +552,9 @@ applygeom(Client *c)
{
struct wlr_box clip;
Client *p = client_get_parent(c);
+ int radius = cornerradius(c);
+ int outer = radius ? radius + (int)c->bw : 0;
+ int floating = c->isfloating || !c->mon->lt[c->mon->sellt]->arrange;
/* We move all floating clients to LyrTile while in floating layout
* to avoid "real" floating clients be always on top */
@@ -560,19 +570,37 @@ applygeom(Client *c)
wlr_scene_node_set_enabled(&c->scene_surface->node, 1);
}
- /* Update scene-graph, including borders */
+ /* Update scene-graph, including borders. The border is a rectangle with
+ * a hole for the content, so their rounded corners stay concentric. */
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);
- 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_rect_set_size(c->border, c->geom.width, c->geom.height);
+ wlr_scene_rect_set_corner_radius(c->border, outer);
+ 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(radius) });
+
+ wlr_scene_node_set_enabled(&c->shadow->node, shadow_sigma && !c->isfullscreen);
+ wlr_scene_shadow_set_size(c->shadow, c->geom.width + 2 * shadow_sigma,
+ c->geom.height + 2 * shadow_sigma);
+ wlr_scene_shadow_set_corner_radius(c->shadow, outer);
+ /* Don't draw the shadow behind translucent windows */
+ wlr_scene_shadow_set_clipped_region(c->shadow, (struct clipped_region){
+ .area = { shadow_sigma, shadow_sigma, c->geom.width, c->geom.height },
+ .corners = corner_radii_all(outer) });
+
+ /* The fullscreen background hides what's behind fullscreen windows */
+ wlr_scene_node_set_enabled(&c->blur->node, blur_data.num_passes && !c->isfullscreen);
+ wlr_scene_node_set_position(&c->blur->node, c->bw, c->bw);
+ wlr_scene_blur_set_size(c->blur, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw);
+ wlr_scene_blur_set_corner_radius(c->blur, radius);
+ /* Only floating windows can be above other windows, tiled ones can use
+ * the cached blur of the background layer */
+ wlr_scene_blur_set_should_only_blur_bottom_layer(c->blur, !floating);
client_get_clip(c, &clip);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, roundbuffer, c);
}
void
@@ -890,6 +918,7 @@ cleanupmon(struct wl_listener *listener, void *data)
closemon(m);
wlr_scene_node_destroy(&m->fullscreen_bg->node);
+ wlr_scene_node_destroy(&m->blur->node);
free(m);
}
@@ -982,6 +1011,10 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
return;
}
+ /* The cached blur of the background layer must be redrawn when it changes */
+ if (scene_layer == layers[LyrBg] || l->scene->node.parent == layers[LyrBg])
+ wlr_scene_optimized_blur_mark_dirty(l->mon->blur);
+
if (layer_surface->current.committed == 0 && l->mapped == layer_surface->surface->mapped)
return;
l->mapped = layer_surface->surface->mapped;
@@ -1043,6 +1076,9 @@ commitnotify(struct wl_listener *listener, void *data)
transactioncommit(c, c->resize_serial && c->surface.xdg->current.configure_serial
>= c->resize_serial);
resize(c, c->geom, (c->isfloating && !c->isfullscreen));
+ /* Subsurfaces may have been added or resized */
+ if (client_surface(c)->mapped)
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, roundbuffer, c);
}
void
@@ -1075,6 +1111,15 @@ commitpopup(struct wl_listener *listener, void *data)
free(listener);
}
+int
+cornerradius(Client *c)
+{
+ if (c->isfullscreen || (corner_radius_only_floating && !c->isfloating
+ && c->mon && c->mon->lt[c->mon->sellt]->arrange))
+ return 0;
+ return corner_radius;
+}
+
void
createdecoration(struct wl_listener *listener, void *data)
{
@@ -1267,6 +1312,10 @@ 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);
+ /* Caches the blur of everything below it, which tiled windows show */
+ m->blur = wlr_scene_optimized_blur_create(&scene->tree, 0, 0);
+ wlr_scene_node_place_above(&m->blur->node, &layers[LyrBg]->node);
+
/* 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,7 +1769,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)))
@@ -1733,6 +1782,7 @@ gpureset(struct wl_listener *listener, void *data)
wl_list_for_each(m, &mons, link) {
wlr_output_init_render(m->wlr_output, alloc, drw);
+ wlr_scene_optimized_blur_mark_dirty(m->blur);
}
wlr_allocator_destroy(old_alloc);
@@ -1941,7 +1991,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),
@@ -1969,11 +2018,14 @@ mapnotify(struct wl_listener *listener, void *data)
goto unset_fullscreen;
}
- 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;
+ c->shadow = wlr_scene_shadow_create(c->scene, 0, 0, 0, shadow_sigma, shadow_color);
+ wlr_scene_node_set_position(&c->shadow->node, -shadow_sigma, -shadow_sigma);
+ wlr_scene_node_lower_to_bottom(&c->shadow->node);
+ c->blur = wlr_scene_blur_create(c->scene, 0, 0);
+ wlr_scene_node_lower_to_bottom(&c->blur->node);
/* Initialize client geometry with room for border */
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
@@ -2494,6 +2546,22 @@ resize(Client *c, struct wlr_box geo, int interact)
transactionschedule();
}
+void
+roundbuffer(struct wlr_scene_buffer *buffer, int sx, int sy, void *data)
+{
+ /* Round the corners of buffers which are at the corners of the window,
+ * including subsurfaces covering it */
+ Client *c = data;
+ int radius = cornerradius(c);
+ int left = sx == (int)c->bw, top = sy == (int)c->bw;
+ int right = sx + buffer->dst_width == c->current.width - (int)c->bw;
+ int bottom = sy + buffer->dst_height == c->current.height - (int)c->bw;
+
+ wlr_scene_buffer_set_corner_radii(buffer, corner_radii_new(
+ top && left ? radius : 0, top && right ? radius : 0,
+ bottom && right ? radius : 0, bottom && left ? radius : 0));
+}
+
void
run(char *startup_cmd)
{
@@ -2737,17 +2805,18 @@ setup(void)
/* Initialize the scene graph used to lay out windows */
scene = wlr_scene_create();
+ 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);
root_bg = wlr_scene_rect_create(&scene->tree, 0, 0, rootcolor);
for (i = 0; i < NUM_LAYERS; i++)
layers[i] = wlr_scene_tree_create(&scene->tree);
drag_icon = wlr_scene_tree_create(&scene->tree);
wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
- /* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user
- * can also specify a renderer using the WLR_RENDERER env var.
+ /* Creates scenefx's GLES2 renderer, which is required to render its effects.
* 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);
@@ -2959,7 +3028,9 @@ snapshot(struct wlr_scene_node *node, struct wlr_scene_tree *parent, void *data)
* the buffers so that they can be shown after the client changes them */
struct wlr_scene_node *child, *copy;
struct wlr_scene_tree *tree;
- struct wlr_scene_rect *rect;
+ struct wlr_scene_rect *src_rect, *rect;
+ struct wlr_scene_shadow *src_shadow, *shadow;
+ struct wlr_scene_blur *src_blur, *blur;
struct wlr_scene_buffer *src, *buffer;
if (!node->enabled)
@@ -2973,8 +3044,29 @@ snapshot(struct wlr_scene_node *node, struct wlr_scene_tree *parent, void *data)
copy = &tree->node;
break;
case WLR_SCENE_NODE_RECT:
- rect = wlr_scene_rect_from_node(node);
- copy = &wlr_scene_rect_create(parent, rect->width, rect->height, rect->color)->node;
+ src_rect = wlr_scene_rect_from_node(node);
+ rect = wlr_scene_rect_create(parent, src_rect->width, src_rect->height, src_rect->color);
+ wlr_scene_rect_set_corner_radii(rect, src_rect->corners);
+ wlr_scene_rect_set_clipped_region(rect, src_rect->clipped_region);
+ copy = &rect->node;
+ break;
+ case WLR_SCENE_NODE_SHADOW:
+ src_shadow = wlr_scene_shadow_from_node(node);
+ shadow = wlr_scene_shadow_create(parent, src_shadow->width, src_shadow->height,
+ src_shadow->corner_radius, src_shadow->blur_sigma, src_shadow->color);
+ wlr_scene_shadow_set_clipped_region(shadow, src_shadow->clipped_region);
+ copy = &shadow->node;
+ break;
+ case WLR_SCENE_NODE_BLUR:
+ src_blur = wlr_scene_blur_from_node(node);
+ blur = wlr_scene_blur_create(parent, src_blur->width, src_blur->height);
+ wlr_scene_blur_set_corner_radii(blur, src_blur->corners);
+ wlr_scene_blur_set_clipped_region(blur, src_blur->clipped_region);
+ wlr_scene_blur_set_should_only_blur_bottom_layer(blur,
+ src_blur->should_only_blur_bottom_layer);
+ wlr_scene_blur_set_alpha(blur, src_blur->alpha);
+ wlr_scene_blur_set_strength(blur, src_blur->strength);
+ copy = &blur->node;
break;
case WLR_SCENE_NODE_BUFFER:
src = wlr_scene_buffer_from_node(node);
@@ -2989,6 +3081,7 @@ snapshot(struct wlr_scene_node *node, struct wlr_scene_tree *parent, void *data)
wlr_scene_buffer_set_color_range(buffer, src->color_range);
wlr_scene_buffer_set_source_box(buffer, &src->src_box);
wlr_scene_buffer_set_transform(buffer, src->transform);
+ wlr_scene_buffer_set_corner_radii(buffer, src->corners);
wlr_scene_buffer_set_buffer(buffer, src->buffer);
copy = &buffer->node;
break;
@@ -3222,6 +3315,8 @@ 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 (l->mon && l->scene->node.parent == layers[LyrBg])
+ wlr_scene_optimized_blur_mark_dirty(l->mon->blur);
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
focusclient(focustop(selmon), NULL, 1);
motionnotify(0, NULL, 0, 0, 0, 0);
@@ -3340,6 +3435,9 @@ updatemons(struct wl_listener *listener, void *data)
wlr_scene_node_set_position(&m->fullscreen_bg->node, m->m.x, m->m.y);
wlr_scene_rect_set_size(m->fullscreen_bg, m->m.width, m->m.height);
+ wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y);
+ wlr_scene_optimized_blur_set_size(m->blur, m->m.width, m->m.height);
+
if (m->lock_surface) {
struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data;
wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);
--
2.56.0
+6 -6
View File
@@ -1,10 +1,10 @@
### Description
# simple_scratchpad — A very simple scratchpad utility.
# simple_scratchpad - A very simple scratchpad utility.
Adds functions to add, toggle and remove clients to/from scratchpad client lists.
![scratchpad in action](https://codeberg.org/julmajustus/my-dwl-patches/raw/branch/main/demos/simple_scratchpad_demo.gif?raw=true)
---
1. **addscratchpad**
@@ -18,12 +18,12 @@ Adds functions to add, toggle and remove clients to/from scratchpad client lists
4. **setscratchpad**
- Sets current scratchpad number
### Download
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/simple_scratchpad)
- [scratchpad-wlroots-next-d41ecb7.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simple_scratchpad/simple_scratchpad-wlroots-next-d41ecb7.patch)
- [scratchpad-v0.8.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/simple_scratchpad/simple_scratchpad-v0.8.patch)
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/simple_scratchpad-0.9)
- [scratchpad-v0.9.patch](/dwl/dwl-patches/raw/branch/main/patches/simple_scratchpad/simple_scratchpad-v0.9.patch)
- [scratchpad-v0.8.patch](/dwl/dwl-patches/raw/branch/main/patches/simple_scratchpad/simple_scratchpad-v0.8.patch)
### Authors
- [julmajustus](https://codeberg.org/julmajustus)
@@ -1,21 +1,35 @@
From be4f7488eac6ea502e0e9d1cc5595e01d97cb345 Mon Sep 17 00:00:00 2001
From da5b4335fab5ca589ac6a9e569aa99aaa091eae9 Mon Sep 17 00:00:00 2001
From: julmajustus <julmajustus@tutanota.com>
Date: Thu, 21 May 2026 00:28:41 +0300
Subject: [PATCH] simple_scratchpad: Spring update scratchpad V2
Date: Sun, 20 Sep 2026 02:23:44 +0300
Subject: [PATCH] simple_scratchpad d16036e refactor
- Added support for multiple scratchpads
---
Makefile | 3 +-
config.def.h | 7 ++++
dwl.c | 43 +++++++++++++++++++++--
simple_scratchpad.c | 85 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 133 insertions(+), 2 deletions(-)
create mode 100644 simple_scratchpad.c
dwl.c | 40 +++++++++++++++++++-
simple_scratchpad.h | 89 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 136 insertions(+), 3 deletions(-)
create mode 100644 simple_scratchpad.h
diff --git a/Makefile b/Makefile
index 8304245..4592dff 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,8 @@ 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 \
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
- wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
+ wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h \
+ simple_scratchpad.h
$(CC) dwl.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
# wayland-scanner is a tool which generates C headers and rigging for Wayland
diff --git a/config.def.h b/config.def.h
index 8a6eda0..a527e09 100644
index 13c5322..acd44d9 100644
--- a/config.def.h
+++ b/config.def.h
@@ -14,6 +14,7 @@ static const float urgentcolor[] = COLOR(0xff0000ff);
@@ -15,6 +15,7 @@ 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 */
@@ -35,27 +49,27 @@ index 8a6eda0..a527e09 100644
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
@@ -144,6 +148,9 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_comma, tagmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_period, tagmon, {.i = WLR_DIRECTION_RIGHT} },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_1, setscratchpad, {.i = 0} },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_2, setscratchpad, {.i = 1} },
+ { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_3, setscratchpad, {.i = 2} },
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_1, 0),
TAGKEYS( XKB_KEY_2, 1),
TAGKEYS( XKB_KEY_3, 2),
diff --git a/dwl.c b/dwl.c
index 8101ffa..1c858a8 100644
index 4cfd0fd..91a7628 100644
--- a/dwl.c
+++ b/dwl.c
@@ -143,6 +143,7 @@ typedef struct {
@@ -159,6 +159,7 @@ typedef struct {
unsigned int bw;
uint32_t tags;
int isfloating, isurgent, isfullscreen;
uint32_t resize; /* configure serial of a pending resize */
+ struct wl_list link_temp;
} Client;
typedef struct {
@@ -244,6 +245,7 @@ typedef struct {
@@ -260,6 +261,7 @@ typedef struct {
} SessionLock;
/* function declarations */
@@ -63,7 +77,7 @@ index 8101ffa..1c858a8 100644
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
static void arrange(Monitor *m);
@@ -318,6 +320,7 @@ static void printstatus(void);
@@ -335,6 +337,7 @@ static void printstatus(void);
static void powermgrsetmode(struct wl_listener *listener, void *data);
static void quit(const Arg *arg);
static void rendermon(struct wl_listener *listener, void *data);
@@ -71,7 +85,7 @@ index 8101ffa..1c858a8 100644
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);
@@ -331,6 +334,7 @@ static void setlayout(const Arg *arg);
@@ -348,6 +351,7 @@ static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, uint32_t newtags);
static void setpsel(struct wl_listener *listener, void *data);
@@ -79,7 +93,7 @@ index 8101ffa..1c858a8 100644
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
static void spawn(const Arg *arg);
@@ -340,6 +344,7 @@ static void tagmon(const Arg *arg);
@@ -357,6 +361,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
@@ -87,19 +101,16 @@ index 8101ffa..1c858a8 100644
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);
@@ -459,6 +464,11 @@ static struct wlr_xwayland *xwayland;
/* attempt to encapsulate suck into one file */
#include "client.h"
@@ -484,6 +489,8 @@ static struct wlr_xwayland *xwayland;
+static struct wl_list scratchpad_clients[SCRATCHPAD_COUNT];
+static int scratchpad_visible[SCRATCHPAD_COUNT];
+static int scratchpad_sel = 0;
+#include "simple_scratchpad.c"
#include "ime.h"
+#include "simple_scratchpad.h"
+
/* function implementations */
void
applybounds(Client *c, struct wlr_box *bbox)
@@ -1332,10 +1342,21 @@ void
@@ -1427,10 +1434,21 @@ void
destroynotify(struct wl_listener *listener, void *data)
{
/* Called when the xdg_toplevel is destroyed. */
@@ -122,7 +133,7 @@ index 8101ffa..1c858a8 100644
#ifdef XWAYLAND
if (c->type != XDGShell) {
wl_list_remove(&c->activate.link);
@@ -2337,11 +2358,24 @@ setcursorshape(struct wl_listener *listener, void *data)
@@ -2490,11 +2508,24 @@ setcursorshape(struct wl_listener *listener, void *data)
void
setfloating(Client *c, int floating)
{
@@ -148,7 +159,7 @@ index 8101ffa..1c858a8 100644
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ||
(p && p->isfullscreen) ? LyrFS
: c->isfloating ? LyrFloat : LyrTile]);
@@ -2561,6 +2595,11 @@ setup(void)
@@ -2714,6 +2745,11 @@ setup(void)
*/
wl_list_init(&clients);
wl_list_init(&fstack);
@@ -160,26 +171,30 @@ index 8101ffa..1c858a8 100644
xdg_shell = wlr_xdg_shell_create(dpy, 6);
wl_signal_add(&xdg_shell->events.new_toplevel, &new_xdg_toplevel);
diff --git a/simple_scratchpad.c b/simple_scratchpad.c
diff --git a/simple_scratchpad.h b/simple_scratchpad.h
new file mode 100644
index 0000000..0e23ddd
index 0000000..36a564e
--- /dev/null
+++ b/simple_scratchpad.c
@@ -0,0 +1,85 @@
+++ b/simple_scratchpad.h
@@ -0,0 +1,89 @@
+/* ************************************************************************** */
+/* @@@ @@@@@@@@ */
+/* @@@ @@@@@@@@@@ */
+/* @@! @@! @@@@ */
+/* !@! !@! @!@!@ */
+/* simple_scratchpad.c @!! @!@ @! !@! */
+/* simple_scratchpad.h @!! @!@ @! !@! */
+/* !!! !@!!! !!! */
+/* By: julmajustus <julmajustus@tutanota.com> !!: !!:! !!! */
+/* ::! :!: !:! */
+/* Created: 2024/12/19 19:35:02 by jmakkone :: ::::::: :: */
+/* Updated: 2026/05/20 23:56:35 by julmajustus : : : : : : */
+/* Updated: 2026/09/20 02:14:02 by julmajustus : : : : : : */
+/* */
+/* ************************************************************************** */
+
+static struct wl_list scratchpad_clients[SCRATCHPAD_COUNT];
+static int scratchpad_visible[SCRATCHPAD_COUNT];
+static int scratchpad_sel = 0;
+
+void
+addscratchpad(const Arg *arg)
+{
@@ -252,5 +267,5 @@ index 0000000..0e23ddd
+ scratchpad_sel = idx;
+}
--
2.53.0
2.55.0
+2 -1
View File
@@ -8,7 +8,8 @@ Adds a rule-based ability to skip automatically focusing a window on creation. E
| 2 | skipfocus entirely |
### Download
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/skipfocus/skipfocus.patch)
- [2026-09-27](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/skipfocus/skipfocus-20260927.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/skipfocus/skipfocus-20240918.patch)
- [2024-07-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/skipfocus/skipfocus-20240714.patch)
- [2024-01-08](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/skipfocus/skipfocus-20240108.patch)
- [git branch](https://codeberg.org/dhruva_sambrani/dwl/src/branch/skipfocus)
@@ -0,0 +1,80 @@
diff --git a/config.def.h b/config.def.h
index a4019d3..f8b8ef0 100644
--- a/config.def.h
+++ b/config.def.h
@@ -22,9 +22,10 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
static int log_level = WLR_ERROR;
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ /* app_id title tags mask isfloating skipfocus monitor */
+ { "Gimp_EXAMPLE", NULL, 0, 1, 0, -1 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, 0, -1 }, /* Start on ONLY tag "9" */
+ { "mako_EXAMPLE", NULL, 0, 1, 1, -1 }, /* Start floating and skip focus */
/* default/example rule: can be changed but cannot be eliminated; at least one rule must exist */
};
diff --git a/dwl.c b/dwl.c
index cca1ea4..7c6938e 100644
--- a/dwl.c
+++ b/dwl.c
@@ -158,7 +158,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, skipfocus;
} Client;
typedef struct {
@@ -248,6 +248,7 @@ typedef struct {
const char *title;
uint32_t tags;
int isfloating;
+ int skipfocus;
int monitor;
} Rule;
@@ -533,6 +534,7 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
+ c->skipfocus = r->skipfocus;
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -1526,6 +1528,13 @@ focusclient(Client *c, LayerSurface *l, int lift)
if (locked)
return;
+ if (c && c->skipfocus != 0){
+ if (c -> skipfocus == 1) {
+ c->skipfocus = 0;
+ }
+ return;
+ }
+
/* Raise client in stacking order if requested */
if (c && lift)
wlr_scene_node_raise_to_top(&c->scene->node);
@@ -1958,11 +1967,13 @@ mapnotify(struct wl_listener *listener, void *data)
printstatus();
unset_fullscreen:
- m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
- wl_list_for_each(w, &clients, link) {
- if (w != c && w != p && w->isfullscreen && m == w->mon && (w->tags & c->tags))
- setfullscreen(w, 0);
- }
+ if (!c->skipfocus) {
+ m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
+ wl_list_for_each(w, &clients, link) {
+ if (w != c && w != p && w->isfullscreen && m == w->mon && (w->tags & c->tags))
+ setfullscreen(w, 0);
+ }
+ }
}
void
+2 -1
View File
@@ -4,7 +4,8 @@ Swapfocus adds a new function on dwl: a shortcut to change the focus to the last
- Alternatively: edit the patch and uncomment and comment out the lines instructed to keep the swapfocus shortcut from changing to another tag.
### Download
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/swapfocus/swapfocus.patch)
- [2026-10-25](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/swapfocus/swapfocus.patch)
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/swapfocus/swapfocus-0.8.patch)
### Authors
- [André Desgualdo Pereira](https://codeberg.org/Kana)
+154
View File
@@ -0,0 +1,154 @@
From 364b9f20b830886b9c0e6539ddba2cc206a286eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= <desgua@gmail.com>
Date: Thu, 21 May 2026 09:50:03 -0300
Subject: [PATCH] swapfocus patch
---
config.def.h | 1 +
dwl.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..23e502d 100644
--- a/config.def.h
+++ b/config.def.h
@@ -132,6 +132,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_Return, zoom, {0} },
{ MODKEY, XKB_KEY_Tab, view, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_c, killclient, {0} },
+ { MODKEY, XKB_KEY_s, swapfocus, {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]} },
diff --git a/dwl.c b/dwl.c
index 101a45f..c512323 100644
--- a/dwl.c
+++ b/dwl.c
@@ -332,6 +332,7 @@ static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
+static void swapfocus(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
@@ -375,6 +376,7 @@ static struct wlr_xdg_activation_v1 *activation;
static struct wlr_xdg_decoration_manager_v1 *xdg_decoration_mgr;
static struct wl_list clients; /* tiling order */
static struct wl_list fstack; /* focus order */
+static Client *prevclient = NULL;
static struct wlr_idle_notifier_v1 *idle_notifier;
static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
static struct wlr_layer_shell_v1 *layer_shell;
@@ -1330,6 +1332,8 @@ destroynotify(struct wl_listener *listener, void *data)
{
/* Called when the xdg_toplevel is destroyed. */
Client *c = wl_container_of(listener, c, destroy);
+ if (c == prevclient)
+ prevclient = NULL;
wl_list_remove(&c->destroy.link);
wl_list_remove(&c->set_title.link);
wl_list_remove(&c->fullscreen.link);
@@ -1424,6 +1428,11 @@ focusclient(Client *c, int lift)
wlr_xdg_popup_destroy(popup);
}
+ /* Capture the client losing focus as the previous client */
+ if (old_c && !client_is_unmanaged(old_c) && old_c != c) {
+ prevclient = old_c;
+ }
+
/* Put the new client atop the focus stack and select its monitor */
if (c && !client_is_unmanaged(c)) {
wl_list_remove(&c->flink);
@@ -2679,6 +2688,87 @@ spawn(const Arg *arg)
}
}
+void
+swapfocus(const Arg *arg)
+{
+ Client *c;
+ int found = 0;
+
+ /* Verify the client still exists in the list of managed windows */
+ if (prevclient) {
+ wl_list_for_each(c, &clients, link) {
+ if (c == prevclient) {
+ found = 1;
+ break;
+ }
+ }
+ }
+
+ if (found && !client_is_unmanaged(prevclient)) {
+ /* Get the bitmask of currently visible tags on the prevclient's monitor */
+ unsigned int visible_tags = prevclient->mon->tagset[prevclient->mon->seltags];
+
+ /* Check if the client's tags are currently visible */
+ if (!(prevclient->tags & visible_tags)) {
+ /* Tag is NOT visible: Switch tags and monitor only.
+ * dwl's view() calls arrange(), which automatically focuses the
+ * top-most window in the focus stack for that tag. */
+ Arg a = {.ui = prevclient->tags};
+ selmon = prevclient->mon;
+ view(&a);
+
+ /* Comment out the 3 lines above and
+ * uncommment the following lines
+ * if changing tags isn't desired */
+
+// int current_tag_clients = 0;
+// Client *tmp;
+// wl_list_for_each(tmp, &clients, link) {
+// /* Make sure it's on the current monitor, visible on the current tag, and mapped */
+// if (tmp->mon == selmon && (tmp->tags & selmon->tagset[selmon->seltags]) && !client_is_unmanaged(tmp)) {
+// current_tag_clients++;
+// }
+// }
+//
+// /* If there's more than 1 window here, mimic Mod+k instead of switching tags */
+// if (current_tag_clients > 1) {
+// Arg arg_focus = {.i = -1};
+// focusstack(&arg_focus);
+// }
+
+ /* End of not changing tags logic */
+ } else {
+ /* Tag IS visible: Just swap focus within the same view */
+ focusclient(prevclient, 1);
+ }
+ } else {
+ Arg a = {.ui = 0};
+ selmon = prevclient->mon;
+ view(&a);
+
+ /* Comment out the 3 lines above and
+ * uncommment the following lines
+ * if changing tags isn't desired */
+
+ /* use the following if changing tags isn't desired */
+// int current_tag_clients = 0;
+// Client *tmp;
+// wl_list_for_each(tmp, &clients, link) {
+// /* Make sure it's on the current monitor, visible on the current tag, and mapped */
+// if (tmp->mon == selmon && (tmp->tags & selmon->tagset[selmon->seltags]) && !client_is_unmanaged(tmp)) {
+// current_tag_clients++;
+// }
+// }
+//
+// /* If there's more than 1 window here, mimic Mod+k instead of switching tags */
+// if (current_tag_clients > 1) {
+// Arg arg_focus = {.i = -1};
+// focusstack(&arg_focus);
+// }
+ /* end of not changing tags logic */
+ }
+}
+
void
startdrag(struct wl_listener *listener, void *data)
{
--
2.53.0
+9 -22
View File
@@ -1,15 +1,5 @@
From 364b9f20b830886b9c0e6539ddba2cc206a286eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= <desgua@gmail.com>
Date: Thu, 21 May 2026 09:50:03 -0300
Subject: [PATCH] swapfocus patch
---
config.def.h | 1 +
dwl.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..23e502d 100644
index a4019d3..02ee21c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -132,6 +132,7 @@ static const Key keys[] = {
@@ -21,18 +11,18 @@ index 8a6eda0..23e502d 100644
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
diff --git a/dwl.c b/dwl.c
index 101a45f..c512323 100644
index d5f2f98..5e65cfa 100644
--- a/dwl.c
+++ b/dwl.c
@@ -332,6 +332,7 @@ static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
@@ -362,6 +362,7 @@ static struct wlr_scene_node *snapshot(struct wlr_scene_node *node,
struct wlr_scene_tree *parent, void *data);
static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data);
+static void swapfocus(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
@@ -375,6 +376,7 @@ static struct wlr_xdg_activation_v1 *activation;
@@ -410,6 +411,7 @@ static struct wlr_xdg_activation_v1 *activation;
static struct wlr_xdg_decoration_manager_v1 *xdg_decoration_mgr;
static struct wl_list clients; /* tiling order */
static struct wl_list fstack; /* focus order */
@@ -40,7 +30,7 @@ index 101a45f..c512323 100644
static struct wlr_idle_notifier_v1 *idle_notifier;
static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
static struct wlr_layer_shell_v1 *layer_shell;
@@ -1330,6 +1332,8 @@ destroynotify(struct wl_listener *listener, void *data)
@@ -1500,6 +1502,8 @@ destroynotify(struct wl_listener *listener, void *data)
{
/* Called when the xdg_toplevel is destroyed. */
Client *c = wl_container_of(listener, c, destroy);
@@ -49,7 +39,7 @@ index 101a45f..c512323 100644
wl_list_remove(&c->destroy.link);
wl_list_remove(&c->set_title.link);
wl_list_remove(&c->fullscreen.link);
@@ -1424,6 +1428,11 @@ focusclient(Client *c, int lift)
@@ -1600,6 +1604,11 @@ focusclient(Client *c, LayerSurface *l, int lift)
wlr_xdg_popup_destroy(popup);
}
@@ -61,7 +51,7 @@ index 101a45f..c512323 100644
/* Put the new client atop the focus stack and select its monitor */
if (c && !client_is_unmanaged(c)) {
wl_list_remove(&c->flink);
@@ -2679,6 +2688,87 @@ spawn(const Arg *arg)
@@ -3015,6 +3024,87 @@ spawn(const Arg *arg)
}
}
@@ -116,7 +106,7 @@ index 101a45f..c512323 100644
+ /* End of not changing tags logic */
+ } else {
+ /* Tag IS visible: Just swap focus within the same view */
+ focusclient(prevclient, 1);
+ focusclient(prevclient, NULL, 1);
+ }
+ } else {
+ Arg a = {.ui = 0};
@@ -149,6 +139,3 @@ index 101a45f..c512323 100644
void
startdrag(struct wl_listener *listener, void *data)
{
--
2.53.0
+1 -1
View File
@@ -3,7 +3,7 @@ Add a rule option to switch to the configured tag when a window opens, then swit
### Download
- [git branch](https://codeberg.org/guidocella/dwl/src/branch/switchtotag)
- [2026-09-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/switchtotag/switchtotag.patch)
- [2026-10-20](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/switchtotag/switchtotag.patch)
### Authors
- [Guido Cella](https://codeberg.org/guidocella)
+15 -51
View File
@@ -1,17 +1,17 @@
From 2d466821072b6b3630169a784a10b0fe40666790 Mon Sep 17 00:00:00 2001
From b636e766b42a75404ada4a5c39fd66221bb19b0b Mon Sep 17 00:00:00 2001
From: Guido Cella <guido@guidocella.xyz>
Date: Mon, 30 Sep 2024 08:40:25 +0200
Date: Sun, 4 Oct 2026 10:22:14 +0200
Subject: [PATCH] allow switching to the configured tag when a window opens
Add a rule option to switch to the configured tag when a window opens,
then switch back when it closes.
---
config.def.h | 6 +++---
dwl.c | 21 +++++++++++++++++----
2 files changed, 20 insertions(+), 7 deletions(-)
dwl.c | 13 +++++++++++++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 13c5322..1e52d05 100644
index a4019d3..ffb0d6a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -22,9 +22,9 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
@@ -28,10 +28,10 @@ index 13c5322..1e52d05 100644
};
diff --git a/dwl.c b/dwl.c
index f7bda0b..a58bd9a 100644
index 7d8fc1e..8201d29 100644
--- a/dwl.c
+++ b/dwl.c
@@ -158,6 +158,7 @@ typedef struct {
@@ -162,6 +162,7 @@ typedef struct {
unsigned int bw;
uint32_t tags;
int isfloating, isurgent, isfullscreen;
@@ -39,7 +39,7 @@ index f7bda0b..a58bd9a 100644
} Client;
typedef struct {
@@ -245,6 +246,7 @@ typedef struct {
@@ -250,6 +251,7 @@ typedef struct {
const char *id;
const char *title;
uint32_t tags;
@@ -47,29 +47,11 @@ index f7bda0b..a58bd9a 100644
int isfloating;
int monitor;
} Rule;
@@ -260,7 +262,7 @@ typedef struct {
/* function declarations */
static void applybounds(Client *c, struct wlr_box *bbox);
-static void applyrules(Client *c);
+static void applyrules(Client *c, bool map);
static void arrange(Monitor *m);
static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
@@ -509,7 +511,7 @@ applybounds(Client *c, struct wlr_box *bbox)
}
void
-applyrules(Client *c)
+applyrules(Client *c, bool map)
{
/* rule matching */
const char *appid, *title;
@@ -531,6 +533,11 @@ applyrules(Client *c)
@@ -594,6 +596,11 @@ applyrules(Client *c)
if (r->monitor == i++)
mon = m;
}
+ if (r->switchtotag && map) {
+ if (r->switchtotag && client_surface(c)->mapped) {
+ c->switchtotag = selmon->tagset[selmon->seltags];
+ mon->seltags ^= 1;
+ mon->tagset[selmon->seltags] = r->tags & TAGMASK;
@@ -77,28 +59,10 @@ index f7bda0b..a58bd9a 100644
}
}
@@ -952,7 +959,7 @@ commitnotify(struct wl_listener *listener, void *data)
* a different monitor based on its title, this will likely select
* a wrong monitor.
*/
- applyrules(c);
+ applyrules(c, false);
if (c->mon) {
client_set_scale(client_surface(c), c->mon->wlr_output->scale);
}
@@ -1914,7 +1921,7 @@ mapnotify(struct wl_listener *listener, void *data)
c->isfloating = 1;
setmon(c, p->mon, p->tags);
} else {
- applyrules(c);
+ applyrules(c, true);
}
printstatus();
@@ -3000,6 +3007,12 @@ unmapnotify(struct wl_listener *listener, void *data)
wlr_scene_node_destroy(&c->image_capture_scene->tree.node);
wlr_scene_node_destroy(&c->scene->node);
client_surface(c)->data = NULL;
@@ -3227,6 +3234,12 @@ unmapnotify(struct wl_listener *listener, void *data)
c->snapshot = NULL;
c->resize_serial = 0;
c->current = (struct wlr_box){0};
+
+ if (c->switchtotag) {
+ Arg a = { .ui = c->switchtotag };
@@ -109,5 +73,5 @@ index f7bda0b..a58bd9a 100644
motionnotify(0, NULL, 0, 0, 0, 0);
}
--
2.55.0
2.56.0
+5 -1
View File
@@ -6,12 +6,14 @@ KNOWN BUGS:
### Download
- [git branch](https://codeberg.org/fauxmight/dwl/src/branch/touch-input)
- [touch-input-wlroots-next-f4249db.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/touch-input/touch-input-wlroots-next-f4249db.patch)
- [touch-input-wlroots-next-4fd683c.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/touch-input/touch-input-wlroots-next-4fd683c.patch)
- [touch-input-0.8.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/touch-input/touch-input-0.8.patch)
- [touch-input-0.9.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/touch-input/touch-input-0.9.patch)
- [touch-input-0.8-osu-ver.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/touch-input/touch-input-0.8-osu-ver.patch)
### Authors
#### Current
- [pi66](https://codeberg.org/pi66)
- [fauxmight](https://codeberg.org/fauxmight)
- [6z7y](https://codeberg.org/6z7y) -- maintaining `osu!` version of the `touch-input` patch
#### Historic
@@ -20,6 +22,8 @@ KNOWN BUGS:
### Changelog
- 2026-09-29 Update patch for dwl wlroots-next branch commit 4fd683c
- 2026-09-25 Update patch for dwl v0.9 and dwl wlroots-next branch commit f1675a4
- 2026-06-15 Add support for osu! fullscreen touch input (fix cursor stuck issue)
- 2026-02-26 Update patch for dwl v0.8 and dwl wlroots-next branch commit f4249db
- 2025-01-01 @fauxmight took over maintenance. Previous maintainer @minego notes [lack of available time](https://codeberg.org/dwl/dwl-patches/pulls/102#issuecomment-2557944)
@@ -1,17 +1,17 @@
From fa06ad17d5f203be0dc6e1af29b1a21a3cac0455 Mon Sep 17 00:00:00 2001
From: A Frederick Christensen <dwl@ivories.org>
Date: Thu, 26 Feb 2026 22:13:43 -0600
Subject: [PATCH] Apply touch-input patch
From 22342273e7dfb9af1e7e4b19b9b64ccc05a70023 Mon Sep 17 00:00:00 2001
From: pi66 <pixel2176@proton.me>
Date: Fri, 25 Sep 2026 19:59:48 +0100
Subject: [PATCH] fix: add missing touches list declaration
---
dwl.c | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 158 insertions(+)
diff --git a/dwl.c b/dwl.c
index 8a9715d..8bf6023 100644
index 4cfd0fd..e6d8433 100644
--- a/dwl.c
+++ b/dwl.c
@@ -52,6 +52,7 @@
@@ -58,6 +58,7 @@
#include <wlr/types/wlr_session_lock_v1.h>
#include <wlr/types/wlr_single_pixel_buffer_v1.h>
#include <wlr/types/wlr_subcompositor.h>
@@ -19,7 +19,7 @@ index 8a9715d..8bf6023 100644
#include <wlr/types/wlr_viewporter.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include <wlr/types/wlr_virtual_pointer_v1.h>
@@ -163,6 +164,12 @@ typedef struct {
@@ -181,6 +182,12 @@ typedef struct {
struct wl_listener destroy;
} KeyboardGroup;
@@ -32,7 +32,7 @@ index 8a9715d..8bf6023 100644
typedef struct {
/* Must keep this field first */
unsigned int type; /* LayerShell */
@@ -270,7 +277,9 @@ static void createnotify(struct wl_listener *listener, void *data);
@@ -289,7 +296,9 @@ static void createnotify(struct wl_listener *listener, void *data);
static void createpointer(struct wlr_pointer *pointer);
static void createpointerconstraint(struct wl_listener *listener, void *data);
static void createpopup(struct wl_listener *listener, void *data);
@@ -42,7 +42,7 @@ index 8a9715d..8bf6023 100644
static void cursorframe(struct wl_listener *listener, void *data);
static void cursorwarptohint(void);
static void destroydecoration(struct wl_listener *listener, void *data);
@@ -340,6 +349,10 @@ static void togglefloating(const Arg *arg);
@@ -359,6 +368,10 @@ static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
@@ -53,15 +53,15 @@ index 8a9715d..8bf6023 100644
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);
@@ -407,6 +420,7 @@ static struct wlr_output_layout *output_layout;
@@ -429,6 +442,7 @@ static struct wlr_output_layout *output_layout;
static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static struct wl_list touches;
static int consumed[KEY_MAX + 1];
/* global event handlers */
static struct wl_listener cursor_axis = {.notify = axisnotify};
@@ -436,6 +450,10 @@ static struct wl_listener request_set_sel = {.notify = setsel};
@@ -459,6 +473,10 @@ static struct wl_listener request_set_sel = {.notify = setsel};
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};
@@ -70,9 +70,9 @@ index 8a9715d..8bf6023 100644
+static struct wl_listener touch_motion = {.notify = touchmotion};
+static struct wl_listener touch_up = {.notify = touchup};
static struct wl_listener new_session_lock = {.notify = locksession};
static struct wl_listener new_foreign_toplevel_capture_request = {.notify = capturerequest};
#ifdef XWAYLAND
@@ -783,6 +801,10 @@ cleanuplisteners(void)
@@ -874,6 +892,10 @@ cleanuplisteners(void)
wl_list_remove(&request_set_cursor_shape.link);
wl_list_remove(&request_start_drag.link);
wl_list_remove(&start_drag.link);
@@ -81,9 +81,9 @@ index 8a9715d..8bf6023 100644
+ wl_list_remove(&touch_motion.link);
+ wl_list_remove(&touch_up.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);
@@ -1201,6 +1223,16 @@ createpopup(struct wl_listener *listener, void *data)
@@ -1297,6 +1319,16 @@ createpopup(struct wl_listener *listener, void *data)
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
}
@@ -100,7 +100,7 @@ index 8a9715d..8bf6023 100644
void
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
{
@@ -1592,6 +1624,9 @@ inputdevice(struct wl_listener *listener, void *data)
@@ -1703,6 +1735,9 @@ inputdevice(struct wl_listener *listener, void *data)
case WLR_INPUT_DEVICE_POINTER:
createpointer(wlr_pointer_from_input_device(device));
break;
@@ -110,7 +110,7 @@ index 8a9715d..8bf6023 100644
default:
/* TODO handle other input device types */
break;
@@ -1604,6 +1639,8 @@ inputdevice(struct wl_listener *listener, void *data)
@@ -1715,6 +1750,8 @@ inputdevice(struct wl_listener *listener, void *data)
caps = WL_SEAT_CAPABILITY_POINTER;
if (!wl_list_empty(&kb_group->wlr_group->devices))
caps |= WL_SEAT_CAPABILITY_KEYBOARD;
@@ -119,7 +119,7 @@ index 8a9715d..8bf6023 100644
wlr_seat_set_capabilities(seat, caps);
}
@@ -2618,6 +2655,13 @@ setup(void)
@@ -2781,6 +2818,13 @@ setup(void)
wl_signal_add(&cursor->events.axis, &cursor_axis);
wl_signal_add(&cursor->events.frame, &cursor_frame);
@@ -133,7 +133,7 @@ index 8a9715d..8bf6023 100644
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
wl_signal_add(&cursor_shape_mgr->events.request_set_shape, &request_set_cursor_shape);
@@ -2790,6 +2834,120 @@ toggleview(const Arg *arg)
@@ -2957,6 +3001,120 @@ toggleview(const Arg *arg)
printstatus();
}
@@ -255,5 +255,5 @@ index 8a9715d..8bf6023 100644
unlocksession(struct wl_listener *listener, void *data)
{
--
2.52.0
2.55.0
@@ -0,0 +1,259 @@
From 5501a1138fb1be89fd3fb21e3d8ac8cfbc6ff38e Mon Sep 17 00:00:00 2001
From: pi66 <pixel2176@proton.me>
Date: Tue, 29 Sep 2026 11:46:55 +0100
Subject: [PATCH] touch-input: update for wlroots-next-4fd683c
---
dwl.c | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 158 insertions(+)
diff --git a/dwl.c b/dwl.c
index 26fb3a0..3c60d4d 100644
--- a/dwl.c
+++ b/dwl.c
@@ -58,6 +58,7 @@
#include <wlr/types/wlr_session_lock_v1.h>
#include <wlr/types/wlr_single_pixel_buffer_v1.h>
#include <wlr/types/wlr_subcompositor.h>
+#include <wlr/types/wlr_touch.h>
#include <wlr/types/wlr_viewporter.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include <wlr/types/wlr_virtual_pointer_v1.h>
@@ -181,6 +182,12 @@ typedef struct {
struct wl_listener destroy;
} KeyboardGroup;
+typedef struct TouchGroup {
+ struct wl_list link;
+ struct wlr_touch *touch;
+ Monitor *m;
+} TouchGroup;
+
typedef struct {
/* Must keep this field first */
unsigned int type; /* LayerShell */
@@ -291,7 +298,9 @@ static void createnotify(struct wl_listener *listener, void *data);
static void createpointer(struct wlr_pointer *pointer);
static void createpointerconstraint(struct wl_listener *listener, void *data);
static void createpopup(struct wl_listener *listener, void *data);
+static void createtouch(struct wlr_touch *touch);
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
+static void createtouch(struct wlr_touch *touch);
static void cursorframe(struct wl_listener *listener, void *data);
static void cursorwarptohint(void);
static void destroydecoration(struct wl_listener *listener, void *data);
@@ -361,6 +370,10 @@ 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 touchdown(struct wl_listener *listener, void *data);
+static void touchup(struct wl_listener *listener, void *data);
+static void touchframe(struct wl_listener *listener, void *data);
+static void touchmotion(struct wl_listener *listener, void *data);
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);
@@ -430,6 +443,7 @@ static struct wlr_output_layout *output_layout;
static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static struct wl_list touches;
static int consumed[KEY_MAX + 1];
/* global event handlers */
@@ -460,6 +474,10 @@ static struct wl_listener request_set_sel = {.notify = setsel};
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 touch_down = {.notify = touchdown};
+static struct wl_listener touch_frame = {.notify = touchframe};
+static struct wl_listener touch_motion = {.notify = touchmotion};
+static struct wl_listener touch_up = {.notify = touchup};
static struct wl_listener new_session_lock = {.notify = locksession};
static struct wl_listener new_foreign_toplevel_capture_request = {.notify = capturerequest};
@@ -873,6 +891,10 @@ cleanuplisteners(void)
wl_list_remove(&request_set_cursor_shape.link);
wl_list_remove(&request_start_drag.link);
wl_list_remove(&start_drag.link);
+ wl_list_remove(&touch_down.link);
+ wl_list_remove(&touch_frame.link);
+ wl_list_remove(&touch_motion.link);
+ wl_list_remove(&touch_up.link);
wl_list_remove(&new_session_lock.link);
wl_list_remove(&new_foreign_toplevel_capture_request.link);
#ifdef XWAYLAND
@@ -1306,6 +1328,16 @@ createpopup(struct wl_listener *listener, void *data)
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
}
+void
+createtouch(struct wlr_touch *wlr_touch)
+{
+ TouchGroup *touch = ecalloc(1, sizeof(TouchGroup));
+
+ touch->touch = wlr_touch;
+ wl_list_insert(&touches, &touch->link);
+ wlr_cursor_attach_input_device(cursor, &wlr_touch->base);
+}
+
void
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
{
@@ -1711,6 +1743,9 @@ inputdevice(struct wl_listener *listener, void *data)
case WLR_INPUT_DEVICE_POINTER:
createpointer(wlr_pointer_from_input_device(device));
break;
+ case WLR_INPUT_DEVICE_TOUCH:
+ createtouch(wlr_touch_from_input_device(device));
+ break;
default:
/* TODO handle other input device types */
break;
@@ -1723,6 +1758,8 @@ inputdevice(struct wl_listener *listener, void *data)
caps = WL_SEAT_CAPABILITY_POINTER;
if (!wl_list_empty(&kb_group->wlr_group->devices))
caps |= WL_SEAT_CAPABILITY_KEYBOARD;
+ if (!wl_list_empty(&touches))
+ caps |= WL_SEAT_CAPABILITY_TOUCH;
wlr_seat_set_capabilities(seat, caps);
}
@@ -2799,6 +2836,13 @@ setup(void)
wl_signal_add(&cursor->events.axis, &cursor_axis);
wl_signal_add(&cursor->events.frame, &cursor_frame);
+ wl_list_init(&touches);
+
+ wl_signal_add(&cursor->events.touch_down, &touch_down);
+ wl_signal_add(&cursor->events.touch_frame, &touch_frame);
+ wl_signal_add(&cursor->events.touch_motion, &touch_motion);
+ wl_signal_add(&cursor->events.touch_up, &touch_up);
+
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
wl_signal_add(&cursor_shape_mgr->events.request_set_shape, &request_set_cursor_shape);
@@ -2975,6 +3019,120 @@ toggleview(const Arg *arg)
printstatus();
}
+void
+touchdown(struct wl_listener *listener, void *data)
+{
+ struct wlr_touch_down_event *event = data;
+ double lx, ly;
+ double sx, sy;
+ struct wlr_surface *surface;
+ Client *c = NULL;
+ uint32_t serial = 0;
+ Monitor *m;
+
+ wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+
+ // Map the input to the appropriate output, to ensure that rotation is
+ // handled.
+ wl_list_for_each(m, &mons, link) {
+ if (m == NULL || m->wlr_output == NULL) {
+ continue;
+ }
+ if (event->touch->output_name != NULL && 0 != strcmp(event->touch->output_name, m->wlr_output->name)) {
+ continue;
+ }
+
+ wlr_cursor_map_input_to_output(cursor, &event->touch->base, m->wlr_output);
+ }
+
+ wlr_cursor_absolute_to_layout_coords(cursor, &event->touch->base, event->x, event->y, &lx, &ly);
+
+ /* Find the client under the pointer and send the event along. */
+ xytonode(lx, ly, &surface, &c, NULL, &sx, &sy);
+ if (sloppyfocus)
+ focusclient(c, NULL, 0);
+
+ if (surface != NULL) {
+ serial = wlr_seat_touch_notify_down(seat, surface, event->time_msec, event->touch_id, sx, sy);
+ }
+
+ if (serial && wlr_seat_touch_num_points(seat) == 1) {
+ /* Emulate a mouse click if the touch event wasn't handled */
+ struct wlr_pointer_button_event *button_event = data;
+ struct wlr_pointer_motion_absolute_event *motion_event = data;
+ double dx, dy;
+
+ wlr_cursor_absolute_to_layout_coords(cursor, &motion_event->pointer->base, motion_event->x, motion_event->y, &lx, &ly);
+ wlr_cursor_warp_closest(cursor, &motion_event->pointer->base, lx, ly);
+ dx = lx - cursor->x;
+ dy = ly - cursor->y;
+ motionnotify(motion_event->time_msec, &motion_event->pointer->base, dx, dy, dx, dy);
+
+ button_event->button = BTN_LEFT;
+ button_event->state = WL_POINTER_BUTTON_STATE_PRESSED;
+ buttonpress(listener, button_event);
+ }
+}
+
+void
+touchup(struct wl_listener *listener, void *data)
+{
+ struct wlr_touch_up_event *event = data;
+
+ if (!wlr_seat_touch_get_point(seat, event->touch_id)) {
+ return;
+ }
+
+ if (wlr_seat_touch_num_points(seat) == 1) {
+ struct wlr_pointer_button_event *button_event = data;
+
+ button_event->button = BTN_LEFT;
+ button_event->state = WL_POINTER_BUTTON_STATE_RELEASED;
+ buttonpress(listener, button_event);
+ }
+
+ wlr_seat_touch_notify_up(seat, event->time_msec, event->touch_id);
+ wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+}
+
+void
+touchframe(struct wl_listener *listener, void *data)
+{
+ wlr_seat_touch_notify_frame(seat);
+ wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+}
+
+void
+touchmotion(struct wl_listener *listener, void *data)
+{
+ struct wlr_touch_motion_event *event = data;
+ double lx, ly;
+ double sx, sy;
+ struct wlr_surface *surface;
+ Client *c = NULL;
+
+ if (!wlr_seat_touch_get_point(seat, event->touch_id)) {
+ return;
+ }
+
+ wlr_cursor_absolute_to_layout_coords(cursor, &event->touch->base, event->x, event->y, &lx, &ly);
+ xytonode(lx, ly, &surface, &c, NULL, &sx, &sy);
+
+ if (c != NULL && surface != NULL) {
+ if (sloppyfocus)
+ focusclient(c, NULL, 0);
+ wlr_seat_touch_point_focus(seat, surface, event->time_msec, event->touch_id, sx, sy);
+ } else {
+ if (sloppyfocus)
+ focusclient(NULL, NULL, 0);
+ wlr_seat_touch_point_clear_focus(seat, event->time_msec, event->touch_id);
+ }
+ wlr_seat_touch_notify_motion(seat, event->time_msec, event->touch_id, sx, sy);
+
+ wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+}
+
+
void
unlocksession(struct wl_listener *listener, void *data)
{
--
2.55.0
+1 -1
View File
@@ -3,7 +3,7 @@ Hide the mouse cursor if it isn't being used for a certain period of time.
### Download
- [git branch](https://codeberg.org/guidocella/dwl/src/branch/unclutter)
- [2026-09-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/unclutter/unclutter.patch)
- [2026-10-04](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/unclutter/unclutter.patch)
### Authors
- [Guido Cella](https://github.com/guidocella)
+156 -92
View File
@@ -1,15 +1,15 @@
From 0987dd26a7b5dd0071fdb509b5ef61e0efbcb6cd Mon Sep 17 00:00:00 2001
From 7a5a1c34dd099c209fff3f4447a5a404af0f3f12 Mon Sep 17 00:00:00 2001
From: Guido Cella <guido@guidocella.xyz>
Date: Thu, 17 Sep 2026 08:53:31 +0200
Subject: [PATCH] hide the cursor when it isn't being used
Date: Sun, 4 Oct 2026 22:48:42 +0200
Subject: [PATCH] hide the mouse cursor when it isn't being used
---
config.def.h | 2 ++
dwl.c | 40 +++++++++++++++++++++++++++++++++++++---
2 files changed, 39 insertions(+), 3 deletions(-)
config.def.h | 2 +
dwl.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 99 insertions(+), 7 deletions(-)
diff --git a/config.def.h b/config.def.h
index 13c5322..45c3c76 100644
index a4019d3..fa640a1 100644
--- a/config.def.h
+++ b/config.def.h
@@ -103,6 +103,8 @@ LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
@@ -22,37 +22,48 @@ index 13c5322..45c3c76 100644
#define MODKEY WLR_MODIFIER_ALT
diff --git a/dwl.c b/dwl.c
index f7bda0b..c8a2f3d 100644
index 216deb5..475733c 100644
--- a/dwl.c
+++ b/dwl.c
@@ -308,6 +308,8 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
@@ -374,6 +374,10 @@ static Monitor *xytomon(double x, double y);
static void xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, double *nx, double *ny);
static void zoom(const Arg *arg);
+static void cursorsurfacedestroy(struct wl_listener *listener, void *data);
+static void handlecursoractivity(void);
+static int hidecursor(void *data);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@@ -411,6 +413,8 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
+static void trackcursorsurface(struct wlr_surface *surface);
/* variables */
static pid_t child_pid = -1;
@@ -414,6 +418,18 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
static struct wlr_cursor *cursor;
static struct wlr_xcursor_manager *cursor_mgr;
+static struct wl_event_source *hide_source;
+static bool cursor_hidden = false;
+static struct {
+ enum wp_cursor_shape_device_v1_shape shape;
+ struct wlr_surface *surface;
+ int hotspot_x;
+ int hotspot_y;
+ struct wl_listener surface_destroy;
+} last_cursor = {
+ .surface_destroy.notify = cursorsurfacedestroy,
+};
+
static struct wlr_scene_rect *root_bg;
static struct wlr_session_lock_manager_v1 *session_lock_mgr;
@@ -671,6 +675,8 @@ axisnotify(struct wl_listener *listener, void *data)
@@ -676,6 +692,7 @@ axisnotify(struct wl_listener *listener, void *data)
}
}
+ handlecursoractivity();
/* Notify the client with pointer focus of the axis event. */
wlr_seat_pointer_notify_axis(seat,
event->time_msec, event->orientation, event->delta,
event->delta_discrete, event->source, event->relative_direction);
+
+ handlecursoractivity();
}
void
@@ -684,6 +690,7 @@ buttonpress(struct wl_listener *listener, void *data)
@@ -693,6 +710,7 @@ buttonpress(struct wl_listener *listener, void *data)
const Button *b;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@@ -60,10 +71,97 @@ index f7bda0b..c8a2f3d 100644
switch (event->state) {
case WL_POINTER_BUTTON_STATE_PRESSED:
@@ -1662,6 +1669,28 @@ handlesig(int signo)
quit(NULL);
@@ -2067,6 +2085,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
wlr_cursor_move(cursor, device, dx, dy);
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+ handlecursoractivity();
/* Update selmon (even while dragging a window) */
if (sloppyfocus)
@@ -2101,7 +2120,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
/* If there's no client surface under the cursor, set the cursor image to a
* default. This is what makes the cursor image appear when you move it
* off of a client or over its border. */
- if (!surface && !seat->drag)
+ if (!surface && !seat->drag && !cursor_hidden)
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
pointerfocus(c, l, surface, sx, sy, time);
@@ -2463,6 +2482,7 @@ run(char *startup_cmd)
* monitor when displayed here */
wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y);
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
+ handlecursoractivity();
/* Run the Wayland event loop. This does not return until you exit the
* compositor. Starting the backend rigged up all of the necessary event
@@ -2486,9 +2506,16 @@ setcursor(struct wl_listener *listener, void *data)
* use the provided surface as the cursor image. It will set the
* hardware cursor on the output that it's currently on and continue to
* do so as the cursor moves between outputs. */
- if (event->seat_client == seat->pointer_state.focused_client)
- wlr_cursor_set_surface(cursor, event->surface,
- event->hotspot_x, event->hotspot_y);
+ if (event->seat_client == seat->pointer_state.focused_client) {
+ last_cursor.shape = 0;
+ trackcursorsurface(event->surface);
+ last_cursor.hotspot_x = event->hotspot_x;
+ last_cursor.hotspot_y = event->hotspot_y;
+
+ if (!cursor_hidden)
+ wlr_cursor_set_surface(cursor, event->surface,
+ event->hotspot_x, event->hotspot_y);
+ }
}
void
@@ -2500,9 +2527,14 @@ setcursorshape(struct wl_listener *listener, void *data)
/* This can be sent by any client, so we check to make sure this one
* actually has pointer focus first. If so, we can tell the cursor to
* use the provided cursor shape. */
- if (event->seat_client == seat->pointer_state.focused_client)
- wlr_cursor_set_xcursor(cursor, cursor_mgr,
- wlr_cursor_shape_v1_name(event->shape));
+ if (event->seat_client == seat->pointer_state.focused_client) {
+ last_cursor.shape = event->shape;
+ trackcursorsurface(NULL);
+
+ if (!cursor_hidden)
+ wlr_cursor_set_xcursor(cursor, cursor_mgr,
+ wlr_cursor_shape_v1_name(event->shape));
+ }
}
void
@@ -2802,6 +2834,8 @@ setup(void)
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
wl_signal_add(&cursor_shape_mgr->events.request_set_shape, &request_set_cursor_shape);
+ hide_source = wl_event_loop_add_timer(event_loop, hidecursor, cursor);
+
/*
* Configures a seat, which is a single "seat" at which a user sits and
* operates the computer. This conceptually includes up to one keyboard,
@@ -3217,6 +3251,7 @@ virtualpointer(struct wl_listener *listener, void *data)
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);
+ handlecursoractivity();
}
Monitor *
@@ -3281,6 +3316,61 @@ zoom(const Arg *arg)
arrange(selmon);
}
+void
+cursorsurfacedestroy(struct wl_listener *listener, void *data)
+{
+ wl_list_remove(&listener->link);
+ last_cursor.surface = NULL;
+}
+
+void
+handlecursoractivity(void)
+{
@@ -74,81 +172,47 @@ index f7bda0b..c8a2f3d 100644
+
+ cursor_hidden = false;
+
+ wlr_seat_pointer_clear_focus(seat);
+ motionnotify(0, NULL, 0, 0, 0, 0);
+ if (last_cursor.shape)
+ wlr_cursor_set_xcursor(cursor, cursor_mgr,
+ wlr_cursor_shape_v1_name(last_cursor.shape));
+ else if (last_cursor.surface)
+ wlr_cursor_set_surface(cursor, last_cursor.surface,
+ last_cursor.hotspot_x, last_cursor.hotspot_y);
+ else
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
+
+ /* Note that calling the functions below instead of manually saving the last
+ * cursor causes issues like making the cursor warp when clicking ReShade's
+ * menu, or can duplicate the cursor in the top left corner. */
+ // wlr_seat_pointer_clear_focus(seat);
+ // motionnotify(0, NULL, 0, 0, 0, 0);
+}
+
+int
+hidecursor(void *data)
+{
+ wlr_cursor_unset_image(cursor);
+ /* Keep pointer focus so that things like browser tooltips don't disappear
+ * immediately if you set a short timeout. Uncomment the following line if you
+ * want them to disappear. */
+ // wlr_seat_pointer_clear_focus(seat);
+ cursor_hidden = true;
+ return 1;
+ return 0;
+}
+
void
incnmaster(const Arg *arg)
{
@@ -2032,6 +2061,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
wlr_cursor_move(cursor, device, dx, dy);
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+ handlecursoractivity();
/* Update selmon (even while dragging a window) */
if (sloppyfocus)
@@ -2066,7 +2096,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
/* If there's no client surface under the cursor, set the cursor image to a
* default. This is what makes the cursor image appear when you move it
* off of a client or over its border. */
- if (!surface && !seat->drag)
+ if (!surface && !seat->drag && !cursor_hidden)
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
pointerfocus(c, l, surface, sx, sy, time);
@@ -2429,6 +2459,7 @@ run(char *startup_cmd)
* monitor when displayed here */
wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y);
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
+ handlecursoractivity();
/* Run the Wayland event loop. This does not return until you exit the
* compositor. Starting the backend rigged up all of the necessary event
@@ -2452,7 +2483,7 @@ setcursor(struct wl_listener *listener, void *data)
* use the provided surface as the cursor image. It will set the
* hardware cursor on the output that it's currently on and continue to
* do so as the cursor moves between outputs. */
- if (event->seat_client == seat->pointer_state.focused_client)
+ if (event->seat_client == seat->pointer_state.focused_client && !cursor_hidden)
wlr_cursor_set_surface(cursor, event->surface,
event->hotspot_x, event->hotspot_y);
}
@@ -2466,7 +2497,7 @@ setcursorshape(struct wl_listener *listener, void *data)
/* This can be sent by any client, so we check to make sure this one
* actually has pointer focus first. If so, we can tell the cursor to
* use the provided cursor shape. */
- if (event->seat_client == seat->pointer_state.focused_client)
+ if (event->seat_client == seat->pointer_state.focused_client && !cursor_hidden)
wlr_cursor_set_xcursor(cursor, cursor_mgr,
wlr_cursor_shape_v1_name(event->shape));
}
@@ -2768,6 +2799,8 @@ setup(void)
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
wl_signal_add(&cursor_shape_mgr->events.request_set_shape, &request_set_cursor_shape);
+ hide_source = wl_event_loop_add_timer(event_loop, hidecursor, cursor);
+void
+trackcursorsurface(struct wlr_surface *surface)
+{
+ if (last_cursor.surface)
+ wl_list_remove(&last_cursor.surface_destroy.link);
+ last_cursor.surface = surface;
+ if (surface)
+ wl_signal_add(&surface->events.destroy, &last_cursor.surface_destroy);
+}
+
/*
* Configures a seat, which is a single "seat" at which a user sits and
* operates the computer. This conceptually includes up to one keyboard,
@@ -3185,6 +3218,7 @@ virtualpointer(struct wl_listener *listener, void *data)
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);
+ handlecursoractivity();
}
Monitor *
#ifdef XWAYLAND
void
activatex11(struct wl_listener *listener, void *data)
--
2.55.0
2.56.0
+1
View File
@@ -26,6 +26,7 @@ This patch is inspired from <https://dwm.suckless.org/patches/winview/>. Citing
> An example of how to insert this line can be found in the default config file template, config.def.h.
### Download
- [2026-09-27](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/winview/winview-20260927.patch)
- [2026-03-14 dwl 0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/winview/winview_dwl_08.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/winview/winview_dwl_07.patch)
- [2024-06-06](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/winview/winview-20240606.patch)
+42
View File
@@ -0,0 +1,42 @@
diff --git a/config.def.h b/config.def.h
index a4019d3..9cbdfe3 100644
--- a/config.def.h
+++ b/config.def.h
@@ -139,6 +139,7 @@ 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, XKB_KEY_o, winview, {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} },
diff --git a/dwl.c b/dwl.c
index cca1ea4..d3a8d62 100644
--- a/dwl.c
+++ b/dwl.c
@@ -370,6 +370,7 @@ static void urgent(struct wl_listener *listener, void *data);
static void view(const Arg *arg);
static void virtualkeyboard(struct wl_listener *listener, void *data);
static void virtualpointer(struct wl_listener *listener, void *data);
+static void winview(const Arg *a);
static Monitor *xytomon(double x, double y);
static void xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, double *nx, double *ny);
@@ -3223,6 +3224,17 @@ virtualpointer(struct wl_listener *listener, void *data)
wlr_seat_set_capabilities(seat, seat->capabilities | WL_SEAT_CAPABILITY_POINTER);
}
+void
+winview(const Arg *a) {
+ Arg b = {0};
+ Client *sel = focustop(selmon);
+ if(!sel)
+ return;
+ b.ui = sel -> tags;
+ view(&b);
+ return;
+}
+
Monitor *
xytomon(double x, double y)
{
-28
View File
@@ -1,28 +0,0 @@
### Description
Largely based on [raphi](https://sr.ht/~raphi/)'s [somebar](https://sr.ht/~raphi/somebar/), this patch provides an ipc for wayland clients to get and set dwl state. The ipc is intended for status bars, but can also be scripted with tools like [dwlmsg](https://codeberg.org/notchoc/dwlmsg).
Status information to stdout is currently disabled as dwl tends to freeze. For now, `dwlmsg -w` should act as a drop-in replacement.
Note to [pertag](../pertag/) users: apply [this](./ipcpertag.patch) for ipc tagsetting to work as expected
### Download
- [git branch](https://codeberg.org/notchoc/dwl/src/branch/ipc)
- [2024-08-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/ipc/ipc.patch)
- [2024-07-29](https://codeberg.org/dwl/dwl-patches/raw/commit/d235f0f88ed069eca234da5a544fb1c6e19f1d33/patches/ipc/ipc.patch) don't focus other outputs (apply [this minipatch](./focus-tagset-output.patch) if you'd prefer that)
- [2024-07-16](https://codeberg.org/dwl/dwl-patches/raw/commit/642b2559d522034785c1c1203c6d426855ec19ca/patches/ipc/ipc.patch)
- [2024-06-30](https://codeberg.org/dwl/dwl-patches/raw/commit/9a751e5020133d3ab9219e68a43109c6f3c931a7/patches/ipc/ipc.patch)
- [2024-06-21](https://codeberg.org/dwl/dwl-patches/raw/commit/f96ee44cbaef06bd38b8fa29ac7ecba8b1b5abd5/patches/ipc/ipc.patch)
- [2024-06-19](https://codeberg.org/dwl/dwl-patches/raw/commit/e69afc7263b8d982a7923e5d4910f2e1f7140bb8/patches/ipc/ipc.patch)
- [2024-06-08](https://codeberg.org/dwl/dwl-patches/raw/commit/f8598a91b44acc3bd7e9041be97265bbce8fa219/patches/ipc/ipc.patch)
- [2024-03-13](https://codeberg.org/dwl/dwl-patches/raw/commit/0150cfebbcd85f2d6e6728afad345a11a0c45947/ipc/ipc.patch)
- [2024-02-20](https://codeberg.org/dwl/dwl-patches/raw/commit/0c5ae06e4bc1d7f641376e8fcb86b43bd48ce2ee/ipc/ipc.patch)
- [2023-10-28](https://gist.githubusercontent.com/fbushstone/b116c44340eb7a7878de1119dd931ca5/raw/ee66ac9e2a5dddd9b528df553e21080c2811e974/ipc-v2-fixed.patch) Updated version of 2023-04-29, prevents ipc from freezing the compositor in printstatus.
- [2023-04-29](https://github.com/djpohly/dwl/compare/main...madcowog:ipc-v2.patch) Use this for dwl-ipc-unstable-v2. If you are using commit [9d68554](https://github.com/djpohly/dwl/commit/9d68554c59a886b641d27a364884fb461af2d4f1) or later, use this. For status bars this protocol is supported by dwlb, Waybar and dwl-bar.
- [2023-04-29](https://github.com/djpohly/dwl/compare/main...madcowog:ipc-bbdf2.patch) Use this for dwl-ipc-unstable-v1. If you are using commit [bbdaf2a9](https://github.com/djpohly/dwl/commit/bbdf2a913b72e7a308ee0dfde6518a4285d4a775), [release 0.4](https://github.com/djpohly/dwl/releases/tag/v0.4) or earlier, use this. For status bars, this protocol is supported by dwl-bar.
- [2023-02-20](https://lists.sr.ht/~raphi/public-inbox/patches/39166) Use this for net-tapesoftware-dwl-wm-unstable-v1. If you are using commit [c69a2bec](https://github.com/djpohly/dwl/commit/c69a2bec3ff417fbc4ea8fec0a49096773e01e7d) or later, use this. For status bars this protocol is supported by somebar.
### Authors
- [MadcowOG](https://github.com/MadcowOG)
- [fbushstone](https://github.com/fbushstone)
- [notchoc](https://codeberg.org/notchoc)
- [snuk](https://codeberg.org/snuk)
@@ -1,24 +0,0 @@
From b65477621f0438b0ed6c405f74c9d15e8fb57e96 Mon Sep 17 00:00:00 2001
From: choc <notchoc@disroot.org>
Date: Mon, 29 Jul 2024 21:26:06 +0800
Subject: [PATCH] ipc: focus set_tag'd output
---
dwl.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/dwl.c b/dwl.c
index 4a025f0..dcbb063 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1533,6 +1533,7 @@ dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource,
if (!ipc_output)
return;
monitor = ipc_output->mon;
+ selmon = monitor;
if (!newtags || newtags == monitor->tagset[monitor->seltags])
return;
--
2.43.0
-113
View File
@@ -1,113 +0,0 @@
### Description
Implement https://github.com/wlrfx/scenefx
```c
/* available options */
static const int opacity = 0; /* flag to enable opacity */
static const float opacity_inactive = 0.5;
static const float opacity_active = 1.0;
static const int shadow = 1; /* flag to enable shadow */
static const int shadow_only_floating = 0; /* only apply shadow to floating windows */
static const float shadow_color[4] = COLOR(0x0000FFff);
static const float shadow_color_focus[4] = COLOR(0xFF0000ff);
static const int shadow_blur_sigma = 20;
static const int shadow_blur_sigma_focus = 40;
static const char *const shadow_ignore_list[] = { NULL }; /* list of app-id to ignore */
static const int corner_radius = 8; /* 0 disables corner_radius */
static const int corner_radius_inner = 8; /* 0 disables corner_radius */
static const int corner_radius_only_floating = 0; /* only apply corner_radius and corner_radius_inner to floating windows */
static const int blur = 1; /* flag to enable blur */
static const int blur_xray = 0; /* flag to make transparent fs and floating windows display your background */
static const int blur_ignore_transparent = 1;
static const struct blur_data blur_data = {
.radius = 5,
.num_passes = 3,
.noise = (float)0.02,
.brightness = (float)0.9,
.contrast = (float)0.9,
.saturation = (float)1.1,
};
```
> **NOTE:** If you are using nix with flakes, scenefx has a flake for scenefx https://github.com/wlrfx/scenefx/blob/main/flake.nix
> **NOTE:** Blur doesn't work on windows with opacity set (opacity_active, opacity_inactive)
> **NOTE:** In DWL's Makefile `scenefx-0.2` must be placed before `wlroots-0.18`, e.g. `PKGS = scenefx-0.2 wlroots-0.18 wayland-server ...`
<details>
<summary>Preview</summary>
<pre>
<img src="https://i.imgur.com/nJIX6lp.png"/>
</pre>
</details>
### Download
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.8-a/scenefx-b)
- [0.8-dev](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/scenefx/scenefx.patch)
**NOTE:** This patch was tested with the `87c0e8b6d5c86557a800445e8e4c322f387fe19c` commit on the `main` branch of `SceneFX`. It supports rounded borders, blur, and shadows. However, it does not add rounded borders or shadows to Xwayland apps. That said, Xwayland apps can have shadows, and they might also support rounded borders, but I was never able to make it work. PRs are welcome!
**IMPORTANT:** This patch requires you to build DWL with the following dependencies
- **scenefx**
- libGL
- [2024-07-09](https://codeberg.org/dwl/dwl-patches/raw/commit/13d96b51b54500dd24544cf3a73c61b7a1414bc6/patches/scenefx/scenefx.patch)
**IMPORTANT:** This patch only works with the `2ec3505248e819191c37cb831197629f373326fb` commit on the `main` branch of `scenefx`, therefore, it does not support **blur**.
**IMPORTANT:** This patch requires you to build DWL with the following dependencies
- **scenefx**
- libGL
<details>
<summary>Preview</summary>
<pre>
<img src="https://i.imgur.com/4kFhSaS.png"/>
<img src="https://i.imgur.com/9ZQAUXx.png"/>
</pre>
</details>
- [2024-04-11](https://codeberg.org/dwl/dwl-patches/raw/commit/6e3a57ffd16dafa31900b7e89e51672bd7bcc1e8/scenefx/scenefx.patch)
**IMPORTANT:** This patch only works with the `de4ec10e1ff9347b5833f00f8615d760d9378c99` commit on the `wlr_scene_blur` branch of `scenefx`, as it adds support for **blur**.
**IMPORTANT:** This patch requires you to build DWL with the dependencies of WLROOTS:
- **scenefx**
- libGL
- libcap
- libinput
- libpng
- libxkbcommon
- mesa
- pixman
- seatd
- vulkan-loader
- wayland
- wayland-protocols
- xorg.libX11
- xorg.xcbutilerrors
- xorg.xcbutilimage
- xorg.xcbutilrenderutil
- xorg.xcbutilwm
- xwayland (optional)
- ffmpeg
- hwdata
- libliftoff
- libdisplay-info
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/7a5c3420822074c544fa102e030b7c30aa6b6be8/scenefx/scenefx.patch)
### Authors
- [wochap](https://codeberg.org/wochap)
-700
View File
@@ -1,700 +0,0 @@
From d209aeaee541a045de9dba2154bbbd5475bba2ec Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com>
Date: Sun, 9 Mar 2025 17:26:07 -0500
Subject: [PATCH] implement scenefx
---
Makefile | 2 +-
client.h | 18 +++
config.def.h | 30 +++-
dwl.c | 414 ++++++++++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 457 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index 3358bae..8dc79bd 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ DWLDEVCFLAGS = -g -pedantic -Wall -Wextra -Wdeclaration-after-statement \
-Wfloat-conversion
# CFLAGS / LDFLAGS
-PKGS = wlroots-0.18 wayland-server xkbcommon libinput $(XLIBS)
+PKGS = scenefx-0.2 wlroots-0.18 wayland-server xkbcommon libinput $(XLIBS)
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` -lm $(LIBS)
diff --git a/client.h b/client.h
index 42f225f..4e8f016 100644
--- a/client.h
+++ b/client.h
@@ -147,6 +147,13 @@ client_get_clip(Client *c, struct wlr_box *clip)
return;
#endif
+ *clip = (struct wlr_box){
+ .x = c->bw,
+ .y = c->bw,
+ .width = c->geom.width - c->bw * 2,
+ .height = c->geom.height - c->bw * 2,
+ };
+
wlr_xdg_surface_get_geometry(c->surface.xdg, &xdg_geom);
clip->x = xdg_geom.x;
clip->y = xdg_geom.y;
@@ -328,6 +335,17 @@ static inline void
client_set_border_color(Client *c, const float color[static 4])
{
int i;
+
+#ifdef XWAYLAND
+ if (!client_is_x11(c)) {
+#endif
+ if (corner_radius > 0) {
+ return;
+ }
+#ifdef XWAYLAND
+ }
+#endif
+
for (i = 0; i < 4; i++)
wlr_scene_rect_set_color(c->border[i], color);
}
diff --git a/config.def.h b/config.def.h
index 22d2171..8c50932 100644
--- a/config.def.h
+++ b/config.def.h
@@ -12,7 +12,35 @@ 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.1f, 0.1f, 0.1f, 0.0f}; /* You can also use glsl colors */
+
+static const int opacity = 0; /* flag to enable opacity */
+static const float opacity_inactive = 0.5;
+static const float opacity_active = 1.0;
+
+static const int shadow = 1; /* flag to enable shadow */
+static const int shadow_only_floating = 0; /* only apply shadow to floating windows */
+static const float shadow_color[4] = COLOR(0x0000FFff);
+static const float shadow_color_focus[4] = COLOR(0xFF0000ff);
+static const int shadow_blur_sigma = 20;
+static const int shadow_blur_sigma_focus = 40;
+static const char *const shadow_ignore_list[] = { NULL }; /* list of app-id to ignore */
+
+static const int corner_radius = 8; /* 0 disables corner_radius */
+static const int corner_radius_inner = 9; /* 0 disables corner_radius */
+static const int corner_radius_only_floating = 0; /* only apply corner_radius and corner_radius_inner to floating windows */
+
+static const int blur = 1; /* flag to enable blur */
+static const int blur_xray = 0; /* flag to make transparent fs and floating windows display your background */
+static const int blur_ignore_transparent = 1;
+static const struct blur_data blur_data = {
+ .radius = 5,
+ .num_passes = 3,
+ .noise = (float)0.02,
+ .brightness = (float)0.9,
+ .contrast = (float)0.9,
+ .saturation = (float)1.1,
+};
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
diff --git a/dwl.c b/dwl.c
index 5bf995e..655e175 100644
--- a/dwl.c
+++ b/dwl.c
@@ -10,8 +10,14 @@
#include <stdlib.h>
#include <sys/wait.h>
#include <time.h>
+#include <scenefx/render/fx_renderer/fx_renderer.h>
+#include <scenefx/types/fx/blur_data.h>
+#include <scenefx/types/fx/clipped_region.h>
+#include <scenefx/types/fx/corner_location.h>
+#include <scenefx/types/wlr_scene.h>
#include <unistd.h>
#include <wayland-server-core.h>
+#include <wayland-util.h>
#include <wlr/backend.h>
#include <wlr/backend/libinput.h>
#include <wlr/render/allocator.h>
@@ -43,7 +49,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>
@@ -83,7 +88,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, LyrBlur, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
#ifdef XWAYLAND
enum { NetWMWindowTypeDialog, NetWMWindowTypeSplash, NetWMWindowTypeToolbar,
NetWMWindowTypeUtility, NetLast }; /* EWMH atoms */
@@ -141,6 +146,12 @@ typedef struct {
uint32_t tags;
int isfloating, isurgent, isfullscreen;
uint32_t resize; /* configure serial of a pending resize */
+
+ float opacity;
+ int corner_radius;
+ struct wlr_scene_shadow *shadow;
+ int has_shadow_enabled;
+ struct wlr_scene_rect *round_border;
} Client;
typedef struct {
@@ -208,6 +219,7 @@ struct Monitor {
int nmaster;
char ltsymbol[16];
int asleep;
+ struct wlr_scene_optimized_blur *blur_layer;
};
typedef struct {
@@ -355,6 +367,18 @@ static Monitor *xytomon(double x, double y);
static void xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, double *nx, double *ny);
static void zoom(const Arg *arg);
+static void iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data);
+static void iter_xdg_scene_buffers_blur(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data);
+static void iter_xdg_scene_buffers_opacity(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data);
+static void iter_xdg_scene_buffers_corner_radius(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data);
+static void output_configure_scene(struct wlr_scene_node *node, Client *c);
+static int in_shadow_ignore_list(const char *str);
+static void client_set_shadow_blur_sigma(Client *c, int blur_sigma);
+static void update_client_corner_radius(Client *c);
+static void update_client_shadow_color(Client *c);
+static void update_client_focus_decorations(Client *c, int focused, int urgent);
+static void update_client_blur(Client *c);
+static void update_buffer_corner_radius(Client *c, struct wlr_scene_buffer *buffer);
/* variables */
static const char broken[] = "broken";
@@ -413,6 +437,8 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static float transparent[4] = {0.1f, 0.1f, 0.1f, 0.0f};
+
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -499,6 +525,10 @@ 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);
+ }
+
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
/* We move all clients (except fullscreen and unmanaged) to LyrTile while
@@ -722,6 +752,11 @@ 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);
}
@@ -785,6 +820,18 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
}
arrangelayers(l->mon);
+
+ if (blur) {
+ // Rerender the optimized blur on change
+ struct wlr_layer_surface_v1 *wlr_layer_surface = l->layer_surface;
+ if (wlr_layer_surface->current.layer ==
+ ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND ||
+ wlr_layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM) {
+ if (l->mon) {
+ wlr_scene_optimized_blur_mark_dirty(l->mon->blur_layer);
+ }
+ }
+ }
}
void
@@ -1036,6 +1083,12 @@ 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(&scene->tree, 0, 0);
+ wlr_scene_node_reparent(&m->blur_layer->node, layers[LyrBlur]);
+ 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
@@ -1061,6 +1114,9 @@ createnotify(struct wl_listener *listener, void *data)
c->surface.xdg = toplevel->base;
c->bw = borderpx;
+ c->opacity = opacity;
+ c->corner_radius = corner_radius;
+
LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify);
LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify);
LISTEN(&toplevel->base->surface->events.unmap, &c->unmap, unmapnotify);
@@ -1369,8 +1425,11 @@ focusclient(Client *c, int lift)
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
- if (!exclusive_focus && !seat->drag)
+ if (!exclusive_focus && !seat->drag) {
client_set_border_color(c, focuscolor);
+
+ update_client_focus_decorations(c, 1, 0);
+ }
}
/* Deactivate old client if focus is changing */
@@ -1389,6 +1448,8 @@ focusclient(Client *c, int lift)
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
client_set_border_color(old_c, bordercolor);
+ update_client_focus_decorations(old_c, 0, 0);
+
client_activate_surface(old, 0);
}
}
@@ -1718,6 +1779,38 @@ mapnotify(struct wl_listener *listener, void *data)
c->border[i]->node.data = c;
}
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers, c);
+
+#ifdef XWAYLAND
+ if (!client_is_x11(c)) {
+#endif
+ if (corner_radius > 0) {
+ c->round_border = wlr_scene_rect_create(c->scene, 0, 0, c->isurgent ? urgentcolor : bordercolor);
+ c->round_border->node.data = c;
+ /* Lower the border below the XDG scene tree */
+ wlr_scene_node_lower_to_bottom(&c->round_border->node);
+
+ /* hide original border */
+ for (i = 0; i < 4; i++) {
+ wlr_scene_rect_set_color(c->border[i], transparent);
+ }
+ }
+#ifdef XWAYLAND
+ }
+#endif
+
+#ifdef XWAYLAND
+ if (!client_is_x11(c)) {
+#endif
+ if (shadow) {
+ c->shadow = wlr_scene_shadow_create(c->scene, 0, 0, c->corner_radius, shadow_blur_sigma, shadow_color);
+ /* Lower the shadow below the border */
+ wlr_scene_node_lower_to_bottom(&c->shadow->node);
+ }
+#ifdef XWAYLAND
+ }
+#endif
+
/* 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;
@@ -1739,6 +1832,13 @@ mapnotify(struct wl_listener *listener, void *data)
}
printstatus();
+ /* TODO: shouldn't we call iter_xdg_scene_buffers_corner_radius? */
+ update_client_corner_radius(c);
+
+ update_client_shadow_color(c);
+
+ update_client_blur(c);
+
unset_fullscreen:
m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
wl_list_for_each(w, &clients, link) {
@@ -2113,6 +2213,8 @@ rendermon(struct wl_listener *listener, void *data)
goto skip;
}
+ output_configure_scene(&m->scene_output->scene->tree.node, NULL);
+
/*
* HACK: The "correct" way to set the gamma is to commit it together with
* the rest of the state in one go, but to do that we would need to rewrite
@@ -2207,6 +2309,21 @@ resize(Client *c, struct wlr_box geo, int interact)
c->geom.height - 2 * c->bw);
client_get_clip(c, &clip);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
+
+ if (corner_radius > 0 && c->round_border) {
+ wlr_scene_node_set_position(&c->round_border->node, 0, 0);
+ wlr_scene_rect_set_size(c->round_border, c->geom.width, c->geom.height);
+ wlr_scene_rect_set_clipped_region(c->round_border, (struct clipped_region) {
+ .corner_radius = c->corner_radius,
+ .corners = CORNER_LOCATION_ALL,
+ .area = { c->bw, c->bw, c->geom.width - c->bw * 2, c->geom.height - c->bw * 2 }
+ });
+ }
+
+ if (shadow && c->shadow) {
+ /* TODO: shouldn't we call wlr_scene_shadow_set_blur_sigma? */
+ client_set_shadow_blur_sigma(c, (int)round(c->shadow->blur_sigma));
+ }
}
void
@@ -2307,6 +2424,13 @@ setfloating(Client *c, int floating)
{
Client *p = client_get_parent(c);
c->isfloating = floating;
+
+ update_client_corner_radius(c);
+
+ update_client_shadow_color(c);
+
+ update_client_blur(c);
+
/* If in floating layout do not change the client's layer */
if (!c->mon || !client_surface(c)->mapped || !c->mon->lt[c->mon->sellt]->arrange)
return;
@@ -2336,6 +2460,13 @@ setfullscreen(Client *c, int fullscreen)
* client positions are set by the user and cannot be recalculated */
resize(c, c->prev, 0);
}
+
+ update_client_corner_radius(c);
+
+ update_client_shadow_color(c);
+
+ update_client_blur(c);
+
arrange(c->mon);
printstatus();
}
@@ -2457,11 +2588,15 @@ 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);
+ }
+
/* 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");
LISTEN_STATIC(&drw->events.lost, gpureset);
@@ -2870,6 +3005,10 @@ updatemons(struct wl_listener *listener, void *data)
wlr_scene_node_set_position(&m->fullscreen_bg->node, m->m.x, m->m.y);
wlr_scene_rect_set_size(m->fullscreen_bg, m->m.width, m->m.height);
+
+ if (blur) {
+ wlr_scene_optimized_blur_set_size(m->blur_layer, m->m.width, m->m.height);
+ }
if (m->lock_surface) {
struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data;
@@ -2940,8 +3079,11 @@ urgent(struct wl_listener *listener, void *data)
c->isurgent = 1;
printstatus();
- if (client_surface(c)->mapped)
+ if (client_surface(c)->mapped) {
client_set_border_color(c, urgentcolor);
+
+ update_client_focus_decorations(c, 1, 1);
+ }
}
void
@@ -3053,6 +3195,268 @@ zoom(const Arg *arg)
arrange(selmon);
}
+void
+iter_xdg_scene_buffers(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data)
+{
+ Client *c = user_data;
+ struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer);
+ struct wlr_xdg_surface *xdg_surface;
+
+ if (!scene_surface) {
+ return;
+ }
+
+ xdg_surface = wlr_xdg_surface_try_from_wlr_surface(scene_surface->surface);
+
+ if (c && xdg_surface && xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
+ /* TODO: Be able to set whole decoration_data instead of calling */
+ /* each individually? */
+ if (opacity) {
+ wlr_scene_buffer_set_opacity(buffer, c->opacity);
+ }
+
+ if (!wlr_subsurface_try_from_wlr_surface(xdg_surface->surface)) {
+ update_buffer_corner_radius(c, buffer);
+
+ if (blur) {
+ int blur_optimized = !c->isfloating || blur_xray;
+ wlr_scene_buffer_set_backdrop_blur(buffer, 1);
+ wlr_scene_buffer_set_backdrop_blur_optimized(buffer, blur_optimized);
+ wlr_scene_buffer_set_backdrop_blur_ignore_transparent(buffer, blur_ignore_transparent);
+ }
+ }
+ }
+}
+
+void
+iter_xdg_scene_buffers_blur(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data)
+{
+ Client *c = user_data;
+ struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer);
+ struct wlr_xdg_surface *xdg_surface;
+
+ if (!scene_surface) {
+ return;
+ }
+
+ xdg_surface = wlr_xdg_surface_try_from_wlr_surface(scene_surface->surface);
+
+ if (c && xdg_surface && xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
+ if (!wlr_subsurface_try_from_wlr_surface(xdg_surface->surface)) {
+ if (blur) {
+ int blur_optimized = !c->isfloating || blur_xray;
+ wlr_scene_buffer_set_backdrop_blur_optimized(buffer, blur_optimized);
+ }
+ }
+ }
+}
+
+void
+iter_xdg_scene_buffers_opacity(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data)
+{
+ Client *c = user_data;
+ struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer);
+ struct wlr_xdg_surface *xdg_surface;
+
+ if (!scene_surface) {
+ return;
+ }
+
+ xdg_surface = wlr_xdg_surface_try_from_wlr_surface(scene_surface->surface);
+
+ if (c && xdg_surface && xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
+ /* TODO: Be able to set whole decoration_data instead of calling */
+ /* each individually? */
+ if (opacity) {
+ wlr_scene_buffer_set_opacity(buffer, c->opacity);
+ }
+ }
+}
+
+void
+iter_xdg_scene_buffers_corner_radius(struct wlr_scene_buffer *buffer, int sx, int sy, void *user_data)
+{
+ Client *c = user_data;
+ struct wlr_scene_surface * scene_surface = wlr_scene_surface_try_from_buffer(buffer);
+ struct wlr_xdg_surface *xdg_surface;
+
+ if (!scene_surface) {
+ return;
+ }
+
+ xdg_surface = wlr_xdg_surface_try_from_wlr_surface(scene_surface->surface);
+
+ if (c && xdg_surface && xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
+ /* TODO: Be able to set whole decoration_data instead of calling */
+ /* each individually? */
+ update_buffer_corner_radius(c, buffer);
+ }
+}
+
+void
+output_configure_scene(struct wlr_scene_node *node, Client *c)
+{
+ Client *_c;
+ struct wlr_xdg_surface *xdg_surface;
+ struct wlr_scene_node *_node;
+
+ if (!node->enabled) {
+ return;
+ }
+
+ _c = node->data;
+ if (_c) {
+ c = _c;
+ }
+
+ if (node->type == WLR_SCENE_NODE_BUFFER) {
+ struct wlr_scene_buffer *buffer = wlr_scene_buffer_from_node(node);
+
+ struct wlr_scene_surface *scene_surface = wlr_scene_surface_try_from_buffer(buffer);
+ if (!scene_surface) {
+ return;
+ }
+
+ xdg_surface = wlr_xdg_surface_try_from_wlr_surface(scene_surface->surface);
+
+ if (c && xdg_surface && xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
+ if (opacity) {
+ wlr_scene_buffer_set_opacity(buffer, c->opacity);
+ }
+
+ if (!wlr_subsurface_try_from_wlr_surface(xdg_surface->surface)) {
+ update_buffer_corner_radius(c, buffer);
+ }
+ }
+ } else if (node->type == WLR_SCENE_NODE_TREE) {
+ struct wlr_scene_tree *tree = wl_container_of(node, tree, node);
+ wl_list_for_each(_node, &tree->children, link) {
+ output_configure_scene(_node, c);
+ }
+ }
+}
+
+int
+in_shadow_ignore_list(const char *str)
+{
+ for (int i = 0; shadow_ignore_list[i] != NULL; i++) {
+ if (strcmp(shadow_ignore_list[i], str) == 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+void
+client_set_shadow_blur_sigma(Client *c, int blur_sigma)
+{
+ wlr_scene_shadow_set_blur_sigma(c->shadow, blur_sigma);
+ wlr_scene_node_set_position(&c->shadow->node, -blur_sigma, -blur_sigma);
+ wlr_scene_shadow_set_size(c->shadow, c->geom.width + blur_sigma * 2, c->geom.height + blur_sigma * 2);
+ wlr_scene_shadow_set_clipped_region(c->shadow, (struct clipped_region) {
+ .corner_radius = c->corner_radius + c->bw,
+ .corners = CORNER_LOCATION_ALL,
+ .area = { blur_sigma, blur_sigma, c->geom.width, c->geom.height }
+ });
+}
+
+void
+update_client_corner_radius(Client *c)
+{
+ if (corner_radius && c->round_border) {
+ int radius = c->corner_radius + c->bw;
+ if ((corner_radius_only_floating && !c->isfloating) || c->isfullscreen) {
+ radius = 0;
+ }
+ wlr_scene_rect_set_corner_radius(c->round_border, radius, CORNER_LOCATION_ALL);
+ }
+
+#ifdef XWAYLAND
+ if (!client_is_x11(c)) {
+#endif
+ if (corner_radius_inner > 0 && c->scene) {
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_corner_radius, c);
+ }
+#ifdef XWAYLAND
+ }
+#endif
+}
+
+void
+update_client_blur(Client *c)
+{
+ if (!blur) {
+ return;
+ }
+
+ if (c->scene) {
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_blur, c);
+ }
+}
+
+void
+update_buffer_corner_radius(Client *c, struct wlr_scene_buffer *buffer)
+{
+ int radius;
+
+#ifdef XWAYLAND
+ if (client_is_x11(c)) {
+ return;
+ }
+#endif
+
+ if (!corner_radius_inner) {
+ return;
+ }
+
+ radius = corner_radius_inner;
+ if ((corner_radius_only_floating && !c->isfloating) || c->isfullscreen) {
+ radius = 0;
+ }
+ wlr_scene_buffer_set_corner_radius(buffer, radius, CORNER_LOCATION_ALL);
+}
+
+void
+update_client_shadow_color(Client *c)
+{
+ int has_shadow_enabled = 1;
+ const float *color;
+
+ if (!shadow || !c->shadow) {
+ return;
+ }
+
+ color = focustop(c->mon) == c ? shadow_color_focus : shadow_color;
+
+ if ((shadow_only_floating && !c->isfloating) ||
+ in_shadow_ignore_list(client_get_appid(c)) ||
+ c->isfullscreen) {
+ color = transparent;
+ has_shadow_enabled = 0;
+ }
+
+ wlr_scene_shadow_set_color(c->shadow, color);
+ c->has_shadow_enabled = has_shadow_enabled;
+}
+
+void
+update_client_focus_decorations(Client *c, int focused, int urgent)
+{
+ if (corner_radius > 0 && c->round_border) {
+ wlr_scene_rect_set_color(c->round_border, urgent ? urgentcolor : (focused ? focuscolor : bordercolor));
+ }
+ if (shadow && c->shadow) {
+ client_set_shadow_blur_sigma(c, (int)round(focused ? shadow_blur_sigma_focus : shadow_blur_sigma));
+ if (c->has_shadow_enabled) {
+ wlr_scene_shadow_set_color(c->shadow, focused ? shadow_color_focus : shadow_color);
+ }
+ }
+ if (opacity) {
+ c->opacity = focused ? opacity_active : opacity_inactive;
+ wlr_scene_node_for_each_buffer(&c->scene_surface->node, iter_xdg_scene_buffers_opacity, c);
+ }
+}
+
#ifdef XWAYLAND
void
activatex11(struct wl_listener *listener, void *data)
--
2.47.2