summaryrefslogtreecommitdiff
path: root/dwm/patch/swaptags.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm/patch/swaptags.c')
-rwxr-xr-xdwm/patch/swaptags.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/dwm/patch/swaptags.c b/dwm/patch/swaptags.c
new file mode 100755
index 0000000..d2341ef
--- /dev/null
+++ b/dwm/patch/swaptags.c
@@ -0,0 +1,30 @@
+void
+swaptags(const Arg *arg)
+{
+ Client *c;
+ unsigned int newtag = arg->ui & TAGMASK;
+ unsigned int curtag = selmon->tagset[selmon->seltags];
+
+ if (newtag == curtag || !curtag || (curtag & (curtag-1)))
+ return;
+
+ #if TAGSYNC_PATCH
+ Monitor *origselmon = selmon;
+ for (selmon = mons; selmon; selmon = selmon->next) {
+ #endif // TAGSYNC_PATCH
+
+ for (c = selmon->clients; c != NULL; c = c->next) {
+ if ((c->tags & newtag) || (c->tags & curtag))
+ c->tags ^= curtag ^ newtag;
+
+ if (!c->tags)
+ c->tags = newtag;
+ }
+
+ #if TAGSYNC_PATCH
+ }
+ selmon = origselmon;
+ #endif // TAGSYNC_PATCH
+
+ view(&((Arg) { .ui = newtag }));
+}