about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--config.def.h1
-rw-r--r--config.mk2
-rw-r--r--dwm.c54
3 files changed, 35 insertions, 22 deletions
diff --git a/config.def.h b/config.def.h
index 5a18854..1636dc6 100644
--- a/config.def.h
+++ b/config.def.h
@@ -49,6 +49,7 @@ Key keys[] = { \
 	{ MODKEY,			XK_l,		setmwfact,	"+0.05" }, \
 	{ MODKEY,			XK_m,		togglemax,	NULL }, \
 	{ MODKEY,			XK_Return,	zoom,		NULL }, \
+	{ MODKEY,			XK_Tab,		viewprevtag,	NULL }, \
 	{ MODKEY|ShiftMask,		XK_space,	togglefloating,	NULL }, \
 	{ MODKEY|ShiftMask,		XK_c,		killclient,	NULL }, \
 	{ MODKEY,			XK_0,		view,		NULL }, \
diff --git a/config.mk b/config.mk
index 1c92834..9944f2a 100644
--- a/config.mk
+++ b/config.mk
@@ -17,7 +17,7 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
 # flags
 CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
 LDFLAGS = -s ${LIBS}
-#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
+#CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
 #LDFLAGS = -g ${LIBS}
 
 # Solaris
diff --git a/dwm.c b/dwm.c
index 9e9e748..a4447f6 100644
--- a/dwm.c
+++ b/dwm.c
@@ -58,6 +58,22 @@ enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
 /* typedefs */
 typedef struct Client Client;
 
+struct Client {
+	char name[256];
+	int x, y, w, h;
+	int rx, ry, rw, rh; /* revert geometry */
+	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
+	int minax, maxax, minay, maxay;
+	long flags;
+	unsigned int border, oldborder;
+	Bool isbanned, isfixed, ismax, isfloating, wasfloating;
+	Bool *tags;
+	Client *next;
+	Client *prev;
+	Client *snext;
+	Window win;
+};
+
 typedef struct {
 	int x, y, w, h;
 	unsigned long norm[ColLast];
@@ -170,6 +186,7 @@ void updatebarpos(void);
 void updatesizehints(Client *c);
 void updatetitle(Client *c);
 void view(const char *arg);
+void viewprevtag(const char *arg);	/* views previous selected tags */
 int xerror(Display *dpy, XErrorEvent *ee);
 int xerrordummy(Display *dsply, XErrorEvent *ee);
 int xerrorstart(Display *dsply, XErrorEvent *ee);
@@ -219,22 +236,7 @@ Regs *regs = NULL;
 /* Statically define the number of tags. */
 unsigned int ntags = sizeof tags / sizeof tags[0];
 Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True};
-
-struct Client {
-	char name[256];
-	int x, y, w, h;
-	int rx, ry, rw, rh; /* revert geometry */
-	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
-	int minax, maxax, minay, maxay;
-	long flags;
-	unsigned int border, oldborder;
-	Bool isbanned, isfixed, ismax, isfloating, wasfloating;
-	Bool tags[sizeof tags / sizeof tags[0]];
-	Client *next;
-	Client *prev;
-	Client *snext;
-	Window win;
-};
+Bool prevtags[sizeof tags / sizeof tags[0]] = {[0] = True};
 
 /* functions*/
 void
@@ -265,8 +267,7 @@ applyrules(Client *c) {
 	if(ch.res_name)
 		XFree(ch.res_name);
 	if(!matched)
-		for(i = 0; i < ntags; i++)
-			c->tags[i] = seltags[i];
+		memcpy(c->tags, seltags, sizeof seltags);
 }
 
 void
@@ -1002,13 +1003,13 @@ leavenotify(XEvent *e) {
 
 void
 manage(Window w, XWindowAttributes *wa) {
-	unsigned int i;
 	Client *c, *t = NULL;
 	Window trans;
 	Status rettrans;
 	XWindowChanges wc;
 
 	c = emallocz(sizeof(Client));
+	c->tags = emallocz(sizeof seltags);
 	c->win = w;
 	c->x = wa->x;
 	c->y = wa->y;
@@ -1043,8 +1044,7 @@ manage(Window w, XWindowAttributes *wa) {
 	if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
 		for(t = clients; t && t->win != trans; t = t->next);
 	if(t)
-		for(i = 0; i < ntags; i++)
-			c->tags[i] = t->tags[i];
+		memcpy(c->tags, t->tags, sizeof seltags);
 	applyrules(c);
 	if(!c->isfloating)
 		c->isfloating = (rettrans == Success) || c->isfixed;
@@ -1702,6 +1702,7 @@ unmanage(Client *c) {
 		focus(NULL);
 	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
 	setclientstate(c, WithdrawnState);
+	free(c->tags);
 	free(c);
 	XSync(dpy, False);
 	XSetErrorHandler(xerror);
@@ -1838,6 +1839,7 @@ void
 view(const char *arg) {
 	unsigned int i;
 
+	memcpy(prevtags, seltags, sizeof seltags);
 	for(i = 0; i < ntags; i++)
 		seltags[i] = arg == NULL;
 	i = idxoftag(arg);
@@ -1847,6 +1849,16 @@ view(const char *arg) {
 }
 
 void
+viewprevtag(const char *arg) {
+	static Bool tmptags[sizeof tags / sizeof tags[0]];
+
+	memcpy(tmptags, seltags, sizeof seltags);
+	memcpy(seltags, prevtags, sizeof seltags);
+	memcpy(prevtags, tmptags, sizeof seltags);
+	arrange();
+}
+
+void
 zoom(const char *arg) {
 	Client *c;
 
sion' href='/acidbong/suckless/dwm/blame/view.c?id=7b6d5ff29863e4bc7ba787357133ffb9bc5157e6'>^
5983c00 ^
c107db5 ^
26157e6 ^
aa13727 ^
aa13727 ^





15abade ^
0925dd5 ^

15abade ^
aa13727 ^



5983c00 ^
b003a35 ^
c107db5 ^
26157e6 ^
7d7cde0 ^

b003a35 ^

aa13727 ^
ce9a993 ^
aa13727 ^




7d7cde0 ^
b003a35 ^

8fa47ac ^
b003a35 ^

aa13727 ^
8fa47ac ^
b003a35 ^


aa13727 ^
2583a7c ^
acdea31 ^

2583a7c ^
b003a35 ^

2583a7c ^
acdea31 ^
b003a35 ^
aa13727 ^

ce9a993 ^
aa13727 ^


6651dd7 ^
15abade ^
0925dd5 ^

15abade ^
aa13727 ^



ca65478 ^
aa13727 ^



aa13727 ^








ca65478 ^
aa13727 ^



aa13727 ^









40bd21c ^
ca65478 ^
40bd21c ^







6499fc4 ^
4b5b3d9 ^
f78c16f ^






5983c00 ^
6499fc4 ^

aa13727 ^
6b25d06 ^
aa13727 ^

67986e8 ^
c60de1a ^

aa13727 ^
c60de1a ^
69b738c ^


aa13727 ^
7225c99 ^




69b738c ^
7225c99 ^

69b738c ^

aa13727 ^
7225c99 ^
aa13727 ^





ca65478 ^
b5159df ^
aa13727 ^
5983c00 ^
aa13727 ^




ca65478 ^
aa13727 ^





5983c00 ^
fee8df6 ^


ca65478 ^
aa13727 ^




5983c00 ^
aa13727 ^


ca65478 ^
daae3bb ^



5983c00 ^
daae3bb ^


ca65478 ^
ec85fdd ^

d800ec0 ^


d800ec0 ^
346bdea ^
d800ec0 ^

0915da8 ^

ec85fdd ^
cff951c ^
aa13727 ^
0915da8 ^
f18ed61 ^
0d0e8bd ^
d22abee ^




8a6679b ^
5983c00 ^
aa13727 ^
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268