aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.arg.h7
-rw-r--r--config.default.h7
-rw-r--r--dmenu.h7
-rw-r--r--draw.c21
-rw-r--r--main.c17
5 files changed, 32 insertions, 27 deletions
diff --git a/config.arg.h b/config.arg.h
index 91b014f..066c1a4 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -4,7 +4,6 @@
4 */ 4 */
5 5
6#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*" 6#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
7#define NORMBGCOLOR "#666699" 7#define BGCOLOR "#666699"
8#define NORMFGCOLOR "#eeeeee" 8#define FGCOLOR "#eeeeee"
9#define SELBGCOLOR "#eeeeee" 9#define BORDERCOLOR "#9999CC"
10#define SELFGCOLOR "#000088"
diff --git a/config.default.h b/config.default.h
index 48c810a..cf1baea 100644
--- a/config.default.h
+++ b/config.default.h
@@ -4,7 +4,6 @@
4 */ 4 */
5 5
6#define FONT "fixed" 6#define FONT "fixed"
7#define NORMBGCOLOR "#666699" 7#define BGCOLOR "#666699"
8#define NORMFGCOLOR "#eeeeee" 8#define FGCOLOR "#eeeeee"
9#define SELBGCOLOR "#eeeeee" 9#define BORDERCOLOR "#9999CC"
10#define SELFGCOLOR "#666699"
diff --git a/dmenu.h b/dmenu.h
index a739fa5..2a8796f 100644
--- a/dmenu.h
+++ b/dmenu.h
@@ -22,8 +22,9 @@ struct Fnt {
22 22
23struct DC { /* draw context */ 23struct DC { /* draw context */
24 int x, y, w, h; 24 int x, y, w, h;
25 unsigned long bg[2]; 25 unsigned long bg;
26 unsigned long fg[2]; 26 unsigned long fg;
27 unsigned long border;
27 Drawable drawable; 28 Drawable drawable;
28 Fnt font; 29 Fnt font;
29 GC gc; 30 GC gc;
@@ -34,7 +35,7 @@ extern Display *dpy;
34extern DC dc; 35extern DC dc;
35 36
36/* draw.c */ 37/* draw.c */
37extern void drawtext(const char *text, unsigned int colidx, Bool border); 38extern void drawtext(const char *text, Bool invert, Bool border);
38extern unsigned long getcolor(const char *colstr); 39extern unsigned long getcolor(const char *colstr);
39extern void setfont(const char *fontstr); 40extern void setfont(const char *fontstr);
40extern unsigned int textw(const char *text); 41extern unsigned int textw(const char *text);
diff --git a/draw.c b/draw.c
index ba1fafd..38ae8c3 100644
--- a/draw.c
+++ b/draw.c
@@ -24,19 +24,19 @@ textnw(const char *text, unsigned int len)
24/* extern */ 24/* extern */
25 25
26void 26void
27drawtext(const char *text, unsigned int colidx, Bool border) 27drawtext(const char *text, Bool invert, Bool border)
28{ 28{
29 int x, y, w, h; 29 int x, y, w, h;
30 static char buf[256]; 30 static char buf[256];
31 unsigned int len, olen; 31 unsigned int len, olen;
32 XGCValues gcv;
32 XPoint points[5]; 33 XPoint points[5];
33 XRectangle r = { dc.x, dc.y, dc.w, dc.h }; 34 XRectangle r = { dc.x, dc.y, dc.w, dc.h };
34 35
35 XSetForeground(dpy, dc.gc, dc.bg[colidx]); 36 XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
36 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); 37 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
37 38
38 w = 0; 39 w = 0;
39 XSetForeground(dpy, dc.gc, dc.fg[colidx]);
40 if(border) { 40 if(border) {
41 points[0].x = dc.x; 41 points[0].x = dc.x;
42 points[0].y = dc.y; 42 points[0].y = dc.y;
@@ -48,6 +48,7 @@ drawtext(const char *text, unsigned int colidx, Bool border)
48 points[3].y = 0; 48 points[3].y = 0;
49 points[4].x = 0; 49 points[4].x = 0;
50 points[4].y = -(dc.h - 1); 50 points[4].y = -(dc.h - 1);
51 XSetForeground(dpy, dc.gc, dc.border);
51 XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); 52 XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
52 } 53 }
53 54
@@ -79,11 +80,17 @@ drawtext(const char *text, unsigned int colidx, Bool border)
79 if(w > dc.w) 80 if(w > dc.w)
80 return; /* too long */ 81 return; /* too long */
81 82
82 if(dc.font.set) 83 gcv.foreground = invert ? dc.bg : dc.fg;
83 XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); 84 gcv.background = invert ? dc.fg : dc.bg;
85 if(dc.font.set) {
86 XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv);
87 XmbDrawImageString(dpy, dc.drawable, dc.font.set, dc.gc,
88 x, y, buf, len);
89 }
84 else { 90 else {
85 XSetFont(dpy, dc.gc, dc.font.xfont->fid); 91 gcv.font = dc.font.xfont->fid;
86 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); 92 XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
93 XDrawImageString(dpy, dc.drawable, dc.gc, x, y, buf, len);
87 } 94 }
88} 95}
89 96
diff --git a/main.c b/main.c
index c3cad1d..840a7bc 100644
--- a/main.c
+++ b/main.c
@@ -77,17 +77,17 @@ drawmenu()
77 dc.y = 0; 77 dc.y = 0;
78 dc.w = mw; 78 dc.w = mw;
79 dc.h = mh; 79 dc.h = mh;
80 drawtext(NULL, 0, False); 80 drawtext(NULL, False, False);
81 81
82 /* print command */ 82 /* print command */
83 if(cmdw && item) 83 if(cmdw && item)
84 dc.w = cmdw; 84 dc.w = cmdw;
85 drawtext(text[0] ? text : NULL, 0, False); 85 drawtext(text[0] ? text : NULL, False, False);
86 dc.x += cmdw; 86 dc.x += cmdw;
87 87
88 if(curr) { 88 if(curr) {
89 dc.w = SPACE; 89 dc.w = SPACE;
90 drawtext((curr && curr->left) ? "<" : NULL, 0, False); 90 drawtext((curr && curr->left) ? "<" : NULL, False, False);
91 dc.x += dc.w; 91 dc.x += dc.w;
92 92
93 /* determine maximum items */ 93 /* determine maximum items */
@@ -95,13 +95,13 @@ drawmenu()
95 dc.w = textw(i->text); 95 dc.w = textw(i->text);
96 if(dc.w > mw / 3) 96 if(dc.w > mw / 3)
97 dc.w = mw / 3; 97 dc.w = mw / 3;
98 drawtext(i->text, sel == i ? 1 : 0, sel == i); 98 drawtext(i->text, sel == i, sel == i);
99 dc.x += dc.w; 99 dc.x += dc.w;
100 } 100 }
101 101
102 dc.x = mw - SPACE; 102 dc.x = mw - SPACE;
103 dc.w = SPACE; 103 dc.w = SPACE;
104 drawtext(next ? ">" : NULL, 0, False); 104 drawtext(next ? ">" : NULL, False, False);
105 } 105 }
106 XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0); 106 XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, mw, mh, 0, 0);
107 XFlush(dpy); 107 XFlush(dpy);
@@ -315,10 +315,9 @@ main(int argc, char *argv[])
315 usleep(1000); 315 usleep(1000);
316 316
317 /* style */ 317 /* style */
318 dc.bg[0] = getcolor(NORMBGCOLOR); 318 dc.bg = getcolor(BGCOLOR);
319 dc.fg[0] = getcolor(NORMFGCOLOR); 319 dc.fg = getcolor(FGCOLOR);
320 dc.bg[1] = getcolor(SELBGCOLOR); 320 dc.border = getcolor(BORDERCOLOR);
321 dc.fg[1] = getcolor(SELFGCOLOR);
322 setfont(FONT); 321 setfont(FONT);
323 322
324 wa.override_redirect = 1; 323 wa.override_redirect = 1;