Commit f68ec648 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Patch by Stefan Mark: Add --bg-max wallpaper mode

parent d37e6dad
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
git HEAD

    * Patch yb Stefan Mark: Add --bg-max (scaled with borders)

Tue, 24 Aug 2010 19:23:36 +0200  Daniel Friesel <derf@chaosdorf.de>

* Release v1.9
+5 −0
Original line number Diff line number Diff line
@@ -551,6 +551,11 @@ Like
but preserves aspect ratio by zooming the image until it fits.  Either a
horizontal or a vertical part of the image will be cut off
.
.It Cm --bg-max
Like
.Cm --bg-fill ,
but scale the image to the maximum size that fits the screen with black borders on one side.
.
.It Cm --bg-scale
Fit the file into the background without repeating it, cutting off stuff or
using borders.  But the aspect ratio is not preserved either
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ enum mode_type { MODE_NORMAL = 0, MODE_PAN, MODE_ZOOM, MODE_ROTATE, MODE_BLUR, M
};

enum bgmode_type { BG_MODE_NONE = 0, BG_MODE_TILE, BG_MODE_CENTER,
	BG_MODE_SEAMLESS, BG_MODE_SCALE, BG_MODE_FILL
	BG_MODE_SEAMLESS, BG_MODE_SCALE, BG_MODE_FILL, BG_MODE_MAX
};

enum slide_change { SLIDE_NEXT, SLIDE_PREV, SLIDE_RAND, SLIDE_FIRST, SLIDE_LAST,
+5 −0
Original line number Diff line number Diff line
@@ -411,6 +411,7 @@ static void feh_parse_option_array(int argc, char **argv)
		{"action8"       , 1, 0, 216},
		{"action9"       , 1, 0, 217},
		{"bg-fill"       , 1, 0, 218},
		{"bg-max"        , 1, 0, 219},
		{"index-name"    , 1, 0, 230},
		{"index-size"    , 1, 0, 231},
		{"index-dim"     , 1, 0, 232},
@@ -682,6 +683,10 @@ static void feh_parse_option_array(int argc, char **argv)
			opt.bgmode = BG_MODE_FILL;
			opt.output_file = estrdup(optarg);
			break;
		case 219:
			opt.bgmode = BG_MODE_MAX;
			opt.output_file = estrdup(optarg);
			break;
		case 204:
			free(opt.menu_style);
			opt.menu_style = estrdup(optarg);
+41 −1
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ void feh_wm_set_bg_file(char *file, unsigned char bgmode)
			break;
		case BG_MODE_FILL:
			feh_wm_set_bg(file, im, 0, 0, 1, 0, 1);
		case BG_MODE_MAX:
			feh_wm_set_bg(file, im, 0, 0, 2, 0, 1);
			break;
		default:
			feh_wm_set_bg(file, im, 1, 0, 0, 0, 1);
@@ -205,7 +207,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
			gib_imlib_render_image_on_drawable(pmap_d1, im, x, y, 1, 0, 0);
			XFreeGC(disp, gc);
			fehbg = estrjoin(" ", "feh --bg-center", filbuf, NULL);
		} else if (filled) {
		} else if (filled == 1) {
			int x = scr->width;
			int y = scr->height;
			int u = gib_imlib_image_get_width(im);
@@ -226,6 +228,44 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
			gib_imlib_render_image_on_drawable_at_size(pmap_d1, im, s, t,
					w, h, 1, 0, 1);
			fehbg = estrjoin(" ", "feh --bg-fill", filbuf, NULL);
		} else if (filled == 2) {
			int x = scr->width;
			int y = scr->height;
			int u = gib_imlib_image_get_width(im);
			int v = gib_imlib_image_get_height(im);
			int s = 0;
			int t = 0;
			XGCValues gcval;

			if(u>v) {
				w = x;
				h = (((x * 10) / u) * v) / 10;
				t = (y - h) / 2;
				if(h>y) {
					h = y;
					w = (((y * 10) / h) * w) / 10;
					s = (x - w) / 2;
					t = 0;
				}
			} else {
				h = y;
				w = (((y * 10) / v) * u) / 10;
				s = (x - w) / 2;
				if(w>x) {
					w = x;
					h = (((x * 10) / w) * h) / 10;
					s = 0;
					t = (y - h) / 2;
				}
			}

			pmap_d1 = XCreatePixmap(disp, root, x, y, depth);
			gcval.foreground = BlackPixel(disp, DefaultScreen(disp));
			gc = XCreateGC(disp, root, GCForeground, &gcval);
			XFillRectangle(disp, pmap_d1, gc, 0, 0, x, y);
			gib_imlib_render_image_on_drawable_at_size(pmap_d1, im, s, t, w, h, 1, 0, 1);
			XFreeGC(disp, gc);
			fehbg = estrjoin(" ", "feh --bg-max", filbuf, NULL);
		} else {
			w = gib_imlib_image_get_width(im);
			h = gib_imlib_image_get_height(im);