aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnselm R.Garbe <arg@10ksloc.org>2006-08-10 11:07:06 +0200
committerAnselm R.Garbe <arg@10ksloc.org>2006-08-10 11:07:06 +0200
commitdd902868dfbb32f3520abe30c640f06bedf4ca9b (patch)
tree23b0de5a51b22a6955eaf7e3514960307780494a
parent4318bf2905a8da290ec83cb67f26bd06ba2e4dc9 (diff)
drawing border around sel item
-rw-r--r--dmenu.h2
-rw-r--r--draw.c25
2 files changed, 21 insertions, 6 deletions
diff --git a/dmenu.h b/dmenu.h
index f118196..ddea3dd 100644
--- a/dmenu.h
+++ b/dmenu.h
@@ -34,7 +34,7 @@ extern Display *dpy;
34extern DC dc; 34extern DC dc;
35 35
36/* draw.c */ 36/* draw.c */
37extern void drawtext(const char *text, Bool invert); 37extern void drawtext(const char *text, Bool sel);
38extern unsigned long getcolor(const char *colstr); 38extern unsigned long getcolor(const char *colstr);
39extern void setfont(const char *fontstr); 39extern void setfont(const char *fontstr);
40extern unsigned int textw(const char *text); 40extern unsigned int textw(const char *text);
diff --git a/draw.c b/draw.c
index 4e079e5..1d6bf21 100644
--- a/draw.c
+++ b/draw.c
@@ -24,18 +24,18 @@ textnw(const char *text, unsigned int len)
24/* extern */ 24/* extern */
25 25
26void 26void
27drawtext(const char *text, Bool invert) 27drawtext(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
73unsigned long 88unsigned long