switchtotag: update

This commit is contained in:
Guido Cella
2026-10-20 21:28:18 +02:00
parent c71551b288
commit 8a28588683
2 changed files with 16 additions and 52 deletions
+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 ### Download
- [git branch](https://codeberg.org/guidocella/dwl/src/branch/switchtotag) - [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 ### Authors
- [Guido Cella](https://codeberg.org/guidocella) - [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> 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 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, Add a rule option to switch to the configured tag when a window opens,
then switch back when it closes. then switch back when it closes.
--- ---
config.def.h | 6 +++--- config.def.h | 6 +++---
dwl.c | 21 +++++++++++++++++---- dwl.c | 13 +++++++++++++
2 files changed, 20 insertions(+), 7 deletions(-) 2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h diff --git a/config.def.h b/config.def.h
index 13c5322..1e52d05 100644 index a4019d3..ffb0d6a 100644
--- a/config.def.h --- a/config.def.h
+++ b/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 @@ -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 diff --git a/dwl.c b/dwl.c
index f7bda0b..a58bd9a 100644 index 7d8fc1e..8201d29 100644
--- a/dwl.c --- a/dwl.c
+++ b/dwl.c +++ b/dwl.c
@@ -158,6 +158,7 @@ typedef struct { @@ -162,6 +162,7 @@ typedef struct {
unsigned int bw; unsigned int bw;
uint32_t tags; uint32_t tags;
int isfloating, isurgent, isfullscreen; int isfloating, isurgent, isfullscreen;
@@ -39,7 +39,7 @@ index f7bda0b..a58bd9a 100644
} Client; } Client;
typedef struct { typedef struct {
@@ -245,6 +246,7 @@ typedef struct { @@ -250,6 +251,7 @@ typedef struct {
const char *id; const char *id;
const char *title; const char *title;
uint32_t tags; uint32_t tags;
@@ -47,29 +47,11 @@ index f7bda0b..a58bd9a 100644
int isfloating; int isfloating;
int monitor; int monitor;
} Rule; } Rule;
@@ -260,7 +262,7 @@ typedef struct { @@ -594,6 +596,11 @@ applyrules(Client *c)
/* 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)
if (r->monitor == i++) if (r->monitor == i++)
mon = m; mon = m;
} }
+ if (r->switchtotag && map) { + if (r->switchtotag && client_surface(c)->mapped) {
+ c->switchtotag = selmon->tagset[selmon->seltags]; + c->switchtotag = selmon->tagset[selmon->seltags];
+ mon->seltags ^= 1; + mon->seltags ^= 1;
+ mon->tagset[selmon->seltags] = r->tags & TAGMASK; + 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) @@ -3227,6 +3234,12 @@ unmapnotify(struct wl_listener *listener, void *data)
* a different monitor based on its title, this will likely select c->snapshot = NULL;
* a wrong monitor. c->resize_serial = 0;
*/ c->current = (struct wlr_box){0};
- 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;
+ +
+ if (c->switchtotag) { + if (c->switchtotag) {
+ Arg a = { .ui = c->switchtotag }; + Arg a = { .ui = c->switchtotag };
@@ -109,5 +73,5 @@ index f7bda0b..a58bd9a 100644
motionnotify(0, NULL, 0, 0, 0, 0); motionnotify(0, NULL, 0, 0, 0, 0);
} }
-- --
2.55.0 2.56.0