Adding reorganizetags patch

This commit is contained in:
bakkeby
2020-08-02 15:18:18 +02:00
parent f067db87aa
commit ed7a43edf1
7 changed files with 55 additions and 0 deletions

View File

@ -137,6 +137,9 @@
#elif PUSH_PATCH
#include "push.c"
#endif
#if REORGANIZETAGS_PATCH
#include "reorganizetags.c"
#endif
#if RESTARTSIG_PATCH
#include "restartsig.c"
#endif

View File

@ -137,6 +137,9 @@
#elif PUSH_PATCH
#include "push.h"
#endif
#if REORGANIZETAGS_PATCH
#include "reorganizetags.h"
#endif
#if RESTARTSIG_PATCH
#include "restartsig.h"
#endif

27
patch/reorganizetags.c Normal file
View File

@ -0,0 +1,27 @@
void
reorganizetags(const Arg *arg)
{
Client *c;
unsigned int occ, unocc, i;
unsigned int tagdest[LENGTH(tags)];
occ = 0;
for (c = selmon->clients; c; c = c->next)
occ |= (1 << (ffs(c->tags)-1));
unocc = 0;
for (i = 0; i < LENGTH(tags); ++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 (selmon->sel)
selmon->tagset[selmon->seltags] = selmon->sel->tags;
arrange(selmon);
}

1
patch/reorganizetags.h Normal file
View File

@ -0,0 +1 @@
static void reorganizetags(const Arg *arg);