summaryrefslogtreecommitdiff
path: root/src/support.c
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-03-01 21:29:35 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2010-03-01 21:29:35 +0100
commitb70e4366354eb7c182c9adb0bd7ac952f432d96a (patch)
tree87f8195daf6ffa21cf42b5b498a96065d78231e7 /src/support.c
parent3670fc8ea0f23221e3723531d59e26b584819ec2 (diff)
downloadfeh-b70e4366354eb7c182c9adb0bd7ac952f432d96a.zip
Apply patchto add --bg-fill (fullscreen background preserving aspect ratio)
Diffstat (limited to 'src/support.c')
-rw-r--r--src/support.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/support.c b/src/support.c
index abe18ce..4688d6f 100644
--- a/src/support.c
+++ b/src/support.c
@@ -53,16 +53,19 @@ void feh_wm_set_bg_file(char *file, unsigned char bgmode)
switch (bgmode) {
case BG_MODE_SEAMLESS:
gib_imlib_image_tile(im);
- feh_wm_set_bg(NULL, im, 0, 0, 0, 1);
+ feh_wm_set_bg(NULL, im, 0, 0, 0, 0, 1);
break;
case BG_MODE_TILE:
- feh_wm_set_bg(file, im, 0, 0, 0, 1);
+ feh_wm_set_bg(file, im, 0, 0, 0, 0, 1);
break;
case BG_MODE_SCALE:
- feh_wm_set_bg(file, im, 0, 1, 0, 1);
+ feh_wm_set_bg(file, im, 0, 1, 0, 0, 1);
+ break;
+ case BG_MODE_FILL:
+ feh_wm_set_bg(file, im, 0, 0, 1, 0, 1);
break;
default:
- feh_wm_set_bg(file, im, 1, 0, 0, 1);
+ feh_wm_set_bg(file, im, 1, 0, 0, 0, 1);
break;
}
gib_imlib_free_image_and_decache(im);
@@ -70,7 +73,8 @@ void feh_wm_set_bg_file(char *file, unsigned char bgmode)
}
}
-void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, int desktop, int set)
+void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
+ int filled, int desktop, int set)
{
char bgname[20];
int num = (int) rand();
@@ -203,6 +207,27 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, int desk
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) {
+ 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;
+
+ if ((u * y) > (x * v)) {
+ h = y;
+ w = (y * u) / v;
+ s = (x - w) / 2;
+ } else {
+ h = (x * v) / u;
+ w = x;
+ t = (y - h) / 2;
+ }
+ pmap_d1 = XCreatePixmap(disp, root, w, h, depth);
+ 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 {
w = gib_imlib_image_get_width(im);
h = gib_imlib_image_get_height(im);