diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2018-02-14 22:35:06 +0100 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2018-02-14 22:35:06 +0100 | 
| commit | 14a9702bb2365e51a6f8854f85a13b6e5cf4001c (patch) | |
| tree | 6a6c396f017f4e4c10794d74e3550481be580477 /src | |
| parent | 4abbd21f698945a662ed57e2dad6b6b25de9e474 (diff) | |
| parent | 5e75b5ef3e7d0270913c04645398bc3596c2a90a (diff) | |
Merge branch 'ulteq-dimension-pruning-without-preload'
Diffstat (limited to 'src')
| -rw-r--r-- | src/feh.h | 1 | ||||
| -rw-r--r-- | src/filelist.c | 14 | ||||
| -rw-r--r-- | src/imlib.c | 12 | ||||
| -rw-r--r-- | src/options.c | 2 | ||||
| -rw-r--r-- | src/options.h | 1 | ||||
| -rw-r--r-- | src/slideshow.c | 16 | ||||
| -rw-r--r-- | src/winwidget.c | 2 | 
7 files changed, 38 insertions, 10 deletions
| @@ -133,6 +133,7 @@ void init_list_mode(void);  void init_loadables_mode(void);  void init_unloadables_mode(void);  void feh_clean_exit(void); +int feh_should_ignore_image(Imlib_Image * im);  int feh_load_image(Imlib_Image * im, feh_file * file);  void show_mini_usage(void);  void slideshow_change_image(winwidget winwid, int change, int render); diff --git a/src/filelist.c b/src/filelist.c index b569b8a..9a4af27 100644 --- a/src/filelist.c +++ b/src/filelist.c @@ -464,9 +464,17 @@ int feh_cmp_format(void *file1, void *file2)  void feh_prepare_filelist(void)  { -	if (opt.list || opt.customlist || (opt.sort > SORT_MTIME) -			|| opt.preload || opt.min_width || opt.min_height -			|| (opt.max_width != UINT_MAX) || (opt.max_height != UINT_MAX)) { +	/* +	 * list and customlist mode as well as the somewhat more fancy sort modes +	 * need access to file infos. Preloading them is also useful for +	 * list/customlist as --min-dimension/--max-dimension may filter images +	 * which should not be processed. +	 * Finally, if --min-dimension/--max-dimension (-> opt.filter_by_dimensions) +	 * is set and we're in thumbnail mode, we need to filter images first so +	 * we can create a properly sized thumbnail list. +	 */ +	if (opt.list || opt.preload || opt.customlist || (opt.sort > SORT_MTIME) +			|| (opt.filter_by_dimensions && (opt.index || opt.collage || opt.thumbs || opt.bgmode))) {  		/* For these sort options, we have to preload images */  		filelist = feh_file_info_preload(filelist);  		if (!gib_list_length(filelist)) diff --git a/src/imlib.c b/src/imlib.c index 6de6bdb..d9c5cd0 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -139,6 +139,18 @@ void init_x_and_imlib(void)  	return;  } +int feh_should_ignore_image(Imlib_Image * im) +{ +	if (opt.filter_by_dimensions) { +		unsigned int w = gib_imlib_image_get_width(im); +		unsigned int h = gib_imlib_image_get_height(im); +		if (w < opt.min_width || w > opt.max_width || h < opt.min_height || h > opt.max_height) { +			return 1; +		} +	} +	return 0; +} +  int feh_load_image_char(Imlib_Image * im, char *filename)  {  	feh_file *file; diff --git a/src/options.c b/src/options.c index bf5c67c..76d70c5 100644 --- a/src/options.c +++ b/src/options.c @@ -433,6 +433,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)  			opt.debug = 1;  			break;  		case '<': +			opt.filter_by_dimensions = 1;  			XParseGeometry(optarg, &discard, &discard, &opt.max_width, &opt.max_height);  			if (opt.max_width == 0)  				opt.max_width = UINT_MAX; @@ -440,6 +441,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)  				opt.max_height = UINT_MAX;  			break;  		case '>': +			opt.filter_by_dimensions = 1;  			XParseGeometry(optarg, &discard, &discard, &opt.min_width, &opt.min_height);  			break;  		case '.': diff --git a/src/options.h b/src/options.h index c6959c8..9bf2763 100644 --- a/src/options.h +++ b/src/options.h @@ -75,6 +75,7 @@ struct __fehoptions {  	unsigned char no_fehbg;  	unsigned char keep_zoom_vp;  	unsigned char insecure_ssl; +	unsigned char filter_by_dimensions;  	char *output_file;  	char *output_dir; diff --git a/src/slideshow.c b/src/slideshow.c index c6d82a6..d56c1b6 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -360,16 +360,20 @@ void slideshow_change_image(winwidget winwid, int change, int render)  			tzoom = winwid->zoom;  		} -		if ((winwidget_loadimage(winwid, FEH_FILE(current_file->data))) -		    != 0) { +		if (winwidget_loadimage(winwid, FEH_FILE(current_file->data))) { +			int w = gib_imlib_image_get_width(winwid->im); +			int h = gib_imlib_image_get_height(winwid->im); +			if (feh_should_ignore_image(winwid->im)) { +				last = current_file; +				continue; +			}  			winwid->mode = MODE_NORMAL;  			winwid->file = current_file; -			if ((winwid->im_w != gib_imlib_image_get_width(winwid->im)) -			    || (winwid->im_h != gib_imlib_image_get_height(winwid->im))) +			if ((winwid->im_w != w) || (winwid->im_h != h))  				winwid->had_resize = 1;  			winwidget_reset_image(winwid); -			winwid->im_w = gib_imlib_image_get_width(winwid->im); -			winwid->im_h = gib_imlib_image_get_height(winwid->im); +			winwid->im_w = w; +			winwid->im_h = h;  			if (opt.keep_zoom_vp) {  				/* put back in: */  				winwid->mode = tmode; diff --git a/src/winwidget.c b/src/winwidget.c index 3311383..9600465 100644 --- a/src/winwidget.c +++ b/src/winwidget.c @@ -115,7 +115,7 @@ winwidget winwidget_create_from_file(gib_list * list, char type)  	ret->file = list;  	ret->type = type; -	if (winwidget_loadimage(ret, file) == 0) { +	if ((winwidget_loadimage(ret, file) == 0) || feh_should_ignore_image(ret->im)) {  		winwidget_destroy(ret);  		return(NULL);  	} | 
