summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-02-28 19:44:21 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-02-28 19:44:21 +0100
commitc2e0b7239522dc417b87f45cd133fb8f046dedfa (patch)
treedb02a2cc715f9345c7dc587788b44678475fd723
parent017b13bcf1cb0e3d82e684d7fcf01954613f8173 (diff)
Respect --geometry in --bg-fill (closes #209)
-rw-r--r--man/feh.pre10
-rw-r--r--src/wallpaper.c27
2 files changed, 31 insertions, 6 deletions
diff --git a/man/feh.pre b/man/feh.pre
index 5290f79..46de5d1 100644
--- a/man/feh.pre
+++ b/man/feh.pre
@@ -919,13 +919,13 @@ instead.
.
.Pp
.
-For the
-.Cm --bg-center
+For
+.Cm --bg-center , --bg-fill ,
and
-.Cm --bg-max
-options, you can use the
+.Cm --bg-max ,
+you can use
.Cm --geometry
-option to specify an offset from one side of the screen instead of
+to specify an offset from one side of the screen instead of
centering the image. Positive values will offset from the left/top
side, negative values from the bottom/right. +0 and -0 are both
valid and distinct values.
diff --git a/src/wallpaper.c b/src/wallpaper.c
index 758a81a..2d3d3bc 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -160,11 +160,36 @@ static void feh_wm_set_bg_filled(Pixmap pmap, Imlib_Image im, int use_filelist,
render_x = ( cut_x ? ((img_w - render_w) >> 1) : 0);
render_y = ( !cut_x ? ((img_h - render_h) >> 1) : 0);
+ if ((opt.geom_flags & XValue) && cut_x) {
+ if (opt.geom_flags & XNegative) {
+ render_x = img_w - render_w + opt.geom_x;
+ } else {
+ render_x = opt.geom_x;
+ }
+ if (render_x < 0) {
+ render_x = 0;
+ } else if (render_x + render_w > img_w) {
+ render_x = img_w - render_w;
+ }
+ }
+ else if ((opt.geom_flags & YValue) && !cut_x) {
+ if (opt.geom_flags & YNegative) {
+ render_y = img_h - render_h + opt.geom_y;
+ } else {
+ render_y = opt.geom_y;
+ }
+ if (render_y < 0) {
+ render_y = 0;
+ } else if (render_y + render_h > img_h) {
+ render_y = img_h - render_h;
+ }
+ }
+
gib_imlib_render_image_part_on_drawable_at_size(pmap, im,
render_x, render_y,
render_w, render_h,
x, y, w, h,
- 1, 0, !opt.force_aliasing);
+ 1, 1, !opt.force_aliasing);
if (use_filelist)
gib_imlib_free_image_and_decache(im);