From 9311c56fb08f19e352473b3222dc2d55233affd8 Mon Sep 17 00:00:00 2001 From: Guido Cella <guido@guidocella.xyz> Date: Wed, 3 May 2023 09:38:59 +0200 Subject: [PATCH] Port switchtotag Adds 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(-) diff --git a/config.def.h b/config.def.h index 1677f6f..625bc56 100644 --- a/config.def.h +++ b/config.def.h @@ -12,11 +12,11 @@ static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; static const int tagcount = TAGCOUNT; static const Rule rules[] = { - /* app_id title tags mask isfloating monitor */ + /* app_id title tags mask switchtotag isfloating monitor */ /* examples: - { "Gimp", NULL, 0, 1, -1 }, + { "Gimp", NULL, 0, 0, 1, -1 }, + { "firefox", NULL, 1 << 8, 1, 0, -1 }, */ - { "firefox", NULL, 1 << 8, 0, -1 }, }; /* layout(s) */ diff --git a/dwl.c b/dwl.c index 4118fd8..e5c8974 100644 --- a/dwl.c +++ b/dwl.c @@ -125,6 +125,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; @@ -207,6 +208,7 @@ typedef struct { const char *id; const char *title; uint32_t tags; + bool switchtotag; int isfloating; int monitor; } Rule; @@ -465,6 +467,11 @@ applyrules(Client *c) wl_list_for_each(m, &mons, link) if (r->monitor == i++) mon = m; + if (r->switchtotag) { + c->switchtotag = selmon->tagset[selmon->seltags]; + mon->seltags ^= 1; + mon->tagset[selmon->seltags] = r->tags & TAGMASK; + } } } wlr_scene_node_reparent(&c->scene->node, layers[c->isfloating ? LyrFloat : LyrTile]); @@ -2486,6 +2493,10 @@ unmapnotify(struct wl_listener *listener, void *data) wlr_scene_node_destroy(&c->scene->node); printstatus(); motionnotify(0); + if (c->switchtotag) { + Arg a = { .ui = c->switchtotag }; + view(&a); + } } void