diff options
| author | bakkeby <[email protected]> | 2022-07-05 13:51:27 +0200 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2022-07-05 13:51:27 +0200 |
| commit | 20692bea017353bcaf069625bcf3bda6eed4ad51 (patch) | |
| tree | 24dd9c250fe47b08b284599323484c8463e1442e /patch/shift.c | |
| parent | 274602fa7a1e629a76d8b2b914e597c772b1add6 (diff) | |
| download | dwm-flexipatch-20692bea017353bcaf069625bcf3bda6eed4ad51.tar.gz dwm-flexipatch-20692bea017353bcaf069625bcf3bda6eed4ad51.zip | |
Refactoring shift functions ref. #270
Diffstat (limited to 'patch/shift.c')
| -rw-r--r-- | patch/shift.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/patch/shift.c b/patch/shift.c new file mode 100644 index 0000000..355e645 --- /dev/null +++ b/patch/shift.c @@ -0,0 +1,46 @@ +static Arg +shift(const Arg *arg, int clients) +{ + Arg shifted; + Client *c; + unsigned int tagmask = 0; + + #if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH + shifted.ui = selmon->tagset[selmon->seltags]; + #else + shifted.ui = selmon->tagset[selmon->seltags]; + #endif // SCRATCHPADS_PATCH + + #if TAGSYNC_PATCH + Monitor *origselmon = selmon; + for (selmon = mons; selmon; selmon = selmon->next) + #endif // TAGSYNC_PATCH + for (c = selmon->clients; c && clients; c = c->next) { + if (c == selmon->sel) + continue; + #if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH + if (!(c->tags & SPTAGMASK)) + tagmask |= c->tags; + #elif SCRATCHPAD_ALT_1_PATCH + if (!(c->tags & SCRATCHPAD_MASK)) + tagmask |= c->tags; + #else + tagmask |= c->tags; + #endif // SCRATCHPADS_PATCH + } + #if TAGSYNC_PATCH + selmon = origselmon; + #endif // TAGSYNC_PATCH + + do { + if (arg->i > 0) // left circular shift + shifted.ui = (shifted.ui << arg->i) | (shifted.ui >> (NUMTAGS - arg->i)); + else // right circular shift + shifted.ui = (shifted.ui >> -arg->i) | (shifted.ui << (NUMTAGS + arg->i)); + #if SCRATCHPADS_PATCH && !RENAMED_SCRATCHPADS_PATCH + shifted.ui &= ~SPTAGMASK; + #endif // SCRATCHPADS_PATCH + } while (tagmask && !(shifted.ui & tagmask)); + + return shifted; +} |
