| @@ -465,7 +465,8 @@ void run_key_handler(const char *key, unsigned int mask) |
| 465 | 465 | | { |
| 466 | 466 | | pid_t pid; |
| 467 | 467 | | int retval, status, n = mode == MODE_IMAGE ? fileidx : tns.sel; |
| 468 | | − | char kstr[32]; |
| 468 | + | char kstr[32], oldbar[sizeof(win.bar.l)]; |
| 469 | + | bool restore_bar = mode == MODE_IMAGE && info.cmd != NULL; |
| 469 | 470 | | struct stat oldst, newst; |
| 470 | 471 | | |
| 471 | 472 | | if (keyhandler.cmd == NULL) { |
| @@ -483,6 +484,11 @@ void run_key_handler(const char *key, unsigned int mask) |
| 483 | 484 | | mask & Mod1Mask ? "M-" : "", |
| 484 | 485 | | mask & ShiftMask ? "S-" : "", key); |
| 485 | 486 | | |
| 487 | + | if (restore_bar) |
| 488 | + | memcpy(oldbar, win.bar.l, sizeof(win.bar.l)); |
| 489 | + | strncpy(win.bar.l, "Running key handler...", sizeof(win.bar.l)); |
| 490 | + | win_update_bar(&win); |
| 491 | + | win_set_cursor(&win, CURSOR_WATCH); |
| 486 | 492 | | stat(files[n].path, &oldst); |
| 487 | 493 | | |
| 488 | 494 | | if ((pid = fork()) == 0) { |
| @@ -491,10 +497,8 @@ void run_key_handler(const char *key, unsigned int mask) |
| 491 | 497 | | exit(EXIT_FAILURE); |
| 492 | 498 | | } else if (pid < 0) { |
| 493 | 499 | | warn("could not fork key handler"); |
| 494 | | − | return; |
| 500 | + | goto end; |
| 495 | 501 | | } |
| 496 | | − | win_set_cursor(&win, CURSOR_WATCH); |
| 497 | | − | |
| 498 | 502 | | waitpid(pid, &status, 0); |
| 499 | 503 | | retval = WEXITSTATUS(status); |
| 500 | 504 | | if (WIFEXITED(status) == 0 || retval != 0) |
| @@ -504,10 +508,12 @@ void run_key_handler(const char *key, unsigned int mask) |
| 504 | 508 | | memcmp(&oldst.st_mtime, &newst.st_mtime, sizeof(oldst.st_mtime)) == 0) |
| 505 | 509 | | { |
| 506 | 510 | | /* file has not changed */ |
| 507 | | − | win_set_cursor(&win, CURSOR_ARROW); |
| 508 | | − | set_timeout(reset_cursor, TO_CURSOR_HIDE, true); |
| 509 | | − | return; |
| 511 | + | goto end; |
| 510 | 512 | | } |
| 513 | + | restore_bar = false; |
| 514 | + | strncpy(win.bar.l, "Reloading image...", sizeof(win.bar.l)); |
| 515 | + | win_update_bar(&win); |
| 516 | + | |
| 511 | 517 | | if (mode == MODE_IMAGE) { |
| 512 | 518 | | img_close(&img, true); |
| 513 | 519 | | load_image(fileidx); |
| @@ -520,6 +526,10 @@ void run_key_handler(const char *key, unsigned int mask) |
| 520 | 526 | | if (tns.sel >= tns.cnt) |
| 521 | 527 | | tns.sel = tns.cnt - 1; |
| 522 | 528 | | } |
| 529 | + | end: |
| 530 | + | if (restore_bar) |
| 531 | + | memcpy(win.bar.l, oldbar, sizeof(win.bar.l)); |
| 532 | + | set_timeout(reset_cursor, TO_CURSOR_HIDE, true); |
| 523 | 533 | | redraw(); |
| 524 | 534 | | } |
| 525 | 535 | | |