Adding proposed view history patch ref. #327

This commit is contained in:
bakkeby 2023-01-18 21:58:32 +01:00
parent 40e2cac4e9
commit 954e60b735
3 changed files with 40 additions and 0 deletions

View File

@ -19,6 +19,8 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
### Changelog:
2023-01-18 - Added the view history patch
2022-10-08 - Added the alt-tab patch
2022-08-12 - Added the nametag patch
@ -802,6 +804,11 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
- adds configurable gaps between windows differentiating between outer, inner, horizontal and
vertical gaps
- viewhistory
- adds a tag change history that is longer than the default current and previous tag
- `MOD`+Tab (`view(0)`) can be pressed multiple times to go further back to earlier tag
selections
- [viewontag](https://dwm.suckless.org/patches/viewontag/)
- follow a window to the tag it is being moved to

23
dwm.c
View File

@ -76,6 +76,7 @@
#define Button8 8
#define Button9 9
#define NUMTAGS 9
#define NUMVIEWHIST NUMTAGS
#define BARRULES 20
#if TAB_PATCH
#define MAXTABS 50
@ -487,7 +488,11 @@ struct Monitor {
#endif // SETBORDERPX_PATCH
unsigned int seltags;
unsigned int sellt;
#if VIEW_HISTORY_PATCH
unsigned int tagset[NUMVIEWHIST];
#else
unsigned int tagset[2];
#endif // VIEW_HISTORY_PATCH
int showbar;
#if TAB_PATCH
int showtab;
@ -1595,7 +1600,12 @@ createmon(void)
m = ecalloc(1, sizeof(Monitor));
#if !EMPTYVIEW_PATCH
#if VIEW_HISTORY_PATCH
for (i = 0; i < LENGTH(m->tagset); i++)
m->tagset[i] = 1;
#else
m->tagset[0] = m->tagset[1] = 1;
#endif // VIEW_HISTORY_PATCH
#endif // EMPTYVIEW_PATCH
m->mfact = mfact;
m->nmaster = nmaster;
@ -4905,7 +4915,20 @@ view(const Arg *arg)
#if BAR_TAGPREVIEW_PATCH
tagpreviewswitchtag();
#endif // BAR_TAGPREVIEW_PATCH
#if VIEW_HISTORY_PATCH
if (!arg->ui) {
selmon->seltags += 1;
if (selmon->seltags == LENGTH(selmon->tagset))
selmon->seltags = 0;
} else {
if (selmon->seltags == 0)
selmon->seltags = LENGTH(selmon->tagset) - 1;
else
selmon->seltags -= 1;
}
#else
selmon->seltags ^= 1; /* toggle sel tagset */
#endif // VIEW_HISTORY_PATCH
if (arg->ui & TAGMASK)
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
#if PERTAG_PATCH

View File

@ -1311,6 +1311,16 @@
*/
#define VANITYGAPS_MONOCLE_PATCH 0
/* By default MOD+Tab will take the user back to the previous tag only. If the user keeps
* using MOD+Tab then the view will switch back and forth between the current and previous tag.
* This patch allows dwm to keep a longer history of previous tag changes such that MOD+Tab can
* be pressed multiple times to go further back to earlier tag selections.
*
* The number of history elements is defined by the NUMVIEWHIST macro in dwm.c and defaults to
* the number of tags in the system.
*/
#define VIEW_HISTORY_PATCH 0
/* Follow a window to the tag it is being moved to.
* https://dwm.suckless.org/patches/viewontag/
*/