about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@gmail.com>2007-08-18 14:20:56 +0200
committerAnselm R. Garbe <garbeam@gmail.com>2007-08-18 14:20:56 +0200
commit0c6062041035105c6266f6bedb286c1990516fa7 (patch)
tree0333fb545f61fa6a409e8fd9d1167ee2f9b25428
parent50be6c8b67c500ee4aa07919609fa80785fd389d (diff)
downloaddwm-0c6062041035105c6266f6bedb286c1990516fa7.tar.gz
hmm I doubt the usefulness of storing this information...
-rw-r--r--client.c38
-rw-r--r--config.mk4
-rw-r--r--dwm.h8
-rw-r--r--layout.c40
-rw-r--r--main.c5
-rw-r--r--tag.c10
6 files changed, 74 insertions, 31 deletions
diff --git a/client.c b/client.c
index 882b8ee..d11ef7f 100644
--- a/client.c
+++ b/client.c
@@ -7,7 +7,7 @@
 
 /* static */
 
-static char config[128];
+static char prop[128];
 
 static void
 attachstack(Client *c) {
@@ -182,23 +182,23 @@ killclient(const char *arg) {
 }
 
 Bool
-loadconfig(Client *c) {
+loadprops(Client *c) {
 	unsigned int i;
 	Bool result = False;
 	XTextProperty name;
 
 	/* check if window has set a property */
 	name.nitems = 0;
-	XGetTextProperty(dpy, c->win, &name, dwmconfig);
+	XGetTextProperty(dpy, c->win, &name, dwmprops);
 	if(name.nitems && name.encoding == XA_STRING) {
-		strncpy(config, (char *)name.value, sizeof config - 1);
-		config[sizeof config - 1] = '\0';
+		strncpy(prop, (char *)name.value, sizeof prop - 1);
+		prop[sizeof prop - 1] = '\0';
 		XFree(name.value);
-		for(i = 0; i < ntags && i < sizeof config - 1 && config[i] != '\0'; i++)
-			if((c->tags[i] = config[i] == '1'))
+		for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
+			if((c->tags[i] = prop[i] == '1'))
 				result = True;
-		if(i < sizeof config - 1 && config[i] != '\0')
-			c->isfloating = config[i] == '1';
+		if(i < sizeof prop - 1 && prop[i] != '\0')
+			c->isfloating = prop[i] == '1';
 	}
 	return result;
 }
@@ -249,11 +249,11 @@ manage(Window w, XWindowAttributes *wa) {
 	if(t)
 		for(i = 0; i < ntags; i++)
 			c->tags[i] = t->tags[i];
-	if(!loadconfig(c))
+	if(!loadprops(c))
 		applyrules(c);
 	if(!c->isfloating)
 		c->isfloating = (rettrans == Success) || c->isfixed;
-	saveconfig(c);
+	saveprops(c);
 	attach(c);
 	attachstack(c);
 	XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */
@@ -325,16 +325,16 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
 }
 
 void
-saveconfig(Client *c) {
+saveprops(Client *c) {
 	unsigned int i;
 
-	for(i = 0; i < ntags && i < sizeof config - 1; i++)
-		config[i] = c->tags[i] ? '1' : '0';
-	if(i < sizeof config - 1)
-		config[i++] = c->isfloating ? '1' : '0';
-	config[i] = '\0';
-	XChangeProperty(dpy, c->win, dwmconfig, XA_STRING, 8,
-			PropModeReplace, (unsigned char *)config, i);
+	for(i = 0; i < ntags && i < sizeof prop - 1; 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, dwmprops, XA_STRING, 8,
+			PropModeReplace, (unsigned char *)prop, i);
 }
 
 void
diff --git a/config.mk b/config.mk
index 320aea1..682bb41 100644
--- a/config.mk
+++ b/config.mk
@@ -20,8 +20,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
 # flags
 CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
 LDFLAGS = -s ${LIBS}
-#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
-#LDFLAGS = -g ${LIBS}
+CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
+LDFLAGS = -g ${LIBS}
 
 # Solaris
 #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
diff --git a/dwm.h b/dwm.h
index fde6b96..9dd764f 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 dwmconfig, wmatom[WMLast], netatom[NetLast];
+extern Atom dwmprops, wmatom[WMLast], netatom[NetLast];
 extern Bool selscreen, *seltags;		/* seltags is array of Bool */
 extern Client *clients, *sel, *stack;		/* global client list and stack */
 extern Cursor cursor[CurLast];
@@ -96,11 +96,11 @@ void configure(Client *c);		/* send synthetic configure event */
 void detach(Client *c);			/* detaches c from global client list */
 void focus(Client *c);			/* focus c if visible && !NULL, or focus top visible */
 void killclient(const char *arg);	/* kill sel  nicely */
-Bool loadconfig(Client *c);		/* loads client properties */
+Bool loadprops(Client *c);		/* loads client properties */
 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 saveconfig(Client *c);		/* saves client properties */
+void saveprops(Client *c);		/* saves client properties */
 void unban(Client *c);			/* unbans c */
 void unmanage(Client *c, long state);	/* unmanage c */
 void updatesizehints(Client *c);	/* update the size hint variables of c */
@@ -122,8 +122,10 @@ const char *getsymbol(void);		/* returns symbol of enabled layout */
 Bool isfloating(void);			/* returns True if floating layout is enabled */
 Bool isarrange(void (*func)());		/* returns True if func is the layout function in use */
 void initlayouts(void);			/* initialize layout array */
+void loaddwmprops(void);		/* loads dwm properties */
 Client *nexttiled(Client *c);		/* returns tiled successor of c */
 void restack(void);			/* restores z layers of all clients */
+void savedwmprops(void);		/* saves dwm properties */
 void setlayout(const char *arg);	/* sets layout, NULL means next layout */
 void togglebar(const char *arg);	/* shows/hides the bar */
 void togglemax(const char *arg);	/* toggles maximization of floating client */
diff --git a/layout.c b/layout.c
index 030c282..aa3bff5 100644
--- a/layout.c
+++ b/layout.c
@@ -1,6 +1,9 @@
 /* See LICENSE file for copyright and license details. */
 #include "dwm.h"
 #include <stdlib.h>
+#include <string.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
 
 /* static */
 
@@ -10,6 +13,7 @@ typedef struct {
 } Layout;
 
 unsigned int blw = 0;
+static char prop[128];
 static unsigned int ltidx = 0; /* default */
 
 static void
@@ -103,6 +107,28 @@ initlayouts(void) {
 	}
 }
 
+void
+loaddwmprops(void) {
+	unsigned int i;
+	XTextProperty name;
+
+	/* check if window has set a property */
+	name.nitems = 0;
+	XGetTextProperty(dpy, root, &name, dwmprops);
+	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++)
+			seltags[i] = prop[i] == '1';
+		if(i < sizeof prop - 1 && prop[i] != '\0') {
+			i = prop[i] - '0';
+			if(i < nlayouts)
+				ltidx = i;
+		}
+	}
+}
+
 Client *
 nexttiled(Client *c) {
 	for(; c && (c->isfloating || !isvisible(c)); c = c->next);
@@ -139,6 +165,19 @@ restack(void) {
 }
 
 void
+savedwmprops(void) {
+	unsigned int i;
+
+	for(i = 0; i < ntags && i < sizeof prop - 1; i++)
+		prop[i] = seltags[i] ? '1' : '0';
+	if(i < sizeof prop - 1)
+		prop[i++] = (char)ltidx;
+	prop[i] = '\0';
+	XChangeProperty(dpy, root, dwmprops, XA_STRING, 8,
+			PropModeReplace, (unsigned char *)prop, i);
+}
+
+void
 setlayout(const char *arg) {
 	int i;
 
@@ -156,6 +195,7 @@ setlayout(const char *arg) {
 		arrange();
 	else
 		drawstatus();
+	savedwmprops();
 }
 
 void
diff --git a/main.c b/main.c
index 0ae288c..7cc5ecf 100644
--- a/main.c
+++ b/main.c
@@ -20,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 dwmconfig, wmatom[WMLast], netatom[NetLast];
+Atom dwmprops, wmatom[WMLast], netatom[NetLast];
 Bool *seltags;
 Bool selscreen = True;
 Client *clients = NULL;
@@ -140,7 +140,7 @@ setup(void) {
 	XSetWindowAttributes wa;
 
 	/* init atoms */
-	dwmconfig = XInternAtom(dpy, "_DWM_CONFIG", False);
+	dwmprops = XInternAtom(dpy, "_DWM_PROPERTIES", False);
 	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
 	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
 	wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
@@ -205,6 +205,7 @@ setup(void) {
 		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
 	/* multihead support */
 	selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
+	loaddwmprops();
 }
 
 /*
diff --git a/tag.c b/tag.c
index 1dd542b..685308a 100644
--- a/tag.c
+++ b/tag.c
@@ -3,8 +3,6 @@
 #include <regex.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <X11/Xatom.h>
 #include <X11/Xutil.h>
 
 /* static */
@@ -118,7 +116,7 @@ tag(const char *arg) {
 	i = idxoftag(arg);
 	if(i >= 0 && i < ntags)
 		sel->tags[i] = True;
-	saveconfig(sel);
+	saveprops(sel);
 	arrange();
 }
 
@@ -129,7 +127,7 @@ togglefloating(const char *arg) {
 	sel->isfloating = !sel->isfloating;
 	if(sel->isfloating) {
 		resize(sel, sel->x, sel->y, sel->w, sel->h, True);
-		saveconfig(sel);
+		saveprops(sel);
 	}
 	arrange();
 }
@@ -145,7 +143,7 @@ toggletag(const char *arg) {
 	for(j = 0; j < ntags && !sel->tags[j]; j++);
 	if(j == ntags)
 		sel->tags[i] = True;
-	saveconfig(sel);
+	saveprops(sel);
 	arrange();
 }
 
@@ -158,6 +156,7 @@ toggleview(const char *arg) {
 	for(j = 0; j < ntags && !seltags[j]; j++);
 	if(j == ntags)
 		seltags[i] = True; /* cannot toggle last view */
+	savedwmprops();
 	arrange();
 }
 
@@ -170,5 +169,6 @@ view(const char *arg) {
 	i = idxoftag(arg);
 	if(i >= 0 && i < ntags)
 		seltags[i] = True;
+	savedwmprops();
 	arrange();
 }
oid'>4d190a9c ^
b79e61fd ^



54c43b61 ^





b79e61fd ^


4d190a9c ^




2101f29e ^

caa95562 ^
e5d4e09f ^
9dad7a7f ^
6f69ce26 ^
2101f29e ^


2acf15de ^
c92b2688 ^
2acf15de ^



c92b2688 ^
2acf15de ^





54c43b61 ^

c92b2688 ^
2acf15de ^





c92b2688 ^

7aa1d931 ^
8c24a7c4 ^
1cc22c23 ^

8c24a7c4 ^

b3f42cd3 ^
8c24a7c4 ^
1cc22c23 ^


b3f42cd3 ^
8c24a7c4 ^

f533c6c1 ^
00f7ce62 ^




e27532d8 ^
86a6e3c1 ^
e27532d8 ^
1cc22c23 ^

00f7ce62 ^
9807c15b ^
1cc22c23 ^
6ab1a84c ^


54c43b61 ^
6ab1a84c ^



5572bbdf ^
aa26278a ^
b3ae1a7d ^
4d190a9c ^

f533c6c1 ^

bb3878bc ^
e27532d8 ^
86a6e3c1 ^
e27532d8 ^
1cc22c23 ^

00f7ce62 ^
9807c15b ^
1cc22c23 ^
9807c15b ^
1cc22c23 ^
54c43b61 ^
6ab1a84c ^
54c43b61 ^
6ab1a84c ^


bb3878bc ^

f533c6c1 ^

509888c4 ^
0dac9148 ^






54c43b61 ^


509888c4 ^

f533c6c1 ^

509888c4 ^
0dac9148 ^






54c43b61 ^


509888c4 ^

9805b2b2 ^



















bff2210b ^
e2665944 ^
da9cf900 ^
70310bb5 ^
da9cf900 ^
cfc23078 ^

cfc23078 ^
70310bb5 ^
db259f64 ^

70310bb5 ^



b3ae1a7d ^
1b7d9e9e ^
70310bb5 ^







da9cf900 ^


cfc23078 ^
da9cf900 ^
cfc23078 ^

da9cf900 ^
cfc23078 ^
70310bb5 ^
54c43b61 ^


f5013914 ^

a336148c ^
cfc23078 ^



a336148c ^
dab37236 ^

a336148c ^
db259f64 ^

6e46e8fe ^




e6b076ce ^
db259f64 ^
dab37236 ^
a336148c ^
cfc23078 ^
cfc23078 ^

f533c6c1 ^
d151b2d0 ^
1cc22c23 ^



54c43b61 ^


d151b2d0 ^

f533c6c1 ^
98dfe8bf ^
1cc22c23 ^

54c43b61 ^


d151b2d0 ^

f533c6c1 ^
e2665944 ^
1cc22c23 ^

54c43b61 ^


0c024607 ^

4f82ece2 ^
5c906167 ^
4f82ece2 ^

5c906167 ^

0ddf97e0 ^


09602a6f ^




0ddf97e0 ^
09602a6f ^
0ddf97e0 ^
09602a6f ^


54c43b61 ^

0ddf97e0 ^

7aa1d931 ^
e2665944 ^


3a8c86c6 ^
e2665944 ^
17a284b2 ^

1cc22c23 ^
0ddf97e0 ^


17a284b2 ^
f020ec9c ^
7aa1d931 ^
1cc22c23 ^



a26403f9 ^




0ddf97e0 ^
54c43b61 ^

17a284b2 ^


86a6e3c1 ^
17a284b2 ^

09602a6f ^


c9666f2f ^
17a284b2 ^
7aa1d931 ^
17a284b2 ^
e2665944 ^
0e473e34 ^
a26403f9 ^













f533c6c1 ^
0e473e34 ^


86a6e3c1 ^
0e473e34 ^


86a6e3c1 ^
e27532d8 ^
0e473e34 ^
f533c6c1 ^
e27532d8 ^


86a6e3c1 ^
e27532d8 ^





6f904646 ^
2e62950f ^
0e473e34 ^
f533c6c1 ^
5c906167 ^
09602a6f ^
5c906167 ^
1cc22c23 ^
09602a6f ^
5c906167 ^
6ab1a84c ^
5c906167 ^
6ab1a84c ^
5c906167 ^
6ab1a84c ^

5c906167 ^
54c43b61 ^

5c906167 ^

1cc22c23 ^
9807c15b ^


1cc22c23 ^
9807c15b ^

f533c6c1 ^
9807c15b ^
9807c15b ^
1cc22c23 ^

9807c15b ^
1cc22c23 ^
9807c15b ^

f533c6c1 ^
5aba98c6 ^





9dad7a7f ^
181c4236 ^
0ddf97e0 ^

09602a6f ^

09602a6f ^
181c4236 ^
dfa7c69d ^
9dad7a7f ^




3a8c86c6 ^

3a8c86c6 ^







9dad7a7f ^
9dad7a7f ^


f533c6c1 ^


dfa7c69d ^
0dac9148 ^

1cc22c23 ^
0dac9148 ^
1cc22c23 ^

dfa7c69d ^
dfa7c69d ^
0dac9148 ^
dfa7c69d ^

0dac9148 ^
dfa7c69d ^
0dac9148 ^
dfa7c69d ^

0dac9148 ^
dfa7c69d ^
0dac9148 ^
dfa7c69d ^
0dac9148 ^





dfa7c69d ^

03b0c018 ^
f533c6c1 ^
03b0c018 ^






4f82ece2 ^





























































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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632