diff --git a/patches/switchtotag/README.md b/patches/switchtotag/README.md index 29d08d4..c3d41d1 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) -- [2024-04-01](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/switchtotag/switchtotag.patch) +- [2024-08-28](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 f39bd40..ff8b1e7 100644 --- a/patches/switchtotag/switchtotag.patch +++ b/patches/switchtotag/switchtotag.patch @@ -1,22 +1,22 @@ -From 5f020a184eb708a4e68602acc0102d0d8fb790bd Mon Sep 17 00:00:00 2001 +From d199c4950688430a79920dc019412eea0a071330 Mon Sep 17 00:00:00 2001 From: Guido Cella -Date: Mon, 1 Apr 2024 08:50:49 +0200 +Date: Wed, 28 Aug 2024 17:22:50 +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 | 11 +++++++++++ - 2 files changed, 14 insertions(+), 3 deletions(-) + dwl.c | 19 +++++++++++++++---- + 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/config.def.h b/config.def.h -index 8847e58..1e2ae93 100644 +index 22d2171..52ea128 100644 --- a/config.def.h +++ b/config.def.h -@@ -21,10 +21,10 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca - static int log_level = WLR_ERROR; +@@ -22,10 +22,10 @@ static int log_level = WLR_ERROR; + /* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */ static const Rule rules[] = { - /* app_id title tags mask isfloating monitor */ + /* app_id title tags mask switchtotag isfloating monitor */ @@ -29,10 +29,10 @@ index 8847e58..1e2ae93 100644 /* layout(s) */ diff --git a/dwl.c b/dwl.c -index 39ce68c..9a77a5f 100644 +index 9021e44..264926a 100644 --- a/dwl.c +++ b/dwl.c -@@ -138,6 +138,7 @@ typedef struct { +@@ -142,6 +142,7 @@ typedef struct { unsigned int bw; uint32_t tags; int isfloating, isurgent, isfullscreen; @@ -40,7 +40,7 @@ index 39ce68c..9a77a5f 100644 uint32_t resize; /* configure serial of a pending resize */ } Client; -@@ -226,6 +227,7 @@ typedef struct { +@@ -230,6 +231,7 @@ typedef struct { const char *id; const char *title; uint32_t tags; @@ -48,11 +48,29 @@ index 39ce68c..9a77a5f 100644 int isfloating; int monitor; } Rule; -@@ -468,6 +470,11 @@ applyrules(Client *c) +@@ -245,7 +247,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); +@@ -449,7 +451,7 @@ applybounds(Client *c, struct wlr_box *bbox) + } + + void +-applyrules(Client *c) ++applyrules(Client *c, bool map) + { + /* rule matching */ + const char *appid, *title; +@@ -472,6 +474,11 @@ applyrules(Client *c) if (r->monitor == i++) mon = m; } -+ if (r->switchtotag) { ++ if (r->switchtotag && map) { + c->switchtotag = selmon->tagset[selmon->seltags]; + mon->seltags ^= 1; + mon->tagset[selmon->seltags] = r->tags & TAGMASK; @@ -60,7 +78,25 @@ index 39ce68c..9a77a5f 100644 } } setmon(c, mon, newtags); -@@ -2694,6 +2701,10 @@ unmapnotify(struct wl_listener *listener, void *data) +@@ -795,7 +802,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); + } +@@ -1734,7 +1741,7 @@ mapnotify(struct wl_listener *listener, void *data) + c->isfloating = 1; + setmon(c, p->mon, p->tags); + } else { +- applyrules(c); ++ applyrules(c, true); + } + printstatus(); + +@@ -2773,6 +2780,10 @@ unmapnotify(struct wl_listener *listener, void *data) wlr_scene_node_destroy(&c->scene->node); printstatus(); motionnotify(0, NULL, 0, 0, 0, 0); @@ -72,5 +108,5 @@ index 39ce68c..9a77a5f 100644 void -- -2.44.0 +2.45.2