aboutsummaryrefslogtreecommitdiff
path: root/x11/hsetroot
diff options
context:
space:
mode:
authorAlexey Dokuchaev <danfe@FreeBSD.org>2017-12-28 10:54:29 +0000
committerAlexey Dokuchaev <danfe@FreeBSD.org>2017-12-28 10:54:29 +0000
commitb13e4c707e6d4658dc84c0dd8923ec0974670c63 (patch)
tree5f0a4d7d50b7f127fb420c8c9bfff479b4ada740 /x11/hsetroot
parentbb8e16483cb2d9a0e1e497ed8c810e84c826f30d (diff)
downloadports-b13e4c707e6d4658dc84c0dd8923ec0974670c63.tar.gz
ports-b13e4c707e6d4658dc84c0dd8923ec0974670c63.zip
Add custom patch that introduces "sane" image rendering mode: it allows to
select the best aspect ratio and display image with minimal scaling yet not centered. This mode is useful when one wants to use an image with author's copyright in the lower corner and wants to hide it. Existing modes did not always provide the best possible result. While here, take maintainership.
Notes
Notes: svn path=/head/; revision=457444
Diffstat (limited to 'x11/hsetroot')
-rw-r--r--x11/hsetroot/Makefile4
-rw-r--r--x11/hsetroot/files/patch-hsetroot.c56
2 files changed, 58 insertions, 2 deletions
diff --git a/x11/hsetroot/Makefile b/x11/hsetroot/Makefile
index fa206f8e155b..88695cb98728 100644
--- a/x11/hsetroot/Makefile
+++ b/x11/hsetroot/Makefile
@@ -3,10 +3,10 @@
PORTNAME= hsetroot
PORTVERSION= 1.0.2
-PORTREVISION= 12
+PORTREVISION= 13
CATEGORIES= x11
-MAINTAINER= ports@FreeBSD.org
+MAINTAINER= danfe@FreeBSD.org
COMMENT= Wallpaper manipulation utility for X11
LICENSE= GPLv2
diff --git a/x11/hsetroot/files/patch-hsetroot.c b/x11/hsetroot/files/patch-hsetroot.c
new file mode 100644
index 000000000000..56516311ea9d
--- /dev/null
+++ b/x11/hsetroot/files/patch-hsetroot.c
@@ -0,0 +1,56 @@
+--- hsetroot.c.orig 2016-02-14 00:09:11 UTC
++++ hsetroot.c
+@@ -8,7 +8,7 @@
+ #include "outputs.h"
+
+
+-typedef enum { Full, Fill, Center, Tile, Xtend, Cover } ImageMode;
++typedef enum { Full, Fill, Center, Tile, Xtend, Cover, Sane } ImageMode;
+
+ void
+ usage(char *commandline)
+@@ -33,6 +33,7 @@ usage(char *commandline)
+ "Image files:\n"
+ " -center <image> Render an image centered on screen\n"
+ " -cover <image> Render an image centered on screen scaled to fill the screen fully\n"
++ " -sane <image> Render an image in sane mode (choose the best aspect, but do not center)\n"
+ " -tile <image> Render an image tiled\n"
+ " -full <image> Render an image maximum aspect\n"
+ " -extend <image> Render an image max aspect and fill borders\n"
+@@ -229,6 +230,20 @@ load_image(ImageMode mode, const char *arg, int alpha,
+ }
+ }
+ }
++ } else if (mode == Sane) {
++ int newW, newH;
++ double aspect_w = ((double) o.w) / imgW;
++ double aspect_h = ((double) o.h) / imgH;
++ if (aspect_h < aspect_w) {
++ // image is taller
++ newW = o.w;
++ newH = (int) (imgH * aspect_w);
++ } else {
++ // image is wider
++ newW = (int) (imgW * aspect_h);
++ newH = o.h;
++ }
++ imlib_blend_image_onto_image(buffer, 0, 0, 0, imgW, imgH, 0, 0, newW, newH);
+ } else { // Center || Tile
+ int left = (o.w - imgW) / 2;
+ int top = (o.h - imgH) / 2;
+@@ -457,6 +472,15 @@ main(int argc, char **argv)
+ }
+ if (load_image(Cover, argv[i], alpha, image, outputs, noutputs) == 0) {
+ fprintf (stderr, "Bad image (%s)\n", argv[i]);
++ continue;
++ }
++ } else if (strcmp (argv[i], "-sane") == 0) {
++ if ((++i) >= argc) {
++ fprintf(stderr, "Missing image\n");
++ continue;
++ }
++ if (load_image(Sane, argv[i], alpha, image, outputs, noutputs) == 0) {
++ fprintf(stderr, "Bad image (%s)\n", argv[i]);
+ continue;
+ }
+ } else if (strcmp(argv[i], "-tint") == 0) {