about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--client.c14
-rw-r--r--dwm.h6
-rw-r--r--event.c5
-rw-r--r--main.c7
-rw-r--r--tag.c31
6 files changed, 35 insertions, 30 deletions
diff --git a/Makefile b/Makefile
index 24947f1..b1378b8 100644
--- a/Makefile
+++ b/Makefile
@@ -36,7 +36,7 @@ dist: clean
 	@echo creating dist tarball
 	@mkdir -p dwm-${VERSION}
 	@cp -R LICENSE Makefile README config.*.h config.mk \
-		dwm.1 dwm.h ${SRC} dwm-${VERSION}
+		dwm.1 dwm.h tile.h ${SRC} dwm-${VERSION}
 	@tar -cf dwm-${VERSION}.tar dwm-${VERSION}
 	@gzip dwm-${VERSION}.tar
 	@rm -rf dwm-${VERSION}
diff --git a/client.c b/client.c
index ed19d9c..22408f2 100644
--- a/client.c
+++ b/client.c
@@ -297,16 +297,6 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
 }
 
 void
-togglefloating(const char *arg) {
-	if(!sel || isfloating())
-		return;
-	sel->isfloating = !sel->isfloating;
-	if(sel->isfloating)
-		resize(sel, sel->x, sel->y, sel->w, sel->h, True);
-	arrange();
-}
-
-void
 unban(Client *c) {
 	if(!c->isbanned)
 		return;
@@ -316,7 +306,7 @@ unban(Client *c) {
 }
 
 void
-unmanage(Client *c) {
+unmanage(Client *c, long state) {
 	XWindowChanges wc;
 
 	wc.border_width = c->oldborder;
@@ -329,7 +319,7 @@ unmanage(Client *c) {
 	if(sel == c)
 		focus(NULL);
 	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
-	setclientstate(c, WithdrawnState);
+	setclientstate(c, state);
 	free(c->tags);
 	free(c);
 	XSync(dpy, False);
diff --git a/dwm.h b/dwm.h
index 236c780..509b845 100644
--- a/dwm.h
+++ b/dwm.h
@@ -81,7 +81,7 @@ extern int wax, way, wah, waw;			/* windowarea geometry */
 extern unsigned int bh, blw, bpos;		/* bar height, bar layout label width, bar position */
 extern unsigned int ntags, numlockmask;		/* number of tags, numlock mask */
 extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
-extern Atom dwmtags, wmatom[WMLast], netatom[NetLast];
+extern Atom dwmconfig, wmatom[WMLast], netatom[NetLast];
 extern Bool selscreen, *seltag;			/* seltag is array of Bool */
 extern Client *clients, *sel, *stack;		/* global client list and stack */
 extern Cursor cursor[CurLast];
@@ -99,9 +99,8 @@ void killclient(const char *arg);	/* kill sel  nicely */
 void manage(Window w, XWindowAttributes *wa);	/* manage new client */
 void resize(Client *c, int x, int y,
 		int w, int h, Bool sizehints);	/* resize with given coordinates c*/
-void togglefloating(const char *arg);	/* toggles sel between floating/tiled state */
 void unban(Client *c);			/* unbans c */
-void unmanage(Client *c);		/* destroy c */
+void unmanage(Client *c, long state);	/* unmanage c */
 void updatesizehints(Client *c);	/* update the size hint variables of c */
 void updatetitle(Client *c);		/* update the name of c */
 
@@ -136,6 +135,7 @@ void compileregs(void);			/* initialize regexps of rules defined in config.h */
 Bool isvisible(Client *c);		/* returns True if client is visible */
 void settags(Client *c, Client *trans);	/* sets tags of c */
 void tag(const char *arg);		/* tags sel with arg's index */
+void togglefloating(const char *arg);	/* toggles sel between floating/tiled state */
 void toggletag(const char *arg);	/* toggles sel tags with arg's index */
 void toggleview(const char *arg);	/* toggles the tag with arg's index (in)visible */
 void view(const char *arg);		/* views the tag with arg's index */
diff --git a/event.c b/event.c
index 4bedf18..b8a16a7 100644
--- a/event.c
+++ b/event.c
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 #include <X11/keysym.h>
 #include <X11/Xatom.h>
+#include <X11/Xutil.h>
 
 /* static */
 
@@ -226,7 +227,7 @@ destroynotify(XEvent *e) {
 	XDestroyWindowEvent *ev = &e->xdestroywindow;
 
 	if((c = getclient(ev->window)))
-		unmanage(c);
+		unmanage(c, WithdrawnState);
 }
 
 static void
@@ -338,7 +339,7 @@ unmapnotify(XEvent *e) {
 
 	if((c = getclient(ev->window)) && (ev->event == root)) {
 		if(ev->send_event || c->unmapped-- == 0)
-			unmanage(c);
+			unmanage(c, WithdrawnState);
 	}
 }
 
diff --git a/main.c b/main.c
index 2140d89..6d84a77 100644
--- a/main.c
+++ b/main.c
@@ -11,6 +11,7 @@
 #include <X11/keysym.h>
 #include <X11/Xatom.h>
 #include <X11/Xproto.h>
+#include <X11/Xutil.h>
 
 /* extern */
 
@@ -19,7 +20,7 @@ int screen, sx, sy, sw, sh, wax, way, waw, wah;
 unsigned int bh, ntags;
 unsigned int bpos = BARPOS;
 unsigned int numlockmask = 0;
-Atom dwmtags, wmatom[WMLast], netatom[NetLast];
+Atom dwmconfig, wmatom[WMLast], netatom[NetLast];
 Bool *seltag;
 Bool selscreen = True;
 Client *clients = NULL;
@@ -41,7 +42,7 @@ cleanup(void) {
 	close(STDIN_FILENO);
 	while(stack) {
 		unban(stack);
-		unmanage(stack);
+		unmanage(stack, NormalState);
 	}
 	if(dc.font.set)
 		XFreeFontSet(dpy, dc.font.set);
@@ -139,7 +140,7 @@ setup(void) {
 	XSetWindowAttributes wa;
 
 	/* init atoms */
-	dwmtags = XInternAtom(dpy, "__DWM_TAGS", False);
+	dwmconfig = XInternAtom(dpy, "_DWM_CONFIG", False);
 	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
 	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
 	wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
diff --git a/tag.c b/tag.c
index a532761..cb1a2c4 100644
--- a/tag.c
+++ b/tag.c
@@ -28,14 +28,15 @@ static unsigned int nrules = 0;
 static char prop[512];
 
 static void
-persisttags(Client *c)
-{
+persistconfig(Client *c) {
 	unsigned int i;
 
 	for(i = 0; i < ntags && i < sizeof prop - 1; i++)
-		prop[i] = c->tags[i] ? '+' : '-';
+		prop[i] = c->tags[i] ? '1' : '0';
+	if(i < sizeof prop - 1)
+		prop[i++] = c->isfloating ? '1' : '0';
 	prop[i] = '\0';
-	XChangeProperty(dpy, c->win, dwmtags, XA_STRING, 8,
+	XChangeProperty(dpy, c->win, dwmconfig, XA_STRING, 8,
 			PropModeReplace, (unsigned char *)prop, i);
 }
 
@@ -93,14 +94,16 @@ settags(Client *c, Client *trans) {
 	else {
 		/* check if window has set a property */
 		name.nitems = 0;
-		XGetTextProperty(dpy, c->win, &name, dwmtags);
+		XGetTextProperty(dpy, c->win, &name, dwmconfig);
 		if(name.nitems && name.encoding == XA_STRING) {
 			strncpy(prop, (char *)name.value, sizeof prop - 1);
 			prop[sizeof prop - 1] = '\0';
 			XFree(name.value);
 			for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
-				if((c->tags[i] = prop[i] == '+'))
+				if((c->tags[i] = prop[i] == '1'))
 					matched = True;
+			if(i < sizeof prop - 1 && prop[i] != '\0')
+				c->isfloating = prop[i] == '1';
 		}
 	}
 	if(!matched) {
@@ -127,7 +130,7 @@ settags(Client *c, Client *trans) {
 	if(!matched)
 		for(i = 0; i < ntags; i++)
 			c->tags[i] = seltag[i];
-	persisttags(c);
+	persistconfig(c);
 }
 
 void
@@ -142,7 +145,17 @@ tag(const char *arg) {
 	if(i >= 0 && i < ntags)
 		sel->tags[i] = True;
 	if(sel)
-		persisttags(sel);
+		persistconfig(sel);
+	arrange();
+}
+
+void
+togglefloating(const char *arg) {
+	if(!sel || isfloating())
+		return;
+	sel->isfloating = !sel->isfloating;
+	if(sel->isfloating)
+		resize(sel, sel->x, sel->y, sel->w, sel->h, True);
 	arrange();
 }
 
@@ -158,7 +171,7 @@ toggletag(const char *arg) {
 	if(j == ntags)
 		sel->tags[i] = True;
 	if(sel)
-		persisttags(sel);
+		persistconfig(sel);
 	arrange();
 }
 
k/mu/commit/sandbox/008-sandbox-edit.mu?h=hlt&id=ceeb92d470c29613f6a036f9c2077126ecc09b47'>ceeb92d4 ^
607ddf33 ^
fa94f4d9 ^



607ddf33 ^
fa94f4d9 ^
3d8b137c ^
607ddf33 ^


29cc15d6 ^
aaf61a53 ^
ada5eb55 ^
fa94f4d9 ^


607ddf33 ^
2d91279b ^
fa94f4d9 ^
4a48bedc ^
607ddf33 ^
3d8b137c ^
dd660682 ^
607ddf33 ^
2d91279b ^
607ddf33 ^
3d8b137c ^



dd660682 ^
607ddf33 ^
2d91279b ^
607ddf33 ^
fa94f4d9 ^

2d91279b ^
fa94f4d9 ^
4a48bedc ^
607ddf33 ^
2d91279b ^
dd660682 ^

607ddf33 ^
ea19d0dc ^
2d91279b ^
607ddf33 ^



fa94f4d9 ^


6f65d591 ^
e00d4854 ^
fa94f4d9 ^
294b2ab3 ^



7b38bc8e ^
6d12a8c4 ^
fa94f4d9 ^



294b2ab3 ^
fa94f4d9 ^


ceeb92d4 ^
607ddf33 ^
7b38bc8e ^
fa94f4d9 ^





ceeb92d4 ^
fa94f4d9 ^
fa94f4d9 ^


607ddf33 ^
fa94f4d9 ^

294b2ab3 ^
fa94f4d9 ^


7b38bc8e ^
ceeb92d4 ^
fa94f4d9 ^



e0d69d3b ^

6f65d591 ^
e0d69d3b ^


294b2ab3 ^


6f65d591 ^
e0d69d3b ^






11569717 ^

e0d69d3b ^
294b2ab3 ^
e0d69d3b ^

ceeb92d4 ^
607ddf33 ^
e0d69d3b ^

ceeb92d4 ^
e0d69d3b ^



607ddf33 ^
e0d69d3b ^

294b2ab3 ^
e0d69d3b ^




ceeb92d4 ^
607ddf33 ^
e0d69d3b ^

ceeb92d4 ^
e0d69d3b ^


95425355 ^

6f65d591 ^
95425355 ^


294b2ab3 ^


6f65d591 ^
294b2ab3 ^
95425355 ^






294b2ab3 ^
95425355 ^


ceeb92d4 ^
607ddf33 ^
95425355 ^

ceeb92d4 ^
607ddf33 ^
95425355 ^


607ddf33 ^
95425355 ^


294b2ab3 ^
95425355 ^




ceeb92d4 ^
607ddf33 ^
95425355 ^

ceeb92d4 ^
607ddf33 ^
95425355 ^


11569717 ^


95425355 ^

294b2ab3 ^
95425355 ^
294b2ab3 ^
95425355 ^

ceeb92d4 ^
607ddf33 ^
95425355 ^

ceeb92d4 ^
95425355 ^


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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319