diff options
Diffstat (limited to 'dmenu.c')
-rw-r--r-- | dmenu.c | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -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 */ |