summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorBagellll <[email protected]>2022-02-11 10:57:53 -0500
committerGitHub <[email protected]>2022-02-11 16:57:53 +0100
commitae67378b200842998bb4bc178e0d67220f09fefc (patch)
tree9da48cb032d37b646a0b93d954fe5b7942f9cf96 /patch
parent8f986a4e3b64533d9d96272941685a314f3fa837 (diff)
downloaddwm-flexipatch-ae67378b200842998bb4bc178e0d67220f09fefc.tar.gz
dwm-flexipatch-ae67378b200842998bb4bc178e0d67220f09fefc.zip
Tag-Sync patch (for syncing tags across all monitors) (#219)
* Tag-Sync patch * Major compatibility updates * SWITCHTAG/TAGSYNC compatibility * tagsync: refactoring Co-authored-by: bakkeby <[email protected]>
Diffstat (limited to 'patch')
-rw-r--r--patch/bar_ewmhtags.c1
-rw-r--r--patch/combo.c15
-rw-r--r--patch/distributetags.c18
-rw-r--r--patch/focusadjacenttag.c49
-rw-r--r--patch/reorganizetags.c58
-rw-r--r--patch/shiftviewclients.c15
-rw-r--r--patch/swaptags.c34
7 files changed, 91 insertions, 99 deletions
diff --git a/patch/bar_ewmhtags.c b/patch/bar_ewmhtags.c
index d86fd88..46ee5e4 100644
--- a/patch/bar_ewmhtags.c
+++ b/patch/bar_ewmhtags.c
@@ -50,4 +50,3 @@ updatecurrentdesktop(void)
long data[] = { i };
XChangeProperty(dpy, root, netatom[NetCurrentDesktop], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 1);
}
-
diff --git a/patch/combo.c b/patch/combo.c
index 058b1f9..58b31f1 100644
--- a/patch/combo.c
+++ b/patch/combo.c
@@ -30,21 +30,10 @@ combotag(const Arg *arg)
void
comboview(const Arg *arg)
{
- unsigned newtags = arg->ui & TAGMASK;
if (combo) {
- selmon->tagset[selmon->seltags] |= newtags;
+ view(&((Arg) { .ui = selmon->tagset[selmon->seltags] | (arg->ui & TAGMASK) }));
} else {
- selmon->seltags ^= 1; /*toggle tagset*/
combo = 1;
- if (newtags) {
- #if PERTAG_PATCH
- pertagview(&((Arg) { .ui = newtags }));
- #else
- selmon->tagset[selmon->seltags] = newtags;
- #endif // PERTAG_PATCH
- }
+ view(arg);
}
- focus(NULL);
- arrange(selmon);
}
-
diff --git a/patch/distributetags.c b/patch/distributetags.c
index 284b24c..f20f53f 100644
--- a/patch/distributetags.c
+++ b/patch/distributetags.c
@@ -1,9 +1,16 @@
void
distributetags(const Arg *arg)
{
+ Client *c;
unsigned int ui = 1;
int i = 0;
- for (Client *c = selmon->clients; c; c = c->next) {
+
+ #if TAGSYNC_PATCH
+ Monitor *origselmon = selmon;
+ for (selmon = mons; selmon; selmon = selmon->next) {
+ #endif // TAGSYNC_PATCH
+
+ for (c = selmon->clients; c; c = c->next) {
if (HIDDEN(c))
continue;
if (!(c->tags & TAGMASK))
@@ -11,7 +18,14 @@ distributetags(const Arg *arg)
c->tags = (ui << i) & TAGMASK;
i = (i + 1) % NUMTAGS;
}
+
+ #if TAGSYNC_PATCH
+ }
+ selmon = origselmon;
+ focus(NULL);
+ arrange(NULL);
+ #else
focus(NULL);
arrange(selmon);
+ #endif // TAGSYNC_PATCH
}
-
diff --git a/patch/focusadjacenttag.c b/patch/focusadjacenttag.c
index 85d9d74..b311b74 100644
--- a/patch/focusadjacenttag.c
+++ b/patch/focusadjacenttag.c
@@ -27,17 +27,7 @@ viewtoleft(const Arg *arg)
{
if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
&& selmon->tagset[selmon->seltags] > 1) {
- selmon->seltags ^= 1; /* toggle sel tagset */
- #if PERTAG_PATCH
- pertagview(&((Arg) { .ui = selmon->tagset[selmon->seltags ^ 1] >> 1 }));
- #else
- selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1;
- #endif // pertagview
- focus(NULL);
- arrange(selmon);
- #if BAR_EWMHTAGS_PATCH
- updatecurrentdesktop();
- #endif // BAR_EWMHTAGS_PATCH
+ view(&((Arg) { .ui = selmon->tagset[selmon->seltags] >> 1 }));
}
}
@@ -46,17 +36,7 @@ viewtoright(const Arg *arg)
{
if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
&& selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
- selmon->seltags ^= 1; /* toggle sel tagset */
- #if PERTAG_PATCH
- pertagview(&((Arg) { .ui = selmon->tagset[selmon->seltags ^ 1] << 1 }));
- #else
- selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1;
- #endif // pertagview
- focus(NULL);
- arrange(selmon);
- #if BAR_EWMHTAGS_PATCH
- updatecurrentdesktop();
- #endif // BAR_EWMHTAGS_PATCH
+ view(&((Arg) { .ui = selmon->tagset[selmon->seltags] << 1 }));
}
}
@@ -67,17 +47,7 @@ tagandviewtoleft(const Arg *arg)
&& __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
&& selmon->tagset[selmon->seltags] > 1) {
selmon->sel->tags >>= 1;
- selmon->seltags ^= 1; /* toggle sel tagset */
- #if PERTAG_PATCH
- pertagview(&((Arg) { .ui = selmon->tagset[selmon->seltags ^ 1] >> 1 }));
- #else
- selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1;
- #endif // pertagview
- focus(selmon->sel);
- arrange(selmon);
- #if BAR_EWMHTAGS_PATCH
- updatecurrentdesktop();
- #endif // BAR_EWMHTAGS_PATCH
+ view(&((Arg) { .ui = selmon->tagset[selmon->seltags] >> 1 }));
}
}
@@ -88,17 +58,6 @@ tagandviewtoright(const Arg *arg)
&& __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
&& selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
selmon->sel->tags <<= 1;
- selmon->seltags ^= 1; /* toggle sel tagset */
- #if PERTAG_PATCH
- pertagview(&((Arg) { .ui = selmon->tagset[selmon->seltags ^ 1] << 1 }));
- #else
- selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1;
- #endif // pertagview
- focus(selmon->sel);
- arrange(selmon);
- #if BAR_EWMHTAGS_PATCH
- updatecurrentdesktop();
- #endif // BAR_EWMHTAGS_PATCH
+ view(&((Arg) { .ui = selmon->tagset[selmon->seltags] << 1 }));
}
}
-
diff --git a/patch/reorganizetags.c b/patch/reorganizetags.c
index 1aff54a..440d75c 100644
--- a/patch/reorganizetags.c
+++ b/patch/reorganizetags.c
@@ -1,28 +1,42 @@
void
reorganizetags(const Arg *arg)
{
- Client *c;
- unsigned int occ, unocc, i;
- unsigned int tagdest[NUMTAGS];
+ Client *c;
+ unsigned int occ, unocc, i;
+ unsigned int tagdest[NUMTAGS];
- occ = 0;
- for (c = selmon->clients; c; c = c->next)
- occ |= (1 << (ffs(c->tags)-1));
- unocc = 0;
- for (i = 0; i < NUMTAGS; ++i) {
- while (unocc < i && (occ & (1 << unocc)))
- unocc++;
- if (occ & (1 << i)) {
- tagdest[i] = unocc;
- occ &= ~(1 << i);
- occ |= 1 << unocc;
- }
- }
+ #if TAGSYNC_PATCH
+ Monitor *origselmon = selmon;
+ for (selmon = mons; selmon; selmon = selmon->next) {
+ #endif // TAGSYNC_PATCH
- 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);
-}
+ occ = 0;
+ for (c = selmon->clients; c; c = c->next)
+ occ |= (1 << (ffs(c->tags)-1));
+ unocc = 0;
+ for (i = 0; i < NUMTAGS; ++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 TAGSYNC_PATCH
+ }
+ selmon = origselmon;
+ #endif // TAGSYNC_PATCH
+ if (selmon->sel)
+ view(&((Arg) { .ui = selmon->sel->tags }));
+ else
+ #if TAGSYNC_PATCH
+ arrange(NULL);
+ #else
+ arrange(selmon);
+ #endif // TAGSYNC_PATCH
+}
diff --git a/patch/shiftviewclients.c b/patch/shiftviewclients.c
index 1bf9de8..b805b51 100644
--- a/patch/shiftviewclients.c
+++ b/patch/shiftviewclients.c
@@ -5,7 +5,11 @@ shiftviewclients(const Arg *arg)
Client *c;
unsigned int tagmask = 0;
- for (c = selmon->clients; c; c = c->next)
+ #if TAGSYNC_PATCH
+ Monitor *origselmon = selmon;
+ for (selmon = mons; selmon; selmon = selmon->next)
+ #endif // TAGSYNC_PATCH
+ for (c = selmon->clients; c; c = c->next) {
#if SCRATCHPADS_PATCH
if (!(c->tags & SPTAGMASK))
tagmask = tagmask | c->tags;
@@ -15,13 +19,17 @@ shiftviewclients(const Arg *arg)
#else
tagmask = tagmask | c->tags;
#endif // SCRATCHPADS_PATCH
+ }
+ #if TAGSYNC_PATCH
+ selmon = origselmon;
+ #endif // TAGSYNC_PATCH
#if SCRATCHPADS_PATCH
shifted.ui = selmon->tagset[selmon->seltags] & ~SPTAGMASK;
#else
shifted.ui = selmon->tagset[selmon->seltags];
#endif // SCRATCHPADS_PATCH
- if (arg->i > 0) // left circular shift
+ if (arg->i > 0) { // left circular shift
do {
shifted.ui = (shifted.ui << arg->i)
| (shifted.ui >> (NUMTAGS - arg->i));
@@ -29,7 +37,7 @@ shiftviewclients(const Arg *arg)
shifted.ui &= ~SPTAGMASK;
#endif // SCRATCHPADS_PATCH
} while (tagmask && !(shifted.ui & tagmask));
- else // right circular shift
+ } else { // right circular shift
do {
shifted.ui = (shifted.ui >> (- arg->i)
| shifted.ui << (NUMTAGS + arg->i));
@@ -37,6 +45,7 @@ shiftviewclients(const Arg *arg)
shifted.ui &= ~SPTAGMASK;
#endif // SCRATCHPADS_PATCH
} while (tagmask && !(shifted.ui & tagmask));
+ }
view(&shifted);
}
diff --git a/patch/swaptags.c b/patch/swaptags.c
index d6a72d7..7e1e920 100644
--- a/patch/swaptags.c
+++ b/patch/swaptags.c
@@ -1,23 +1,31 @@
void
swaptags(const Arg *arg)
{
- unsigned int newtag = arg->ui & TAGMASK;
- unsigned int curtag = selmon->tagset[selmon->seltags];
+ Client *c;
+ unsigned int newtag = arg->ui & TAGMASK;
+ unsigned int curtag = selmon->tagset[selmon->seltags];
- if (newtag == curtag || !curtag || (curtag & (curtag-1)))
- return;
+ if (newtag == curtag || !curtag || (curtag & (curtag-1)))
+ return;
- for (Client *c = selmon->clients; c != NULL; c = c->next) {
- if ((c->tags & newtag) || (c->tags & curtag))
- c->tags ^= curtag ^ newtag;
+ #if TAGSYNC_PATCH
+ Monitor *origselmon = selmon;
+ for (selmon = mons; selmon; selmon = selmon->next) {
+ #endif // TAGSYNC_PATCH
- if (!c->tags)
- c->tags = newtag;
- }
+ for (c = selmon->clients; c != NULL; c = c->next) {
+ if ((c->tags & newtag) || (c->tags & curtag))
+ c->tags ^= curtag ^ newtag;
- selmon->tagset[selmon->seltags] = newtag;
+ if (!c->tags)
+ c->tags = newtag;
+ }
- focus(NULL);
- arrange(selmon);
+ #if TAGSYNC_PATCH
+ }
+ selmon = origselmon;
+ #endif // TAGSYNC_PATCH
+
+ view(&((Arg) { .ui = newtag }));
}