summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2020-07-03 13:30:21 +0200
committerbakkeby <[email protected]>2020-07-03 13:30:21 +0200
commita7763038fdfd4307bb206475b033d5c2a130149b (patch)
treef403e7d9bdb4ed47c457c67305c9cc2f360e7210
parent188f2f482fba12de02658f5e127fcd5a9a1f0971 (diff)
downloaddwm-flexipatch-a7763038fdfd4307bb206475b033d5c2a130149b.tar.gz
dwm-flexipatch-a7763038fdfd4307bb206475b033d5c2a130149b.zip
switchtag improvements, making the restoring of tags optional and configurable
-rw-r--r--dwm.c27
-rw-r--r--patches.def.h4
2 files changed, 21 insertions, 10 deletions
diff --git a/dwm.c b/dwm.c
index 5cc9026..e068ee7 100644
--- a/dwm.c
+++ b/dwm.c
@@ -604,6 +604,9 @@ applyrules(Client *c)
char role[64];
#endif // WINDOWROLERULE_PATCH
unsigned int i;
+ #if SWITCHTAG_PATCH
+ unsigned int newtagset;
+ #endif // SWITCHTAG_PATCH
const Rule *r;
Monitor *m;
XClassHint ch = { NULL, NULL };
@@ -662,23 +665,26 @@ applyrules(Client *c)
if (r->switchtag)
#endif // SWALLOW_PATCH
{
- unsigned int newtagset;
- if (r->switchtag == 2)
+ selmon = c->mon;
+ if (r->switchtag == 2 || r->switchtag == 4)
newtagset = c->mon->tagset[c->mon->seltags] ^ c->tags;
else
newtagset = c->tags;
/* Switch to the client's tag, but only if that tag is not already shown */
- if (newtagset && !(newtagset & c->mon->tagset[c->mon->seltags])) {
- c->switchtag = c->mon->tagset[c->mon->seltags];
+ if (newtagset && !(c->tags & 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;
- if (r->switchtag == 1)
+ if (r->switchtag == 1 || r->switchtag == 3) {
#if PERTAG_PATCH
pertagview(&((Arg) { .ui = newtagset }));
+ arrange(c->mon);
#else
view(&((Arg) { .ui = newtagset }));
#endif // PERTAG_PATCH
- arrange(c->mon);
+ } else
+ arrange(c->mon);
}
}
#endif // SWITCHTAG_PATCH
@@ -697,7 +703,7 @@ applyrules(Client *c)
#else
else if (c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags];
#endif // SCRATCHPADS_PATCH
- else c->tags = 1;
+ else c->tags = 1;
#elif SCRATCHPADS_PATCH
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : (c->mon->tagset[c->mon->seltags] & ~SPTAGMASK);
#elif SCRATCHPAD_ALT_1_PATCH
@@ -3763,6 +3769,9 @@ void
unmanage(Client *c, int destroyed)
{
Monitor *m = c->mon;
+ #if SWITCHTAG_PATCH
+ unsigned int switchtag = c->switchtag;
+ #endif // SWITCHTAG_PATCH
XWindowChanges wc;
#if SWALLOW_PATCH
@@ -3803,8 +3812,8 @@ unmanage(Client *c, int destroyed)
updateclientlist();
arrange(m);
#if SWITCHTAG_PATCH
- if (c->switchtag)
- view(&((Arg) { .ui = c->switchtag }));
+ if (switchtag)
+ view(&((Arg) { .ui = switchtag }));
#endif // SWITCHTAG_PATCH
}
diff --git a/patches.def.h b/patches.def.h
index 908b8f7..b778a7a 100644
--- a/patches.def.h
+++ b/patches.def.h
@@ -671,8 +671,10 @@
* 0 is default behaviour
* 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
+ * 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
* Also see https://dwm.suckless.org/patches/switchtotag