diff options
author | Bert <ber.t@gmx.com> | 2011-02-18 15:02:49 +0100 |
---|---|---|
committer | Bert <ber.t@gmx.com> | 2011-02-18 15:02:49 +0100 |
commit | 637be490753ff107e1c43a1c69a786ada6b02e2c (patch) | |
tree | dabd9fa846b4c0ad6e1f2ea4c00b83f8b9fdafbc | |
parent | 73a92795982d1c0896217caabcd48335c3ed9d63 (diff) |
Nicer tns_translate
-rw-r--r-- | thumbs.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -181,9 +181,11 @@ int tns_translate(tns_t *tns, int x, int y) { if (!tns || x < tns->x || y < tns->y) return -1; - if ((n = (y - tns->y) / thumb_dim * tns->cols + (x - tns->x) / thumb_dim) < tns->cnt) { + n = (y - tns->y) / thumb_dim * tns->cols + (x - tns->x) / thumb_dim; + + if (n < tns->cnt) { t = &tns->thumbs[n]; - if (x > t->x && x < t->x + t->w && y > t->y && y < t->y + t->h) + if (x >= t->x && x <= t->x + t->w && y >= t->y && y <= t->y + t->h) return n; } |