Adding view same tag gives previous tag patch

This commit is contained in:
bakkeby 2020-09-05 09:11:12 +02:00
parent 69277ea1a8
commit dcf7b049ba
3 changed files with 22 additions and 8 deletions

14
dwm.c
View File

@ -1146,9 +1146,9 @@ clientmessage(XEvent *e)
} else { } else {
for (i = 0; i < NUMTAGS && !((1 << i) & c->tags); i++); for (i = 0; i < NUMTAGS && !((1 << i) & c->tags); i++);
if (i < NUMTAGS) { if (i < NUMTAGS) {
const Arg a = {.ui = 1 << i};
selmon = c->mon; selmon = c->mon;
view(&a); if (((1 << i) & TAGMASK) != selmon->tagset[selmon->seltags])
view(&((Arg) { .ui = 1 << i }));
focus(c); focus(c);
restack(selmon); restack(selmon);
} }
@ -3281,7 +3281,8 @@ tag(const Arg *arg)
#endif // SWAPFOCUS_PATCH #endif // SWAPFOCUS_PATCH
arrange(selmon); arrange(selmon);
#if VIEWONTAG_PATCH #if VIEWONTAG_PATCH
view(arg); if ((arg->ui & TAGMASK) != selmon->tagset[selmon->seltags])
view(arg);
#endif // VIEWONTAG_PATCH #endif // VIEWONTAG_PATCH
} }
} }
@ -3562,7 +3563,7 @@ unmanage(Client *c, int destroyed)
updateclientlist(); updateclientlist();
arrange(m); arrange(m);
#if SWITCHTAG_PATCH #if SWITCHTAG_PATCH
if (switchtag) if (switchtag && ((switchtag & TAGMASK) != selmon->tagset[selmon->seltags]))
view(&((Arg) { .ui = switchtag })); view(&((Arg) { .ui = switchtag }));
#endif // SWITCHTAG_PATCH #endif // SWITCHTAG_PATCH
} }
@ -3928,7 +3929,12 @@ view(const Arg *arg)
#else #else
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
#endif // EMPTYVIEW_PATCH #endif // EMPTYVIEW_PATCH
{
#if VIEW_SAME_TAG_GIVES_PREVIOUS_TAG_PATCH
view(&((Arg) { .ui = 0 }));
#endif // VIEW_SAME_TAG_GIVES_PREVIOUS_TAG_PATCH
return; return;
}
selmon->seltags ^= 1; /* toggle sel tagset */ selmon->seltags ^= 1; /* toggle sel tagset */
#if PERTAG_PATCH #if PERTAG_PATCH
pertagview(arg); pertagview(arg);

View File

@ -3,12 +3,12 @@ focusurgent(const Arg *arg)
{ {
Client *c; Client *c;
int i; int i;
for (c=selmon->clients; c && !c->isurgent; c=c->next); for (c = selmon->clients; c && !c->isurgent; c = c->next);
if (c) { 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) { if (i < NUMTAGS) {
const Arg a = {.ui = 1 << i}; if (((1 << i) & TAGMASK) != selmon->tagset[selmon->seltags])
view(&a); view(&((Arg) { .ui = 1 << i }));
focus(c); focus(c);
} }
} }

View File

@ -936,6 +936,14 @@
*/ */
#define VIEWONTAG_PATCH 0 #define VIEWONTAG_PATCH 0
/* By default tags can be changed using MOD+<num> while MOD+Tab toggles between the current and
* the previous tag. This patch changes this so that if you hit MOD+<num> 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 /* 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. * when the mouse cursor is (a) on a different screen or (b) on top of a different window.
* https://dwm.suckless.org/patches/warp/ * https://dwm.suckless.org/patches/warp/