From 0a006ed6767e42bbc1608400faf0fa9e008ff49c Mon Sep 17 00:00:00 2001 From: ulteq Date: Wed, 27 Dec 2017 19:03:03 +0100 Subject: Add option to change the imlib cache size This option allows you to change the default imlib2 image cache size of 4 MiB. --- src/imlib.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index 5b96e8a..48808a1 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -131,6 +131,8 @@ void init_x_and_imlib(void) imlib_context_set_operation(IMLIB_OP_COPY); wmDeleteWindow = XInternAtom(disp, "WM_DELETE_WINDOW", False); + imlib_set_cache_size(opt.cache_size * 1024 * 1024); + /* Initialise random numbers */ srand(getpid() * time(NULL) % ((unsigned int) -1)); -- cgit v1.2.3 From 91b331f0fa6999dff69fa1da90a8816b8d855ccc Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 28 Dec 2017 19:04:20 +0100 Subject: Always check file modification time before loading images from cache --- src/imlib.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/imlib.c') diff --git a/src/imlib.c b/src/imlib.c index 48808a1..73b7039 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -256,6 +256,16 @@ int feh_load_image(Imlib_Image * im, feh_file * file) return(0); } + /* + * By default, Imlib2 unconditionally loads a cached file without checking + * if it was modified on disk. However, feh (or rather its users) should + * expect image changes to appear at the next reload. So we tell Imlib2 to + * always check the file modification time and only use a cached image if + * the mtime was not changed. The performance penalty is usually negligible. + */ + imlib_context_set_image(*im); + imlib_image_set_changes_on_disk(); + #ifdef HAVE_LIBEXIF int orientation = 0; ExifData *exifData = exif_data_new_from_file(file->filename); -- cgit v1.2.3