wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 4a85fd4aa0b75a1ee077be7197a2608029ae6668
parent 207aac30fe4ffd3e96f31f0e2d752a5ac66ea28e
Author: Kris Maglione <bsdaemon@wmii.de>
Date:   Sat,  1 Jul 2006 06:52:44 -0400

Made xcharof non-recursive (same algorithm)


Diffstat:
liblitz/input.c | 19++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/liblitz/input.c b/liblitz/input.c @@ -116,17 +116,18 @@ blitz_ispointinrect(int x, int y, XRectangle * r) static char * xcharof(BlitzInput *i, int x, char *start, unsigned int len) { - unsigned int piv, tw; + unsigned int tw; - if(!(piv = len / 2)) - return start; /* found */ + while((len /= 2)) { + tw = blitz_textwidth_l(i->font, start, len); - tw = blitz_textwidth_l(i->font, start, piv); - - if(x < tw) - return xcharof(i, x, start, piv); - else - return xcharof(i, x - tw, start + piv, strlen(start + piv)); + if(x >= tw) { + x -= tw; + start += len; + len = strlen(start); + } + } + return start; /* found */ } static char *