1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

Add fill screen scale to wmsetbg

I noticed that I can have different background with wmmsetbg for each
desktop and wanted to use it, but it was missing option to fill the
screen with proportionally scaled image, so here it is.
This commit is contained in:
Amadeusz Sławiński
2012-06-03 17:48:14 +02:00
committed by Carlos R. Mafra
parent 21a5f41c08
commit fc5c0fe1a4

View File

@@ -175,9 +175,18 @@ applyImage(RContext * rc, BackgroundTexture * texture, RImage * image, char type
switch (toupper(type)) { switch (toupper(type)) {
case 'S': case 'S':
case 'M': case 'M':
case 'F':
if (toupper(type) == 'S') { if (toupper(type) == 'S') {
w = width; w = width;
h = height; h = height;
} else if(toupper(type) == 'F') {
if (image->width * height > image->height * width) {
w = (height * image->width) / image->height;
h = height;
} else {
w = width;
h = (width * image->height) / image->width;
}
} else { } else {
if (image->width * height > image->height * width) { if (image->width * height > image->height * width) {
w = width; w = width;
@@ -465,7 +474,7 @@ BackgroundTexture *parseTexture(RContext * rc, char *text)
texture->pixmap = pixmap; texture->pixmap = pixmap;
} else if (strcasecmp(type, "cpixmap") == 0 } else if (strcasecmp(type, "cpixmap") == 0
|| strcasecmp(type, "spixmap") == 0 || strcasecmp(type, "spixmap") == 0 || strcasecmp(type, "fpixmap") == 0
|| strcasecmp(type, "mpixmap") == 0 || strcasecmp(type, "tpixmap") == 0) { || strcasecmp(type, "mpixmap") == 0 || strcasecmp(type, "tpixmap") == 0) {
XColor color; XColor color;
Pixmap pixmap = None; Pixmap pixmap = None;
@@ -528,6 +537,7 @@ BackgroundTexture *parseTexture(RContext * rc, char *text)
case 'S': case 'S':
case 'M': case 'M':
case 'C': case 'C':
case 'F':
{ {
Pixmap tpixmap = Pixmap tpixmap =
XCreatePixmap(dpy, root, scrWidth, scrHeight, DefaultDepth(dpy, scr)); XCreatePixmap(dpy, root, scrWidth, scrHeight, DefaultDepth(dpy, scr));
@@ -1136,6 +1146,7 @@ void print_help()
puts(" -e, --center center image"); puts(" -e, --center center image");
puts(" -s, --scale scale image (default)"); puts(" -s, --scale scale image (default)");
puts(" -a, --maxscale scale image and keep aspect ratio"); puts(" -a, --maxscale scale image and keep aspect ratio");
puts(" -f, --fillscale scale image to fill screen and keep aspect ratio");
puts(" -u, --update-wmaker update WindowMaker domain database"); puts(" -u, --update-wmaker update WindowMaker domain database");
puts(" -D, --update-domain <domain> update <domain> database"); puts(" -D, --update-domain <domain> update <domain> database");
puts(" -c, --colors <cpc> colors per channel to use"); puts(" -c, --colors <cpc> colors per channel to use");
@@ -1227,6 +1238,8 @@ int main(int argc, char **argv)
style = "cpixmap"; style = "cpixmap";
} else if (strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "--maxscale") == 0) { } else if (strcmp(argv[i], "-a") == 0 || strcmp(argv[i], "--maxscale") == 0) {
style = "mpixmap"; style = "mpixmap";
} else if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--fillscale") == 0) {
style = "fpixmap";
} else if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--dither") == 0) { } else if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--dither") == 0) {
render_mode = RDitheredRendering; render_mode = RDitheredRendering;
obey_user++; obey_user++;