From aec8bbf5c30772d7c869eab557f3ba23b27865e9 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Wed, 16 Sep 2026 20:25:32 +0200 Subject: [PATCH] update switchtotag --- patches/switchtotag/README.md | 2 +- patches/switchtotag/switchtotag.patch | 44 +++++++++++++-------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/patches/switchtotag/README.md b/patches/switchtotag/README.md index 7798695..4d92fe1 100644 --- a/patches/switchtotag/README.md +++ b/patches/switchtotag/README.md @@ -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-02-09](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/switchtotag/switchtotag.patch) +- [2026-09-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/switchtotag/switchtotag.patch) ### Authors - [Guido Cella](https://codeberg.org/guidocella) diff --git a/patches/switchtotag/switchtotag.patch b/patches/switchtotag/switchtotag.patch index 98349ac..9603415 100644 --- a/patches/switchtotag/switchtotag.patch +++ b/patches/switchtotag/switchtotag.patch @@ -1,4 +1,4 @@ -From bfcfb26b00cb93a359469cb8817861439818b430 Mon Sep 17 00:00:00 2001 +From 2d466821072b6b3630169a784a10b0fe40666790 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Mon, 30 Sep 2024 08:40:25 +0200 Subject: [PATCH] allow switching to the configured tag when a window opens @@ -7,14 +7,14 @@ 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 | 23 +++++++++++++++++++---- - 2 files changed, 22 insertions(+), 7 deletions(-) + dwl.c | 21 +++++++++++++++++---- + 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/config.def.h b/config.def.h -index 8a6eda0..59e3ac5 100644 +index 13c5322..1e52d05 100644 --- a/config.def.h +++ b/config.def.h -@@ -21,9 +21,9 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca +@@ -22,9 +22,9 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca static int log_level = WLR_ERROR; static const Rule rules[] = { @@ -28,18 +28,18 @@ index 8a6eda0..59e3ac5 100644 }; diff --git a/dwl.c b/dwl.c -index 44f3ad9..7a97d94 100644 +index f7bda0b..a58bd9a 100644 --- a/dwl.c +++ b/dwl.c -@@ -138,6 +138,7 @@ typedef struct { +@@ -158,6 +158,7 @@ typedef struct { unsigned int bw; uint32_t tags; int isfloating, isurgent, isfullscreen; + int switchtotag; - uint32_t resize; /* configure serial of a pending resize */ } Client; -@@ -226,6 +227,7 @@ typedef struct { + typedef struct { +@@ -245,6 +246,7 @@ typedef struct { const char *id; const char *title; uint32_t tags; @@ -47,7 +47,7 @@ index 44f3ad9..7a97d94 100644 int isfloating; int monitor; } Rule; -@@ -241,7 +243,7 @@ typedef struct { +@@ -260,7 +262,7 @@ typedef struct { /* function declarations */ static void applybounds(Client *c, struct wlr_box *bbox); @@ -56,7 +56,7 @@ index 44f3ad9..7a97d94 100644 static void arrange(Monitor *m); static void arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int exclusive); -@@ -474,7 +476,7 @@ applybounds(Client *c, struct wlr_box *bbox) +@@ -509,7 +511,7 @@ applybounds(Client *c, struct wlr_box *bbox) } void @@ -65,7 +65,7 @@ index 44f3ad9..7a97d94 100644 { /* rule matching */ const char *appid, *title; -@@ -496,6 +498,11 @@ applyrules(Client *c) +@@ -531,6 +533,11 @@ applyrules(Client *c) if (r->monitor == i++) mon = m; } @@ -77,7 +77,7 @@ index 44f3ad9..7a97d94 100644 } } -@@ -864,7 +871,7 @@ commitnotify(struct wl_listener *listener, void *data) +@@ -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. */ @@ -86,7 +86,7 @@ index 44f3ad9..7a97d94 100644 if (c->mon) { client_set_scale(client_surface(c), c->mon->wlr_output->scale); } -@@ -1790,7 +1797,7 @@ mapnotify(struct wl_listener *listener, void *data) +@@ -1914,7 +1921,7 @@ mapnotify(struct wl_listener *listener, void *data) c->isfloating = 1; setmon(c, p->mon, p->tags); } else { @@ -95,21 +95,19 @@ index 44f3ad9..7a97d94 100644 } printstatus(); -@@ -2831,6 +2838,14 @@ unmapnotify(struct wl_listener *listener, void *data) - wl_list_remove(&c->flink); - } - +@@ -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; ++ + if (c->switchtotag) { + Arg a = { .ui = c->switchtotag }; -+ // Call view() -> arrange() -> checkidleinhibitor() before -+ // wlr_scene_node_destroy() to prevent a rare use after free of -+ // tree->node. + view(&a); + } + - wlr_scene_node_destroy(&c->scene->node); printstatus(); motionnotify(0, NULL, 0, 0, 0, 0); + } -- -2.52.0 +2.55.0