v02i068: new improved toolplacements replacement, Part01/01

Mike Wexler mikew at wyse.wyse.com
Fri Dec 30 08:49:34 AEST 1988


Submitted-by: mtr at mace.cc.purdue.edu (Michael Rowan)
Posting-number: Volume 2, Issue 68
Archive-name: xplaces2/part01

[Here is another program that tries to figure out the commands to 
restart all your windows.  I will be posting one myself in January. -mcw]

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  README AUTHOR Imakefile Makefile patchlevel.h strcasecmp.c
#   xplaces.1 xplaces.c
# Wrapped by mikew at wyse on Thu Dec 29 14:45:43 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(578 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X
XThis program walks your tree of windows and decides which ones
Xare actually commands and tries to print out a start up file that
Xcan be used as a xtools startup file or a shell script you can 
Xuse for the same type of thing.
X
XIt is based on the suntools version that does the same thing.  I 
Xhave also seen Ken Yap's version of this, but it didn't work in my
Xenviorment.  I am not saying it doesn't work, just not for me. 
X
XThis one isn't perfect, but it works for my site.    Can you say 
Xkludge? :-)
X
XThere is a Imakefile, although the Makefile should be 100% portable.
X
Xmtr
END_OF_FILE
if test 578 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'AUTHOR' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'AUTHOR'\"
else
echo shar: Extracting \"'AUTHOR'\" \(38 characters\)
sed "s/^X//" >'AUTHOR' <<'END_OF_FILE'
XMichael Rowan, mtr at mace.cc.purdue.edu
END_OF_FILE
if test 38 -ne `wc -c <'AUTHOR'`; then
    echo shar: \"'AUTHOR'\" unpacked with wrong size!
fi
# end of 'AUTHOR'
fi
if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Imakefile'\"
else
echo shar: Extracting \"'Imakefile'\" \(139 characters\)
sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
XLOCAL_LIBRARIES = $(XLIB)
X           SRCS = xplaces.c strcasecmp.c
X           OBJS = xplaces.o strcasecmp.o
X
XComplexProgramTarget(xplaces)
END_OF_FILE
if test 139 -ne `wc -c <'Imakefile'`; then
    echo shar: \"'Imakefile'\" unpacked with wrong size!
fi
# end of 'Imakefile'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(6445 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.37 88/10/08 20:08: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# X Window System Makefile generated from template file Imake.tmpl
X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
X#
X# Do not change the body of the imake template file.  Server-specific
X# parameters may be set in the appropriate .macros file; site-specific
X# parameters (but shared by all servers) may be set in site.def.  If you
X# make any changes, you'll need to rebuild the makefiles using
X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
X# the top level directory.
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 Sun.macros to change
X
X# platform:  $XConsortium: Sun.macros,v 1.52 88/10/23 11:00:55 jim Exp $
X# operating system:   SunOS 3.4
X
XBOOTSTRAPCFLAGS =
X             AS = as
X             CC = cc
X            CPP = /lib/cpp
X             LD = ld
X           LINT = lint
X        INSTALL = install
X           TAGS = ctags
X             RM = rm -f
X             MV = mv
X             LN = ln -s
X         RANLIB = ranlib
XRANLIBINSTFLAGS = -t
X             AR = ar clq
X             LS = ls
X       LINTOPTS = -axz
X    LINTLIBFLAG = -C
X           MAKE = make
XSTD_CPP_DEFINES =
X    STD_DEFINES =
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
X
X###########################################################################
X# definitions common to all Makefiles - do not edit
X
X          SHELL =  /bin/sh
X
X        DESTDIR = /global
X      USRLIBDIR = $(DESTDIR)/lib
X         BINDIR = $(DESTDIR)/bin/X11
X         INCDIR = $(DESTDIR)/include
X         ADMDIR = $(DESTDIR)/usr/adm
X         LIBDIR = $(USRLIBDIR)/X11
X     LINTLIBDIR = $(USRLIBDIR)/lint
X        FONTDIR = $(LIBDIR)/fonts
X       XINITDIR = $(LIBDIR)/xinit
X         XDMDIR = $(LIBDIR)/xdm
X         UWMDIR = $(LIBDIR)/uwm
X         AWMDIR = $(LIBDIR)/awm
X         TWMDIR = $(LIBDIR)/twm
X          DTDIR = $(LIBDIR)/dt
X        MANPATH = /usr/man
X  MANSOURCEPATH = $(MANPATH)/man
X         MANDIR = $(MANSOURCEPATH)n
X      LIBMANDIR = $(MANSOURCEPATH)n3
X    XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X   INSTBINFLAGS = -m 0755
X   INSTUIDFLAGS = -m 4755
X   INSTLIBFLAGS = -m 0664
X   INSTINCFLAGS = -m 0444
X   INSTMANFLAGS = -m 0444
X   INSTAPPFLAGS = -m 0444
X  INSTKMEMFLAGS = -m 4755
X        FCFLAGS = -t
X    CDEBUGFLAGS = -O
X
X        PATHSEP = /
X         DEPEND = $(BINDIR)/makedepend
X          IMAKE = $(BINDIR)/imake
X            RGB = $(LIBDIR)/rgb
X             FC = $(BINDIR)/bdftosnf
X      MKFONTDIR = $(BINDIR)/mkfontdir
X      MKDIRHIER = $(BINDIR)/mkdirhier.sh
X
X         CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
X      LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
X        LDFLAGS = $(CDEBUGFLAGS) -L$(USRLIBDIR) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
X
X       IRULESRC = $(LIBDIR)/imake.includes
X
X   EXTENSIONLIB = $(USRLIBDIR)/libext.a
X           XLIB = $(USRLIBDIR)/libX11.a
X         XMULIB = $(USRLIBDIR)/libXmu.a
X        OLDXLIB = $(USRLIBDIR)/liboldX.a
X       XTOOLLIB = $(USRLIBDIR)/libXt.a
X         XAWLIB = $(USRLIBDIR)/libXaw.a
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       INCLUDES = -I$(INCDIR)
X      MACROFILE = Sun.macros
X   ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
X			$(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
X  IMAKE_DEFINES =
X      IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
X			-s Makefile $(IMAKE_DEFINES)
X         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
X			.emacs_* tags TAGS make.log MakeOut
X
X###########################################################################
X# rules:  $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
XLOCAL_LIBRARIES = $(XLIB)
X           SRCS = xplaces.c strcasecmp.c
X           OBJS = xplaces.o strcasecmp.o
X
X PROGRAM = xplaces
X
Xall:: xplaces
X
Xxplaces: $(OBJS) $(LOCAL_LIBRARIES)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LDFLAGS) $(SYSLAST_LIBRARIES)
X
Xrelink::
X	$(RM) $(PROGRAM)
X	$(MAKE) $(MFLAGS) $(PROGRAM)
X
Xinstall:: xplaces
X	$(INSTALL) -c $(INSTALLFLAGS) xplaces $(BINDIR)
X
Xinstall.man:: xplaces.man
X	$(INSTALL) -c $(INSTMANFLAGS) xplaces.man $(MANDIR)/xplaces.n
X
Xdepend:: $(DEPEND)
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
X
X$(DEPEND):
X	@echo "making $@"; \
X	cd $(DEPENDSRC); $(MAKE)
X
Xclean::
X	$(RM) $(PROGRAM)
X
X###########################################################################
X# Imake.tmpl common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile:: $(IMAKE)
X
XMakefile:: Imakefile \
X	$(IRULESRC)/Imake.tmpl \
X	$(IRULESRC)/Imake.rules \
X	$(IRULESRC)/site.def \
X	$(IRULESRC)/$(MACROFILE)
X	- at 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)
X
X$(IMAKE):
X	@echo "making $@"; \
X	cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)
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 done"
X
Xinstall.man::
X	@echo "install.man done"
X
XMakefiles::
X
X###########################################################################
X# dependencies generated by makedepend
X
END_OF_FILE
if test 6445 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patchlevel.h'\"
else
echo shar: Extracting \"'patchlevel.h'\" \(21 characters\)
sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
X#define PATCHLEVEL 0
END_OF_FILE
if test 21 -ne `wc -c <'patchlevel.h'`; then
    echo shar: \"'patchlevel.h'\" unpacked with wrong size!
fi
# end of 'patchlevel.h'
fi
if test -f 'strcasecmp.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'strcasecmp.c'\"
else
echo shar: Extracting \"'strcasecmp.c'\" \(350 characters\)
sed "s/^X//" >'strcasecmp.c' <<'END_OF_FILE'
X#include <stdio.h> 
X#include <ctype.h>
X
X
Xint 
Xstrcasecmp(pch1, pch2)
X	char	*pch1,
X		*pch2;
X{
X	char	chtemp1,
X		chtemp2;
X
X	while(NULL != *pch1) {
X		chtemp1 = (isupper(*pch1) ? tolower(*pch1) : *pch1);
X		chtemp2 = (isupper(*pch2) ? tolower(*pch2) : *pch2);
X		if(chtemp1 != chtemp2) {
X			return chtemp1 - chtemp2;
X		}
X		pch1++; pch2++;
X	}
X	return 0;
X}
X
X
END_OF_FILE
if test 350 -ne `wc -c <'strcasecmp.c'`; then
    echo shar: \"'strcasecmp.c'\" unpacked with wrong size!
fi
# end of 'strcasecmp.c'
fi
if test -f 'xplaces.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xplaces.1'\"
else
echo shar: Extracting \"'xplaces.1'\" \(3449 characters\)
sed "s/^X//" >'xplaces.1' <<'END_OF_FILE'
X.TH XPLACES 1 
X.SH NAME
Xxplaces - window information dump for startup files 
X.SH SYNOPSIS
X.B "xplaces"
X[-borderwidth] [-iconic] [-icongeometry] [-rsh] [-e \fIprefix\fP]
X[-f \fIfilename\fP] [-help]
X[-display \fIdisplay\fP]
X.SH DESCRIPTION
X.PP
X.I Xplaces
Xdumps the locations of your current X window screen setup
Xto a file that can be used as an
X.IR xtools
Xor 
X.IR xinit
Xstartup file.
XThis way users can set up thier windows that way they want, and then
Xget a startup file from
X.IR xplaces
Xthat has the window locations, commands, fonts and sizes.    By default
X.IR xplaces
Xprints out the command line you used to make the window (if it can find
Xthe command line) and the geometry.
X.SH OPTIONS
X.PP
X.TP 8
X.B "-help"
XPrint out the "Usage" command syntax summary.
X.PP
X.TP 8
X.B "-borderwidth"
XThis option will print out the borderwidth of each window using the 
Xstandard \fB-borderwidth\fP option.
X.PP
X.TP 8
X.B "-iconic"
XThis option will check the current state of each window and, if
Xthe window is iconified, will add the \fB-iconic\fP option to
Xthe output.  With this the user can setup which windows in his 
Xdefault layoout will be open or iconified.
X.PP
X.TP 8
X.B "-icongeometry"
XIf there are icon geometry hints, this option will make 
X.IR xplaces
Xto print them out using the standard \fB-xrm\fP option.
X.PP
X.TP 8
X.B "-rsh"
XThis option tells 
X.IR xplaces
Xto attempt to determine whether a window was
Xmade with 
X.IR rsh
X, or if it is an 
X.IR xterm
X, whether it used the \fB-e\fP
Xoption.  The checks it makes are simple, and the output will probably
Xrequire some editing to work correctly.
X.PP
X.TP 8
X.B "-e \fIprefix\fP"
XThis option specifies a prefix of window names to ignore.  For example, when
Xusing 
X.IR xtools
X, you will get two extra windows, \fBconfirm\fP and \fBxtools\fP.
XYou would not want these in your .xtools file, since these are created by
X.IR xtools 
Xon startup.  See EXAMPLE below.
X.PP
X.TP 8
X.B "-f \fIfile\fP"
XThis option specifies the file to put the output in.  Without this option, 
Xoutput is printed to \fIstdout\fP.  If the \fIfile\fP already exists, 
X.IR xplaces
Xrenames it to \fIfile.old\fP before it outputs anything.
X.PP
X.TP 8
X.B -display \fIdisplay\fP
XThis option allows you to specify the server to connect to; see 
X.IR X
X.SH EXAMPLES
X.LP
XSample output from the command (these all use the default xterm font):
X.br
Xxplaces
X.br
X
X.nf
Xconfirm -geometry =88x48+1061+750 &
Xxtools -geometry =80x48+1069+750 &
XTWM Icon Manager -geometry =0x-13+9+759 &
Xxterm -T Console -geometry =80x24+1+20 &
X/usr/bin/X11/xterm -T Mentor -geometry =80x24+1+20 &
X/usr/bin/X11/xterm -T S.cc.purdue.edu -geometry =80x24+1+20 &
X/usr/bin/X11/xterm -T Staff -geometry =80x24+212+407 &
X/usr/bin/X11/xterm -T J.cc -geometry =80x24+1+20 &
X/usr/bin/X11/xterm -T Smaug -geometry =82x26+145+405 &
X.fi
X.LP
XAnd from the same session:
X.br
Xxplaces -rsh -iconic -e confirm -e xtools -e TWM
X.br
X
X.nf
Xxterm -T Console -geometry =80x24+1+20 -iconic -e rlogin Console &
Xrsh mentor -n /usr/bin/X11/xterm -T Mentor -geometry =80x24+1+20 -iconic &
Xrsh s.cc.purdue.edu -n /usr/bin/X11/xterm -T S.cc.purdue.edu -geometry =80x24+1+20 -iconic &
Xrsh staff -n /usr/bin/X11/xterm -T Staff -geometry =80x24+212+407 &
Xrsh j.cc -n /usr/bin/X11/xterm -T J.cc -geometry =80x24+1+20 &
Xrsh smaug -n /usr/bin/X11/xterm -T Smaug -geometry =82x26+145+405 &
X.fi
X.SH ENVIRONMENT
X.PP
X.TP 8
X.SH SEE ALSO
XX(1), xtools(1)
X.SH AUTHOR
XMichael Rowan, Purdue University Computing Center Unix Group
END_OF_FILE
if test 3449 -ne `wc -c <'xplaces.1'`; then
    echo shar: \"'xplaces.1'\" unpacked with wrong size!
fi
# end of 'xplaces.1'
fi
if test -f 'xplaces.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xplaces.c'\"
else
echo shar: Extracting \"'xplaces.c'\" \(8811 characters\)
sed "s/^X//" >'xplaces.c' <<'END_OF_FILE'
X/*
X *	xplaces - dump "command" windows with geometrys 
X *		 This is ideal for dumping a setup you	
X *		 have to a startup file (stdout by default)
X *		 The idea came from a similar program for
X *		 suntools (sic)
X *
X *	Copyright (C) 1988 Michael Rowan
X *
X * 	Evveryone is granted permision to copy, modify and 
X *	redistribute this code provided that 1) you leave this
X *	copyright message and 2) you send changes/fixes back to
X *	me so I can include them in the next release.
X *
X *	Mike Rowan (mtr at mace.cc.purdue.edu)
X */
X
X#include	<stdio.h>
X#include 	<ctype.h>
X#include 	<sys/file.h>
X#include 	<sys/param.h>
X#include	<X11/Xlib.h>
X#include	<X11/Xutil.h>
X#include 	<X11/Xatom.h>
X
X#ifndef XTERMPROG
X#define XTERMPROG 	"/usr/bin/X11/xterm"
X#endif /* XTERMPROG */
X#ifndef MAXEXCEPT
X#define MAXEXCEPT 25
X#endif /* MAXEXCEPT */
X
Xint	borderwidth,
X	icong,
X	iconic,
X	checkrsh,
X	supress_bg,
X	iExcepts;
X
XFILE	*pFout;
Xchar	*do_prop(),
X	*strdwncase();
Xvoid	dumpcommandname();
X
Xchar	*except[MAXEXCEPT],
X	*dasheme;
X
Xint
Xmain(argc, argv)
X	int		argc;
X	char		**argv;
X{
X	register Display	*dpy;
X	char			*pchDisplayName = NULL,
X				*pchFile = NULL,
X				*progname;
X	Window			Root;
X	int			screen,
X				i;
X
X	iExcepts = supress_bg = icong =iconic = checkrsh = borderwidth = 0;
X	progname = argv[0];
X
X	for (i = 1; i < argc; i++) {
X		if (!strcmp ("-display", argv[i]) || !strcmp ("-d", argv[i])) {
X			if (++i >= argc) {
X				usage ();
X			}
X			pchDisplayName = argv[i];
X			continue;
X		}
X		if (!strcmp("-help", argv[i])) {
X			usage();
X		}
X		if(!strcmp("-bw",argv[i]) || !strcmp("-borderwidth",argv[i])) {
X			borderwidth++;
X			continue;
X		}		
X		if(!strcmp("-ig",argv[i]) || !strcmp("-icongeometry",argv[i])) {
X			icong++;
X			continue;
X		}
X		if(!strcmp("-iconic",argv[i])) {
X			iconic++;
X			continue;
X		}
X		if(!strcmp("-rsh",argv[i])) {
X			checkrsh++;
X			continue;
X		}
X		if(!strcmp("-except",argv[i]) || !strcmp("-e",argv[i])) {
X			except[iExcepts++] = argv[++i];
X			continue;
X		}
X		if(!strcmp("-f",argv[i])) {
X			pchFile = argv[++i];
X			continue;
X		}
X		if(!strcmp("-nbg",argv[i])) {
X			supress_bg++;
X			continue;
X		}
X		fprintf(stderr,"%s: Bad option :%s: \n",progname,argv[i]);
X		usage();
X	} 
X
X	if((Display *)0 == (dpy = XOpenDisplay(pchDisplayName))) {
X		fprintf(stderr, "%s:  unable to open display '%s'\n",
X			progname, XDisplayName (pchDisplayName));
X		usage ();
X	}
X	if(NULL != pchFile) {
X		if(!access(pchFile,F_OK)) {
X			char	pchTemp[MAXPATHLEN];
X
X			sprintf(pchTemp, "%s.old", pchFile);
X			rename(pchFile, pchTemp);
X		}
X		if(NULL == (pFout = fopen(pchFile,"w"))) {
X			fprintf(stderr,"Can't open output file\n");
X			exit(1);
X		}
X	} else {
X		pFout = stdout;
X	}
X	screen = DefaultScreen(dpy);
X	Root = RootWindow(dpy, screen);
X	Childs(Root, dpy);
X}
X
Xusage()
X{
X	fprintf(stderr,"Usage: ");
X	fprintf(stderr,"xquery [options]  where options are:\n");
X	fprintf(stderr,"\t-display <display> or -d <display>\n");
X	fprintf(stderr,"\t-help                 - this message\n");
X	fprintf(stderr,"\t-f file               - set output file (stdout by default\n");
X	fprintf(stderr,"\t-bw or -borderwidth   - output border width\n");
X	fprintf(stderr,"\t-ig or -icongeometry  - output icon geometry\n");
X	fprintf(stderr,"\t-iconic               - use current state for each window\n");
X	fprintf(stderr,"\t-rsh                  - attempt to guess at rsh's\n");
X	exit(1);
X}
X
X
XChilds(currwin, dpy)
X	Window currwin;
X	Display	*dpy;
X{
X	Window	*children,
X		misc,
X		parent;
X	int	iChildren;
X	char	*pchWin,
X		*pchName;
X	int	iCnt,
X		x, 
X		y, 
X		xterm = 0,
X		done = 0,
X		didrsh = 0;	
X	unsigned int		w, h, b, d;
X	unsigned long		nitems,
X				retn = 0;
X	int			winwidth, 
X				winheight;
X	XSizeHints		hints;
X	XWindowAttributes	info;
X	XClassHint		classhints;
X
X	if(0 == XQueryTree(dpy, currwin,&misc,&parent,&children, &iChildren)) {
X		fprintf(stderr,"Can't query window tree");
X		exit(1);
X	}
X	for(iCnt = 0; iCnt < iChildren; iCnt++, children++) {
X		/*
X		 *  first lets do all this guys children 
X		 */
X		Childs(*children,dpy);
X		dasheme = NULL;
X		/*
X		 * if there are hints, lets get the standard things
X		 */
X		if(XGetNormalHints(dpy, *children, &hints)) {
X			XFetchName(dpy, *children, &pchWin);
X			if(exception(pchWin)) {
X				continue;
X			}
X			info.width = info.height = 0;
X			XGetWindowAttributes(dpy, *children, &info);
X			XGetGeometry(dpy, *children, &misc, &x, &y, 
X							&w, &h, &b, &d);
X			/*  
X			 *  Is geometry in pixels or chars? 
X			 */
X			if (hints.width_inc > 1 && hints.height_inc > 1) {
X				winwidth = (hints.width - hints.min_width) / hints.width_inc;
X				winheight = (hints.height - hints.min_height) / hints.height_inc;
X			}  else {
X				winwidth = info.width;
X				winheight = info.height;
X			}
X			if(XGetClassHint(dpy, *children, &classhints)) {
X				pchName = do_prop(XA_WM_COMMAND,dpy,
X						*children, &nitems);
X				if(checkrsh) {
X					didrsh = isrsh(pchName, pchWin);
X				}
X				/* 
X				 * if there was a WM_COMMAND - use it!
X				 */
X				if(pchName !=  NULL) {
X					dumpcommandname(pchName, nitems, &retn);
X					done++;
X				} else {
X					if(!strcasecmp("xterm",
X							classhints.res_name)) {
X						xterm++;
X						if(!strcmp("xterm", pchWin)) {
X							fprintf(pFout, "%s ", 
X								pchWin);
X						} else {
X							fprintf(pFout,"%s -T %s",XTERMPROG,pchWin);
X						}
X					} else {
X						fprintf(pFout,"%s ", pchWin);
X					}
X				}
X			} else {
X				fprintf(pFout, "%s ", pchWin);
X			}
X			fprintf(pFout,"-geometry %dx%d+%d+%d",
X				winwidth,winheight,hints.x, hints.y);
X			if(borderwidth) {
X				fprintf(pFout," -borderwidth %d ",b);
X			}		
X			if(iconic) {
X				if(info.map_state == IsUnmapped) {
X					fprintf(pFout," -iconic");
X				}
X			}
X			if(icong) {
X				do_icons(dpy, *children);
X			}
X			if(dasheme == NULL && checkrsh && !didrsh && !done && xterm) {
X				fprintf(pFout," -e rlogin %s",pchWin);
X			}
X			if(dasheme != NULL) {
X				fprintf(pFout," -e ", dasheme);
X				dumpcommandname(dasheme, retn, &retn);
X			}
X			if(!supress_bg) {
X				fprintf(pFout," &");
X			}
X			fprintf(pFout,"\n");
X		}	
X	}
X}
X
X/* 
X *  If the window manager sets a windows icon window or pixmap
X *  then we can do icon geometry - right?
X *
X */
X
Xdo_icons(dpy, window)
X	Display	*dpy;
X	Window	window;
X{
X	XWMHints	*wmhints;
X	Window		misc,
X			iconwindow;
X	int		x, y, w, h, b, d;
X
X	if(NULL != (wmhints = XGetWMHints(dpy,window))) {
X		if(wmhints->flags & IconPixmapHint) {
X			iconwindow = wmhints->icon_pixmap;
X		} else if(wmhints->flags & IconWindowHint) {
X			iconwindow = wmhints->icon_window;
X		} else {
X			return;
X		}
X		if(iconwindow == (Window) 0) {
X			return;
X		}
X		if(!XGetGeometry(dpy, iconwindow, &misc, &x, &y, &w, &h, &b, &d)) {
X			fprintf(pFout," -xrm \"*iconGeometry:  +%d+%d\"",x,y);
X		}
X	}
X}
X
X/*
X *  This gets a property - actually it gets the WM_COMMAND
X *	but is psuedo non-specific;  you need to check the 
X * 	actual return type (&atomret) and verify its type
X *	and extract it in a switch
X */
X
Xchar *
Xdo_prop(prop, dpy, win, ret_nitems)
X	Atom	prop;
X	Display	*dpy;
X	Window	win;
X	unsigned long *ret_nitems;
X{
X	char	*data;
X	Atom	atomret;
X	int	format;
X	unsigned long	nitems, 
X			bytes;
X	
X	if(Success ==	XGetWindowProperty(dpy, win, prop, 0L, 200L, False,
X				AnyPropertyType, &atomret,&format,&nitems,
X				&bytes,&data)) {
X		if(atomret == None) {
X			return NULL;
X		}
X		if(bytes == 0 && nitems != 0) { 
X			*ret_nitems = nitems;
X			return data;
X		}
X	}
X	return NULL;
X}
X
X/*
X *  is this window in the exception list?
X *
X */
X
Xint
Xexception(pch)
X	char	*pch;
X{
X	int	i;
X
X	for(i=0; i < iExcepts; i++) {
X		if(!strncmp(except[i],pch,strlen(except[i]))) {
X			return 1;
X		}
X	}
X	return 0;
X}
X		
X/*
X *  A really simple check that doesn't always work :-)
X *  this assumes that if it was and rsh you would have
X *  specified a complete pathname - and most likey
X *  your window name will be the host name.  if the command
X *  name and the window name are the same, I return
X *  (a /usr/bin/X11/xterm will have a name (by default) of xterm)
X */
X
Xisrsh(pchCommand, pchWin)
X	char	*pchCommand,
X		*pchWin;
X{
X	char	*pch,
X		tempstr[MAXPATHLEN],
X		*rindex();
X
X	if(pchCommand == NULL || pchWin == NULL) {
X		return 0;
X	}
X	if(NULL == (pch = rindex(pchCommand,'/'))) {
X		return 0;
X	}
X	if(strcmp(pch, pchWin)) {
X		strcpy(tempstr, pchWin);	
X		fprintf(pFout,"rsh %s -n ", strdwncase(tempstr));
X		return 1;
X	}
X	return 0;
X}
X
Xchar *
Xstrdwncase(pchstart)
X	char	*pchstart;
X{
X	char	*pch = pchstart;
X
X	while(*pch != NULL) {
X		if(isupper(*pch)) {
X			*pch = tolower(*pch);
X		}
X		pch++;
X	}
X	return pchstart;
X}
X
Xvoid
Xdumpcommandname(pch, nitems, retnitems)
X	char *pch;
X	unsigned long nitems;
X	unsigned long *retnitems;
X{
X	int i;
X
X	for(i = 0; i< nitems; ) {
X		int temp;
X
X		if(!strcmp("-e",pch)) {
X			temp = strlen(pch) + 1;
X			pch += temp;  
X			i += temp;
X			dasheme =  pch;
X			*retnitems = (unsigned long) i;
X			return;
X		} else {
X			fprintf(pFout,"%s ",pch);
X		}
X		temp = strlen(pch) + 1;
X		pch += temp;  
X		i += temp;
X	} 
X}
END_OF_FILE
if test 8811 -ne `wc -c <'xplaces.c'`; then
    echo shar: \"'xplaces.c'\" unpacked with wrong size!
fi
# end of 'xplaces.c'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
Moderator of comp.sources.x



More information about the Comp.sources.x mailing list