From 31dd33b47820d368d943c465a5291e86b0496cbc 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 7a7df0f..665d3d7 100644 --- a/dwl.c +++ b/dwl.c @@ -538,10 +538,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 @@ -1306,12 +1336,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<