| @@ -170,9 +170,11 @@ void tns_init(tns_t *tns, const fileinfo_t *files, int cnt, int *sel, win_t *win |
| 170 | 170 | | tns->loadnext = tns->first = tns->end = tns->r_first = tns->r_end = 0; |
| 171 | 171 | | tns->sel = sel; |
| 172 | 172 | | tns->win = win; |
| 173 | | − | tns->zl = 1; |
| 174 | 173 | | tns->dirty = false; |
| 175 | 174 | | |
| 175 | + | tns->zl = 0; |
| 176 | + | tns_zoom(tns, 1); |
| 177 | + | |
| 176 | 178 | | if ((homedir = getenv("XDG_CACHE_HOME")) == NULL || homedir[0] == '\0') { |
| 177 | 179 | | homedir = getenv("HOME"); |
| 178 | 180 | | dsuffix = "/.cache"; |
| @@ -392,7 +394,6 @@ void tns_render(tns_t *tns) |
| 392 | 394 | | thumb_t *t; |
| 393 | 395 | | win_t *win; |
| 394 | 396 | | int i, cnt, r, x, y; |
| 395 | | − | int thumb_dim; |
| 396 | 397 | | |
| 397 | 398 | | if (tns == NULL || tns->thumbs == NULL || tns->win == NULL) |
| 398 | 399 | | return; |
| @@ -403,9 +404,8 @@ void tns_render(tns_t *tns) |
| 403 | 404 | | win_clear(win); |
| 404 | 405 | | imlib_context_set_drawable(win->buf.pm); |
| 405 | 406 | | |
| 406 | | − | thumb_dim = thumb_size[tns->zl] + 10; |
| 407 | | − | tns->cols = MAX(1, win->w / thumb_dim); |
| 408 | | − | tns->rows = MAX(1, win->h / thumb_dim); |
| 407 | + | tns->cols = MAX(1, win->w / tns->dim); |
| 408 | + | tns->rows = MAX(1, win->h / tns->dim); |
| 409 | 409 | | |
| 410 | 410 | | if (tns->cnt < tns->cols * tns->rows) { |
| 411 | 411 | | tns->first = 0; |
| @@ -419,8 +419,8 @@ void tns_render(tns_t *tns) |
| 419 | 419 | | cnt -= r % tns->cols; |
| 420 | 420 | | } |
| 421 | 421 | | r = cnt % tns->cols ? 1 : 0; |
| 422 | | − | tns->x = x = (win->w - MIN(cnt, tns->cols) * thumb_dim) / 2 + 5; |
| 423 | | − | tns->y = y = (win->h - (cnt / tns->cols + r) * thumb_dim) / 2 + 5; |
| 422 | + | tns->x = x = (win->w - MIN(cnt, tns->cols) * tns->dim) / 2 + 5; |
| 423 | + | tns->y = y = (win->h - (cnt / tns->cols + r) * tns->dim) / 2 + 5; |
| 424 | 424 | | tns->loadnext = tns->cnt; |
| 425 | 425 | | tns->end = tns->first + cnt; |
| 426 | 426 | | |
| @@ -445,9 +445,9 @@ void tns_render(tns_t *tns) |
| 445 | 445 | | } |
| 446 | 446 | | if ((i + 1) % tns->cols == 0) { |
| 447 | 447 | | x = tns->x; |
| 448 | | − | y += thumb_dim; |
| 448 | + | y += tns->dim; |
| 449 | 449 | | } else { |
| 450 | | − | x += thumb_dim; |
| 450 | + | x += tns->dim; |
| 451 | 451 | | } |
| 452 | 452 | | } |
| 453 | 453 | | tns->dirty = false; |
| @@ -574,6 +574,8 @@ bool tns_zoom(tns_t *tns, int d) |
| 574 | 574 | | tns->zl = MAX(tns->zl, 0); |
| 575 | 575 | | tns->zl = MIN(tns->zl, ARRLEN(thumb_size)-1); |
| 576 | 576 | | |
| 577 | + | tns->dim = thumb_size[tns->zl] + 10; |
| 578 | + | |
| 577 | 579 | | if (tns->zl != oldzl) { |
| 578 | 580 | | for (i = 0; i < tns->cnt; i++) |
| 579 | 581 | | tns_unload(tns, i); |
| @@ -591,8 +593,8 @@ int tns_translate(tns_t *tns, int x, int y) |
| 591 | 593 | | if (x < tns->x || y < tns->y) |
| 592 | 594 | | return -1; |
| 593 | 595 | | |
| 594 | | − | n = tns->first + (y - tns->y) / (thumb_size[tns->zl] + 10) * tns->cols + |
| 595 | | − | (x - tns->x) / (thumb_size[tns->zl] + 10); |
| 596 | + | n = tns->first + (y - tns->y) / tns->dim * tns->cols + |
| 597 | + | (x - tns->x) / tns->dim; |
| 596 | 598 | | if (n >= tns->cnt) |
| 597 | 599 | | n = -1; |
| 598 | 600 | | |