summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.c33
-rw-r--r--thumbs.c1
-rw-r--r--thumbs.h3
3 files changed, 20 insertions, 17 deletions
diff --git a/main.c b/main.c
index 7f5c453..e6353d3 100644
--- a/main.c
+++ b/main.c
@@ -158,15 +158,21 @@ void update_title() {
float size;
const char *unit;
- if (img.valid) {
- size = filesize;
- size_readable(&size, &unit);
- n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] <%d%%> (%.2f%s) %s",
- fileidx + 1, filecnt, (int) (img.zoom * 100.0), size, unit,
- filenames[fileidx]);
+ if (mode == MODE_THUMBS) {
+ n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] %s",
+ tns.cnt ? tns.sel + 1 : 0, tns.cnt,
+ tns.cnt ? tns.thumbs[tns.sel].filename : "");
} else {
- n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] broken: %s",
- fileidx + 1, filecnt, filenames[fileidx]);
+ if (img.valid) {
+ size = filesize;
+ size_readable(&size, &unit);
+ n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] <%d%%> (%.2f%s) %s",
+ fileidx + 1, filecnt, (int) (img.zoom * 100.0), size, unit,
+ filenames[fileidx]);
+ } else {
+ n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] broken: %s",
+ fileidx + 1, filecnt, filenames[fileidx]);
+ }
}
if (n >= TITLE_LEN) {
@@ -491,7 +497,7 @@ void run() {
if (tns_loaded == filecnt)
win_set_cursor(&win, CURSOR_ARROW);
if (!XPending(win.env.dpy)) {
- tns_render(&tns, &win);
+ redraw();
continue;
} else {
timeout = 1;
@@ -503,13 +509,8 @@ void run() {
FD_ZERO(&fds);
FD_SET(xfd, &fds);
- if (!XPending(win.env.dpy) && !select(xfd + 1, &fds, 0, 0, &t)) {
- timeout = 0;
- if (mode == MODE_NORMAL)
- img_render(&img, &win);
- else
- tns_render(&tns, &win);
- }
+ if (!XPending(win.env.dpy) && !select(xfd + 1, &fds, 0, 0, &t))
+ redraw();
}
if (!XNextEvent(win.env.dpy, &ev)) {
diff --git a/thumbs.c b/thumbs.c
index b4e6976..a5b98fa 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -69,6 +69,7 @@ void tns_load(tns_t *tns, win_t *win, const char *filename) {
z = MIN(zw, zh);
t = &tns->thumbs[tns->cnt++];
+ t->filename = filename;
t->w = z * w;
t->h = z * h;
diff --git a/thumbs.h b/thumbs.h
index 170be27..01b161a 100644
--- a/thumbs.h
+++ b/thumbs.h
@@ -22,11 +22,12 @@
#include "window.h"
typedef struct thumb_s {
+ Pixmap pm;
+ const char *filename;
int x;
int y;
int w;
int h;
- Pixmap pm;
} thumb_t;
typedef struct tns_s {