Krolyxon
Commit 637be49

Branches

Refs →

nsxiv637be49

Nicer tns_translate

Author
Bert
Date
2011-02-18 15:02 +0100
Parent
73a9279
Commit
637be490753ff107e1c43a1c69a786ada6b02e2c

+4 −2

1 file changed

  1. M thumbs.c +4 −2
M thumbs.c View
@@ -181,9 +181,11 @@ int tns_translate(tns_t *tns, int x, int y) {
181181 if (!tns || x < tns->x || y < tns->y)
182182 return -1;
183183
184− if ((n = (y - tns->y) / thumb_dim * tns->cols + (x - tns->x) / thumb_dim) < tns->cnt) {
184+ n = (y - tns->y) / thumb_dim * tns->cols + (x - tns->x) / thumb_dim;
185+
186+ if (n < tns->cnt) {
185187 t = &tns->thumbs[n];
186− if (x > t->x && x < t->x + t->w && y > t->y && y < t->y + t->h)
188+ if (x >= t->x && x <= t->x + t->w && y >= t->y && y <= t->y + t->h)
187189 return n;
188190 }
189191