summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--man/feh.pre5
-rw-r--r--src/feh.h2
-rw-r--r--src/options.c5
-rw-r--r--src/support.c42
5 files changed, 56 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 038e9b1..f031ce7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+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
diff --git a/man/feh.pre b/man/feh.pre
index 0dbb631..08b9b33 100644
--- a/man/feh.pre
+++ b/man/feh.pre
@@ -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
diff --git a/src/feh.h b/src/feh.h
index 23d41fc..b72fb88 100644
--- a/src/feh.h
+++ b/src/feh.h
@@ -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,
diff --git a/src/options.c b/src/options.c
index 606e2ee..f7381a7 100644
--- a/src/options.c
+++ b/src/options.c
@@ -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);
diff --git a/src/support.c b/src/support.c
index 3e80828..3b13416 100644
--- a/src/support.c
+++ b/src/support.c
@@ -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);