From 2e4fe1cdf9d64f9ea5cbe91e737f2979b592e59a Mon Sep 17 00:00:00 2001 From: Rutherther Date: Fri, 10 May 2024 15:52:39 +0200 Subject: [PATCH] fix: singletagset unexpectedly changed selmon When viewing tag that was previously on another monitor, and the current monitor was empty, this lead to selmon being changed, since focusclient(focustop(origm), 1) cannot change the monitor in this scenario --- dwl.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dwl.c b/dwl.c index ed748e5b761b8d201d262b470308e42ed656b863..a0374ef218ace97d07b01b2885de2c8cbae196bc 100644 --- a/dwl.c +++ b/dwl.c @@ -2915,23 +2915,27 @@ view(const Arg *arg) Monitor *m, *origm = selmon; unsigned int newtags; - if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) + if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) { return; + } - newtags = selmon->tagset[selmon->seltags ^ 1]; + newtags = origm->tagset[origm->seltags ^ 1]; /* swap tags when trying to display a tag from another monitor */ - if (arg->ui & TAGMASK) + if (arg->ui & TAGMASK) { newtags = arg->ui & TAGMASK; + } wl_list_for_each(m, &mons, link) { - if (m != selmon && newtags & m->tagset[m->seltags]) { + if (m != origm && newtags & m->tagset[m->seltags]) { /* prevent displaying all tags (MODKEY-0) when multiple monitors * are connected */ - if (newtags & selmon->tagset[selmon->seltags]) + if (newtags & origm->tagset[origm->seltags]) { return; + } m->seltags ^= 1; - m->tagset[m->seltags] = selmon->tagset[selmon->seltags]; + m->tagset[m->seltags] = origm->tagset[origm->seltags]; attachclients(m); + /* Beware: this changes selmon */ focusclient(focustop(m), 1); arrange(m); break; @@ -2941,6 +2945,9 @@ view(const Arg *arg) origm->seltags ^= 1; /* toggle sel tagset */ if (arg->ui & TAGMASK) origm->tagset[origm->seltags] = arg->ui & TAGMASK; + + /* Change selmon back to orig mon */ + selmon = origm; attachclients(origm); focusclient(focustop(origm), 1); arrange(origm);