diff options
| author | coasteen <coasteen@proton.me> | 2026-07-09 10:42:28 +0330 |
|---|---|---|
| committer | coasteen <coasteen@proton.me> | 2026-07-09 10:42:28 +0330 |
| commit | 8cbadb61604667b407b53ee1258433994fa4765a (patch) | |
| tree | 97765fb29418fd6278fcb4cbb9760893afaf7a58 /dwm/patch/reorganizetags.c | |
Diffstat (limited to 'dwm/patch/reorganizetags.c')
| -rwxr-xr-x | dwm/patch/reorganizetags.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/dwm/patch/reorganizetags.c b/dwm/patch/reorganizetags.c new file mode 100755 index 0000000..440d75c --- /dev/null +++ b/dwm/patch/reorganizetags.c @@ -0,0 +1,42 @@ +void +reorganizetags(const Arg *arg) +{ + Client *c; + unsigned int occ, unocc, i; + unsigned int tagdest[NUMTAGS]; + + #if TAGSYNC_PATCH + Monitor *origselmon = selmon; + for (selmon = mons; selmon; selmon = selmon->next) { + #endif // TAGSYNC_PATCH + + occ = 0; + for (c = selmon->clients; c; c = c->next) + occ |= (1 << (ffs(c->tags)-1)); + unocc = 0; + for (i = 0; i < NUMTAGS; ++i) { + while (unocc < i && (occ & (1 << unocc))) + unocc++; + if (occ & (1 << i)) { + tagdest[i] = unocc; + occ &= ~(1 << i); + occ |= 1 << unocc; + } + } + + for (c = selmon->clients; c; c = c->next) + c->tags = 1 << tagdest[ffs(c->tags)-1]; + #if TAGSYNC_PATCH + } + selmon = origselmon; + #endif // TAGSYNC_PATCH + + if (selmon->sel) + view(&((Arg) { .ui = selmon->sel->tags })); + else + #if TAGSYNC_PATCH + arrange(NULL); + #else + arrange(selmon); + #endif // TAGSYNC_PATCH +} |
