[comp.sources.x] v06i037: Bitmap previewer for X11, Part01/01

kucharsk@number6.Solbourne.COM (William Kucharski) (03/21/90)

Submitted-by: kucharsk@number6.Solbourne.COM (William Kucharski)
Posting-number: Volume 6, Issue 37
Archive-name: xbv/part01



The enclosed is a simple client which allows you to put up a window which
displays an X bitmap.  I've found it quite useful, as the only other bitmap
display program I have handy is xsetroot(1).  If you find it useful, I'd
appreciate it if you'd post it to the group; if not, I'd like to know what
most people are using to display bitmaps these days.

It's written entirely in Xlib, so it also makes a nice program to use in an
"Intro to X"-type tutorial (and has, in fact, been used as such in the past).

					Thanks,
						Bill

#! /bin/sh
# This is a shell archive, meaning:
# 1.  Remove everything above the #! /bin/sh line.
# 2.  Save the resulting test in a file
# 3.  Execute the file with /bin/sh (not csh) to create the files:
#
#Imakefile
#Makefile
#patchlevel.h
#README
#xbv.c
#xbv.man
#
# Created by kucharsk () on Wed Mar 14 15:04:03 MST 1990
#
if test -f 'Imakefile'
then
    echo shar: will not over-write existing file "Imakefile"
else
echo extracting "Imakefile"
sed 's/^X//' >Imakefile <<'SHAR_EOF'
X       INCLUDES = -I$(TOP) -I$(TOP)/X11
XLOCAL_LIBRARIES = $(XLIB)
X           SRCS = xbv.c
X           OBJS = xbv.o
X
XSimpleProgramTarget(xbv)
SHAR_EOF
if test 140 -ne "`wc -c < Imakefile`"
then
    echo shar: error transmitting "Imakefile" '(should have been 140 characters)'
fi
fi
if test -f 'Makefile'
then
    echo shar: will not over-write existing file "Makefile"
else
echo extracting "Makefile"
sed 's/^X//' >Makefile <<'SHAR_EOF'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
X#
X# The cpp used on this machine replaces all newlines and multiple tabs and
X# spaces in a macro expansion with a single space.  Imake tries to compensate
X# for this, but is not always successful.
X#
X
X###########################################################################
X# Makefile generated from "Imake.tmpl" and <Imakefile>
X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
X#
X# Platform-specific parameters may be set in the appropriate .cf
X# configuration files.  Site-wide parameters may be set in the file
X# site.def.  Full rebuilds are recommended if any parameters are changed.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X###########################################################################
X# platform-specific configuration parameters - edit sol.cf to change
X
X# platform:  $XConsortium: sun.cf,v 1.32 89/10/11 18:54:52 jim Exp $
X# operating system:  SunOS 4.0.3
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $
X
X            SHELL = /bin/sh
X
X              TOP = .
X      CURRENT_DIR = .
X
X               AR = ar cq
X  BOOTSTRAPCFLAGS =
X               CC = cc
X
X         COMPRESS = compress
X              CPP = /lib/cpp $(STD_CPP_DEFINES)
X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
X          INSTALL = install
X               LD = ld
X             LINT = lint
X      LINTLIBFLAG = -C
X         LINTOPTS = -axz
X               LN = ln -s
X             MAKE = make
X               MV = mv
X               CP = cp
X           RANLIB = ranlib
X  RANLIBINSTFLAGS =
X               RM = rm -f
X     STD_INCLUDES =
X  STD_CPP_DEFINES =
X      STD_DEFINES =
X EXTRA_LOAD_FLAGS =
X  EXTRA_LIBRARIES =
X             TAGS = ctags
X
X    SHAREDCODEDEF = -DSHAREDCODE
X         SHLIBDEF = -DSUNSHLIB
X
X    PROTO_DEFINES =
X
X     INSTPGMFLAGS =
X
X     INSTBINFLAGS = -m 0755
X     INSTUIDFLAGS = -m 4755
X     INSTLIBFLAGS = -m 0664
X     INSTINCFLAGS = -m 0444
X     INSTMANFLAGS = -m 0444
X     INSTDATFLAGS = -m 0444
X    INSTKMEMFLAGS = -m 4755
X
X          DESTDIR =
X
X     TOP_INCLUDES = -I$(INCROOT)
X
X      CDEBUGFLAGS = -O
X        -DSOLSHM =
X      COMPATFLAGS =
X
X         SOLTOP = $(TOP)/../Solbourne
X       SOLOILIB = $(SOLTOP)/OI/libOI.a
X      ALLINCLUDES = -I$(SOLTOP)/OI $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
X           CFLAGS = $(CDEBUGFLAGS) $(-DSOLSHM) $(ALLDEFINES)
X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X        LDOPTIONS = $(CDEBUGFLAGS) $(-DSOLSHM)
X   LDCOMBINEFLAGS = -X -r
X
X        MACROFILE = sol.cf
X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
X
X    IMAKE_DEFINES =
X
X         IRULESRC = $(CONFIGDIR)
X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
X
X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
X			$(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
X			$(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
X
X###########################################################################
X# X Window System Build Parameters
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X###########################################################################
X# X Window System make variables; this need to be coordinated with rules
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X          PATHSEP = /
X        USRLIBDIR = $(DESTDIR)/usr/lib
X           BINDIR = $(DESTDIR)/usr/bin/X11
X          INCROOT = $(DESTDIR)/usr/include
X     BUILDINCROOT = $(TOP)
X      BUILDINCDIR = $(BUILDINCROOT)/X11
X      BUILDINCTOP = ..
X           INCDIR = $(INCROOT)/X11
X           ADMDIR = $(DESTDIR)/usr/adm
X           LIBDIR = $(USRLIBDIR)/X11
X        CONFIGDIR = $(LIBDIR)/config
X       LINTLIBDIR = $(USRLIBDIR)/lint
X
X          FONTDIR = $(LIBDIR)/fonts
X         XINITDIR = $(LIBDIR)/xinit
X           XDMDIR = $(LIBDIR)/xdm
X           AWMDIR = $(LIBDIR)/awm
X           TWMDIR = $(LIBDIR)/twm
X           GWMDIR = $(LIBDIR)/gwm
X          MANPATH = $(DESTDIR)/usr/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = $(MANSOURCEPATH)n
X        LIBMANDIR = $(MANSOURCEPATH)3
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X        SOXLIBREV = 4.2
X          SOXTREV = 4.0
X         SOXAWREV = 4.0
X        SOOLDXREV = 4.0
X         SOXMUREV = 4.0
X        SOXEXTREV = 4.0
X
X       FONTCFLAGS = -t
X
X     INSTAPPFLAGS = $(INSTDATFLAGS)
X
X            IMAKE = imake
X           DEPEND = makedepend
X              RGB = rgb
X            FONTC = bdftosnf
X        MKFONTDIR = mkfontdir
X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh
X
X        CONFIGSRC = $(TOP)/config
X        CLIENTSRC = $(TOP)/clients
X          DEMOSRC = $(TOP)/demos
X           LIBSRC = $(TOP)/lib
X          FONTSRC = $(TOP)/fonts
X       INCLUDESRC = $(TOP)/X11
X        SERVERSRC = $(TOP)/server
X          UTILSRC = $(TOP)/util
X        SCRIPTSRC = $(UTILSRC)/scripts
X       EXAMPLESRC = $(TOP)/examples
X       CONTRIBSRC = $(TOP)/../contrib
X           DOCSRC = $(TOP)/doc
X           RGBSRC = $(TOP)/rgb
X        DEPENDSRC = $(UTILSRC)/makedepend
X         IMAKESRC = $(CONFIGSRC)
X         XAUTHSRC = $(LIBSRC)/Xau
X          XLIBSRC = $(LIBSRC)/X
X           XMUSRC = $(LIBSRC)/Xmu
X       TOOLKITSRC = $(LIBSRC)/Xt
X       AWIDGETSRC = $(LIBSRC)/Xaw
X       OLDXLIBSRC = $(LIBSRC)/oldX
X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
X     EXTENSIONSRC = $(TOP)/extensions
X
X  DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a
X     EXTENSIONLIB =  -lXext
X
X          DEPXLIB = $(DEPEXTENSIONLIB)
X             XLIB = $(EXTENSIONLIB) -lX11
X
X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
X         XAUTHLIB =  -lXau
X
X        DEPXMULIB =
X           XMULIB = -lXmu
X
X       DEPOLDXLIB =
X          OLDXLIB = -loldX
X
X      DEPXTOOLLIB =
X         XTOOLLIB = -lXt
X
X        DEPXAWLIB =
X           XAWLIB = -lXaw
X
X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln
X         LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
X          LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
X        LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
X          LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
X
X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
X
X         DEPLIBS1 = $(DEPLIBS)
X         DEPLIBS2 = $(DEPLIBS)
X         DEPLIBS3 = $(DEPLIBS)
X
X###########################################################################
X# Imake rules for building libraries, programs, scripts, and data files
X# rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
X       INCLUDES = -I$(TOP) -I$(TOP)/X11
XLOCAL_LIBRARIES = $(XLIB)
X           SRCS = xbv.c
X           OBJS = xbv.o
X
X OBJS = xbv.o
X SRCS = xbv.c
X
X PROGRAM = xbv
X
Xall:: xbv
X
Xxbv: $(OBJS) $(DEPLIBS)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
X
Xinstall:: xbv
X	$(INSTALL) -c $(INSTPGMFLAGS)   xbv $(BINDIR)
X
Xinstall.man:: xbv.man
X	$(INSTALL) -c $(INSTMANFLAGS) xbv.man $(MANDIR)/xbv.n
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
X
Xlint:
X	$(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
Xlint1:
X	$(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
X
Xclean::
X	$(RM) $(PROGRAM)
X
X###########################################################################
X# common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile::
X	-@if [ -f Makefile ]; then \
X	echo "	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
X
Xtags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X	@echo "install in $(CURRENT_DIR) done"
X
Xinstall.man::
X	@echo "install.man in $(CURRENT_DIR) done"
X
XMakefiles::
X
Xincludes::
X
X###########################################################################
SHAR_EOF
if test 8653 -ne "`wc -c < Makefile`"
then
    echo shar: error transmitting "Makefile" '(should have been 8653 characters)'
fi
fi
if test -f 'patchlevel.h'
then
    echo shar: will not over-write existing file "patchlevel.h"
else
echo extracting "patchlevel.h"
sed 's/^X//' >patchlevel.h <<'SHAR_EOF'
X#define PATCHLEVEL	1
SHAR_EOF
if test 21 -ne "`wc -c < patchlevel.h`"
then
    echo shar: error transmitting "patchlevel.h" '(should have been 21 characters)'
fi
fi
if test -f 'README'
then
    echo shar: will not over-write existing file "README"
else
echo extracting "README"
sed 's/^X//' >README <<'SHAR_EOF'
XXbv is a simple client written both to fulfill the need for a simple bitmap
Xviewer and as a sample X client.  It is pretty much consistent with X11R4 and
XICCCM guidelines, but also sets appropriate hints for pre-R4 window managers.
X
XYou may copy this program freely as long as this README file is distributed
Xintact, and no changes are made to the copyright message within the C source
Xcode. You must also note in the documentation for this program if you have made
Xany changes to this program without the written permission of the author.
X
XCopyright 1990 Solbourne Computer, Inc.
X
XPermission to use, copy, modify, distribute, and sell this software and its
Xdocumentation for any purpose is hereby granted without fee, provided that
Xthe above copyright notice appear in all copies and that both that
Xcopyright notice and this permission notice appear in supporting
Xdocumentation, and that the name of Solbourne not be used in advertising or
Xpublicity pertaining to distribution of the software without specific,
Xwritten prior permission.  Solbourne Computer, Inc. makes no representations 
Xabout the suitability of this software for any purpose.  It is provided 
X"as is" without express or implied warranty.
X
XSOLBOURNE COMPUTER, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 
XIN NO EVENT SHALL SOLBOURNE COMPUTER, INC. BE LIABLE FOR ANY SPECIAL,
XINDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
XLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
XPERFORMANCE OF THIS SOFTWARE.
X
XAuthor:  William Kucharski, Solbourne Computer, Inc.
X         ARPA: kucharsk@Solbourne.COM
X         uucp: ...!{boulder,sun,uunet}!stan!kucharsk
SHAR_EOF
if test 1824 -ne "`wc -c < README`"
then
    echo shar: error transmitting "README" '(should have been 1824 characters)'
fi
fi
if test -f 'xbv.c'
then
    echo shar: will not over-write existing file "xbv.c"
else
echo extracting "xbv.c"
sed 's/^X//' >xbv.c <<'SHAR_EOF'
X/*
X * Copyright 1990 Solbourne Computer, Inc.
X *
X * Permission to use, copy, modify, distribute, and sell this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of Solbourne not be used in advertising or
X * publicity pertaining to distribution of the software without specific,
X * written prior permission.  Solbourne Computer, Inc. makes no representations 
X * about the suitability of this software for any purpose.  It is provided 
X * "as is" without express or implied warranty.
X *
X * SOLBOURNE COMPUTER, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 
X * IN NO EVENT SHALL SOLBOURNE COMPUTER, INC. BE LIABLE FOR ANY SPECIAL,
X * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
X * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
X * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
X * PERFORMANCE OF THIS SOFTWARE.
X *
X * Author:  William Kucharski, Solbourne Computer, Inc.
X *          kucharsk@Solbourne.COM
X *	    ...!{boulder,sun,uunet}!stan!kucharsk
X */
X
X#include <X11/Xos.h>
X#include <X11/cursorfont.h>
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X#include <stdio.h>
X
Xstatic void
Xusage(progname)
Xchar	*progname;
X{
X	(void) fprintf(stderr, 
X		"usage: %s [-d display] [-b borderwidth] [-g geometry] [-rv] bitmapfile\n",
X		progname);
X
X	exit(1);
X}
X
X
Xstatic char *
Xmsg(err)
Xint	err;	/* error # to return message for */
X{
X	extern	int	sys_nerr;	/* # errors we have messages for */
X	extern	char	*sys_errlist[];	/* list of error messages */
X
X	char	errmsg[27];
X
X	if (err < sys_nerr)
X		return(sys_errlist[err]);
X	else {
X		(void) sprintf(errmsg, "Unknown errno (%d)", err);
X		return(errmsg);
X	}
X}
X
X
Xstatic char *
Xbitmap_err(status)
Xint	status;	/* bitmap read return status */
X{
X	char	*mesg;
X	char	unknown[50];
X
X	switch(status) {
X		case BitmapOpenFailed:
X				mesg = "bitmap open failed";
X				break;
X
X		case BitmapFileInvalid:
X				mesg = "not a valid X11 bitmap file";
X				break;
X
X		case BitmapNoMemory:
X				mesg = "not enough memory to create bitmap";
X				break;
X
X		default:
X			(void) sprintf(unknown, 
X				"unknown failure code (%d)", status);
X			mesg = unknown;
X	}
X	return(mesg);
X}
X
Xvoid
Xmain(argc, argv)
Xint	argc;
Xchar	*argv[];
X{
X	extern	int	errno;
X	extern	char	*getenv();
X
X	Display	*dpy;	/* display to use */
X	GC	bkgc;	/* GC for background pixmap */
X	Pixmap	bitmap;	/* bitmap (!) */
X	Pixmap	backg;	/* window background */
X	Window	root;	/* root window */
X	Window	wind;	/* window to create */
X	XEvent	event;	/* Event holder */
X	
X	Cursor	curs;	/* cursor for bitmap window */
X
X	XSizeHints	hints;	/* window size hints */
X
X	XTextProperty	winname;
X
X	unsigned int	width;	/* bitmap width */
X	unsigned int	height;	/* bitmap height */
X	unsigned long	myfg;	/* foreground */
X	unsigned long	mybg;	/* background */
X
X	char	*display = NULL;
X
X	char	*wnname[1];
X
X	char	*file;	/* bitmap filename */
X	int	argctr;	/* argument counter */
X	int	status;	/* return status of XReadBitmapFile(3X11) */
X
X	int	bwidth = 2;	/* default border width */
X	int	geomask = 0;	/* mask returned by XParseGeometry(3X11) */
X	int	reverse = 0;	/* reverse video */
X
X	argctr = 1;	/* start at argv[1] */
X
X	/* set initial hints for window manager */
X
X	hints.x = 0;		hints.y = 0;
X	hints.width = 0;	hints.height = 0;
X	hints.min_width = 1;	hints.min_height = 1;
X	hints.flags = PMinSize;
X
X	if (argc == 1)
X		usage(argv[0]);
X
X	while (*(argv[argctr]) == '-') {
X		switch(*(argv[argctr] +1)) {
X			case 'b':
X				if (argc <= ++argctr)
X					usage(argv[0]);
X
X				bwidth = atoi(argv[argctr++]);
X				break;
X
X			case 'd':
X				if (argc <= ++argctr)
X					usage(argv[0]);
X
X				display = argv[argctr++];
X				break;
X
X			case 'g':
X				if (argc <= ++argctr)
X					usage(argv[0]);
X
X				geomask = XParseGeometry(argv[argctr++], 
X					&(hints.x),
X					&(hints.y),
X					&(hints.width),
X					&(hints.height));
X
X				if (geomask) {
X					if (((geomask & XValue) == XValue) ||
X						((geomask &YValue) == YValue)) {
X
X						hints.flags |= USPosition;
X					}
X					if (((geomask & WidthValue) == WidthValue)
X						|| ((geomask & HeightValue) == HeightValue)) {
X						hints.flags |= USSize;
X					}
X				} else
X					usage(argv[0]);
X
X				break;
X
X			case 'r':
X				reverse = (!reverse);
X				argctr++;
X				break;
X
X			default:
X				usage(argv[0]);
X		}
X	}
X
X	if (argc < (argctr + 1))
X		usage(argv[0]);
X
X	file = argv[argctr];		/* bitmap filename */
X	wnname[0] = file;
X
X	if (access(file, R_OK)) {
X		(void) fprintf(stderr,
X			"%s: %s: %s\n", argv[0], file, msg(errno));
X
X		exit(1);
X	}
X
X	if ((dpy = XOpenDisplay(display)) == NULL) {
X		(void) fprintf(stderr, "%s: Can't Open Display \"%s\" (%s)\n",
X			argv[0],
X			(display ? display : 
X			(getenv("DISPLAY") ? getenv("DISPLAY") : "unknown display")),
X			msg(errno));
X
X		exit(2);
X	}
X
X        if (!XStringListToTextProperty(wnname, 1, &winname)) {
X                (void) fprintf(stderr,
X                        "%s: Could not convert window name to Text Property!\n",
X                        argv[0]);
X
X                (void) fflush(stderr);
X                exit(1);
X        }
X
X	root = DefaultRootWindow(dpy);	/* use root window for a drawable */
X
X	status = XReadBitmapFile(dpy, root, file, &width, &height, 
X			&bitmap, 0, 0);
X
X	if (status != BitmapSuccess) {
X		(void) fprintf(stderr, "%s: %s: %s\n", argv[0], file, 
X			bitmap_err(status));
X
X		exit(2);
X	}
X
X	/* clean up window hints */
X
X	if ((hints.height == 0) && (hints.width == 0)) {
X		hints.height = height;
X		hints.width = width;
X		hints.flags |= PSize;
X	} else if (hints.height == 0) {
X		hints.height = height;
X	} else if (hints.width == 0) {
X		hints.width = width;
X	}
X
X	/* negative offset means starting from bottom/right */
X
X	if (hints.x < 0) {
X		hints.x += 
X			(DisplayWidth(dpy, DefaultScreen(dpy)) - hints.width);
X
X		if (hints.x < 0)
X			hints.x = 0;
X	}
X
X	if (hints.y < 0) {
X		hints.y += 
X			(DisplayHeight(dpy, DefaultScreen(dpy)) - hints.height);
X
X		if (hints.y < 0)
X			hints.y = 0;
X	}
X
X	/* create bitmap window */
X
X	if (!reverse) {
X		myfg = BlackPixel(dpy, DefaultScreen(dpy));
X		mybg = WhitePixel(dpy, DefaultScreen(dpy));
X	} else {
X		myfg = WhitePixel(dpy, DefaultScreen(dpy));
X		mybg = BlackPixel(dpy, DefaultScreen(dpy));
X	}
X
X	wind = XCreateSimpleWindow(dpy, root, hints.x, hints.y, hints.width,
X		hints.height, bwidth, myfg, mybg);
X
X        XSetWMProperties(dpy, wind, &winname, NULL, argv, argc, &hints, NULL,
X                NULL);
X
X	/* create gumby cursor */
X
X	curs = XCreateFontCursor(dpy, XC_gumby);
X	XDefineCursor(dpy, wind, curs);
X
X	/* create background pixmap */
X
X	backg = XCreatePixmap(dpy, wind, width, height, 
X		    DefaultDepth(dpy, DefaultScreen(dpy)));
X
X	/* create/manipulate background pixmap GC */
X
X	bkgc = XCreateGC(dpy, backg, 0, 0);
X
X	XSetBackground(dpy, bkgc, mybg);
X	XSetForeground(dpy, bkgc, myfg);
X
X	/* we don't care about graphics exposures */
X
X	XSetGraphicsExposures(dpy, bkgc, False);
X
X	/* copy pixmap we read into background pixmap */
X
X	XCopyPlane(dpy, bitmap, backg, bkgc, 0, 0, width, height, 0, 0, 1);
X	XFreePixmap(dpy, bitmap);
X	XFreeGC(dpy, bkgc);
X
X	/* set new window background to the pixmap */
X
X	XSetWindowBackgroundPixmap(dpy, wind, backg);
X
X	/* select button press events only */
X
X	XSelectInput(dpy, wind, ButtonPressMask);
X	XMapRaised(dpy, wind);		/* map window */
X	XNextEvent(dpy, &event);	/* wait for ButtonPress event */
X
X	/* button click - exit program */
X
X	XFreeCursor(dpy, curs);
X	XDestroyWindow(dpy, wind);
X	XFreePixmap(dpy, backg);
X	XCloseDisplay(dpy);
X	exit(0);
X}
SHAR_EOF
if test 7702 -ne "`wc -c < xbv.c`"
then
    echo shar: error transmitting "xbv.c" '(should have been 7702 characters)'
fi
fi
if test -f 'xbv.man'
then
    echo shar: will not over-write existing file "xbv.man"
else
echo extracting "xbv.man"
sed 's/^X//' >xbv.man <<'SHAR_EOF'
X.TH XCPUSTATE 1
X.SH NAME
Xxbv - display X11 bitmaps
X.SH SYNTAX
X.B xbv
X.RB "[\|" \-b
X.IR borderwidth "\|]"
X.RB "[\|" \-d
X.IR display "\|]"
X.RB "[\|" \-g
X.IR geometry "\|]"
X.RB "[\|" \-rv  "\|]"
X.RI bitmapfile 
X.SH DESCRIPTION
X.I Xbv displays a window with the contents of the specified X11 bitmap file on
Xthe specified display. Clicking a mouse button while the pointer is in the
Xwindow will dismiss the window.
X.SH OPTIONS
X.TP 8
X.IR \-b " borderwidth"
XSets the window's border width to the specified value
X.TP 8
X.IR \-d " display"
XDisplay the window on the specified display.
X.TP 8
X.IR \-g " geometry"
XSpecify the geometry of the bitmap window using standard X11 geometry syntax.
X.SH NOTES
X.I Xbv
Xis one of the few ways to easily display an X bitmap without resorting to
Xthe use of the \fIxsetroot\fR(1) command. This program is written entirely
Xin Xlib and is a good \*Qsample\*U program for introductory X tutorials.
X.SH BUGS
XX11R4 window managers may not respect the size information within the geometry
Xspecification.
X.SH SEE ALSO
X\fIxsetroot\fR(1)
X.SH AUTHOR
XWilliam Kucharski, Solbourne Computer, Inc.
X.ex
SHAR_EOF
if test 1111 -ne "`wc -c < xbv.man`"
then
    echo shar: error transmitting "xbv.man" '(should have been 1111 characters)'
fi
fi
# end of shell archive
exit 0
--
===============================================================================
| ARPA:	kucharsk@Solbourne.COM	              |	William Kucharski             |
| uucp:	...!{boulder,sun,uunet}!stan!kucharsk |	Solbourne Computer, Inc.      |
= The opinions above are mine alone and NOT those of Solbourne Computer, Inc. =

dan
-----------------------------------------------------------
		    O'Reilly && Associates
		argv@sun.com / argv@ora.com
	   632 Petaluma Ave, Sebastopol, CA 95472 
     800-338-NUTS, in CA: 800-533-NUTS, FAX 707-829-0104
    Opinions expressed reflect those of the author only.