Skip to content

Commit

Permalink
Adding proposed view history patch ref. bakkeby#327
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkeby authored and UtkarshVerma committed Feb 19, 2023
1 parent 59cb087 commit 610a7ae
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions dwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -499,7 +500,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;
Expand Down Expand Up @@ -1607,7 +1612,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;
Expand Down Expand Up @@ -4917,7 +4927,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
Expand Down
10 changes: 10 additions & 0 deletions patches.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -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/
*/
Expand Down

0 comments on commit 610a7ae

Please sign in to comment.