| @@ -233,30 +233,36 @@ static bool check_timeouts(struct timeval *t) |
| 233 | 233 | | return tmin > 0; |
| 234 | 234 | | } |
| 235 | 235 | | |
| 236 | | − | size_t get_win_title(unsigned char *buf, int len) |
| 236 | + | size_t get_win_title(unsigned char *buf, int len, bool init) |
| 237 | 237 | | { |
| 238 | 238 | | char *argv[8]; |
| 239 | 239 | | spawn_t pfd; |
| 240 | 240 | | char w[12] = "", h[12] = "", z[12] = "", fidx[12], fcnt[12]; |
| 241 | 241 | | ssize_t n = -1; |
| 242 | 242 | | |
| 243 | | − | if (wintitle.f.err || buf == NULL || len <= 0) |
| 243 | + | if (buf == NULL || len <= 0) |
| 244 | 244 | | return 0; |
| 245 | 245 | | |
| 246 | | − | if (mode == MODE_IMAGE) { |
| 247 | | − | snprintf(w, ARRLEN(w), "%d", img.w); |
| 248 | | − | snprintf(h, ARRLEN(h), "%d", img.h); |
| 249 | | − | snprintf(z, ARRLEN(z), "%d", (int)(img.zoom * 100)); |
| 250 | | − | } |
| 251 | | − | snprintf(fidx, ARRLEN(fidx), "%d", fileidx+1); |
| 252 | | − | snprintf(fcnt, ARRLEN(fcnt), "%d", filecnt); |
| 253 | | − | construct_argv(argv, ARRLEN(argv), wintitle.f.cmd, files[fileidx].path, |
| 254 | | − | fidx, fcnt, w, h, z, NULL); |
| 255 | | − | pfd = spawn(wintitle.f.cmd, argv, X_READ); |
| 256 | | − | if (pfd.readfd >= 0) { |
| 257 | | − | if ((n = read(pfd.readfd, buf, len-1)) > 0) |
| 258 | | − | buf[n] = '\0'; |
| 246 | + | if (init) { |
| 247 | + | n = snprintf((char *)buf, len, "%s", options->res_name != NULL ? |
| 248 | + | options->res_name : "nsxiv"); |
| 249 | + | } else if (!wintitle.f.err) { |
| 250 | + | if (mode == MODE_IMAGE) { |
| 251 | + | snprintf(w, ARRLEN(w), "%d", img.w); |
| 252 | + | snprintf(h, ARRLEN(h), "%d", img.h); |
| 253 | + | snprintf(z, ARRLEN(z), "%d", (int)(img.zoom * 100)); |
| 254 | + | } |
| 255 | + | snprintf(fidx, ARRLEN(fidx), "%d", fileidx+1); |
| 256 | + | snprintf(fcnt, ARRLEN(fcnt), "%d", filecnt); |
| 257 | + | construct_argv(argv, ARRLEN(argv), wintitle.f.cmd, files[fileidx].path, |
| 258 | + | fidx, fcnt, w, h, z, NULL); |
| 259 | + | pfd = spawn(wintitle.f.cmd, argv, X_READ); |
| 260 | + | if (pfd.readfd >= 0) { |
| 261 | + | if ((n = read(pfd.readfd, buf, len-1)) > 0) |
| 262 | + | buf[n] = '\0'; |
| 263 | + | } |
| 259 | 264 | | } |
| 265 | + | |
| 260 | 266 | | return MAX(0, n); |
| 261 | 267 | | } |
| 262 | 268 | | |
| @@ -459,7 +465,7 @@ void redraw(void) |
| 459 | 465 | | tns_render(&tns); |
| 460 | 466 | | } |
| 461 | 467 | | update_info(); |
| 462 | | − | win_set_title(&win); |
| 468 | + | win_set_title(&win, false); |
| 463 | 469 | | win_draw(&win); |
| 464 | 470 | | reset_timeout(redraw); |
| 465 | 471 | | reset_cursor(); |