summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Willner <sven.willner@gmail.com>2017-09-01 14:51:21 +0200
committerSven Willner <sven.willner@gmail.com>2017-09-01 14:51:21 +0200
commit177cbff6af7b9845d592fb0497464d70ee423418 (patch)
treec7ccf8d9706016bb0c8857bc915ba11e7288a1c5
parent2a981df18167cf8dd0a1310b03061010c8ef71dd (diff)
fixed inotify for thumbnail mode
-rw-r--r--src/thumbnail.c6
-rw-r--r--src/winwidget.c50
-rw-r--r--src/winwidget.h5
3 files changed, 40 insertions, 21 deletions
diff --git a/src/thumbnail.c b/src/thumbnail.c
index edf0f4f..b7108c8 100644
--- a/src/thumbnail.c
+++ b/src/thumbnail.c
@@ -790,7 +790,13 @@ void feh_thumbnail_show_fullsize(feh_file *thumbfile)
free(thumbwin->file);
thumbwin->file = gib_list_add_front(NULL, thumbfile);
winwidget_rename(thumbwin, s);
+#ifdef HAVE_INOTIFY
+ winwidget_inotify_remove(thumbwin);
+#endif
feh_reload_image(thumbwin, 1, 1);
+#ifdef HAVE_INOTIFY
+ winwidget_inotify_add(thumbwin, thumbfile->filename);
+#endif
}
}
diff --git a/src/winwidget.c b/src/winwidget.c
index 1a0bc7d..039a582 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -764,12 +764,7 @@ void winwidget_destroy_xwin(winwidget winwid)
void winwidget_destroy(winwidget winwid)
{
#ifdef HAVE_INOTIFY
- if (winwid->inotify_wd >= 0) {
- D(("Removing inotify watch\n"));
- if (inotify_rm_watch(opt.inotify_fd, winwid->inotify_wd))
- eprintf("inotify_rm_watch failed");
- winwid->inotify_wd = -1;
- }
+ winwidget_inotify_remove(winwid);
#endif
winwidget_destroy_xwin(winwid);
if (winwid->name)
@@ -785,6 +780,32 @@ void winwidget_destroy(winwidget winwid)
}
#ifdef HAVE_INOTIFY
+void winwidget_inotify_remove(winwidget winwid)
+{
+ if (winwid->inotify_wd >= 0) {
+ D(("Removing inotify watch\n"));
+ if (inotify_rm_watch(opt.inotify_fd, winwid->inotify_wd))
+ eprintf("inotify_rm_watch failed");
+ winwid->inotify_wd = -1;
+ }
+}
+#endif
+
+#ifdef HAVE_INOTIFY
+void winwidget_inotify_add(winwidget winwid, char *filename)
+{
+ if (opt.inotify) {
+ D(("Adding inotify watch for %s\n", filename));
+ winwid->inotify_wd = inotify_add_watch(opt.inotify_fd,
+ filename,
+ IN_CLOSE_WRITE);
+ if (winwid->inotify_wd < 0)
+ eprintf("inotify_add_watch failed");
+ }
+}
+#endif
+
+#ifdef HAVE_INOTIFY
#define INOTIFY_BUFFER_LEN (1024 * (sizeof (struct inotify_event)) + 16)
void feh_event_handle_inotify(void)
{
@@ -802,7 +823,6 @@ void feh_event_handle_inotify(void)
event = (struct inotify_event *) &buf[i];
for (int i = 0; i < window_num; i++) {
if(windows[i]->inotify_wd == event->wd) {
- windows[i]->inotify_wd = -1;
feh_reload_image(windows[i], 0, 1);
break;
}
@@ -846,24 +866,12 @@ int winwidget_loadimage(winwidget winwid, feh_file * file)
{
D(("filename %s\n", file->filename));
#ifdef HAVE_INOTIFY
- if (winwid->inotify_wd >= 0) {
- D(("Removing inotify watch\n"));
- if (inotify_rm_watch(opt.inotify_fd, winwid->inotify_wd))
- eprintf("inotify_rm_watch failed");
- winwid->inotify_wd = -1;
- }
+ winwidget_inotify_remove(winwid);
#endif
int res = feh_load_image(&(winwid->im), file);
#ifdef HAVE_INOTIFY
if (res) {
- if (opt.inotify) {
- D(("Adding inotify watch for %s\n", file->filename));
- winwid->inotify_wd = inotify_add_watch(opt.inotify_fd,
- file->filename,
- IN_CLOSE_WRITE);
- if (winwid->inotify_wd < 0)
- eprintf("inotify_add_watch failed");
- }
+ winwidget_inotify_add(winwid, file->filename);
}
#endif
return(res);
diff --git a/src/winwidget.h b/src/winwidget.h
index 0555201..d6b9546 100644
--- a/src/winwidget.h
+++ b/src/winwidget.h
@@ -122,6 +122,11 @@ struct __winwidget {
#endif
};
+#ifdef HAVE_INOTIFY
+void winwidget_inotify_remove(winwidget winwid);
+void winwidget_inotify_add(winwidget winwid, char *filename);
+#endif
+
int winwidget_loadimage(winwidget winwid, feh_file * filename);
void winwidget_show(winwidget winwid);
void winwidget_show_menu(winwidget winwid);