diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-04-16 21:44:57 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-04-16 21:44:57 +0200 |
commit | 44987e991f923eb1fee80f6a5d9538adc0c88d30 (patch) | |
tree | c3afb48091c90d643c1c4b30f32cfab50ba16faf /src/slideshow.c | |
parent | 4abe831aa00eeb2fbbbe5d0b5905e07b047fca71 (diff) |
feh_reload_image: Work around broken Imlib2 caching (closes #39)
Diffstat (limited to 'src/slideshow.c')
-rw-r--r-- | src/slideshow.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/slideshow.c b/src/slideshow.c index 497b9bc..79b931f 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -101,12 +101,15 @@ void feh_reload_image(winwidget w, int resize, int force_new) char *title, *new_title; int len; Imlib_Image tmp; + int old_w, old_h; if (!w->file) { weprintf("couldn't reload, this image has no file associated with it."); return; } + D(("resize %d, force_new %d\n", resize, force_new)); + free(FEH_FILE(w->file->data)->caption); FEH_FILE(w->file->data)->caption = NULL; @@ -116,10 +119,11 @@ void feh_reload_image(winwidget w, int resize, int force_new) title = estrdup(w->name); winwidget_rename(w, new_title); + old_w = gib_imlib_image_get_width(w->im); + old_h = gib_imlib_image_get_height(w->im); + /* force imlib2 not to cache */ - if (force_new) { - winwidget_free_image(w); - } + winwidget_free_image(w); /* if the image has changed in dimensions - we gotta resize */ if ((feh_load_image(&tmp, FEH_FILE(w->file->data))) == 0) { @@ -134,19 +138,13 @@ void feh_reload_image(winwidget w, int resize, int force_new) filelist = feh_file_remove_from_list(filelist, w->file); return; } - if (force_new) { - w->im = tmp; + + if (!resize && ((old_w != gib_imlib_image_get_width(tmp)) || + (old_h != gib_imlib_image_get_height(tmp)))) resize = 1; - winwidget_reset_image(w); - } else { - if ((gib_imlib_image_get_width(w->im) != gib_imlib_image_get_width(tmp)) - || (gib_imlib_image_get_height(w->im) != gib_imlib_image_get_height(tmp))) { - resize = 1; - winwidget_reset_image(w); - } - winwidget_free_image(w); - w->im = tmp; - } + + w->im = tmp; + winwidget_reset_image(w); w->mode = MODE_NORMAL; if ((w->im_w != gib_imlib_image_get_width(w->im)) |