nsxiv637be49
Nicer tns_translate
+4 −2
1 file changed
- M thumbs.c +4 −2
| @@ -181,9 +181,11 @@ int tns_translate(tns_t *tns, int x, int y) { | |||
| 181 | 181 | if (!tns || x < tns->x || y < tns->y) | |
| 182 | 182 | return -1; | |
| 183 | 183 | ||
| 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) { | |
| 185 | 187 | 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) | |
| 187 | 189 | return n; | |
| 188 | 190 | } | |
| 189 | 191 | ||