1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-02 22:25:48 +01:00

Update for 0.51.0

This commit is contained in:
dan
1999-01-25 19:06:50 +00:00
parent 3aeb1eb052
commit 416e3a82be
238 changed files with 24235 additions and 11473 deletions

View File

@@ -7,10 +7,10 @@ bin_PROGRAMS = wxcopy wxpaste wdwrite getstyle setstyle seticons geticonset wmse
bin_SCRIPTS = wmaker.inst wm-oldmenu2new wsetfont
EXTRA_DIST = wmaker.inst.in bughint wm-oldmenu2new wsetfont
EXTRA_DIST = wmaker.inst.in bughint wm-oldmenu2new wsetfont directjpeg.c
INCLUDES = @DFLAGS@ -I$(top_srcdir)/wrlib -I$(top_srcdir)/libPropList\
@XCFLAGS@ @GFXFLAGS@
INCLUDES = @DFLAGS@ -I$(top_srcdir)/wrlib \
-I$(top_srcdir)/libPropList @XCFLAGS@ @GFXFLAGS@
# X_EXTRA_LIBS is for libproplist in systems that need -lsocket
liblist= $(top_builddir)/libPropList/libPropList.la @X_EXTRA_LIBS@
@@ -31,8 +31,8 @@ seticons_LDADD= $(liblist)
geticonset_LDADD= $(liblist)
wmsetbg_LDADD = \
$(top_builddir)/wrlib/libwraster.la \
$(top_builddir)/WINGs/libWINGs.a \
$(top_builddir)/wrlib/libwraster.la \
$(top_builddir)/libPropList/libPropList.la \
@GFXLFLAGS@ @XLFLAGS@ @GFXLIBS@ @XLIBS@ -lm
@@ -50,7 +50,7 @@ wxpaste_SOURCES = wxpaste.c
wdwrite_SOURCES = wdwrite.c
wmsetbg_SOURCES = wmsetbg.c
wmsetbg_SOURCES = wmsetbg.c
CLEANFILES = wmaker.inst

View File

@@ -63,8 +63,6 @@ DFLAGS = @DFLAGS@
GFXFLAGS = @GFXFLAGS@
GFXLFLAGS = @GFXLFLAGS@
GFXLIBS = @GFXLIBS@
I18N = @I18N@
I18N_MB = @I18N_MB@
ICONEXT = @ICONEXT@
INTLIBS = @INTLIBS@
LD = @LD@
@@ -77,19 +75,13 @@ NLSDIR = @NLSDIR@
NM = @NM@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
REDUCE_APPICONS = @REDUCE_APPICONS@
SHAPE = @SHAPE@
SOUND = @SOUND@
VERSION = @VERSION@
WPMOFILES = @WPMOFILES@
XCFLAGS = @XCFLAGS@
XGETTEXT = @XGETTEXT@
XLFLAGS = @XLFLAGS@
XLIBS = @XLIBS@
XSHM = @XSHM@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_LOCALE = @X_LOCALE@
pixmapdir = @pixmapdir@
wprefsdir = @wprefsdir@
AUTOMAKE_OPTIONS = no-dependencies
@@ -100,10 +92,10 @@ bin_PROGRAMS = wxcopy wxpaste wdwrite getstyle setstyle seticons geticonset wmse
bin_SCRIPTS = wmaker.inst wm-oldmenu2new wsetfont
EXTRA_DIST = wmaker.inst.in bughint wm-oldmenu2new wsetfont
EXTRA_DIST = wmaker.inst.in bughint wm-oldmenu2new wsetfont directjpeg.c
INCLUDES = @DFLAGS@ -I$(top_srcdir)/wrlib -I$(top_srcdir)/libPropList\
@XCFLAGS@ @GFXFLAGS@
INCLUDES = @DFLAGS@ -I$(top_srcdir)/wrlib \
-I$(top_srcdir)/libPropList @XCFLAGS@ @GFXFLAGS@
# X_EXTRA_LIBS is for libproplist in systems that need -lsocket
liblist= $(top_builddir)/libPropList/libPropList.la @X_EXTRA_LIBS@
@@ -123,8 +115,8 @@ seticons_LDADD= $(liblist)
geticonset_LDADD= $(liblist)
wmsetbg_LDADD = \
$(top_builddir)/wrlib/libwraster.la \
$(top_builddir)/WINGs/libWINGs.a \
$(top_builddir)/wrlib/libwraster.la \
$(top_builddir)/libPropList/libPropList.la \
@GFXLFLAGS@ @XLFLAGS@ @GFXLIBS@ @XLIBS@ -lm
@@ -142,7 +134,7 @@ wxpaste_SOURCES = wxpaste.c
wdwrite_SOURCES = wdwrite.c
wmsetbg_SOURCES = wmsetbg.c
wmsetbg_SOURCES = wmsetbg.c
CLEANFILES = wmaker.inst
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -180,8 +172,8 @@ geticonset_OBJECTS = geticonset.o
geticonset_DEPENDENCIES = $(top_builddir)/libPropList/libPropList.la
geticonset_LDFLAGS =
wmsetbg_OBJECTS = wmsetbg.o
wmsetbg_DEPENDENCIES = $(top_builddir)/wrlib/libwraster.la \
$(top_builddir)/WINGs/libWINGs.a \
wmsetbg_DEPENDENCIES = $(top_builddir)/WINGs/libWINGs.a \
$(top_builddir)/wrlib/libwraster.la \
$(top_builddir)/libPropList/libPropList.la
wmsetbg_LDFLAGS =
SCRIPTS = $(bin_SCRIPTS)

222
util/directjpeg.c Normal file
View File

@@ -0,0 +1,222 @@
/* directjpeg.c- loads a jpeg file directly into a XImage
*
* WindowMaker window manager
*
* Copyright (c) 1999 Alfredo K. Kojima
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include "../src/config.h"
#ifdef USE_JPEG
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <jpeglib.h>
#include "../wrlib/wraster.h"
#include <setjmp.h>
struct my_error_mgr {
struct jpeg_error_mgr pub; /* "public" fields */
jmp_buf setjmp_buffer; /* for return to caller */
};
typedef struct my_error_mgr * my_error_ptr;
/*
* Here's the routine that will replace the standard error_exit method:
*/
static void
my_error_exit (j_common_ptr cinfo)
{
/* cinfo->err really points to a my_error_mgr struct, so coerce pointer */
my_error_ptr myerr = (my_error_ptr) cinfo->err;
/* Always display the message. */
/* We could postpone this until after returning, if we chose. */
(*cinfo->err->output_message) (cinfo);
/* Return control to the setjmp point */
longjmp(myerr->setjmp_buffer, 1);
}
static Bool
canLoad(RContext *rc)
{
if (rc->depth != 16 || rc->vclass != TrueColor
|| rc->red_offset!=11 || rc->green_offset!=5 || rc->blue_offset!=0)
return False;
return True;
}
static void
readData(RContext *rc, struct jpeg_decompress_struct *cinfo,
JSAMPROW *buffer, RXImage *ximg)
{
int i, j;
unsigned long pixel;
int y = 0;
/* for 16bpp only */
while (cinfo->output_scanline < cinfo->output_height) {
jpeg_read_scanlines(cinfo, buffer, (JDIMENSION)1);
if (cinfo->out_color_space==JCS_RGB) {
for (i=0,j=0; i<cinfo->image_width; i++) {
printf("%i %i %i\n",
(((unsigned long)buffer[0][j])&0xf8)<<8,
(((unsigned long)buffer[0][j+1])&0xf4)<<3,
(((unsigned long)buffer[0][j+2]))>>3);
pixel = (((unsigned long)buffer[0][j++])&0xf8)<<8
|(((unsigned long)buffer[0][j++])&0xf4)<<3
|(((unsigned long)buffer[0][j++]))>>3;
XPutPixel(ximg->image, i, y, pixel);
}
} else {
for (i=0,j=0; i<cinfo->image_width; i++, j++) {
pixel = (unsigned long)buffer[0][j]<<8
|(unsigned long)buffer[0][j]<<3
|(unsigned long)buffer[0][j]>>3;
XPutPixel(ximg->image, i, y, pixel);
}
}
y++;
}
}
Pixmap
LoadJPEG(RContext *rc, char *file_name, int *width, int *height)
{
struct jpeg_decompress_struct cinfo;
JSAMPROW buffer[1];
FILE *file;
struct my_error_mgr jerr;
RXImage *ximg = NULL;
unsigned char buf[8];
Pixmap p = None;
if (!canLoad(rc))
return None;
file = fopen(file_name, "r");
if (!file) {
return None;
}
if (fread(buf, 2, 1, file) != 1) {
fclose(file);
return None;
}
if (buf[0] != 0xff || buf[1] != 0xd8) {
fclose(file);
return None;
}
rewind(file);
cinfo.err = jpeg_std_error(&jerr.pub);
jerr.pub.error_exit = my_error_exit;
/* Establish the setjmp return context for my_error_exit to use. */
if (setjmp(jerr.setjmp_buffer)) {
/* If we get here, the JPEG code has signaled an error.
* We need to clean up the JPEG object, close the input file, and return.
*/
jpeg_destroy_decompress(&cinfo);
fclose(file);
if (ximg) {
RDestroyXImage(rc, ximg);
}
return None;
}
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, file);
jpeg_read_header(&cinfo, TRUE);
buffer[0] = (JSAMPROW)malloc(cinfo.image_width*cinfo.num_components);
if (!buffer[0]) {
RErrorCode = RERR_NOMEMORY;
goto bye;
}
if(cinfo.jpeg_color_space==JCS_GRAYSCALE) {
cinfo.out_color_space=JCS_GRAYSCALE;
} else
cinfo.out_color_space = JCS_RGB;
cinfo.quantize_colors = FALSE;
cinfo.do_fancy_upsampling = FALSE;
cinfo.do_block_smoothing = FALSE;
jpeg_calc_output_dimensions(&cinfo);
ximg = RCreateXImage(rc, rc->depth, cinfo.image_width, cinfo.image_height);
if (!ximg) {
goto bye;
}
jpeg_start_decompress(&cinfo);
readData(rc, &cinfo, buffer, ximg);
jpeg_finish_decompress(&cinfo);
p = XCreatePixmap(rc->dpy, rc->drawable, cinfo.image_width,
cinfo.image_height, rc->depth);
RPutXImage(rc, p, rc->copy_gc, ximg, 0, 0, 0, 0, cinfo.image_width,
cinfo.image_height);
*width = cinfo.image_width;
*height = cinfo.image_height;
bye:
jpeg_destroy_decompress(&cinfo);
fclose(file);
if (buffer[0])
free(buffer[0]);
if (ximg)
RDestroyXImage(rc, ximg);
return p;
}
#endif /* USE_JPEG */

View File

@@ -63,6 +63,12 @@ static char *options[] = {
"IconBack",
"IconTitleColor",
"IconTitleBack",
#ifdef TITLE_TEXT_SHADOW
"Shadow",
"FShadowColor",
"PShadowColor",
"UShadowColor",
#endif
NULL
};
@@ -94,6 +100,21 @@ print_help()
}
char*
globalDefaultsPathForDomain(char *domain)
{
char path[1024];
char *tmp;
sprintf(path, "%s/%s/%s", PKGDATADIR, DEFAULTS_DIR, domain);
tmp = malloc(strlen(path)+2);
strcpy(tmp, path);
return tmp;
}
char*
defaultsPathForDomain(char *domain)
{
@@ -401,6 +422,12 @@ findCopyFile(char *dir, char *file)
char *fullPath;
fullPath = wfindfileinarray(PixmapPath, file);
if (!fullPath) {
char buffer[4000];
sprintf(buffer, "coould not find file %s", file);
abortar(buffer);
}
copyFile(dir, fullPath);
free(fullPath);
}
@@ -444,6 +471,7 @@ makeThemePack(proplist_t style, char *themeName)
if (t && (strcasecmp(t, "tpixmap")==0
|| strcasecmp(t, "spixmap")==0
|| strcasecmp(t, "cpixmap")==0
|| strcasecmp(t, "mpixmap")==0
|| strcasecmp(t, "tdgradient")==0
|| strcasecmp(t, "tvgradient")==0
|| strcasecmp(t, "thgradient")==0)) {
@@ -515,6 +543,16 @@ main(int argc, char **argv)
ProgName, path);
exit(1);
}
free(path);
/* get global value */
path = globalDefaultsPathForDomain("WindowMaker");
val = PLGetProplistWithPath(path);
if (val) {
PLMergeDictionaries(val, prop);
PLRelease(prop);
prop = val;
}
style = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
@@ -528,7 +566,8 @@ main(int argc, char **argv)
}
val = PLGetDictionaryEntry(prop, PLMakeString("PixmapPath"));
PixmapPath = PLGetString(val);
if (val)
PixmapPath = PLGetString(val);
if (theme_too) {
for (i=0; theme_options[i]!=NULL; i++) {
@@ -542,7 +581,6 @@ main(int argc, char **argv)
if (make_pack) {
char *path;
char *themeDir;
makeThemePack(style, style_file);

View File

@@ -38,6 +38,7 @@ char *FontOptions[] = {
"DisplayFont",
"MenuTextFont",
"MenuTitleFont",
"WindowTitleFont",
NULL
};
@@ -103,13 +104,14 @@ hackPaths(proplist_t style, char *prefix)
t = PLGetString(type);
if (t && (strcasecmp(t, "tpixmap")==0
|| strcasecmp(t, "spixmap")==0
|| strcasecmp(t, "mpixmap")==0
|| strcasecmp(t, "cpixmap")==0
|| strcasecmp(t, "tvgradient")==0
|| strcasecmp(t, "thgradient")==0
|| strcasecmp(t, "tdgradient")==0)) {
proplist_t file;
char buffer[4018];
file = PLGetArrayElement(value, 1);
sprintf(buffer, "%s/%s", prefix, PLGetString(file));
PLRemoveArrayElement(value, 1);
@@ -147,15 +149,17 @@ hackStyle(proplist_t style)
if (str) {
int j, found;
for (j = 0, found = 0; FontOptions[j]!=NULL; j++) {
if (strcasecmp(str, FontOptions[j])==0) {
PLRemoveDictionaryEntry(style, tmp);
found = 1;
break;
}
}
if (found)
continue;
if (ignoreFonts) {
for (j = 0, found = 0; FontOptions[j]!=NULL; j++) {
if (strcasecmp(str, FontOptions[j])==0) {
PLRemoveDictionaryEntry(style, tmp);
found = 1;
break;
}
}
if (found)
continue;
}
if (strcasecmp(str, "IconTitleColor")==0
|| strcasecmp(str, "IconTitleBack")==0) {

View File

@@ -3,6 +3,14 @@
# Install Window Maker for the current user
#
# xx herbert
if test x"$1" = x"--batch" ; then
BATCH="1"
else
BATCH=""
fi
# /xx herbert
# directory where system wide configuration is stored
GLOBALDIR="#pkgdatadir#"
@@ -112,7 +120,9 @@ echo "Copying defaults database..."
FILES=`(cd $GLOBALDIR/Defaults;ls *)`
all=""
for i in $FILES; do
if [ -f $GSDIR/Defaults/$i ]; then
# xx herbert
if [ -f $GSDIR/Defaults/$i -a -z "$BATCH" ]; then
# /xx herbert
echo "The configuration file \"$i\" already exists in your defaults database."
echo "Do you wish to replace it? <y/n/a> [n] $all"
if [ "$all" != "a" ]; then
@@ -203,7 +213,9 @@ fi
if test -z "#LITE#" ; then
FILES=`(cd $GLOBALDIR; ls menu menu.* plmenu plmenu.?? wmmacros)`
for i in $FILES; do
if [ -f "$GSDIR/Library/WindowMaker/$i" ]; then
# xx herbert
if [ -f "$GSDIR/Library/WindowMaker/$i" -a -z "$BATCH" ]; then
# /xx herbert
echo "The file \"$i\" already exists in $GSDIR/Library/WindowMaker"
echo "Do you wish to replace it? <y/n/a> [n] $all"
if [ "$all" != "a" ]; then
@@ -222,11 +234,30 @@ done
fi
cp $GLOBALDIR/README.themes $GSDIR/Library/WindowMaker
cp $GLOBALDIR/README $GSDIR/Library/WindowMaker
cp -i $GLOBALDIR/autostart.sh $GSDIR/Library/WindowMaker/autostart
chmod +rx $GSDIR/Library/WindowMaker/autostart
cp -i $GLOBALDIR/exitscript.sh $GSDIR/Library/WindowMaker/exitscript
chmod +rx $GSDIR/Library/WindowMaker/exitscript
cp $GLOBALDIR/README $GSDIR/Library/WindowMaker
# xx herbert
if test -n "$BATCH"; then
test -f ~$GSDIR/Library/WindowMaker/autostart || \
cp $GLOBALDIR/autostart.sh $GSDIR/Library/WindowMaker/autostart
chmod +rx $GSDIR/Library/WindowMaker/autostart
test -f ~$GSDIR/Library/WindowMaker/exitscript || \
cp $GLOBALDIR/exitscript.sh $GSDIR/Library/WindowMaker/exitscript
chmod +rx $GSDIR/Library/WindowMaker/exitscript
else
cp -i $GLOBALDIR/autostart.sh $GSDIR/Library/WindowMaker/autostart
chmod +rx $GSDIR/Library/WindowMaker/autostart
cp -i $GLOBALDIR/exitscript.sh $GSDIR/Library/WindowMaker/exitscript
chmod +rx $GSDIR/Library/WindowMaker/exitscript
fi
# /xx herbert
# xx herbert
if test -n "$BATCH" ; then
echo "Installation Finished"
exit 0
fi
# /xx herbert
#
#######################
@@ -250,10 +281,14 @@ else
fi
}
if test -z "`grep wmaker ~/.xinitrc`"; then
show_end_message
exit 0
fi
wmaker_found=1
for xinit in .xinitrc .Xclients .xsession; do
test ! -f "$HOME/$xinit" && continue
test -z "`grep wmaker $HOME/$xinit`"
[ $? -eq 0 ] && wmaker_found=0
done
[ $wmaker_found -eq 1 ] && show_end_message && exit 0
trap "show_end_message;exit" 2

View File

@@ -42,12 +42,15 @@
#include <proplist.h>
#define PROG_VERSION "wmsetbg (Window Maker) 2.1"
#define WORKSPACE_COUNT (MAX_WORKSPACES+1)
Display *dpy;
char *display = "";
Window root;
int scr;
int scrWidth;
@@ -57,6 +60,8 @@ Pixmap CurrentPixmap = None;
char *PixmapPath = NULL;
extern Pixmap LoadJPEG(RContext *rc, char *file_name, int *width, int *height);
typedef struct BackgroundTexture {
int refcount;
@@ -73,17 +78,20 @@ typedef struct BackgroundTexture {
RImage*
loadImage(RContext *rc, char *file)
{
char *path;
RImage *image;
path = wfindfile(PixmapPath, file);
if (!path) {
wwarning("%s:could not find image file used in texture", file);
return NULL;
if (access(file, F_OK)!=0) {
path = wfindfile(PixmapPath, file);
if (!path) {
wwarning("%s:could not find image file used in texture", file);
return NULL;
}
} else {
path = wstrdup(file);
}
image = RLoadImage(rc, path, 0);
@@ -97,7 +105,6 @@ loadImage(RContext *rc, char *file)
}
BackgroundTexture*
parseTexture(RContext *rc, char *text)
{
@@ -315,15 +322,24 @@ parseTexture(RContext *rc, char *text)
|| strcasecmp(type, "mpixmap")==0
|| strcasecmp(type, "tpixmap")==0) {
XColor color;
Pixmap pixmap;
RImage *image;
Pixmap pixmap = None;
RImage *image = NULL;
int w, h;
int iwidth, iheight;
GETSTR(val, tmp, 1);
/*
if (toupper(type[0]) == 'T' || toupper(type[0]) == 'C')
pixmap = LoadJPEG(rc, tmp, &iwidth, &iheight);
*/
image = loadImage(rc, tmp);
if (!image) {
goto error;
if (!pixmap) {
image = loadImage(rc, tmp);
if (!image) {
goto error;
}
iwidth = image->width;
iheight = image->height;
}
GETSTR(val, tmp, 2);
@@ -333,24 +349,26 @@ parseTexture(RContext *rc, char *text)
RDestroyImage(image);
goto error;
}
{
if (!XAllocColor(dpy, DefaultColormap(dpy, scr), &color)) {
RColor rcolor;
rcolor.red = color.red >> 8;
rcolor.green = color.green >> 8;
rcolor.blue = color.blue >> 8;
rcolor.blue = color.blue >> 8;
RGetClosestXColor(rc, &rcolor, &color);
}
switch (toupper(type[0])) {
case 'T':
texture->width = image->width;
texture->height = image->height;
if (!RConvertImage(rc, image, &pixmap)) {
texture->width = iwidth;
texture->height = iheight;
if (!pixmap && !RConvertImage(rc, image, &pixmap)) {
wwarning("could not convert texture:%s",
RMessageForError(RErrorCode));
RDestroyImage(image);
goto error;
}
if (image)
RDestroyImage(image);
break;
case 'S':
case 'M':
@@ -358,12 +376,12 @@ parseTexture(RContext *rc, char *text)
w = scrWidth;
h = scrHeight;
} else {
if (image->width*scrHeight > image->height*scrWidth) {
if (iwidth*scrHeight > iheight*scrWidth) {
w = scrWidth;
h = (scrWidth*image->height)/image->width;
h = (scrWidth*iheight)/iwidth;
} else {
h = scrHeight;
w = (scrHeight*image->width)/image->height;
w = (scrHeight*iwidth)/iheight;
}
}
{
@@ -378,21 +396,22 @@ parseTexture(RContext *rc, char *text)
}
RDestroyImage(image);
image = simage;
iwidth = image->width;
iheight = image->height;
}
/* fall through */
case 'c':
case 'C':
{
Pixmap cpixmap;
if (!RConvertImage(rc, image, &pixmap)) {
if (!pixmap && !RConvertImage(rc, image, &pixmap)) {
wwarning("could not convert texture:%s",
RMessageForError(RErrorCode));
RDestroyImage(image);
goto error;
}
if (image->width != scrWidth || image->height != scrHeight) {
if (iwidth != scrWidth || iheight != scrHeight) {
int x, y, sx, sy, w, h;
cpixmap = XCreatePixmap(dpy, root, scrWidth, scrHeight,
@@ -402,21 +421,21 @@ parseTexture(RContext *rc, char *text)
XFillRectangle(dpy, cpixmap, DefaultGC(dpy, scr),
0, 0, scrWidth, scrHeight);
if (image->height < scrHeight) {
h = image->height;
if (iheight < scrHeight) {
h = iheight;
y = (scrHeight - h)/2;
sy = 0;
} else {
sy = (image->height - scrHeight)/2;
sy = (iheight - scrHeight)/2;
y = 0;
h = scrHeight;
}
if (image->width < scrWidth) {
w = image->width;
if (iwidth < scrWidth) {
w = iwidth;
x = (scrWidth - w)/2;
sx = 0;
} else {
sx = (image->width - scrWidth)/2;
sx = (iwidth - scrWidth)/2;
x = 0;
w = scrWidth;
}
@@ -426,7 +445,8 @@ parseTexture(RContext *rc, char *text)
XFreePixmap(dpy, pixmap);
pixmap = cpixmap;
}
RDestroyImage(image);
if (image)
RDestroyImage(image);
texture->width = scrWidth;
texture->height = scrHeight;
@@ -638,7 +658,7 @@ duplicatePixmap(Pixmap pixmap, int width, int height)
/* must open a new display or the RetainPermanent will
* leave stuff allocated in RContext unallocated after exit */
tmpDpy = XOpenDisplay("");
tmpDpy = XOpenDisplay(display);
if (!tmpDpy) {
wwarning("could not open display to update background image information");
@@ -855,7 +875,7 @@ helperLoop(RContext *rc)
void
updateDomain(char *domain, int workspace, char *texture)
updateDomain(char *domain, char *texture)
{
char *program = "wdwrite";
@@ -952,21 +972,25 @@ wAbort()
void
print_help(char *ProgName)
{
printf("usage: %s [-options] image\n", ProgName);
printf("usage: %s [options] image\n", ProgName);
puts("options:");
puts(" -d dither image");
puts(" -m match colors");
puts(" -b <color> background color");
puts(" -t tile image");
puts(" -e center image");
puts(" -s scale image (default)");
puts(" -a scale image and keep aspect ratio");
puts(" -u update WindowMaker domain database");
puts(" -D <domain> update <domain> database");
puts(" -c <cpc> colors per channel to use");
puts(" -p <texture> proplist style texture specification");
/* puts(" -w <workspace> update the background for the specified workspace");
*/
#define P(m) puts(m)
P(" -display display to use");
P(" -d, --dither dither image");
P(" -m, --match match colors");
P(" -b, --back-color <color> background color");
P(" -t, --tile tile image");
P(" -e, --center center image");
P(" -s, --scale scale image (default)");
P(" -a, --maxscale scale image and keep aspect ratio");
P(" -u, --update-wmaker update WindowMaker domain database");
P(" -D, --update-domain <domain> update <domain> database");
P(" -c, --colors <cpc> colors per channel to use");
P(" -p, --parse <texture> proplist style texture specification");
P(" -w, --workspace <workspace> update background for the specified workspace");
P(" --version show version of wmsetbg and exit");
P(" --help show this help and exit");
#undef P
}
@@ -1044,26 +1068,41 @@ main(int argc, char **argv)
WMInitializeApplication("wmsetbg", &argc, argv);
for (i=0; i<argc; i++) {
for (i=1; i<argc; i++) {
if (strcmp(argv[i], "-helper")==0) {
helperMode = 1;
} else if (strcmp(argv[i], "-s")==0) {
} else if (strcmp(argv[i], "-display")==0) {
i++;
if (i>=argc) {
wfatal("too few arguments for %s\n", argv[i-1]);
exit(1);
}
display = argv[i+1];
} else if (strcmp(argv[i], "-s")==0
|| strcmp(argv[i], "--scale")==0) {
style = "spixmap";
} else if (strcmp(argv[i], "-t")==0) {
} else if (strcmp(argv[i], "-t")==0
|| strcmp(argv[i], "--tile")==0) {
style = "tpixmap";
} else if (strcmp(argv[i], "-e")==0) {
} else if (strcmp(argv[i], "-e")==0
|| strcmp(argv[i], "--center")==0) {
style = "cpixmap";
} else if (strcmp(argv[i], "-a")==0) {
} else if (strcmp(argv[i], "-a")==0
|| strcmp(argv[i], "--maxscale")==0) {
style = "mpixmap";
} else if (strcmp(argv[i], "-d")==0) {
} else if (strcmp(argv[i], "-d")==0
|| strcmp(argv[i], "--dither")==0) {
render_mode = RM_DITHER;
obey_user++;
} else if (strcmp(argv[i], "-m")==0) {
} else if (strcmp(argv[i], "-m")==0
|| strcmp(argv[i], "--match")==0) {
render_mode = RM_MATCH;
obey_user++;
} else if (strcmp(argv[i], "-u")==0) {
} else if (strcmp(argv[i], "-u")==0
|| strcmp(argv[i], "--update-wmaker")==0) {
update++;
} else if (strcmp(argv[i], "-D")==0) {
} else if (strcmp(argv[i], "-D")==0
|| strcmp(argv[i], "--update-domain")==0) {
update++;
i++;
if (i>=argc) {
@@ -1071,7 +1110,8 @@ main(int argc, char **argv)
exit(1);
}
domain = wstrdup(argv[i]);
} else if (strcmp(argv[i], "-c")==0) {
} else if (strcmp(argv[i], "-c")==0
|| strcmp(argv[i], "--colors")==0) {
i++;
if (i>=argc) {
wfatal("too few arguments for %s\n", argv[i-1]);
@@ -1081,21 +1121,24 @@ main(int argc, char **argv)
wfatal("bad value for colors per channel: \"%s\"\n", argv[i]);
exit(1);
}
} else if (strcmp(argv[i], "-b")==0) {
} else if (strcmp(argv[i], "-b")==0
|| strcmp(argv[i], "--back-color")==0) {
i++;
if (i>=argc) {
wfatal("too few arguments for %s\n", argv[i-1]);
exit(1);
}
back_color = argv[i];
} else if (strcmp(argv[i], "-p")==0) {
} else if (strcmp(argv[i], "-p")==0
|| strcmp(argv[i], "--parse")==0) {
i++;
if (i>=argc) {
wfatal("too few arguments for %s\n", argv[i-1]);
exit(1);
}
texture = argv[i];
} else if (strcmp(argv[i], "-w")==0) {
} else if (strcmp(argv[i], "-w")==0
|| strcmp(argv[i], "--workspace")==0) {
i++;
if (i>=argc) {
wfatal("too few arguments for %s\n", argv[i-1]);
@@ -1106,6 +1149,11 @@ main(int argc, char **argv)
argv[i]);
exit(1);
}
} else if (strcmp(argv[i], "--version")==0) {
printf(PROG_VERSION);
exit(0);
} else if (argv[i][0] != '-') {
image_name = argv[i];
} else {
@@ -1113,12 +1161,16 @@ main(int argc, char **argv)
exit(1);
}
}
if (!image_name && !texture) {
printf("%s: you must specify a image file name\n", argv[0]);
exit(1);
}
domain_prop = getDomain(domain);
PixmapPath = getPixmapPath(domain_prop);
dpy = XOpenDisplay("");
dpy = XOpenDisplay(display);
if (!dpy) {
wfatal("could not open display");
exit(1);
@@ -1153,12 +1205,12 @@ main(int argc, char **argv)
char buffer[4098];
if (!texture) {
sprintf(buffer, "(%s, %s, %s)", style, image_name, back_color);
sprintf(buffer, "(%s, \"%s\", %s)", style, image_name, back_color);
texture = (char*)buffer;
}
if (update && workspace < 0) {
updateDomain(domain, workspace, texture);
updateDomain(domain, texture);
}
tex = parseTexture(rc, texture);
@@ -1167,10 +1219,12 @@ main(int argc, char **argv)
if (workspace<0)
changeTexture(tex);
else
else {
/* always update domain */
changeTextureForWorkspace(domain_prop, texture, workspace);
}
}
return -1;
return 0;
}