about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@10kloc.org>2006-08-25 12:59:45 +0200
committerAnselm R. Garbe <arg@10kloc.org>2006-08-25 12:59:45 +0200
commitb55bd709ee6d0b09c141bf5ffe0647866e0374ef (patch)
tree50bb320829520b71e8280a298af162b0ba1508a2
parent9833610356f7ce033589680fddf87000e5788774 (diff)
downloaddwm-b55bd709ee6d0b09c141bf5ffe0647866e0374ef.tar.gz
new color stuff/new rendering stuff
-rw-r--r--config.arg.h39
-rw-r--r--config.default.h11
-rw-r--r--draw.c49
-rw-r--r--dwm.h11
-rw-r--r--event.c4
-rw-r--r--main.c14
6 files changed, 70 insertions, 58 deletions
diff --git a/config.arg.h b/config.arg.h
index 170c91c..7716916 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -4,50 +4,59 @@
  */
 
 #define TAGS \
-const char *tags[] = { "work", "net", "fnord", NULL };
+const char *tags[] = { "1", "2", "3", "4", "5", NULL };
 
 #define DEFMODE			dotile /* dofloat */
-#define FONT			"-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
-#define BGCOLOR			"#666699"
-#define FGCOLOR			"#eeeeee"
-#define BORDERCOLOR		"#9999CC"
+
+#define FONT			"fixed"
+#define SELBGCOLOR		"#666699"
+#define SELFGCOLOR		"#eeeeee"
+#define NORMBGCOLOR		"#333366"
+#define NORMFGCOLOR		"#cccccc"
+#define STATUSBGCOLOR		"#dddddd"
+#define STATUSFGCOLOR		"#222222"
+
 #define MODKEY			Mod1Mask
 #define MASTERW			60 /* percent */
 
 #define KEYS \
 static Key key[] = { \
 	/* modifier			key		function	arguments */ \
-	{ MODKEY|ShiftMask,		XK_Return,	spawn, \
-		{ .cmd = "exec uxterm -bg '#e0e0e0' -fg '#000000' -cr '#000000' +sb -fn '"FONT"'" } }, \
-	{ MODKEY,			XK_p,		spawn, \
-		{ .cmd = "exec `ls -lL /usr/bin /usr/X11R6/bin /usr/local/bin 2>/dev/null | " \
-			"awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort -u | dmenu`" } }, \
-	{ MODKEY,			XK_j,		focusnext,	{ 0 } }, \
-	{ MODKEY,			XK_k,		focusprev,	{ 0 } }, \
+	{ MODKEY|ShiftMask,		XK_Return,	spawn,		{ .cmd = "exec xterm" } }, \
+	{ MODKEY,			XK_Tab,		focusnext,	{ 0 } }, \
+	{ MODKEY|ShiftMask,		XK_Tab,		focusprev,	{ 0 } }, \
 	{ MODKEY,			XK_Return,	zoom,		{ 0 } }, \
 	{ MODKEY,			XK_m,		togglemax,	{ 0 } }, \
 	{ MODKEY|ShiftMask,		XK_1,		tag,		{ .i = 0 } }, \
 	{ MODKEY|ShiftMask,		XK_2,		tag,		{ .i = 1 } }, \
 	{ MODKEY|ShiftMask,		XK_3,		tag,		{ .i = 2 } }, \
+	{ MODKEY|ShiftMask,		XK_4,		tag,		{ .i = 3 } }, \
+	{ MODKEY|ShiftMask,		XK_5,		tag,		{ .i = 4 } }, \
 	{ MODKEY|ControlMask|ShiftMask,	XK_1,		toggletag,	{ .i = 0 } }, \
 	{ MODKEY|ControlMask|ShiftMask,	XK_2,		toggletag,	{ .i = 1 } }, \
 	{ MODKEY|ControlMask|ShiftMask,	XK_3,		toggletag,	{ .i = 2 } }, \
+	{ MODKEY|ControlMask|ShiftMask,	XK_4,		toggletag,	{ .i = 3 } }, \
+	{ MODKEY|ControlMask|ShiftMask,	XK_5,		toggletag,	{ .i = 4 } }, \
 	{ MODKEY|ShiftMask,		XK_c,		killclient,	{ 0 } }, \
 	{ MODKEY,			XK_space,	togglemode,	{ 0 } }, \
 	{ MODKEY,			XK_1,		view,		{ .i = 0 } }, \
 	{ MODKEY,			XK_2,		view,		{ .i = 1 } }, \
 	{ MODKEY,			XK_3,		view,		{ .i = 2 } }, \
+	{ MODKEY,			XK_4,		view,		{ .i = 3 } }, \
+	{ MODKEY,			XK_5,		view,		{ .i = 4 } }, \
 	{ MODKEY|ControlMask,		XK_1,		toggleview,	{ .i = 0 } }, \
 	{ MODKEY|ControlMask,		XK_2,		toggleview,	{ .i = 1 } }, \
 	{ MODKEY|ControlMask,		XK_3,		toggleview,	{ .i = 2 } }, \
+	{ MODKEY|ControlMask,		XK_4,		toggleview,	{ .i = 3 } }, \
+	{ MODKEY|ControlMask,		XK_5,		toggleview,	{ .i = 4 } }, \
 	{ MODKEY|ShiftMask,		XK_q,		quit,		{ 0 } }, \
 };
 
+/* Query class:instance:title for regex matching info with following command:
+ * xprop | awk -F '"' '/^WM_CLASS/ { printf("%s:%s:",$4,$2) }; /^WM_NAME/{ printf("%s\n",$2) }' */
 #define RULES \
 static Rule rule[] = { \
 	/* class:instance:title regex	tags regex	isfloat */ \
-	{ "Firefox.*",			"net",		False }, \
+	{ "Firefox.*",			"2",		False }, \
 	{ "Gimp.*",			NULL,		True}, \
-	{ "MPlayer.*",			NULL,		True}, \
-	{ "Acroread.*",			NULL,		True}, \
 };
diff --git a/config.default.h b/config.default.h
index c0102b0..7716916 100644
--- a/config.default.h
+++ b/config.default.h
@@ -7,10 +7,15 @@
 const char *tags[] = { "1", "2", "3", "4", "5", NULL };
 
 #define DEFMODE			dotile /* dofloat */
+
 #define FONT			"fixed"
-#define BGCOLOR			"#666699"
-#define FGCOLOR			"#eeeeee"
-#define BORDERCOLOR		"#9999CC"
+#define SELBGCOLOR		"#666699"
+#define SELFGCOLOR		"#eeeeee"
+#define NORMBGCOLOR		"#333366"
+#define NORMFGCOLOR		"#cccccc"
+#define STATUSBGCOLOR		"#dddddd"
+#define STATUSFGCOLOR		"#222222"
+
 #define MODKEY			Mod1Mask
 #define MASTERW			60 /* percent */
 
diff --git a/draw.c b/draw.c
index fdb36d7..ff6f779 100644
--- a/draw.c
+++ b/draw.c
@@ -22,29 +22,16 @@ textnw(const char *text, unsigned int len)
 }
 
 static void
-drawtext(const char *text, Bool invert, Bool highlight)
+drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
 {
 	int x, y, w, h;
 	static char buf[256];
 	unsigned int len, olen;
 	XGCValues gcv;
-	XPoint points[5];
 	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
 
-	XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
+	XSetForeground(dpy, dc.gc, col[ColBG]);
 	XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
-	points[0].x = dc.x;
-	points[0].y = dc.y;
-	points[1].x = dc.w - 1;
-	points[1].y = 0;
-	points[2].x = 0;
-	points[2].y = dc.h - 1;
-	points[3].x = -(dc.w - 1);
-	points[3].y = 0;
-	points[4].x = 0;
-	points[4].y = -(dc.h - 1);
-	XSetForeground(dpy, dc.gc, dc.border);
-	XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
 
 	if(!text)
 		return;
@@ -74,15 +61,14 @@ drawtext(const char *text, Bool invert, Bool highlight)
 
 	if(w > dc.w)
 		return; /* too long */
-	gcv.foreground = invert ? dc.bg : dc.fg;
-	gcv.background = invert ? dc.fg : dc.bg;
+	gcv.foreground = col[ColFG];
 	if(dc.font.set) {
-		XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv);
+		XChangeGC(dpy, dc.gc, GCForeground, &gcv);
 		XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
 	}
 	else {
 		gcv.font = dc.font.xfont->fid;
-		XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
+		XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
 		XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
 	}
 	if(highlight) {
@@ -108,21 +94,25 @@ drawall()
 void
 drawstatus()
 {
+	static const char *mode[] = { "~", "=" };
 	int i, x;
-	Bool istile = arrange == dotile;
 
 	dc.x = dc.y = 0;
 	dc.w = bw;
-	drawtext(NULL, !istile, False);
+
+	if(!modew)
+		modew = textw(mode[0]) > textw(mode[1]) ? textw(mode[0]) : textw(mode[1]);
+	drawtext(mode[arrange == dotile ? 1 : 0], dc.status, False);
 
 	dc.w = 0;
+	dc.x = modew;
 	for(i = 0; i < ntags; i++) {
 		dc.x += dc.w;
 		dc.w = textw(tags[i]);
-		if(istile)
-			drawtext(tags[i], seltag[i], sel && sel->tags[i]);
+		if(seltag[i])
+			drawtext(tags[i], dc.sel, sel && sel->tags[i]);
 		else
-			drawtext(tags[i], !seltag[i], sel && sel->tags[i]);
+			drawtext(tags[i], dc.norm, sel && sel->tags[i]);
 	}
 	x = dc.x + dc.w;
 	dc.w = textw(stext);
@@ -131,11 +121,11 @@ drawstatus()
 		dc.x = x;
 		dc.w = bw - x;
 	}
-	drawtext(stext, !istile, False);
+	drawtext(stext, dc.status, False);
 
 	if(sel && ((dc.w = dc.x - x) > bh)) {
 		dc.x = x;
-		drawtext(sel->name, istile, False);
+		drawtext(sel->name, dc.sel, False);
 	}
 	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
 	XSync(dpy, False);
@@ -145,20 +135,19 @@ void
 drawtitle(Client *c)
 {
 	int i;
-	Bool istile = arrange == dotile;
 
 	if(c == sel && issel) {
 		drawstatus();
 		XUnmapWindow(dpy, c->twin);
-		XSetWindowBorder(dpy, c->win, dc.fg);
+		XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
 		return;
 	}
 
-	XSetWindowBorder(dpy, c->win, dc.bg);
+	XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
 	XMapWindow(dpy, c->twin);
 	dc.x = dc.y = 0;
 	dc.w = c->tw;
-	drawtext(c->name, !istile, False);
+	drawtext(c->name, dc.norm, False);
 	XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
 	XSync(dpy, False);
 }
diff --git a/dwm.h b/dwm.h
index 9d2d959..c23c86c 100644
--- a/dwm.h
+++ b/dwm.h
@@ -23,6 +23,9 @@ enum { WMProtocols, WMDelete, WMLast };
 /* cursor */
 enum { CurNormal, CurResize, CurMove, CurLast };
 
+/* color */
+enum { ColFG, ColBG, ColLast };
+
 /* window corners */
 typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
 
@@ -36,9 +39,9 @@ typedef struct {
 
 typedef struct { /* draw context */
 	int x, y, w, h;
-	unsigned long bg;
-	unsigned long fg;
-	unsigned long border;
+	unsigned long norm[ColLast];
+	unsigned long sel[ColLast];
+	unsigned long status[ColLast];
 	Drawable drawable;
 	Fnt font;
 	GC gc;
@@ -66,7 +69,7 @@ struct Client {
 extern const char *tags[];
 extern char stext[1024];
 extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
-extern unsigned int ntags, numlockmask;
+extern unsigned int ntags, numlockmask, modew;
 extern void (*handler[LASTEvent])(XEvent *);
 extern void (*arrange)(Arg *);
 extern Atom wmatom[WMLast], netatom[NetLast];
diff --git a/event.c b/event.c
index c2288f4..86fb43b 100644
--- a/event.c
+++ b/event.c
@@ -105,7 +105,9 @@ buttonpress(XEvent *e)
 	XButtonPressedEvent *ev = &e->xbutton;
 
 	if(barwin == ev->window) {
-		x = 0;
+		if(ev->x < modew)
+			return;
+		x = modew;
 		for(a.i = 0; a.i < ntags; a.i++) {
 			x += textw(tags[a.i]);
 			if(ev->x < x) {
diff --git a/main.c b/main.c
index 5b00d0c..0727c2a 100644
--- a/main.c
+++ b/main.c
@@ -20,7 +20,7 @@
 char stext[1024];
 Bool *seltag;
 int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
-unsigned int ntags, numlockmask;
+unsigned int ntags, numlockmask, modew;
 Atom wmatom[WMLast], netatom[NetLast];
 Bool running = True;
 Bool issel = True;
@@ -121,11 +121,15 @@ setup()
 	seltag[0] = True;
 
 	/* style */
-	dc.bg = getcolor(BGCOLOR);
-	dc.fg = getcolor(FGCOLOR);
-	dc.border = getcolor(BORDERCOLOR);
+	dc.norm[ColBG] = getcolor(NORMBGCOLOR);
+	dc.norm[ColFG] = getcolor(NORMFGCOLOR);
+	dc.sel[ColBG] = getcolor(SELBGCOLOR);
+	dc.sel[ColFG] = getcolor(SELFGCOLOR);
+	dc.status[ColBG] = getcolor(STATUSBGCOLOR);
+	dc.status[ColFG] = getcolor(STATUSFGCOLOR);
 	setfont(FONT);
 
+	modew = 0;
 	sx = sy = 0;
 	sw = DisplayWidth(dpy, screen);
 	sh = DisplayHeight(dpy, screen);
@@ -133,7 +137,7 @@ setup()
 
 	bx = by = 0;
 	bw = sw;
-	dc.h = bh = dc.font.height + 4;
+	dc.h = bh = dc.font.height + 2;
 	wa.override_redirect = 1;
 	wa.background_pixmap = ParentRelative;
 	wa.event_mask = ButtonPressMask | ExposureMask;
3new.cc?h=main&id=bc6fcd0fcb56df5e12ace096a66d56badb97cdfc'>^
c157066c ^
795f5244 ^
57d01f21 ^
795f5244 ^

ff8d96ae ^


ff8d96ae ^



b954ac38 ^
ff8d96ae ^










795f5244 ^
166e3c0d ^
ff8d96ae ^
fd41212e ^
ff8d96ae ^




0ee448dc ^
263e6b2a ^


6c1376f8 ^

c3779a78 ^
218c3612 ^
0487a30e ^
ac0e9db5 ^
cdd6fd09 ^
0487a30e ^
cfb142b9 ^
0487a30e ^
5f06655c ^
0c0bc3ae ^
795f5244 ^
0c0bc3ae ^
263e6b2a ^



fd41212e ^

218c3612 ^

e2240eb4 ^

0ee448dc ^
ff8d96ae ^













6c1376f8 ^










34c4850f ^
0487a30e ^
ac0e9db5 ^
0cfc678f ^

263e6b2a ^
0cfc678f ^

0487a30e ^




cdd6fd09 ^
0487a30e ^


5f06655c ^

795f5244 ^
5f06655c ^
455fbac6 ^

5f06655c ^


88be3dbc ^
0ee448dc ^
455fbac6 ^


0ee448dc ^
455fbac6 ^
fc9dc705 ^
263e6b2a ^

d472e0dd ^
8fb0e672 ^

455fbac6 ^


8fb0e672 ^
455fbac6 ^
8fb0e672 ^
263e6b2a ^

8fb0e672 ^
218c3612 ^

263e6b2a ^
218c3612 ^
455fbac6 ^

218c3612 ^
263e6b2a ^

218c3612 ^
84e4ed1a ^




455fbac6 ^



84e4ed1a ^











795f5244 ^
166e3c0d ^
84e4ed1a ^
166e3c0d ^
795f5244 ^
e4630643 ^

166e3c0d ^

455fbac6 ^

84e4ed1a ^

166e3c0d ^



84e4ed1a ^
263e6b2a ^
c6034af3 ^
263e6b2a ^
c6034af3 ^

263e6b2a ^

ff9d5f43 ^
455fbac6 ^
c6034af3 ^
263e6b2a ^
84e4ed1a ^




263e6b2a ^
6c1376f8 ^


84e4ed1a ^

795f5244 ^
84e4ed1a ^
795f5244 ^
84e4ed1a ^


ff8d96ae ^
84e4ed1a ^
263e6b2a ^
84e4ed1a ^
795f5244 ^
35064671 ^
795f5244 ^
5f98a10c ^
35064671 ^


84e4ed1a ^
263e6b2a ^
84e4ed1a ^
795f5244 ^
84e4ed1a ^






455fbac6 ^



84e4ed1a ^





455fbac6 ^



84e4ed1a ^



3d68a0b0 ^
7284d503 ^
88be3dbc ^
c495d2ac ^
455fbac6 ^

c495d2ac ^
5497090a ^
c495d2ac ^

3d68a0b0 ^

455fbac6 ^


3d68a0b0 ^




ff8d96ae ^
7afe09fb ^
ff8d96ae ^

c495d2ac ^
7afe09fb ^
166e3c0d ^



f45657bd ^

de92036d ^
c495d2ac ^
f45657bd ^
6c1376f8 ^

0487a30e ^
0487a30e ^
f45657bd ^
263e6b2a ^


795f5244 ^
3d68a0b0 ^
3d68a0b0 ^
ac0e9db5 ^
3d68a0b0 ^


795f5244 ^
3d68a0b0 ^

c495d2ac ^

f45657bd ^
c495d2ac ^
0487a30e ^
9edabeaa ^



455fbac6 ^

9edabeaa ^





ba625111 ^
9edabeaa ^

064813d9 ^

455fbac6 ^

064813d9 ^


ba625111 ^

455fbac6 ^

ba625111 ^


0487a30e ^



455fbac6 ^

0487a30e ^


3d68a0b0 ^













9edabeaa ^
9edabeaa ^
263e6b2a ^

795f5244 ^
9edabeaa ^


795f5244 ^
9edabeaa ^


7afe09fb ^

ff8d96ae ^

ae256ea1 ^
7afe09fb ^
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