optimize drawtext a little

This commit is contained in:
Julien Danjou 2007-09-11 17:46:25 +02:00
parent 9223e8c0b8
commit 60c33390a8
1 changed files with 2 additions and 2 deletions

4
draw.c
View File

@ -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);