Skip to content

Commit 610a7ae

Browse files
bakkebyUtkarshVerma
authored andcommitted
Adding proposed view history patch ref. bakkeby#327
1 parent 59cb087 commit 610a7ae

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
1919
2020
### Changelog:
2121
22+
2023-01-18 - Added the view history patch
23+
2224
2022-10-08 - Added the alt-tab patch
2325
2426
2022-08-12 - Added the nametag patch
@@ -802,6 +804,11 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
802804
- adds configurable gaps between windows differentiating between outer, inner, horizontal and
803805
vertical gaps
804806
807+
- viewhistory
808+
- adds a tag change history that is longer than the default current and previous tag
809+
- `MOD`+Tab (`view(0)`) can be pressed multiple times to go further back to earlier tag
810+
selections
811+
805812
- [viewontag](https://dwm.suckless.org/patches/viewontag/)
806813
- follow a window to the tag it is being moved to
807814

dwm.c

+23
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#define Button8 8
7777
#define Button9 9
7878
#define NUMTAGS 9
79+
#define NUMVIEWHIST NUMTAGS
7980
#define BARRULES 20
8081
#if TAB_PATCH
8182
#define MAXTABS 50
@@ -499,7 +500,11 @@ struct Monitor {
499500
#endif // SETBORDERPX_PATCH
500501
unsigned int seltags;
501502
unsigned int sellt;
503+
#if VIEW_HISTORY_PATCH
504+
unsigned int tagset[NUMVIEWHIST];
505+
#else
502506
unsigned int tagset[2];
507+
#endif // VIEW_HISTORY_PATCH
503508
int showbar;
504509
#if TAB_PATCH
505510
int showtab;
@@ -1607,7 +1612,12 @@ createmon(void)
16071612

16081613
m = ecalloc(1, sizeof(Monitor));
16091614
#if !EMPTYVIEW_PATCH
1615+
#if VIEW_HISTORY_PATCH
1616+
for (i = 0; i < LENGTH(m->tagset); i++)
1617+
m->tagset[i] = 1;
1618+
#else
16101619
m->tagset[0] = m->tagset[1] = 1;
1620+
#endif // VIEW_HISTORY_PATCH
16111621
#endif // EMPTYVIEW_PATCH
16121622
m->mfact = mfact;
16131623
m->nmaster = nmaster;
@@ -4917,7 +4927,20 @@ view(const Arg *arg)
49174927
#if BAR_TAGPREVIEW_PATCH
49184928
tagpreviewswitchtag();
49194929
#endif // BAR_TAGPREVIEW_PATCH
4930+
#if VIEW_HISTORY_PATCH
4931+
if (!arg->ui) {
4932+
selmon->seltags += 1;
4933+
if (selmon->seltags == LENGTH(selmon->tagset))
4934+
selmon->seltags = 0;
4935+
} else {
4936+
if (selmon->seltags == 0)
4937+
selmon->seltags = LENGTH(selmon->tagset) - 1;
4938+
else
4939+
selmon->seltags -= 1;
4940+
}
4941+
#else
49204942
selmon->seltags ^= 1; /* toggle sel tagset */
4943+
#endif // VIEW_HISTORY_PATCH
49214944
if (arg->ui & TAGMASK)
49224945
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
49234946
#if PERTAG_PATCH

patches.def.h

+10
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,16 @@
13111311
*/
13121312
#define VANITYGAPS_MONOCLE_PATCH 0
13131313

1314+
/* By default MOD+Tab will take the user back to the previous tag only. If the user keeps
1315+
* using MOD+Tab then the view will switch back and forth between the current and previous tag.
1316+
* This patch allows dwm to keep a longer history of previous tag changes such that MOD+Tab can
1317+
* be pressed multiple times to go further back to earlier tag selections.
1318+
*
1319+
* The number of history elements is defined by the NUMVIEWHIST macro in dwm.c and defaults to
1320+
* the number of tags in the system.
1321+
*/
1322+
#define VIEW_HISTORY_PATCH 0
1323+
13141324
/* Follow a window to the tag it is being moved to.
13151325
* https://dwm.suckless.org/patches/viewontag/
13161326
*/

0 commit comments

Comments
 (0)