diff --git a/dwm.c b/dwm.c index df6319c..a1deebf 100644 --- a/dwm.c +++ b/dwm.c @@ -1146,9 +1146,9 @@ clientmessage(XEvent *e) } else { for (i = 0; i < NUMTAGS && !((1 << i) & c->tags); i++); if (i < NUMTAGS) { - const Arg a = {.ui = 1 << i}; selmon = c->mon; - view(&a); + if (((1 << i) & TAGMASK) != selmon->tagset[selmon->seltags]) + view(&((Arg) { .ui = 1 << i })); focus(c); restack(selmon); } @@ -3281,7 +3281,8 @@ tag(const Arg *arg) #endif // SWAPFOCUS_PATCH arrange(selmon); #if VIEWONTAG_PATCH - view(arg); + if ((arg->ui & TAGMASK) != selmon->tagset[selmon->seltags]) + view(arg); #endif // VIEWONTAG_PATCH } } @@ -3562,7 +3563,7 @@ unmanage(Client *c, int destroyed) updateclientlist(); arrange(m); #if SWITCHTAG_PATCH - if (switchtag) + if (switchtag && ((switchtag & TAGMASK) != selmon->tagset[selmon->seltags])) view(&((Arg) { .ui = switchtag })); #endif // SWITCHTAG_PATCH } @@ -3928,7 +3929,12 @@ view(const Arg *arg) #else if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) #endif // EMPTYVIEW_PATCH + { + #if VIEW_SAME_TAG_GIVES_PREVIOUS_TAG_PATCH + view(&((Arg) { .ui = 0 })); + #endif // VIEW_SAME_TAG_GIVES_PREVIOUS_TAG_PATCH return; + } selmon->seltags ^= 1; /* toggle sel tagset */ #if PERTAG_PATCH pertagview(arg); diff --git a/patch/focusurgent.c b/patch/focusurgent.c index cebb5a3..74946ce 100644 --- a/patch/focusurgent.c +++ b/patch/focusurgent.c @@ -3,12 +3,12 @@ focusurgent(const Arg *arg) { Client *c; int i; - for (c=selmon->clients; c && !c->isurgent; c=c->next); + for (c = selmon->clients; c && !c->isurgent; c = c->next); if (c) { - for (i=0; i < NUMTAGS && !((1 << i) & c->tags); i++); + for (i = 0; i < NUMTAGS && !((1 << i) & c->tags); i++); if (i < NUMTAGS) { - const Arg a = {.ui = 1 << i}; - view(&a); + if (((1 << i) & TAGMASK) != selmon->tagset[selmon->seltags]) + view(&((Arg) { .ui = 1 << i })); focus(c); } } diff --git a/patches.def.h b/patches.def.h index 91bb480..61c8c34 100644 --- a/patches.def.h +++ b/patches.def.h @@ -936,6 +936,14 @@ */ #define VIEWONTAG_PATCH 0 +/* By default tags can be changed using MOD+ while MOD+Tab toggles between the current and + * the previous tag. This patch changes this so that if you hit MOD+ for the tag you are + * currently on, then it works the same as MOD+Tab and switches back to the previous tag. + * Idea ref. + * https://www.reddit.com/r/suckless/comments/ik27vd/key_toggle_between_next_and_previous_tag_dwm/ + */ +#define VIEW_SAME_TAG_GIVES_PREVIOUS_TAG_PATCH 0 + /* This patch warps the mouse cursor to the center of the currently focused window or screen * when the mouse cursor is (a) on a different screen or (b) on top of a different window. * https://dwm.suckless.org/patches/warp/