{
int i;
- c->tw = 0;
- for(i = 0; i < ntags; i++)
- if(c->tags[i])
- c->tw += textw(tags[i]);
- c->tw += textw(c->name);
+ c->tw = textw(c->name);
if(c->tw > c->w)
c->tw = c->w + 2;
c->tx = c->x + c->w - c->tw + 2;
c->ty = c->y;
if(isvisible(c))
- XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th);
+ XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th);
else
- XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th);
+ XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th);
}
ban(Client *c)
{
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
- XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
+ XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
}
void
Client *c;
for(c = clients; c; c = c->next)
- if(c->title == w)
+ if(c->twin == w)
return c;
return NULL;
}
twa.background_pixmap = ParentRelative;
twa.event_mask = ExposureMask | EnterWindowMask;
- c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
+ c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
0, DefaultDepth(dpy, screen), CopyFromParent,
DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
sel = c;
arrange(NULL);
XMapWindow(dpy, c->win);
- XMapWindow(dpy, c->title);
+ XMapWindow(dpy, c->twin);
if(isvisible(c))
focus(c);
}
settitle(Client *c)
{
char **list = NULL;
- int n;
+ int i, n;
XTextProperty name;
name.nitems = 0;
XSetErrorHandler(xerrordummy);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
- XDestroyWindow(dpy, c->title);
+ XDestroyWindow(dpy, c->twin);
if(c->prev)
c->prev->next = c->next;
}
static void
-drawtext(const char *text, Bool invert)
+drawborder()
{
- int x, y, w, h;
- static char buf[256];
- unsigned int len, olen;
- XGCValues gcv;
XPoint points[5];
- XRectangle r = { dc.x, dc.y, dc.w, dc.h };
-
- XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
- XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
- XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
- XSetForeground(dpy, dc.gc, dc.border);
points[0].x = dc.x;
points[0].y = dc.y;
points[1].x = dc.w - 1;
points[4].x = 0;
points[4].y = -(dc.h - 1);
XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
+}
+
+static void
+drawtext(const char *text, Bool invert, Bool highlight)
+{
+ int x, y, w, h;
+ static char buf[256];
+ unsigned int len, olen;
+ DC tmp;
+ XGCValues gcv;
+ XRectangle r = { dc.x, dc.y, dc.w, dc.h };
+
+ XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
+ XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
+ XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
+ XSetForeground(dpy, dc.gc, dc.border);
+ drawborder();
if(!text)
return;
if(w > dc.w)
return; /* too long */
-
gcv.foreground = invert ? dc.bg : dc.fg;
gcv.background = invert ? dc.fg : dc.bg;
if(dc.font.set) {
XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv);
- XmbDrawImageString(dpy, dc.drawable, dc.font.set, dc.gc,
- x, y, buf, len);
+ XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
}
else {
gcv.font = dc.font.xfont->fid;
XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
- XDrawImageString(dpy, dc.drawable, dc.gc, x, y, buf, len);
+ XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
+ }
+ if(highlight) {
+ tmp = dc;
+ dc.x += 2;
+ dc.y += 2;
+ dc.w -= 4;
+ dc.h -= 4;
+ drawborder();
+ dc = tmp;
}
}
dc.x = dc.y = 0;
dc.w = bw;
- drawtext(NULL, !istile);
+ drawtext(NULL, !istile, False);
dc.w = 0;
for(i = 0; i < ntags; i++) {
dc.x += dc.w;
dc.w = textw(tags[i]);
if(istile)
- drawtext(tags[i], seltag[i]);
+ drawtext(tags[i], seltag[i], sel && sel->tags[i]);
else
- drawtext(tags[i], !seltag[i]);
+ drawtext(tags[i], !seltag[i], sel && sel->tags[i]);
}
x = dc.x + dc.w;
dc.w = textw(stext);
dc.x = bx + bw - dc.w;
- drawtext(stext, !istile);
-
- if(sel) {
- for(i = 0; i < ntags; i++)
- if(sel->tags[i]) {
- dc.w = textw(tags[i]);
- dc.x -= dc.w;
- if(dc.x < x)
- break;
- drawtext(tags[i], istile);
- }
- if(dc.x > x && (dc.x - x) > bh) {
- dc.w = dc.x - x;
- dc.x = x;
- drawtext(sel->name, istile);
- }
+ if(dc.x < x) {
+ dc.x = x;
+ dc.w = bw - x;
+ }
+ drawtext(stext, !istile, False);
+
+ if(sel && ((dc.w = dc.x - x) > bh)) {
+ dc.x = x;
+ drawtext(sel->name, istile, False);
}
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
XSync(dpy, False);
if(c == sel && issel) {
drawstatus();
- XUnmapWindow(dpy, c->title);
+ XUnmapWindow(dpy, c->twin);
XSetWindowBorder(dpy, c->win, dc.fg);
return;
}
XSetWindowBorder(dpy, c->win, dc.bg);
- XMapWindow(dpy, c->title);
-
- dc.y = dc.w = 0;
- dc.x = c->tw;
- for(i = 0; i < ntags; i++)
- if(c->tags[i]) {
- dc.w = textw(tags[i]);
- dc.x -= dc.w;
- drawtext(tags[i], !istile);
- }
- dc.w = dc.x;
- dc.x = 0;
- drawtext(c->name, !istile);
- XCopyArea(dpy, dc.drawable, c->title, dc.gc, 0, 0, c->tw, c->th, 0, 0);
+ XMapWindow(dpy, c->twin);
+ dc.x = dc.y = 0;
+ dc.w = c->tw;
+ drawtext(c->name, !istile, False);
+ XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
XSync(dpy, False);
}