removed colors from dc
723361fa
3 file(s) · +24 −22
| 42 | 42 | static unsigned int cursor = 0; |
|
| 43 | 43 | static unsigned int numlockmask = 0; |
|
| 44 | 44 | static unsigned int mw, mh; |
|
| 45 | + | static unsigned long normcol[ColLast]; |
|
| 46 | + | static unsigned long selcol[ColLast]; |
|
| 45 | 47 | static Bool running = True; |
|
| 46 | 48 | static DC dc; |
|
| 47 | 49 | static Display *dpy; |
|
| 60 | 62 | ||
| 61 | 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 | 66 | XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); |
|
| 65 | 67 | } |
|
| 66 | 68 | ||
| 71 | 73 | dc.y = 0; |
|
| 72 | 74 | dc.w = mw; |
|
| 73 | 75 | dc.h = mh; |
|
| 74 | - | drawtext(&dc, NULL, dc.norm); |
|
| 76 | + | drawtext(&dc, NULL, normcol); |
|
| 75 | 77 | /* print prompt? */ |
|
| 76 | 78 | if(prompt) { |
|
| 77 | 79 | dc.w = promptw; |
|
| 78 | - | drawtext(&dc, prompt, dc.sel); |
|
| 80 | + | drawtext(&dc, prompt, selcol); |
|
| 79 | 81 | dc.x += dc.w; |
|
| 80 | 82 | } |
|
| 81 | 83 | dc.w = mw - dc.x; |
|
| 82 | - | drawtext(&dc, *text ? text : NULL, dc.norm); |
|
| 84 | + | drawtext(&dc, *text ? text : NULL, normcol); |
|
| 83 | 85 | drawcursor(); |
|
| 84 | 86 | XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0); |
|
| 85 | 87 | XFlush(dpy); |
|
| 268 | 270 | XFreeModifiermap(modmap); |
|
| 269 | 271 | ||
| 270 | 272 | dc.dpy = dpy; |
|
| 271 | - | dc.norm[ColBG] = getcolor(&dc, normbgcolor); |
|
| 272 | - | dc.norm[ColFG] = getcolor(&dc, normfgcolor); |
|
| 273 | - | dc.sel[ColBG] = getcolor(&dc, selbgcolor); |
|
| 274 | - | dc.sel[ColFG] = getcolor(&dc, selfgcolor); |
|
| 273 | + | normcol[ColBG] = getcolor(&dc, normbgcolor); |
|
| 274 | + | normcol[ColFG] = getcolor(&dc, normfgcolor); |
|
| 275 | + | selcol[ColBG] = getcolor(&dc, selbgcolor); |
|
| 276 | + | selcol[ColFG] = getcolor(&dc, selfgcolor); |
|
| 275 | 277 | initfont(&dc, font); |
|
| 276 | 278 | fprintf(stderr, "dc.font.xfont: %u\n", (size_t)dc.font.xfont); |
|
| 277 | 279 | ||
| 59 | 59 | static unsigned int lines = 0; |
|
| 60 | 60 | static unsigned int numlockmask = 0; |
|
| 61 | 61 | static unsigned int mw, mh; |
|
| 62 | + | static unsigned long normcol[ColLast]; |
|
| 63 | + | static unsigned long selcol[ColLast]; |
|
| 62 | 64 | static Bool running = True; |
|
| 63 | 65 | static DC dc; |
|
| 64 | 66 | static Display *dpy; |
|
| 159 | 161 | dc.y = 0; |
|
| 160 | 162 | dc.w = mw; |
|
| 161 | 163 | dc.h = mh; |
|
| 162 | - | drawtext(&dc, NULL, dc.norm); |
|
| 164 | + | drawtext(&dc, NULL, normcol); |
|
| 163 | 165 | /* print prompt? */ |
|
| 164 | 166 | if(prompt) { |
|
| 165 | 167 | dc.w = promptw; |
|
| 166 | - | drawtext(&dc, prompt, dc.sel); |
|
| 168 | + | drawtext(&dc, prompt, selcol); |
|
| 167 | 169 | dc.x += dc.w; |
|
| 168 | 170 | } |
|
| 169 | 171 | dc.w = mw - dc.x; |
|
| 170 | 172 | /* print command */ |
|
| 171 | 173 | if(cmdw && item && lines == 0) |
|
| 172 | 174 | dc.w = cmdw; |
|
| 173 | - | drawtext(&dc, *text ? text : NULL, dc.norm); |
|
| 175 | + | drawtext(&dc, *text ? text : NULL, normcol); |
|
| 174 | 176 | if(curr) { |
|
| 175 | 177 | if(lines > 0) |
|
| 176 | 178 | drawmenuv(); |
|
| 187 | 189 | ||
| 188 | 190 | dc.x += cmdw; |
|
| 189 | 191 | dc.w = spaceitem; |
|
| 190 | - | drawtext(&dc, curr->left ? "<" : NULL, dc.norm); |
|
| 192 | + | drawtext(&dc, curr->left ? "<" : NULL, normcol); |
|
| 191 | 193 | dc.x += dc.w; |
|
| 192 | 194 | for(i = curr; i != next; i=i->right) { |
|
| 193 | 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 | 197 | dc.x += dc.w; |
|
| 196 | 198 | } |
|
| 197 | 199 | dc.w = spaceitem; |
|
| 198 | 200 | dc.x = mw - dc.w; |
|
| 199 | - | drawtext(&dc, next ? ">" : NULL, dc.norm); |
|
| 201 | + | drawtext(&dc, next ? ">" : NULL, normcol); |
|
| 200 | 202 | } |
|
| 201 | 203 | ||
| 202 | 204 | void |
|
| 207 | 209 | dc.h = dc.font.height + 2; |
|
| 208 | 210 | dc.y = dc.h; |
|
| 209 | 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 | 213 | dc.y += dc.h; |
|
| 212 | 214 | } |
|
| 213 | 215 | dc.h = mh - dc.y; |
|
| 214 | - | drawtext(&dc, NULL, dc.norm); |
|
| 216 | + | drawtext(&dc, NULL, normcol); |
|
| 215 | 217 | } |
|
| 216 | 218 | ||
| 217 | 219 | Bool |
|
| 490 | 492 | XFreeModifiermap(modmap); |
|
| 491 | 493 | ||
| 492 | 494 | dc.dpy = dpy; |
|
| 493 | - | dc.norm[ColBG] = getcolor(&dc, normbgcolor); |
|
| 494 | - | dc.norm[ColFG] = getcolor(&dc, normfgcolor); |
|
| 495 | - | dc.sel[ColBG] = getcolor(&dc, selbgcolor); |
|
| 496 | - | dc.sel[ColFG] = getcolor(&dc, selfgcolor); |
|
| 495 | + | normcol[ColBG] = getcolor(&dc, normbgcolor); |
|
| 496 | + | normcol[ColFG] = getcolor(&dc, normfgcolor); |
|
| 497 | + | selcol[ColBG] = getcolor(&dc, selbgcolor); |
|
| 498 | + | selcol[ColFG] = getcolor(&dc, selfgcolor); |
|
| 497 | 499 | initfont(&dc, font); |
|
| 498 | 500 | ||
| 499 | 501 | /* menu window */ |
|
| 6 | 6 | /* typedefs */ |
|
| 7 | 7 | typedef struct { |
|
| 8 | 8 | int x, y, w, h; |
|
| 9 | - | unsigned long norm[ColLast]; |
|
| 10 | - | unsigned long sel[ColLast]; |
|
| 11 | 9 | Drawable drawable; |
|
| 12 | 10 | Display *dpy; |
|
| 13 | 11 | GC gc; |