Add autoreload support by inotify (and dummy backend nop)
This commit is contained in:
13
main.c
13
main.c
@ -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");
|
||||
|
Reference in New Issue
Block a user