diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/thumbnail.c | 2 | ||||
-rw-r--r-- | src/winwidget.c | 25 | ||||
-rw-r--r-- | src/winwidget.h | 2 |
3 files changed, 15 insertions, 14 deletions
diff --git a/src/thumbnail.c b/src/thumbnail.c index b7108c8..761162f 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -795,7 +795,7 @@ void feh_thumbnail_show_fullsize(feh_file *thumbfile) #endif feh_reload_image(thumbwin, 1, 1); #ifdef HAVE_INOTIFY - winwidget_inotify_add(thumbwin, thumbfile->filename); + winwidget_inotify_add(thumbwin, thumbfile); #endif } } diff --git a/src/winwidget.c b/src/winwidget.c index 9270d69..c012fc0 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -792,13 +792,13 @@ void winwidget_inotify_remove(winwidget winwid) #endif #ifdef HAVE_INOTIFY -void winwidget_inotify_add(winwidget winwid, char *filename) +void winwidget_inotify_add(winwidget winwid, feh_file * file) { if (opt.auto_reload) { - D(("Adding inotify watch for %s\n", filename)); - winwid->inotify_wd = inotify_add_watch(opt.inotify_fd, - filename, - IN_CLOSE_WRITE); + D(("Adding inotify watch for %s\n", file->filename)); + char dir[PATH_MAX]; + feh_file_dirname(dir, file, PATH_MAX); + winwid->inotify_wd = inotify_add_watch(opt.inotify_fd, dir, IN_CLOSE_WRITE | IN_MOVED_TO); if (winwid->inotify_wd < 0) eprintf("inotify_add_watch failed"); } @@ -824,12 +824,13 @@ void feh_event_handle_inotify(void) for (int j = 0; j < window_num; j++) { if(windows[j]->inotify_wd == event->wd) { if (event->mask & IN_IGNORED) { - D(("Inotify watch was implicitely removed\n")); - feh_reload_image(windows[j], 0, 1); - winwidget_inotify_add(windows[j], FEH_FILE(windows[j]->file->data)->filename); - } else if (event->mask & IN_CLOSE_WRITE) { - D(("Inotify says file changed\n")); - feh_reload_image(windows[j], 0, 1); + D(("inotify watch was implicitely removed\n")); + windows[j]->inotify_wd = -1; + } else if (event->mask & (IN_CLOSE_WRITE | IN_MOVED_TO)) { + if (strcmp(event->name, FEH_FILE(windows[j]->file->data)->name) == 0) { + D(("inotify says file changed\n")); + feh_reload_image(windows[j], 0, 1); + } } break; } @@ -878,7 +879,7 @@ int winwidget_loadimage(winwidget winwid, feh_file * file) int res = feh_load_image(&(winwid->im), file); #ifdef HAVE_INOTIFY if (res) { - winwidget_inotify_add(winwid, file->filename); + winwidget_inotify_add(winwid, file); } #endif return(res); diff --git a/src/winwidget.h b/src/winwidget.h index d6b9546..b8d777e 100644 --- a/src/winwidget.h +++ b/src/winwidget.h @@ -124,7 +124,7 @@ struct __winwidget { #ifdef HAVE_INOTIFY void winwidget_inotify_remove(winwidget winwid); -void winwidget_inotify_add(winwidget winwid, char *filename); +void winwidget_inotify_add(winwidget winwid, feh_file * file); #endif int winwidget_loadimage(winwidget winwid, feh_file * filename); |