diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/thumbnail.c | 6 | ||||
-rw-r--r-- | src/winwidget.c | 50 | ||||
-rw-r--r-- | src/winwidget.h | 5 |
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); |