switchtag improvements, making the restoring of tags optional and configurable

dwm-flexipatch-1.0
bakkeby 4 years ago
parent 188f2f482f
commit a7763038fd

27
dwm.c

@ -604,6 +604,9 @@ applyrules(Client *c)
char role[64]; char role[64];
#endif // WINDOWROLERULE_PATCH #endif // WINDOWROLERULE_PATCH
unsigned int i; unsigned int i;
#if SWITCHTAG_PATCH
unsigned int newtagset;
#endif // SWITCHTAG_PATCH
const Rule *r; const Rule *r;
Monitor *m; Monitor *m;
XClassHint ch = { NULL, NULL }; XClassHint ch = { NULL, NULL };
@ -662,23 +665,26 @@ applyrules(Client *c)
if (r->switchtag) if (r->switchtag)
#endif // SWALLOW_PATCH #endif // SWALLOW_PATCH
{ {
unsigned int newtagset; selmon = c->mon;
if (r->switchtag == 2) if (r->switchtag == 2 || r->switchtag == 4)
newtagset = c->mon->tagset[c->mon->seltags] ^ c->tags; newtagset = c->mon->tagset[c->mon->seltags] ^ c->tags;
else else
newtagset = c->tags; newtagset = c->tags;
/* Switch to the client's tag, but only if that tag is not already shown */ /* Switch to the client's tag, but only if that tag is not already shown */
if (newtagset && !(newtagset & c->mon->tagset[c->mon->seltags])) { if (newtagset && !(c->tags & c->mon->tagset[c->mon->seltags])) {
c->switchtag = c->mon->tagset[c->mon->seltags]; if (r->switchtag == 3 || r->switchtag == 4)
c->switchtag = c->mon->tagset[c->mon->seltags];
c->mon->tagset[c->mon->seltags] = newtagset; c->mon->tagset[c->mon->seltags] = newtagset;
if (r->switchtag == 1) if (r->switchtag == 1 || r->switchtag == 3) {
#if PERTAG_PATCH #if PERTAG_PATCH
pertagview(&((Arg) { .ui = newtagset })); pertagview(&((Arg) { .ui = newtagset }));
arrange(c->mon);
#else #else
view(&((Arg) { .ui = newtagset })); view(&((Arg) { .ui = newtagset }));
#endif // PERTAG_PATCH #endif // PERTAG_PATCH
arrange(c->mon); } else
arrange(c->mon);
} }
} }
#endif // SWITCHTAG_PATCH #endif // SWITCHTAG_PATCH
@ -697,7 +703,7 @@ applyrules(Client *c)
#else #else
else if (c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags]; else if (c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags];
#endif // SCRATCHPADS_PATCH #endif // SCRATCHPADS_PATCH
else c->tags = 1; else c->tags = 1;
#elif SCRATCHPADS_PATCH #elif SCRATCHPADS_PATCH
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK); c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK);
#elif SCRATCHPAD_ALT_1_PATCH #elif SCRATCHPAD_ALT_1_PATCH
@ -3763,6 +3769,9 @@ void
unmanage(Client *c, int destroyed) unmanage(Client *c, int destroyed)
{ {
Monitor *m = c->mon; Monitor *m = c->mon;
#if SWITCHTAG_PATCH
unsigned int switchtag = c->switchtag;
#endif // SWITCHTAG_PATCH
XWindowChanges wc; XWindowChanges wc;
#if SWALLOW_PATCH #if SWALLOW_PATCH
@ -3803,8 +3812,8 @@ unmanage(Client *c, int destroyed)
updateclientlist(); updateclientlist();
arrange(m); arrange(m);
#if SWITCHTAG_PATCH #if SWITCHTAG_PATCH
if (c->switchtag) if (switchtag)
view(&((Arg) { .ui = c->switchtag })); view(&((Arg) { .ui = switchtag }));
#endif // SWITCHTAG_PATCH #endif // SWITCHTAG_PATCH
} }

@ -671,8 +671,10 @@
* 0 is default behaviour * 0 is default behaviour
* 1 automatically moves you to the tag of the newly opened application and * 1 automatically moves you to the tag of the newly opened application and
* 2 enables the tag of the newly opened application in addition to your existing enabled tags * 2 enables the tag of the newly opened application in addition to your existing enabled tags
* 3 as 1, but closing that window reverts the view back to what it was previously (*)
* 4 as 2, but closing that window reverts the view back to what it was previously (*)
* *
* Closing that window reverts the view back to what it was before the window was opened. * (*) except if the client has been moved between tags or to another monitor
* *
* https://github.com/bakkeby/patches/tree/master/dwm/dwm-switchtag-6.2.diff * https://github.com/bakkeby/patches/tree/master/dwm/dwm-switchtag-6.2.diff
* Also see https://dwm.suckless.org/patches/switchtotag * Also see https://dwm.suckless.org/patches/switchtotag

Loading…
Cancel
Save