back to 3 colors 98336103
Anselm R. Garbe · 2006-08-25 07:54 5 file(s) · +35 −38
config.arg.h +3 −4
8 8
9 9
#define DEFMODE			dotile /* dofloat */
10 10
#define FONT			"-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
11 -
#define NORMBGCOLOR		"#666699"
12 -
#define NORMFGCOLOR		"#eeeeee"
13 -
#define SELBGCOLOR		"#eeeeee"
14 -
#define SELFGCOLOR		"#000088"
11 +
#define BGCOLOR			"#666699"
12 +
#define FGCOLOR			"#eeeeee"
13 +
#define BORDERCOLOR		"#9999CC"
15 14
#define MODKEY			Mod1Mask
16 15
#define MASTERW			60 /* percent */
17 16
config.default.h +3 −4
8 8
9 9
#define DEFMODE			dotile /* dofloat */
10 10
#define FONT			"fixed"
11 -
#define NORMBGCOLOR		"#666699"
12 -
#define NORMFGCOLOR		"#eeeeee"
13 -
#define SELBGCOLOR		"#eeeeee"
14 -
#define SELFGCOLOR		"#666699"
11 +
#define BGCOLOR			"#666699"
12 +
#define FGCOLOR			"#eeeeee"
13 +
#define BORDERCOLOR		"#9999CC"
15 14
#define MODKEY			Mod1Mask
16 15
#define MASTERW			60 /* percent */
17 16
draw.c +23 −24
22 22
}
23 23
24 24
static void
25 -
drawtext(const char *text, unsigned int colidx, Bool highlight)
25 +
drawtext(const char *text, Bool invert, Bool highlight)
26 26
{
27 27
	int x, y, w, h;
28 28
	static char buf[256];
29 29
	unsigned int len, olen;
30 +
	XGCValues gcv;
30 31
	XPoint points[5];
31 32
	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
32 33
33 -
	XSetForeground(dpy, dc.gc, dc.bg[colidx]);
34 +
	XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
34 35
	XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
35 36
	points[0].x = dc.x;
36 37
	points[0].y = dc.y;
42 43
	points[3].y = 0;
43 44
	points[4].x = 0;
44 45
	points[4].y = -(dc.h - 1);
45 -
	XSetForeground(dpy, dc.gc, dc.fg[colidx]);
46 +
	XSetForeground(dpy, dc.gc, dc.border);
46 47
	XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
47 48
48 49
	if(!text)
73 74
74 75
	if(w > dc.w)
75 76
		return; /* too long */
76 -
	if(dc.font.set)
77 +
	gcv.foreground = invert ? dc.bg : dc.fg;
78 +
	gcv.background = invert ? dc.fg : dc.bg;
79 +
	if(dc.font.set) {
80 +
		XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv);
77 81
		XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
82 +
	}
78 83
	else {
79 -
		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
84 +
		gcv.font = dc.font.xfont->fid;
85 +
		XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
80 86
		XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
81 87
	}
82 88
	if(highlight) {
83 -
		points[0].x = dc.x + 1;
84 -
		points[0].y = dc.y + 1;
85 -
		points[1].x = dc.w - 3;
86 -
		points[1].y = 0;
87 -
		points[2].x = 0;
88 -
		points[2].y = dc.h - 3;
89 -
		points[3].x = -(dc.w - 3);
90 -
		points[3].y = 0;
91 -
		points[4].x = 0;
92 -
		points[4].y = -(dc.h - 3);
93 -
		XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
89 +
		r.x = dc.x + 2;
90 +
		r.y = dc.y + 2;
91 +
		r.width = r.height = 3;
92 +
		XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
94 93
	}
95 94
}
96 95
114 113
115 114
	dc.x = dc.y = 0;
116 115
	dc.w = bw;
117 -
	drawtext(NULL, istile ? 1 : 0, False);
116 +
	drawtext(NULL, !istile, False);
118 117
119 118
	dc.w = 0;
120 119
	for(i = 0; i < ntags; i++) {
121 120
		dc.x += dc.w;
122 121
		dc.w = textw(tags[i]);
123 122
		if(istile)
124 -
			drawtext(tags[i], seltag[i] ? 0 : 1, sel && sel->tags[i]);
123 +
			drawtext(tags[i], seltag[i], sel && sel->tags[i]);
125 124
		else
126 -
			drawtext(tags[i], seltag[i] ? 1 : 0, sel && sel->tags[i]);
125 +
			drawtext(tags[i], !seltag[i], sel && sel->tags[i]);
127 126
	}
128 127
	x = dc.x + dc.w;
129 128
	dc.w = textw(stext);
132 131
		dc.x = x;
133 132
		dc.w = bw - x;
134 133
	}
135 -
	drawtext(stext, istile ? 1 : 0, False);
134 +
	drawtext(stext, !istile, False);
136 135
137 136
	if(sel && ((dc.w = dc.x - x) > bh)) {
138 137
		dc.x = x;
139 -
		drawtext(sel->name, istile ? 0 : 1, False);
138 +
		drawtext(sel->name, istile, False);
140 139
	}
141 140
	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
142 141
	XSync(dpy, False);
151 150
	if(c == sel && issel) {
152 151
		drawstatus();
153 152
		XUnmapWindow(dpy, c->twin);
154 -
		XSetWindowBorder(dpy, c->win, dc.fg[1]);
153 +
		XSetWindowBorder(dpy, c->win, dc.fg);
155 154
		return;
156 155
	}
157 156
158 -
	XSetWindowBorder(dpy, c->win, dc.bg[0]);
157 +
	XSetWindowBorder(dpy, c->win, dc.bg);
159 158
	XMapWindow(dpy, c->twin);
160 159
	dc.x = dc.y = 0;
161 160
	dc.w = c->tw;
162 -
	drawtext(c->name, istile ? 1 : 0, False);
161 +
	drawtext(c->name, !istile, False);
163 162
	XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
164 163
	XSync(dpy, False);
165 164
}
dwm.h +3 −2
36 36
37 37
typedef struct { /* draw context */
38 38
	int x, y, w, h;
39 -
	unsigned long bg[2];
40 -
	unsigned long fg[2];
39 +
	unsigned long bg;
40 +
	unsigned long fg;
41 +
	unsigned long border;
41 42
	Drawable drawable;
42 43
	Fnt font;
43 44
	GC gc;
main.c +3 −4
121 121
	seltag[0] = True;
122 122
123 123
	/* style */
124 -
	dc.bg[0] = getcolor(NORMBGCOLOR);
125 -
	dc.fg[0] = getcolor(NORMFGCOLOR);
126 -
	dc.bg[1] = getcolor(SELBGCOLOR);
127 -
	dc.fg[1] = getcolor(SELFGCOLOR);
124 +
	dc.bg = getcolor(BGCOLOR);
125 +
	dc.fg = getcolor(FGCOLOR);
126 +
	dc.border = getcolor(BORDERCOLOR);
128 127
	setfont(FONT);
129 128
130 129
	sx = sy = 0;