diff options
| -rw-r--r-- | dinput.c | 18 | ||||
| -rw-r--r-- | dmenu.c | 26 | ||||
| -rw-r--r-- | draw.h | 2 |
3 files changed, 24 insertions, 22 deletions
| @@ -42,6 +42,8 @@ static int screen; | |||
| 42 | static unsigned int cursor = 0; | 42 | static unsigned int cursor = 0; |
| 43 | static unsigned int numlockmask = 0; | 43 | static unsigned int numlockmask = 0; |
| 44 | static unsigned int mw, mh; | 44 | static unsigned int mw, mh; |
| 45 | static unsigned long normcol[ColLast]; | ||
| 46 | static unsigned long selcol[ColLast]; | ||
| 45 | static Bool running = True; | 47 | static Bool running = True; |
| 46 | static DC dc; | 48 | static DC dc; |
| 47 | static Display *dpy; | 49 | static 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 | ||
| @@ -59,6 +59,8 @@ static int screen; | |||
| 59 | static unsigned int lines = 0; | 59 | static unsigned int lines = 0; |
| 60 | static unsigned int numlockmask = 0; | 60 | static unsigned int numlockmask = 0; |
| 61 | static unsigned int mw, mh; | 61 | static unsigned int mw, mh; |
| 62 | static unsigned long normcol[ColLast]; | ||
| 63 | static unsigned long selcol[ColLast]; | ||
| 62 | static Bool running = True; | 64 | static Bool running = True; |
| 63 | static DC dc; | 65 | static DC dc; |
| 64 | static Display *dpy; | 66 | static 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 | ||
| 202 | void | 204 | void |
| @@ -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 | ||
| 217 | Bool | 219 | Bool |
| @@ -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 */ |
| @@ -6,8 +6,6 @@ enum { ColFG, ColBG, ColLast }; | |||
| 6 | /* typedefs */ | 6 | /* typedefs */ |
| 7 | typedef struct { | 7 | typedef 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; |
