Commit 44987e99 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

feh_reload_image: Work around broken Imlib2 caching (closes #39)

parent 4abe831a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -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);
	}
+13 −15
Original line number Diff line number Diff line
@@ -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);
	}

	/* 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;
		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))) {

	if (!resize && ((old_w != gib_imlib_image_get_width(tmp)) ||
			(old_h != gib_imlib_image_get_height(tmp))))
		resize = 1;
			winwidget_reset_image(w);
		}
		winwidget_free_image(w);

	w->im = tmp;
	}
	winwidget_reset_image(w);

	w->mode = MODE_NORMAL;
	if ((w->im_w != gib_imlib_image_get_width(w->im))