diff options
-rw-r--r-- | dmenu.h | 2 | ||||
-rw-r--r-- | draw.c | 25 |
2 files changed, 21 insertions, 6 deletions
@@ -34,7 +34,7 @@ extern Display *dpy; | |||
34 | extern DC dc; | 34 | extern DC dc; |
35 | 35 | ||
36 | /* draw.c */ | 36 | /* draw.c */ |
37 | extern void drawtext(const char *text, Bool invert); | 37 | extern void drawtext(const char *text, Bool sel); |
38 | extern unsigned long getcolor(const char *colstr); | 38 | extern unsigned long getcolor(const char *colstr); |
39 | extern void setfont(const char *fontstr); | 39 | extern void setfont(const char *fontstr); |
40 | extern unsigned int textw(const char *text); | 40 | extern unsigned int textw(const char *text); |
@@ -24,18 +24,18 @@ textnw(const char *text, unsigned int len) | |||
24 | /* extern */ | 24 | /* extern */ |
25 | 25 | ||
26 | void | 26 | void |
27 | drawtext(const char *text, Bool invert) | 27 | drawtext(const char *text, Bool sel) |
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; | 31 | unsigned int len; |
32 | XGCValues gcv; | 32 | XGCValues gcv; |
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, invert ? dc.fg : dc.bg); | 36 | XSetForeground(dpy, dc.gc, sel ? dc.fg : dc.bg); |
36 | XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); | 37 | XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); |
37 | w = 0; | 38 | w = 0; |
38 | |||
39 | if(!text) | 39 | if(!text) |
40 | return; | 40 | return; |
41 | 41 | ||
@@ -56,8 +56,8 @@ drawtext(const char *text, Bool invert) | |||
56 | if(w > dc.w) | 56 | if(w > dc.w) |
57 | return; /* too long */ | 57 | return; /* too long */ |
58 | 58 | ||
59 | gcv.foreground = invert ? dc.bg : dc.fg; | 59 | gcv.foreground = sel ? dc.bg : dc.fg; |
60 | gcv.background = invert ? dc.fg : dc.bg; | 60 | gcv.background = sel ? dc.fg : dc.bg; |
61 | if(dc.font.set) { | 61 | if(dc.font.set) { |
62 | XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv); | 62 | XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv); |
63 | XmbDrawImageString(dpy, dc.drawable, dc.font.set, dc.gc, | 63 | XmbDrawImageString(dpy, dc.drawable, dc.font.set, dc.gc, |
@@ -68,6 +68,21 @@ drawtext(const char *text, Bool invert) | |||
68 | XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv); | 68 | XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv); |
69 | XDrawImageString(dpy, dc.drawable, dc.gc, x, y, buf, len); | 69 | XDrawImageString(dpy, dc.drawable, dc.gc, x, y, buf, len); |
70 | } | 70 | } |
71 | if(sel) { | ||
72 | XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); | ||
73 | points[0].x = dc.x; | ||
74 | points[0].y = dc.y; | ||
75 | points[1].x = dc.w - 1; | ||
76 | points[1].y = 0; | ||
77 | points[2].x = 0; | ||
78 | points[2].y = dc.h - 1; | ||
79 | points[3].x = -(dc.w - 1); | ||
80 | points[3].y = 0; | ||
81 | points[4].x = 0; | ||
82 | points[4].y = -(dc.h - 1); | ||
83 | XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); | ||
84 | } | ||
85 | |||
71 | } | 86 | } |
72 | 87 | ||
73 | unsigned long | 88 | unsigned long |