From 32db514beb17516c50b436896831728c08acb4ec Mon Sep 17 00:00:00 2001 From: Rutherther Date: Mon, 29 Apr 2024 20:55:34 +0200 Subject: [PATCH] Fix getunusedtag, attachclients If client is on multiple monitors, it should be hidden, as the client is visible just on one of the monitors, and on the other there is empty space instead Unused tags are only the tags that are not on any of the monitors. --- dwl.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/dwl.c b/dwl.c index fc3367a065cd962c9a8597440c3b0214e0f7076c..27d9083f7c1e71d3dbe8f10d32c06e19c757d12b 100644 --- a/dwl.c +++ b/dwl.c @@ -563,10 +563,40 @@ arrangelayers(Monitor *m) void attachclients(Monitor *m) { + Monitor *tm; + unsigned int utags = 0; Client *c; - wl_list_for_each(c, &clients, link) - if (c->tags & m->tagset[m->seltags]) + int rmons = 0; + + if (m == NULL) { + return; + } + + wl_list_for_each(tm, &mons, link) { + if (tm != m) { + utags |= tm->tagset[tm->seltags]; + } + } + + wl_list_for_each(c, &clients, link) { + if (VISIBLEON(c, m)) { + /* if client is also visible on other tags that are displayed on + * other monitors, remove these tags */ + if (c->tags & utags) { + c->tags = c->tags & m->tagset[m->seltags]; + rmons = 1; + } setmon(c, m, c->tags); + } + } + + if (rmons) { + wl_list_for_each(tm, &mons, link) { + if (tm != m) { + arrange(tm); + } + } + } } void @@ -1383,12 +1413,19 @@ getunusedtag(void) { size_t i = 0; Monitor *m; - if (wl_list_empty(&mons)) + if (wl_list_empty(&mons)) { return i; + } for (i=0; i < TAGCOUNT; i++) { + int is_used = 0; wl_list_for_each(m, &mons, link) { - if (!(m->tagset[m->seltags] & (1<tagset[m->seltags] & (1<