optimize drawtext a little
This commit is contained in:
parent
9223e8c0b8
commit
60c33390a8
4
draw.c
4
draw.c
|
@ -31,6 +31,8 @@ drawtext(Display *disp, const char *text, unsigned long col[ColLast])
|
||||||
/* shorten text if necessary */
|
/* shorten text if necessary */
|
||||||
while(len && (w = textnw(buf, len)) > dc.w - h)
|
while(len && (w = textnw(buf, len)) > dc.w - h)
|
||||||
buf[--len] = 0;
|
buf[--len] = 0;
|
||||||
|
if(w > dc.w)
|
||||||
|
return; /* too long */
|
||||||
if(len < olen)
|
if(len < olen)
|
||||||
{
|
{
|
||||||
if(len > 1)
|
if(len > 1)
|
||||||
|
@ -40,8 +42,6 @@ drawtext(Display *disp, const char *text, unsigned long col[ColLast])
|
||||||
if(len > 3)
|
if(len > 3)
|
||||||
buf[len - 3] = '.';
|
buf[len - 3] = '.';
|
||||||
}
|
}
|
||||||
if(w > dc.w)
|
|
||||||
return; /* too long */
|
|
||||||
XSetForeground(disp, dc.gc, col[ColFG]);
|
XSetForeground(disp, dc.gc, col[ColFG]);
|
||||||
if(dc.font.set)
|
if(dc.font.set)
|
||||||
XmbDrawString(disp, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
|
XmbDrawString(disp, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
|
||||||
|
|
Loading…
Reference in New Issue