v08i052: xbv - bitmap previewer, Patch3, Part01/01

William Kucharski kucharsk at number6.Solbourne.COM
Thu Jul 12 04:40:26 AEST 1990


Submitted-by: kucharsk at number6.Solbourne.COM (William Kucharski)
Posting-number: Volume 8, Issue 52
Archive-name: xbv/patch3
Patch-To: xbv: Volume 6, Issue 37,40

The following patch to xbv cleans up a few bugs, and, thanks to Jim Wight of
the University of Newcastle upon Tyne, changes things so that xbv can read a
bitmap from stdin.

						-- Bill


*** patchlevel.h.orig	Tue Jun 19 11:08:47 1990
--- patchlevel.h	Tue Jun 19 11:08:53 1990
Prereq: 2
***************
*** 1 ****
! #define PATCHLEVEL	2
--- 1 ----
! #define PATCHLEVEL	3

*** xbv.c.orig	Wed Mar 21 10:31:27 1990
--- xbv.c	Tue Jun 19 10:56:10 1990
***************
*** 28,33 ****
--- 28,34 ----
  #include <X11/cursorfont.h>
  #include <X11/Xlib.h>
  #include <X11/Xutil.h>
+ #include <X11/Xmu/Xmu.h>
  #include <stdio.h>
  
  static void
***************
*** 35,41 ****
  char	*progname;
  {
  	(void) fprintf(stderr, 
! 		"usage: %s [-d display] [-b borderwidth] [-g geometry] [-rv] bitmapfile\n",
  		progname);
  
  	exit(1);
--- 36,42 ----
  char	*progname;
  {
  	(void) fprintf(stderr, 
! 		"usage: %s [-d display] [-b borderwidth] [-g geometry] [-rv] [bitmapfile]\n",
  		progname);
  
  	exit(1);
***************
*** 119,128 ****
  
  	char	*wnname[1];
  
! 	char	*file;	/* bitmap filename */
! 	int	argctr;	/* argument counter */
! 	int	status;	/* return status of XReadBitmapFile(3X11) */
  
  	int	bwidth = 2;	/* default border width */
  	int	geomask = 0;	/* mask returned by XParseGeometry(3X11) */
  	int	reverse = 0;	/* reverse video */
--- 120,134 ----
  
  	char	*wnname[1];
  
! 	int     stdio = FALSE;  	/* input from stdin */
! 	char    *stdinput = "stdin";	/* 'filename' for stdin */
! 	char    *datap; 		/* bitmap data pointer */
! 	int     x_hot;  		/* bitmap hot spot x coord */
! 	int     y_hot;  		/* bitmap hot spot y coord */
! 	char	*file;			/* bitmap filename */
! 	int	argctr;			/* argument counter */
  
+ 	int	status;		/* return status of XReadBitmapFile(3X11) */
  	int	bwidth = 2;	/* default border width */
  	int	geomask = 0;	/* mask returned by XParseGeometry(3X11) */
  	int	reverse = 0;	/* reverse video */
***************
*** 136,145 ****
  	hints.min_width = 1;	hints.min_height = 1;
  	hints.flags = PMinSize;
  
! 	if (argc == 1)
! 		usage(argv[0]);
! 
! 	while (*(argv[argctr]) == '-') {
  		switch(*(argv[argctr] +1)) {
  			case 'b':
  				if (argc <= ++argctr)
--- 142,148 ----
  	hints.min_width = 1;	hints.min_height = 1;
  	hints.flags = PMinSize;
  
! 	while ((argctr < argc) && (*(argv[argctr]) == '-')) {
  		switch(*(argv[argctr] +1)) {
  			case 'b':
  				if (argc <= ++argctr)
***************
*** 191,207 ****
  	}
  
  	if (argc < (argctr + 1))
! 		usage(argv[0]);
  
! 	file = argv[argctr];		/* bitmap filename */
! 	wnname[0] = file;
  
- 	if (access(file, R_OK)) {
- 		(void) fprintf(stderr,
- 			"%s: %s: %s\n", argv[0], file, msg(errno));
- 
  		exit(1);
  	}
  
  	if ((dpy = XOpenDisplay(display)) == NULL) {
  		(void) fprintf(stderr, "%s: Can't Open Display \"%s\" (%s)\n",
--- 194,214 ----
  	}
  
  	if (argc < (argctr + 1))
! 		stdio = TRUE;
  
! 	if (stdio)
! 	    file = stdinput;
! 	else
! 	{
! 	    file = argv[argctr];		/* bitmap filename */
! 	    if (access(file, R_OK)) {
! 		    (void) fprintf(stderr,
! 		            "%s: %s: %s\n", argv[0], file, msg(errno));
  
  		exit(1);
+ 	    }
  	}
+ 	wnname[0] = file;
  
  	if ((dpy = XOpenDisplay(display)) == NULL) {
  		(void) fprintf(stderr, "%s: Can't Open Display \"%s\" (%s)\n",
***************
*** 224,231 ****
  
  	root = DefaultRootWindow(dpy);	/* use root window for a drawable */
  
! 	status = XReadBitmapFile(dpy, root, file, &width, &height, 
! 			&bitmap, 0, 0);
  
  	if (status != BitmapSuccess) {
  		(void) fprintf(stderr, "%s: %s: %s\n", argv[0], file, 
--- 231,242 ----
  
  	root = DefaultRootWindow(dpy);	/* use root window for a drawable */
  
! 	if (stdio)
! 	    status = XmuReadBitmapData(stdin, &width, &height, &datap,
! 				       &x_hot, &y_hot);
! 	else
! 	    status = XReadBitmapFile(dpy, root, file, &width, &height, 
! 				     &bitmap, 0, 0);
  
  	if (status != BitmapSuccess) {
  		(void) fprintf(stderr, "%s: %s: %s\n", argv[0], file, 
***************
*** 234,239 ****
--- 245,260 ----
  		exit(2);
  	}
  
+ 	if (stdio)
+ 	    bitmap = XCreateBitmapFromData(dpy, root, datap, width, height);
+ 
+ 	if (bitmap == None)
+ 	{
+ 	    (void) fprintf(stderr, "%s: %s: %s\n", argv[0], file, 
+ 			   bitmap_err(BitmapNoMemory));
+ 	    exit(2);
+ 	}
+ 	    
  	/* clean up window hints */
  
  	if ((hints.height == 0) && (hints.width == 0)) {

*** xbv.man.orig	Tue Jun 19 11:07:30 1990
--- xbv.man	Tue Jun 19 11:16:27 1990
***************
*** 1,4 ****
! .TH XCPUSTATE 1
  .SH NAME
  xbv - display X11 bitmaps
  .SH SYNTAX
--- 1,4 ----
! .TH XBV 1
  .SH NAME
  xbv - display X11 bitmaps
  .SH SYNTAX
***************
*** 9,18 ****
  .IR display "\|]"
  .RB "[\|" \-g
  .IR geometry "\|]"
! .RB "[\|" \-rv  "\|]"
! .RI bitmapfile 
  .SH DESCRIPTION
! .I Xbv displays a window with the contents of the specified X11 bitmap file on
  the specified display. Clicking a mouse button while the pointer is in the
  window will dismiss the window.
  .SH OPTIONS
--- 9,19 ----
  .IR display "\|]"
  .RB "[\|" \-g
  .IR geometry "\|]"
! .RB "[\|" \-rv "\|]"
! .RI "[\|" bitmapfile "\|]"
  .SH DESCRIPTION
! .I Xbv
! displays a window with the contents of the specified X11 bitmap file on
  the specified display. Clicking a mouse button while the pointer is in the
  window will dismiss the window.
  .SH OPTIONS
***************
*** 25,38 ****
  .TP 8
  .IR \-g " geometry"
  Specify the geometry of the bitmap window using standard X11 geometry syntax.
  .SH NOTES
  .I Xbv
  is one of the few ways to easily display an X bitmap without resorting to
  the use of the \fIxsetroot\fR(1) command. This program is written entirely
! in Xlib and is a good \*Qsample\*U program for introductory X tutorials.
  .SH BUGS
! X11R4 window managers may not respect the size information within the geometry
! specification.
  .SH SEE ALSO
  \fIxsetroot\fR(1)
  .SH AUTHOR
--- 26,45 ----
  .TP 8
  .IR \-g " geometry"
  Specify the geometry of the bitmap window using standard X11 geometry syntax.
+ .TP 8
+ .I bitmapfile
+ Specifies the name of a X11 bitmap file to read. If a filename is not specified,
+ input is taken from stdin. (Stdin modification by Jim Wight at the University of
+ Newcastle upon Tyne, UK.)
  .SH NOTES
  .I Xbv
  is one of the few ways to easily display an X bitmap without resorting to
  the use of the \fIxsetroot\fR(1) command. This program is written entirely
! in Xlib (with a call to Xmu tossed in for good measure) and is a good 
! \*Qsample\*U program for introductory X tutorials.
  .SH BUGS
! Some X11R4 window managers may not respect the size information within the
! geometry specification.
  .SH SEE ALSO
  \fIxsetroot\fR(1)
  .SH AUTHOR

*** Imakefile.orig	Tue Jun 19 10:54:08 1990
--- Imakefile	Tue Jun 19 10:53:48 1990
***************
*** 1,5 ****
         INCLUDES = -I$(TOP) -I$(TOP)/X11
! LOCAL_LIBRARIES = $(XLIB)
             SRCS = xbv.c
             OBJS = xbv.o
  
--- 1,5 ----
         INCLUDES = -I$(TOP) -I$(TOP)/X11
! LOCAL_LIBRARIES = $(XMULIB) $(XLIB)
             SRCS = xbv.c
             OBJS = xbv.o
  
--
===============================================================================
| Internet:   kucharsk at 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 at sun.com / argv at ora.com
Opinions expressed reflect those of the author only.



More information about the Comp.sources.x mailing list