diff options
Diffstat (limited to '')
| -rw-r--r-- | draw.c | 49 |
1 files changed, 19 insertions, 30 deletions
| @@ -22,29 +22,16 @@ textnw(const char *text, unsigned int len) | |||
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | static void | 24 | static void |
| 25 | drawtext(const char *text, Bool invert, Bool highlight) | 25 | drawtext(const char *text, unsigned long col[ColLast], Bool highlight) |
| 26 | { | 26 | { |
| 27 | int x, y, w, h; | 27 | int x, y, w, h; |
| 28 | static char buf[256]; | 28 | static char buf[256]; |
| 29 | unsigned int len, olen; | 29 | unsigned int len, olen; |
| 30 | XGCValues gcv; | 30 | XGCValues gcv; |
| 31 | XPoint points[5]; | ||
| 32 | XRectangle r = { dc.x, dc.y, dc.w, dc.h }; | 31 | XRectangle r = { dc.x, dc.y, dc.w, dc.h }; |
| 33 | 32 | ||
| 34 | XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg); | 33 | XSetForeground(dpy, dc.gc, col[ColBG]); |
| 35 | XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); | 34 | XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); |
| 36 | points[0].x = dc.x; | ||
| 37 | points[0].y = dc.y; | ||
| 38 | points[1].x = dc.w - 1; | ||
| 39 | points[1].y = 0; | ||
| 40 | points[2].x = 0; | ||
| 41 | points[2].y = dc.h - 1; | ||
| 42 | points[3].x = -(dc.w - 1); | ||
| 43 | points[3].y = 0; | ||
| 44 | points[4].x = 0; | ||
| 45 | points[4].y = -(dc.h - 1); | ||
| 46 | XSetForeground(dpy, dc.gc, dc.border); | ||
| 47 | XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); | ||
| 48 | 35 | ||
| 49 | if(!text) | 36 | if(!text) |
| 50 | return; | 37 | return; |
| @@ -74,15 +61,14 @@ drawtext(const char *text, Bool invert, Bool highlight) | |||
| 74 | 61 | ||
| 75 | if(w > dc.w) | 62 | if(w > dc.w) |
| 76 | return; /* too long */ | 63 | return; /* too long */ |
| 77 | gcv.foreground = invert ? dc.bg : dc.fg; | 64 | gcv.foreground = col[ColFG]; |
| 78 | gcv.background = invert ? dc.fg : dc.bg; | ||
| 79 | if(dc.font.set) { | 65 | if(dc.font.set) { |
| 80 | XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv); | 66 | XChangeGC(dpy, dc.gc, GCForeground, &gcv); |
| 81 | XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); | 67 | XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); |
| 82 | } | 68 | } |
| 83 | else { | 69 | else { |
| 84 | gcv.font = dc.font.xfont->fid; | 70 | gcv.font = dc.font.xfont->fid; |
| 85 | XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv); | 71 | XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv); |
| 86 | XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); | 72 | XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); |
| 87 | } | 73 | } |
| 88 | if(highlight) { | 74 | if(highlight) { |
| @@ -108,21 +94,25 @@ drawall() | |||
| 108 | void | 94 | void |
| 109 | drawstatus() | 95 | drawstatus() |
| 110 | { | 96 | { |
| 97 | static const char *mode[] = { "~", "=" }; | ||
| 111 | int i, x; | 98 | int i, x; |
| 112 | Bool istile = arrange == dotile; | ||
| 113 | 99 | ||
| 114 | dc.x = dc.y = 0; | 100 | dc.x = dc.y = 0; |
| 115 | dc.w = bw; | 101 | dc.w = bw; |
| 116 | drawtext(NULL, !istile, False); | 102 | |
| 103 | if(!modew) | ||
| 104 | modew = textw(mode[0]) > textw(mode[1]) ? textw(mode[0]) : textw(mode[1]); | ||
| 105 | drawtext(mode[arrange == dotile ? 1 : 0], dc.status, False); | ||
| 117 | 106 | ||
| 118 | dc.w = 0; | 107 | dc.w = 0; |
| 108 | dc.x = modew; | ||
| 119 | for(i = 0; i < ntags; i++) { | 109 | for(i = 0; i < ntags; i++) { |
| 120 | dc.x += dc.w; | 110 | dc.x += dc.w; |
| 121 | dc.w = textw(tags[i]); | 111 | dc.w = textw(tags[i]); |
| 122 | if(istile) | 112 | if(seltag[i]) |
| 123 | drawtext(tags[i], seltag[i], sel && sel->tags[i]); | 113 | drawtext(tags[i], dc.sel, sel && sel->tags[i]); |
| 124 | else | 114 | else |
| 125 | drawtext(tags[i], !seltag[i], sel && sel->tags[i]); | 115 | drawtext(tags[i], dc.norm, sel && sel->tags[i]); |
| 126 | } | 116 | } |
| 127 | x = dc.x + dc.w; | 117 | x = dc.x + dc.w; |
| 128 | dc.w = textw(stext); | 118 | dc.w = textw(stext); |
| @@ -131,11 +121,11 @@ drawstatus() | |||
| 131 | dc.x = x; | 121 | dc.x = x; |
| 132 | dc.w = bw - x; | 122 | dc.w = bw - x; |
| 133 | } | 123 | } |
| 134 | drawtext(stext, !istile, False); | 124 | drawtext(stext, dc.status, False); |
| 135 | 125 | ||
| 136 | if(sel && ((dc.w = dc.x - x) > bh)) { | 126 | if(sel && ((dc.w = dc.x - x) > bh)) { |
| 137 | dc.x = x; | 127 | dc.x = x; |
| 138 | drawtext(sel->name, istile, False); | 128 | drawtext(sel->name, dc.sel, False); |
| 139 | } | 129 | } |
| 140 | XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); | 130 | XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); |
| 141 | XSync(dpy, False); | 131 | XSync(dpy, False); |
| @@ -145,20 +135,19 @@ void | |||
| 145 | drawtitle(Client *c) | 135 | drawtitle(Client *c) |
| 146 | { | 136 | { |
| 147 | int i; | 137 | int i; |
| 148 | Bool istile = arrange == dotile; | ||
| 149 | 138 | ||
| 150 | if(c == sel && issel) { | 139 | if(c == sel && issel) { |
| 151 | drawstatus(); | 140 | drawstatus(); |
| 152 | XUnmapWindow(dpy, c->twin); | 141 | XUnmapWindow(dpy, c->twin); |
| 153 | XSetWindowBorder(dpy, c->win, dc.fg); | 142 | XSetWindowBorder(dpy, c->win, dc.sel[ColBG]); |
| 154 | return; | 143 | return; |
| 155 | } | 144 | } |
| 156 | 145 | ||
| 157 | XSetWindowBorder(dpy, c->win, dc.bg); | 146 | XSetWindowBorder(dpy, c->win, dc.norm[ColBG]); |
| 158 | XMapWindow(dpy, c->twin); | 147 | XMapWindow(dpy, c->twin); |
| 159 | dc.x = dc.y = 0; | 148 | dc.x = dc.y = 0; |
| 160 | dc.w = c->tw; | 149 | dc.w = c->tw; |
| 161 | drawtext(c->name, !istile, False); | 150 | drawtext(c->name, dc.norm, False); |
| 162 | XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0); | 151 | XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0); |
| 163 | XSync(dpy, False); | 152 | XSync(dpy, False); |
| 164 | } | 153 | } |
