summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoel Bradshaw <cincodenada@gmail.com>2013-09-26 00:42:43 -0700
committerJoel Bradshaw <cincodenada@gmail.com>2013-09-26 00:42:43 -0700
commitbae543b21847b3251f08acc6bcabffe8328067d1 (patch)
tree8c8351ccfc14a7202afb2ab4d6da61091e298e6d /src
parent520c79ab533a40a7bc3687df12b2b032290a3ef5 (diff)
Support geometry in --bg-max and --bg-center
Overloads the --geometry option for wallpaper setting Currently only supports the two options that result in black borders, --bg-max and --bg-center. For both, if a geometry offset is specified (w/h is ignored), the image will be offset the specified pixels from the screen edge Left side for + numbers, right side for -. +/-0 will align at the edge of the screen.
Diffstat (limited to 'src')
-rw-r--r--src/wallpaper.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/wallpaper.c b/src/wallpaper.c
index 30c3925..886beb6 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -104,8 +104,21 @@ static void feh_wm_set_bg_centered(Pixmap pmap, Imlib_Image im, int use_filelist
if (use_filelist)
feh_wm_load_next(&im);
- offset_x = (w - gib_imlib_image_get_width(im)) >> 1;
- offset_y = (h - gib_imlib_image_get_height(im)) >> 1;
+ if(opt.geom_flags & XValue)
+ if(opt.geom_flags & XNegative)
+ offset_x = (w - gib_imlib_image_get_width(im)) + opt.geom_x;
+ else
+ offset_x = opt.geom_x;
+ else
+ offset_x = (w - gib_imlib_image_get_width(im)) >> 1;
+
+ if(opt.geom_flags & YValue)
+ if(opt.geom_flags & YNegative)
+ offset_y = (h - gib_imlib_image_get_height(im)) + opt.geom_y;
+ else
+ offset_y = opt.geom_y;
+ else
+ offset_y = (h - gib_imlib_image_get_height(im)) >> 1;
gib_imlib_render_image_part_on_drawable_at_size(pmap, im,
((offset_x < 0) ? -offset_x : 0),
@@ -161,6 +174,7 @@ static void feh_wm_set_bg_maxed(Pixmap pmap, Imlib_Image im, int use_filelist,
{
int img_w, img_h, border_x;
int render_w, render_h, render_x, render_y;
+ int margin_x, margin_y;
if (use_filelist)
feh_wm_load_next(&im);
@@ -173,8 +187,24 @@ static void feh_wm_set_bg_maxed(Pixmap pmap, Imlib_Image im, int use_filelist,
render_w = ( border_x ? ((img_w * h) / img_h) : w);
render_h = ( !border_x ? ((img_h * w) / img_w) : h);
- render_x = x + ( border_x ? ((w - render_w) >> 1) : 0);
- render_y = y + ( !border_x ? ((h - render_h) >> 1) : 0);
+ if(opt.geom_flags & XValue)
+ if(opt.geom_flags & XNegative)
+ margin_x = (w - render_w) + opt.geom_x;
+ else
+ margin_x = opt.geom_x;
+ else
+ margin_x = (w - render_w) >> 1;
+
+ if(opt.geom_flags & YValue)
+ if(opt.geom_flags & YNegative)
+ margin_y = (h - render_h) + opt.geom_y;
+ else
+ margin_y = opt.geom_y;
+ else
+ margin_y = (h - render_h) >> 1;
+
+ render_x = x + ( border_x ? margin_x : 0);
+ render_y = y + ( !border_x ? margin_y : 0);
gib_imlib_render_image_on_drawable_at_size(pmap, im,
render_x, render_y,