Add remembertags-pertag patch

This commit is contained in:
markus-langgeng 2025-03-31 13:42:09 +07:00
parent 93523c00fb
commit 5fc962c218
No known key found for this signature in database
2 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,25 @@
### Description
Based on the original remembertags patch by minego.
This patch expects the pertag patch to be applied first.
To quote from the original remembertags patch:
> This patch modifies the behavior when selecting tags so that selecting a tag will also enable any other tags that were previously visible.
>
> For example:
>
> 1. Select tag 5, with mod+5
> 2. Toggle tag 8, with ctrl+mod+8
> 3. Select tag 1, with mod+1. Tags 5 and 8 should no longer be visible.
> 4. Select tag 5 again, with mod+5. Tag 8 should be visible since it was remembered.
> 5. Select tag 5 again, with mod_5. Selecting the already selected tag resets any remembered tags, so now tag 5 should be the only one visible.
Remember to change `TAGCOUNT` to `(int)LENGTH(tags)` if you're also using bar patch.
### Download
- [git branch](/markus-langgeng/dwl/src/branch/0.7-remembertags-pertag)
- [0.7](/dwl/dwl-patches/raw/branch/main/patches/remembertags-pertag/remembertags-pertag.patch)
### Author
- [markus-langgeng](https://codeberg.org/markus-langgeng)

View File

@ -0,0 +1,80 @@
From d0c296b215f8a20ad654ff702abd5e6d7e7e3605 Mon Sep 17 00:00:00 2001
From: markus-langgeng <markus.langgeng4@gmail.com>
Date: Mon, 31 Mar 2025 12:53:52 +0700
Subject: [PATCH] Add remembertags-pertag
Based on the original remembertags patch but requires the pertag patch
to be applied first.
fix out-of-bound access when is 0
---
dwl.c | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/dwl.c b/dwl.c
index d234cd2..26bf772 100644
--- a/dwl.c
+++ b/dwl.c
@@ -209,6 +209,11 @@ struct Monitor {
int gamma_lut_changed;
int nmaster;
char ltsymbol[16];
+ unsigned int createtag[2]; /* Create windows on the last tag directly selected, not all selected */
+ struct {
+ unsigned int tagset;
+ Client *zoomed;
+ } remembered[31];
int asleep;
};
@@ -2993,26 +2998,43 @@ void
view(const Arg *arg)
{
size_t i, tmptag;
+ int oldtag;
+ unsigned int newcreate;
if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
+
+ oldtag = selmon->createtag[selmon->seltags];
+ if (oldtag < TAGCOUNT) {
+ selmon->remembered[oldtag].tagset = selmon->tagset[selmon->seltags];
+ }
+
selmon->seltags ^= 1; /* toggle sel tagset */
if (arg->ui & ~0) {
- selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ for (i = 0; !(arg->ui & 1 << i); i++) {};
+ newcreate = arg->ui & TAGMASK;
+ if (oldtag == (int)i + 1) {
+ /* Select twice to isolate the tag */
+ selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
+ } else {
+ /* Restore whatever was previously on this tag */
+ selmon->tagset[selmon->seltags] = (arg->ui & TAGMASK) | selmon->remembered[newcreate].tagset;
+ }
+
selmon->pertag->prevtag = selmon->pertag->curtag;
if (arg->ui == TAGMASK)
selmon->pertag->curtag = 0;
- else {
- for (i = 0; !(arg->ui & 1 << i); i++) ;
+ else
selmon->pertag->curtag = i + 1;
- }
} else {
+ newcreate = selmon->createtag[selmon->seltags];
tmptag = selmon->pertag->prevtag;
selmon->pertag->prevtag = selmon->pertag->curtag;
selmon->pertag->curtag = tmptag;
}
+ selmon->createtag[selmon->seltags] = newcreate;
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
--
2.47.2