diff --git a/README.md b/README.md index a0a90bb..b7aabdc 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2020-08-02 - Added reorganizetags patch + 2020-07-19 - Added barmodules patch - making extrabar, leftlayout, staticstatus and statusallmons patches redundant, added powerline patch 2020-07-18 - **Note**: Up until now building dwm-flexipath without any patches selected would have given you something more or less identical with mainstream dwm. In order to reduce complexity when it comes to maintainance future versions of dwm-flexipatch may diverge from this by making some patches non-optional. For the classic dwm-flexipatch and its many patch integration hints refer to branch [dwm-flexipatch-1.0](https://github.com/bakkeby/dwm-flexipatch/tree/dwm-flexipatch-1.0) which will be subject to bug fixes and mainstream dwm updates as far as feasible. @@ -354,6 +356,10 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [push](https://dwm.suckless.org/patches/push/) - this patch provides a way to move clients up and down inside the client list + - [reorganizetags](https://dwm.suckless.org/patches/reorganizetags/) + - shifts all clients per tag to leftmost unoccupied tags + - e.g. if clients A, B, C are tagged on tags 1, 5, 9 respectively, when reorganized they will now be on tag 1, 2, and 3 + - [resizecorners](https://dwm.suckless.org/patches/resizecorners/) - by default, windows only resize from the bottom right corner - with this patch the mouse is warped to the nearest corner and you resize from there diff --git a/config.def.h b/config.def.h index 3d0b4fb..ac842b3 100644 --- a/config.def.h +++ b/config.def.h @@ -928,6 +928,9 @@ static Key keys[] = { #if TRANSFER_ALL_PATCH { MODKEY|ControlMask, XK_x, transferall, {0} }, #endif // TRANSFER_ALL_PATCH + #if REORGANIZETAGS_PATCH + { MODKEY|ControlMask, XK_r, reorganizetags, {0} }, + #endif // REORGANIZETAGS_PATCH { MODKEY, XK_Return, zoom, {0} }, #if VANITYGAPS_PATCH { MODKEY|Mod4Mask, XK_u, incrgaps, {.i = +1 } }, diff --git a/patch/include.c b/patch/include.c index 2964b98..9e008b9 100644 --- a/patch/include.c +++ b/patch/include.c @@ -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 diff --git a/patch/include.h b/patch/include.h index b3bce6f..245933e 100644 --- a/patch/include.h +++ b/patch/include.h @@ -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 diff --git a/patch/reorganizetags.c b/patch/reorganizetags.c new file mode 100644 index 0000000..3c0211d --- /dev/null +++ b/patch/reorganizetags.c @@ -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); +} \ No newline at end of file diff --git a/patch/reorganizetags.h b/patch/reorganizetags.h new file mode 100644 index 0000000..27c0cea --- /dev/null +++ b/patch/reorganizetags.h @@ -0,0 +1 @@ +static void reorganizetags(const Arg *arg); \ No newline at end of file diff --git a/patches.def.h b/patches.def.h index 88ab21b..05d493f 100644 --- a/patches.def.h +++ b/patches.def.h @@ -572,6 +572,18 @@ */ #define PUSH_NO_MASTER_PATCH 0 +/* Shifts all clients per tag to leftmost unoccupied tags. + * + * For example, if clients A, B, C are tagged on tags 1, 5, 9 respectively, when + * this function is called, they will now be on 1, 2, and 3. The focused client + * will also remain focused. + * + * Clients on multiple tags will be treated as if they only were only on their + * leftmost tag, and will be reduced to one tag after the operation is complete. + * https://dwm.suckless.org/patches/reorganizetags/ + */ +#define REORGANIZETAGS_PATCH 0 + /* Resets the layout and mfact if there is only one visible client. * https://dwm.suckless.org/patches/resetlayout/ */