summaryrefslogtreecommitdiff
path: root/dwm/patch/shift.c
diff options
context:
space:
mode:
authorcoasteen <coasteen@proton.me>2026-07-09 10:42:28 +0330
committercoasteen <coasteen@proton.me>2026-07-09 10:42:28 +0330
commit8cbadb61604667b407b53ee1258433994fa4765a (patch)
tree97765fb29418fd6278fcb4cbb9760893afaf7a58 /dwm/patch/shift.c
Diffstat (limited to 'dwm/patch/shift.c')
-rwxr-xr-xdwm/patch/shift.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/dwm/patch/shift.c b/dwm/patch/shift.c
new file mode 100755
index 0000000..66b4dce
--- /dev/null
+++ b/dwm/patch/shift.c
@@ -0,0 +1,50 @@
+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] & ~SPTAGMASK;
+ #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 STICKY_PATCH
+ if (c->issticky)
+ continue;
+ #endif // STICKY_PATCH
+ #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;
+}