summaryrefslogtreecommitdiffstats
path: root/dwl-patches/stale-patches/remembertags/remembertags.patch
blob: fd6135e2aea8db6bbab862f2ca769059f0810411 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
From fea6eb3cfc84ede8403c89a3230f5c658a6c7bd1 Mon Sep 17 00:00:00 2001
From: Micah N Gorrell <m@minego.net>
Date: Wed, 27 Mar 2024 13:05:09 -0600
Subject: [PATCH] remembertags

---
 config.def.h |  8 ++++----
 dwl.c        | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/config.def.h b/config.def.h
index 9009517..2312802 100644
--- a/config.def.h
+++ b/config.def.h
@@ -105,10 +105,10 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
 #define MODKEY WLR_MODIFIER_ALT
 
 #define TAGKEYS(KEY,SKEY,TAG) \
-	{ MODKEY,                    KEY,            view,            {.ui = 1 << TAG} }, \
-	{ MODKEY|WLR_MODIFIER_CTRL,  KEY,            toggleview,      {.ui = 1 << TAG} }, \
-	{ MODKEY|WLR_MODIFIER_SHIFT, SKEY,           tag,             {.ui = 1 << TAG} }, \
-	{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }
+	{ MODKEY,										KEY,	remembertagsview,	{.i = TAG} }, \
+	{ MODKEY|WLR_MODIFIER_CTRL,						KEY,	toggleview,			{.ui = 1 << TAG} }, \
+	{ MODKEY|WLR_MODIFIER_SHIFT,					SKEY,	tag,				{.ui = 1 << TAG} }, \
+	{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,	SKEY,	toggletag,			{.ui = 1 << TAG} }
 
 /* helper for spawning shell commands in the pre dwm-5.0 fashion */
 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
diff --git a/dwl.c b/dwl.c
index 5867b0c..31a81aa 100644
--- a/dwl.c
+++ b/dwl.c
@@ -205,6 +205,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];
 };
 
 typedef struct {
@@ -308,6 +313,7 @@ static void pointerfocus(Client *c, struct wlr_surface *surface,
 		double sx, double sy, uint32_t time);
 static void printstatus(void);
 static void quit(const Arg *arg);
+static void remembertagsview(const Arg *arg);
 static void rendermon(struct wl_listener *listener, void *data);
 static void requestdecorationmode(struct wl_listener *listener, void *data);
 static void requeststartdrag(struct wl_listener *listener, void *data);
@@ -1951,6 +1957,48 @@ quit(const Arg *arg)
 	wl_display_terminate(dpy);
 }
 
+void
+remembertagsview(const Arg *arg) {
+	unsigned newtags = (1 << arg->i) & TAGMASK;
+	int oldtag;
+	int active;
+	unsigned int newcreate;
+
+	if (selmon == NULL) {
+		return;
+	}
+
+	oldtag = selmon->createtag[selmon->seltags];
+	active = (oldtag == arg->i);
+
+	if (oldtag < TAGCOUNT) {
+		selmon->remembered[oldtag].tagset = selmon->tagset[selmon->seltags];
+	}
+
+	selmon->seltags ^= 1;	/*toggle tagset*/
+
+	if (-1 == arg->i) {
+		/* A specific tag was not specified */
+		active = 0;
+		newcreate = selmon->createtag[selmon->seltags];
+	} else {
+		newcreate = arg->i;
+	}
+
+	if (active) {
+		/* Select twice to isolate the tag */
+		selmon->tagset[selmon->seltags] = newtags;
+	} else if (arg->i < TAGCOUNT) {
+		/* Restore whatever was previously on this tag */
+		selmon->tagset[selmon->seltags] = newtags | selmon->remembered[newcreate].tagset;
+	}
+
+	selmon->createtag[selmon->seltags] = newcreate;
+	focusclient(focustop(selmon), 1);
+	arrange(selmon);
+	printstatus();
+}
+
 void
 rendermon(struct wl_listener *listener, void *data)
 {
-- 
2.44.0