aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Lane Smith <cls@lubutu.com>2010-06-24 16:24:04 +0100
committerConnor Lane Smith <cls@lubutu.com>2010-06-24 16:24:04 +0100
commit723361fa124aa666d637e3fc9f5df1210a9e02b4 (patch)
tree75d9bde58ac3e0d85de65a7709d3175316345812
parent96c65400ccdcb76cf20ec7721920f944e6b490ec (diff)
removed colors from dc
-rw-r--r--dinput.c18
-rw-r--r--dmenu.c26
-rw-r--r--draw.h2
3 files changed, 24 insertions, 22 deletions
diff --git a/dinput.c b/dinput.c
index 39889b3..cd13b1d 100644
--- a/dinput.c
+++ b/dinput.c
@@ -42,6 +42,8 @@ static int screen;
42static unsigned int cursor = 0; 42static unsigned int cursor = 0;
43static unsigned int numlockmask = 0; 43static unsigned int numlockmask = 0;
44static unsigned int mw, mh; 44static unsigned int mw, mh;
45static unsigned long normcol[ColLast];
46static unsigned long selcol[ColLast];
45static Bool running = True; 47static Bool running = True;
46static DC dc; 48static DC dc;
47static Display *dpy; 49static Display *dpy;
@@ -60,7 +62,7 @@ drawcursor(void) {
60 62
61 r.x += textnw(&dc, text, cursor) + dc.font.height / 2; 63 r.x += textnw(&dc, text, cursor) + dc.font.height / 2;
62 64
63 XSetForeground(dpy, dc.gc, dc.norm[ColFG]); 65 XSetForeground(dpy, dc.gc, normcol[ColFG]);
64 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); 66 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
65} 67}
66 68
@@ -71,15 +73,15 @@ drawinput(void)
71 dc.y = 0; 73 dc.y = 0;
72 dc.w = mw; 74 dc.w = mw;
73 dc.h = mh; 75 dc.h = mh;
74 drawtext(&dc, NULL, dc.norm); 76 drawtext(&dc, NULL, normcol);
75 /* print prompt? */ 77 /* print prompt? */
76 if(prompt) { 78 if(prompt) {
77 dc.w = promptw; 79 dc.w = promptw;
78 drawtext(&dc, prompt, dc.sel); 80 drawtext(&dc, prompt, selcol);
79 dc.x += dc.w; 81 dc.x += dc.w;
80 } 82 }
81 dc.w = mw - dc.x; 83 dc.w = mw - dc.x;
82 drawtext(&dc, *text ? text : NULL, dc.norm); 84 drawtext(&dc, *text ? text : NULL, normcol);
83 drawcursor(); 85 drawcursor();
84 XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0); 86 XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
85 XFlush(dpy); 87 XFlush(dpy);
@@ -268,10 +270,10 @@ setup(Bool topbar) {
268 XFreeModifiermap(modmap); 270 XFreeModifiermap(modmap);
269 271
270 dc.dpy = dpy; 272 dc.dpy = dpy;
271 dc.norm[ColBG] = getcolor(&dc, normbgcolor); 273 normcol[ColBG] = getcolor(&dc, normbgcolor);
272 dc.norm[ColFG] = getcolor(&dc, normfgcolor); 274 normcol[ColFG] = getcolor(&dc, normfgcolor);
273 dc.sel[ColBG] = getcolor(&dc, selbgcolor); 275 selcol[ColBG] = getcolor(&dc, selbgcolor);
274 dc.sel[ColFG] = getcolor(&dc, selfgcolor); 276 selcol[ColFG] = getcolor(&dc, selfgcolor);
275 initfont(&dc, font); 277 initfont(&dc, font);
276 fprintf(stderr, "dc.font.xfont: %u\n", (size_t)dc.font.xfont); 278 fprintf(stderr, "dc.font.xfont: %u\n", (size_t)dc.font.xfont);
277 279
diff --git a/dmenu.c b/dmenu.c
index 0b42073..6641ba2 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -59,6 +59,8 @@ static int screen;
59static unsigned int lines = 0; 59static unsigned int lines = 0;
60static unsigned int numlockmask = 0; 60static unsigned int numlockmask = 0;
61static unsigned int mw, mh; 61static unsigned int mw, mh;
62static unsigned long normcol[ColLast];
63static unsigned long selcol[ColLast];
62static Bool running = True; 64static Bool running = True;
63static DC dc; 65static DC dc;
64static Display *dpy; 66static Display *dpy;
@@ -159,18 +161,18 @@ drawmenu(void) {
159 dc.y = 0; 161 dc.y = 0;
160 dc.w = mw; 162 dc.w = mw;
161 dc.h = mh; 163 dc.h = mh;
162 drawtext(&dc, NULL, dc.norm); 164 drawtext(&dc, NULL, normcol);
163 /* print prompt? */ 165 /* print prompt? */
164 if(prompt) { 166 if(prompt) {
165 dc.w = promptw; 167 dc.w = promptw;
166 drawtext(&dc, prompt, dc.sel); 168 drawtext(&dc, prompt, selcol);
167 dc.x += dc.w; 169 dc.x += dc.w;
168 } 170 }
169 dc.w = mw - dc.x; 171 dc.w = mw - dc.x;
170 /* print command */ 172 /* print command */
171 if(cmdw && item && lines == 0) 173 if(cmdw && item && lines == 0)
172 dc.w = cmdw; 174 dc.w = cmdw;
173 drawtext(&dc, *text ? text : NULL, dc.norm); 175 drawtext(&dc, *text ? text : NULL, normcol);
174 if(curr) { 176 if(curr) {
175 if(lines > 0) 177 if(lines > 0)
176 drawmenuv(); 178 drawmenuv();
@@ -187,16 +189,16 @@ drawmenuh(void) {
187 189
188 dc.x += cmdw; 190 dc.x += cmdw;
189 dc.w = spaceitem; 191 dc.w = spaceitem;
190 drawtext(&dc, curr->left ? "<" : NULL, dc.norm); 192 drawtext(&dc, curr->left ? "<" : NULL, normcol);
191 dc.x += dc.w; 193 dc.x += dc.w;
192 for(i = curr; i != next; i=i->right) { 194 for(i = curr; i != next; i=i->right) {
193 dc.w = MIN(textw(&dc, i->text), mw / 3); 195 dc.w = MIN(textw(&dc, i->text), mw / 3);
194 drawtext(&dc, i->text, (sel == i) ? dc.sel : dc.norm); 196 drawtext(&dc, i->text, (sel == i) ? selcol : normcol);
195 dc.x += dc.w; 197 dc.x += dc.w;
196 } 198 }
197 dc.w = spaceitem; 199 dc.w = spaceitem;
198 dc.x = mw - dc.w; 200 dc.x = mw - dc.w;
199 drawtext(&dc, next ? ">" : NULL, dc.norm); 201 drawtext(&dc, next ? ">" : NULL, normcol);
200} 202}
201 203
202void 204void
@@ -207,11 +209,11 @@ drawmenuv(void) {
207 dc.h = dc.font.height + 2; 209 dc.h = dc.font.height + 2;
208 dc.y = dc.h; 210 dc.y = dc.h;
209 for(i = curr; i != next; i=i->right) { 211 for(i = curr; i != next; i=i->right) {
210 drawtext(&dc, i->text, (sel == i) ? dc.sel : dc.norm); 212 drawtext(&dc, i->text, (sel == i) ? selcol : normcol);
211 dc.y += dc.h; 213 dc.y += dc.h;
212 } 214 }
213 dc.h = mh - dc.y; 215 dc.h = mh - dc.y;
214 drawtext(&dc, NULL, dc.norm); 216 drawtext(&dc, NULL, normcol);
215} 217}
216 218
217Bool 219Bool
@@ -490,10 +492,10 @@ setup(Bool topbar) {
490 XFreeModifiermap(modmap); 492 XFreeModifiermap(modmap);
491 493
492 dc.dpy = dpy; 494 dc.dpy = dpy;
493 dc.norm[ColBG] = getcolor(&dc, normbgcolor); 495 normcol[ColBG] = getcolor(&dc, normbgcolor);
494 dc.norm[ColFG] = getcolor(&dc, normfgcolor); 496 normcol[ColFG] = getcolor(&dc, normfgcolor);
495 dc.sel[ColBG] = getcolor(&dc, selbgcolor); 497 selcol[ColBG] = getcolor(&dc, selbgcolor);
496 dc.sel[ColFG] = getcolor(&dc, selfgcolor); 498 selcol[ColFG] = getcolor(&dc, selfgcolor);
497 initfont(&dc, font); 499 initfont(&dc, font);
498 500
499 /* menu window */ 501 /* menu window */
diff --git a/draw.h b/draw.h
index e4f937a..1705909 100644
--- a/draw.h
+++ b/draw.h
@@ -6,8 +6,6 @@ enum { ColFG, ColBG, ColLast };
6/* typedefs */ 6/* typedefs */
7typedef struct { 7typedef struct {
8 int x, y, w, h; 8 int x, y, w, h;
9 unsigned long norm[ColLast];
10 unsigned long sel[ColLast];
11 Drawable drawable; 9 Drawable drawable;
12 Display *dpy; 10 Display *dpy;
13 GC gc; 11 GC gc;