diff --git a/config.def.h b/config.def.h index 469f70f..f74b909 100644 --- a/config.def.h +++ b/config.def.h @@ -133,8 +133,6 @@ static const char dmenufont[] = "monospace:size=10"; static char c000000[] = "#000000"; // placeholder value -#if BAR_FLEXWINTITLE_PATCH -#endif // BAR_FLEXWINTITLE_PATCH static char normfgcolor[] = "#bbbbbb"; static char normbgcolor[] = "#222222"; static char normbordercolor[] = "#444444"; diff --git a/dwm.c b/dwm.c index 37c265f..693ddf3 100644 --- a/dwm.c +++ b/dwm.c @@ -923,8 +923,14 @@ applyrules(Client *c) view(&((Arg) { .ui = newtagset })); #endif // PERTAG_PATCH } else { + #if TAGSYNC_PATCH + for (m = mons; m; m = m->next) + m->tagset[m->seltags] = newtagset; + arrange(NULL); + #else c->mon->tagset[c->mon->seltags] = newtagset; arrange(c->mon); + #endif // TAGSYNC_PATCH } } } @@ -4052,7 +4058,11 @@ toggletag(const Arg *arg) void toggleview(const Arg *arg) { - unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK); + unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK);; + #if TAGSYNC_PATCH + Monitor *origselmon = selmon; + for (selmon = mons; selmon; selmon = selmon->next) { + #endif // TAGSYNC_PATCH #if PERTAG_PATCH int i; #endif // PERTAG_PATCH @@ -4123,11 +4133,25 @@ toggleview(const Arg *arg) togglebar(NULL); #endif // PERTAGBAR_PATCH #endif // PERTAG_PATCH + #if !TAGSYNC_PATCH focus(NULL); arrange(selmon); + #endif // TAGSYNC_PATCH #if !EMPTYVIEW_PATCH } #endif // EMPTYVIEW_PATCH + #if TAGSYNC_PATCH + } + selmon = origselmon; + #if !EMPTYVIEW_PATCH + if (newtagset) { + #endif // EMPTYVIEW_PATCH + focus(NULL); + arrange(NULL); + #if !EMPTYVIEW_PATCH + } + #endif // EMPTYVIEW_PATCH + #endif // TAGSYNC_PATCH #if BAR_EWMHTAGS_PATCH updatecurrentdesktop(); #endif // BAR_EWMHTAGS_PATCH @@ -4685,6 +4709,10 @@ updatewmhints(Client *c) void view(const Arg *arg) { + #if TAGSYNC_PATCH + Monitor *origselmon = selmon; + for (selmon = mons; selmon; selmon = selmon->next) { + #endif // TAGSYNC_PATCH #if EMPTYVIEW_PATCH if (arg->ui && (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) #else @@ -4699,18 +4727,20 @@ view(const Arg *arg) selmon->seltags ^= 1; /* toggle sel tagset */ #if PERTAG_PATCH pertagview(arg); - #if SWAPFOCUS_PATCH - Client *unmodified = selmon->pertag->prevclient[selmon->pertag->curtag]; - #endif // SWAPFOCUS_PATCH #else if (arg->ui & TAGMASK) selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; #endif // PERTAG_PATCH + #if TAGSYNC_PATCH + } + selmon = origselmon; + #endif // TAGSYNC_PATCH focus(NULL); - #if SWAPFOCUS_PATCH && PERTAG_PATCH - selmon->pertag->prevclient[selmon->pertag->curtag] = unmodified; - #endif // SWAPFOCUS_PATCH + #if TAGSYNC_PATCH + arrange(NULL); + #else arrange(selmon); + #endif // TAGSYNC_PATCH #if BAR_EWMHTAGS_PATCH updatecurrentdesktop(); #endif // BAR_EWMHTAGS_PATCH 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 })); } diff --git a/patches.def.h b/patches.def.h index dbd133d..697f6e6 100644 --- a/patches.def.h +++ b/patches.def.h @@ -1130,6 +1130,13 @@ */ #define TAGSWAPMON_PATCH 0 +/* Sync tag actions across all monitors. + * This is comparable to a sort of pseudo-desktop environment. + * Also refer to the desktop patch: + * https://github.com/bakkeby/patches/blob/master/dwm/dwm-desktop-6.3.diff + */ +#define TAGSYNC_PATCH 0 + /* This patch can be useful to the touchpad users because it allows to * resize windows using Mod + two-finger scroll. It is useful when * two-finger scrolling is configured in libinput. @@ -1328,4 +1335,3 @@ * This can be optionally disabled in favour of other layouts. */ #define MONOCLE_LAYOUT 1 -