From 44987e991f923eb1fee80f6a5d9538adc0c88d30 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 16 Apr 2011 21:44:57 +0200 Subject: feh_reload_image: Work around broken Imlib2 caching (closes #39) --- src/signals.c | 1 - src/slideshow.c | 28 +++++++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/signals.c b/src/signals.c index 85104a6..956c861 100644 --- a/src/signals.c +++ b/src/signals.c @@ -69,7 +69,6 @@ void feh_handle_signal(int signo) else if (signo == SIGUSR2) slideshow_change_image(winwid, SLIDE_PREV); } else if (opt.multiwindow) { - puts("yo"); for (i = window_num - 1; i >= 0; i--) feh_reload_image(windows[i], 0, 0); } 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)) -- cgit v1.2.3