aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2022-06-01 10:59:16 +0200
committerN-R-K <nrk@disroot.org>2022-06-02 10:09:51 +0200
commit810a9651a362992383081619ca63122f41f1cd0a (patch)
treebea298b12676f642a4801a5d6385a781f918a639 /main.c
parent364c3d6f019a26e68f2bfb9594d6bc599a947be2 (diff)
downloadnsxiv-810a9651a362992383081619ca63122f41f1cd0a.tar.zst
reduce calls to win-title
rather than calling the script unconditionally per redraw, we now have a `title_dirty` flag and keep track of when any of the relavent information changes. Co-authored-by: Arthur Williams <taaparthur@gmail.com> Partially fixes: https://github.com/nsxiv/nsxiv/issues/258
Diffstat (limited to 'main.c')
-rw-r--r--main.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/main.c b/main.c
index 5dc52d4..7c7b436 100644
--- a/main.c
+++ b/main.c
@@ -85,6 +85,8 @@ static struct {
extcmd_t f;
} wintitle;
+bool title_dirty;
+
static timeout_t timeouts[] = {
{ { 0, 0 }, false, redraw },
{ { 0, 0 }, false, reset_cursor },
@@ -343,6 +345,7 @@ void load_image(int new)
close_info();
open_info();
arl_setup(&arl, files[fileidx].path);
+ title_dirty = true;
if (img.multi.cnt > 0 && img.multi.animate)
set_timeout(animate, img.multi.frames[img.multi.sel].delay, true);
@@ -451,7 +454,10 @@ void redraw(void)
tns_render(&tns);
}
update_info();
- win_set_title(&win, false);
+ if (title_dirty) {
+ win_set_title(&win, false);
+ title_dirty = false;
+ }
win_draw(&win);
reset_timeout(redraw);
reset_cursor();