diff options
author | Max Voit <max.voit+gtdv@with-eyes.net> | 2017-01-26 22:18:32 +0100 |
---|---|---|
committer | Bert Münnich <ber.t@posteo.de> | 2017-05-17 15:52:40 +0200 |
commit | edb117e3bdb4d6bef4a4749d94144df8472c0a4d (patch) | |
tree | 6bb2a23fff028c565f40257d3f867e47e1c91edb /main.c | |
parent | 1fb3ec576ca4de2056a914b8bc3fd5ba8e99429e (diff) |
Add autoreload support by inotify (and dummy backend nop)
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -38,6 +38,7 @@ #include "thumbs.h" #include "util.h" #include "window.h" +#include "autoreload.h" #define _MAPPINGS_CONFIG #include "config.h" @@ -64,6 +65,7 @@ fileinfo_t *files; int filecnt, fileidx; int alternate; int markcnt; +autoreload_t autoreload; int prefix; bool extprefix; @@ -98,6 +100,7 @@ timeout_t timeouts[] = { void cleanup(void) { img_close(&img, false); + arl_cleanup(); tns_free(&tns); win_close(&win); } @@ -317,6 +320,7 @@ void load_image(int new) info.open = false; open_info(); + arl_setup(); if (img.multi.cnt > 0 && img.multi.animate) set_timeout(animate, img.multi.frames[img.multi.sel].delay, true); @@ -685,7 +689,7 @@ void run(void) init_thumb = mode == MODE_THUMB && tns.initnext < filecnt; load_thumb = mode == MODE_THUMB && tns.loadnext < tns.end; - if ((init_thumb || load_thumb || to_set || info.fd != -1) && + if ((init_thumb || load_thumb || to_set || info.fd != -1 || autoreload.fd != -1) && XPending(win.env.dpy) == 0) { if (load_thumb) { @@ -708,9 +712,15 @@ void run(void) FD_SET(info.fd, &fds); xfd = MAX(xfd, info.fd); } + if (autoreload.fd != -1) { + FD_SET(autoreload.fd, &fds); + xfd = MAX(xfd, autoreload.fd); + } select(xfd + 1, &fds, 0, 0, to_set ? &timeout : NULL); if (info.fd != -1 && FD_ISSET(info.fd, &fds)) read_info(); + if (autoreload.fd != -1 && FD_ISSET(autoreload.fd, &fds)) + arl_handle(); } continue; } @@ -854,6 +864,7 @@ int main(int argc, char **argv) win_init(&win); img_init(&img, &win); + arl_init(); if ((homedir = getenv("XDG_CONFIG_HOME")) == NULL || homedir[0] == '\0') { homedir = getenv("HOME"); |