[comp.windows.x] awm kit, Part02

jkh@ardent.UUCP (Jordan K. Hubbard) (06/06/88)

#! /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 2 (of 8)."
# Contents:  CHANGES FocusChng.c Makefile Menu.c MoveOpaque.c Push.c
#   Refresh.c Restart.c StoreBox.c exp_path.c menu_sup.c
# Wrapped by jkh@ardent on Sun Jun  5 18:56:26 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'CHANGES' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'CHANGES'\"
else
echo shar: Extracting \"'CHANGES'\" \(4951 characters\)
sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
This file last changed: 6/3/88
X
The most recent changes to awm include:
X
Bug fixes/enhancements for first release.
X
A new context named "border" has been added. When enabled (by giving it a width, see
man page), it results in an artificial border area to which actions may be bound.
See the man page for information on configuring this.
X
It is now possible to bind to "text action" strings in the same manner as functions
and menus. Specifically, you may now invoke programs and manipulate the cut buffer
directly through bindings rather than having to go through menus. See the man
page for a more thorough explanation.
X
Cursors for title bars and border contexts (new) are now definable resources.
X
X"resizeRelative" option from R2 uwm folded in along with uwm bug fixes.
X
New title.push option allows you to specify whether you want titles to push windows
down to make room (the default) or be added on top without moving them.
X
Support for the RTL Neaten package has been added. See the README file if you
wish to compile it in.
X
To avoid some confusion, it's now manadatory that you compile XRdBitFD.c into Xlib.
Seperate compilation is no longer supported. The resulting inconvenience is relatively
minor compared to what some people with irregular source trees experienced when trying
to compile it as part of awm.
X
Many bugs have been fixed, most notably a race condition on window mapping,
mapping/unmapping of windows, bogus event masks to gadgets, resize weirdness,
rubber banding and a number of coordinate botches that resulted from
adding frames around things. It's now possible to compile awm with gcc 1.22,
though I don't know about the neaten package.
X
X
Bug fixes to Beta.3
X
DEF_FONT is now in awm.h where it belongs and GetFontRes() has been
modified to use it.
X
Some of the default specs in awm.h have been ifdef'd so that you can
also specify them at compile time. Currently, you can do this for the font specs:
X
NAME			Default value
X----			-------------
DEF_FONT		"fixed"
DEF_TITLE_FONT		"vtsingle"
DEF_ICON_FONT		"8x13"
DEF_POPUP_FONT		"9x15"
DEF_GADGET_FONT		"fixed"
DEF_MENU_FONT		"8x13"
DEF_BOLD_FONT		"8x13bold"
X
And the name and class of awm:
X
NAME			"awm"
CLASS			"Wm"
X
It's still suggested that you change them in awm.h when you're configuring
awm for your site, but this gives you an additional way of setting them.
X
Changes for beta release 3.
X
X1. Total rewrite of Iconify.c and NewIconify, problems fixed are iconic
startup, icon/window positioning, icon_mask hints.
X
X2. Each gadget may now have its own font, rather than having to
use a global gadget font (though this is still the default).
Non-printable characters can also now be specified, allowing you
to grab individual glyphs out of fonts and use them in gadgets.
The is probably most useful for getting things out of the cursor font.
See the man page for details.
Note: Though much of the necessary code is in place, it still is not
possible to use 16 bit fonts for this purpose. Though I'd love
to have gadgets containing Kanji glyphs (a picture is worth a thousand
words, especially in Kanji) and the like, I still don't know enough
about the mechanism to know how and when to use the X*Text*16 routines,
or how to store the "string" in such a way that it could be
painted into an 8 bit font as well.
X
X3. Overall structure of the window manager has changed slightly.
The code should be easier to read and debug.
X
X4. New "wall" boolean allows you to constrain moves to the edges of
the screen.
X
X5. Some things that should have been getting their colors out of
the resource database now do.
X
X6. Window name and class are now both checked when determing whether
or not to title a window.
X
X7. Icons now use save-unders.
X
X8. Certain operations should be faster.
X
X9. The man page has been made more readable and updated somewhat.
X
X
CHANGES OVER UWM:
X
This window manager represents a fairly large departure from uwm
in the following ways:
X
X o	There are title bars and gadget boxes that represent fully independent
X	contexts now (I.E. you can bind to them without conflict).
X
X o	Icons now represent a truly independent context.
X
X o	The menus have changed completely to allow walking menus and
X	more flexibility as to contents (pictures or text) of individual panes.
X	The menu interface has also been de-coupled somewhat from awm so
X	that another menu package could be substituted at a
X	later date. When an "official" toolkit menu widget exists, this
X	will probably happen.
X
X o	Boolean variables may be set within menus and are also displayed
X	with a checkmark (depending on whether or not they're set).
X
X o	Some effort is made to use save-unders and/or to minimize expose
X	events due to window manager actions.
X
X o	Autoraise and border highlighting are available on focus.
X
X o	Almost everything has been moved out of the .awmrc file and into
X	the resource database where it belongs.
X
X o	awm now supports a startup file that makes usage from xinit more
X	friendly.
X
X 
END_OF_FILE
if test 4951 -ne `wc -c <'CHANGES'`; then
    echo shar: \"'CHANGES'\" unpacked with wrong size!
fi
# end of 'CHANGES'
fi
if test -f 'FocusChng.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'FocusChng.c'\"
else
echo shar: Extracting \"'FocusChng.c'\" \(3511 characters\)
sed "s/^X//" >'FocusChng.c' <<'END_OF_FILE'
X#ifndef lint
X     static char *rcsid_FocusChange_c = "$Header: FocusChange.c,v 1.0 87/11/23 03:26:00 jkh Exp $";
X#endif	lint
X
X/*
X * MODIFICATION HISTORY
X *
X * 002 -- Jordan Hubbard, U.C. Berkeley.
X Hacks for autoraise and titles.
X */
X
X#include "awm.h"
X
X#if defined(sun) || defined(ibm032) || defined(titan)
X#include <sys/time.h>
X#else
X#include <time.h>
X#endif
X
HandleFocusIn(ev)
XXEvent *ev;
X{
X     XEnterWindowEvent *e = (XEnterWindowEvent *)ev;
X     Window w = e->window;
X     AwmInfoPtr awi;
X     XEvent event;
X     
X     Entry("HandleFocusIn")
X
X     awi = GetAwmInfo(w);
X     if (!awi)  /* probably a menu or something */
X         Leave(TRUE)
X     w = awi->client;
X
X     if (e->mode == NotifyNormal && e->detail != NotifyInferior &&
X	 e->focus && (Hilite || Autoraise) &&
X	 !Snatched) {
X	  struct timeval foo;
X	  
X	  foo.tv_sec = 0;
X	  foo.tv_usec = RaiseDelay * 1000; 
X	  /*
X	   * Sleep for awhile to avoid race conditions and give any potential
X	   * leave events a chance to get here..
X	   */
X	  select(0, 0, 0, 0, &foo);
X	  /* Did we leave this window already? */
X	  if (XCheckTypedWindowEvent(dpy, w, LeaveNotify, &event)) {
X	       XPutBackEvent(dpy, &event);
X	       Leave(FALSE)
X	  }
X	  /* light the border */
X	  if (Hilite) {
X	       SetBorderColors(w, ForeColor);
X	       if (awi->frame) {
X		    if (awi->bold) {
X			 XSetWindowBackgroundPixmap(dpy, awi->title,
X						    awi->bold);
X			 PaintTitle(w);
X		    }
X		    if (awi->BC_bold && BContext) {
X			 XSetWindowBackgroundPixmap(dpy, awi->frame,
X						    awi->BC_bold);
X			 XClearWindow(dpy, awi->frame);
X		    }
X	       }
X	  }
X	  /*
X	   * If Autoraise is set, raise that puppy..
X	   */
X	  if (Autoraise)
X	       XRaiseWindow(dpy, (awi->frame) ? awi->frame : awi->client);
X	  Leave(FALSE)
X     }
X     Leave(TRUE)
X}
X
HandleFocusOut(ev)
XXEvent *ev;
X{
X     XLeaveWindowEvent *e = (XEnterWindowEvent *)ev;
X     Window w = e->window;
X     AwmInfoPtr awi;
X     XEvent event;
X
X     Entry("HandleFocusOut")
X
X     awi = GetAwmInfo(w);
X     if (!awi) /* probably a menu or something */
X         Leave(TRUE)
X     w = awi->client;
X
X     if (e->mode == NotifyNormal && e->detail != NotifyInferior &&
X	 (Hilite || Autoraise) && !Snatched) {
X	  /* Did we come back into this window? */
X	  if (XCheckTypedWindowEvent(dpy, w, EnterNotify, &event)) {
X	       XPutBackEvent(dpy, &event);
X	       Leave(FALSE)
X	  }
X	  /* set the window to grey */
X	  if (Hilite) {
X	       SetBorderPixmaps(w, GrayPixmap);
X	       if (awi->frame) {
X		    if (awi->back)
X			 XSetWindowBackgroundPixmap(dpy, awi->title,
X						    awi->back);
X		    if (awi->BC_back && BContext) {
X			 XSetWindowBackgroundPixmap(dpy, awi->frame,
X						    awi->BC_back);
X			 XClearWindow(dpy, awi->frame);
X		    }
X		    PaintTitle(w);
X	       }
X	  }
X	  Leave(FALSE)
X     }
X     Leave(TRUE)
X}
X
void SetBorderColors(w, color)
Window w;
Pixel color;
X{
X     AwmInfoPtr awi;
X
X     Entry("SetBorderColors")
X
X     awi = GetAwmInfo(w);
X     if (!awi)
X	  Leave_void
X     XSetWindowBorder(dpy, awi->client, color);
X     if (awi->frame) {
X	  XSetWindowBorder(dpy, awi->title, color);
X	  XSetWindowBorder(dpy, awi->frame, color);
X     }
X     Leave_void
X}
X
void SetBorderPixmaps(w, pix)
Window w;
Pixmap pix;
X{
X     AwmInfoPtr awi;
X
X     Entry("SetBorderPixmaps")
X
X     awi = GetAwmInfo(w);
X     if (!awi)
X	  Leave_void
X     XSetWindowBorderPixmap(dpy, awi->client, pix);
X     if (awi->frame) {
X	  XSetWindowBorderPixmap(dpy, awi->title, pix);
X	  XSetWindowBorderPixmap(dpy, awi->frame, pix);
X     }
X     Leave_void
X}
END_OF_FILE
if test 3511 -ne `wc -c <'FocusChng.c'`; then
    echo shar: \"'FocusChng.c'\" unpacked with wrong size!
fi
# end of 'FocusChng.c'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(5768 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X#
X# Warning: the cpp used on this machine replaces
X# all newlines and multiple tabs/spaces in a macro
X# expansion with a single space.  Imake tries to
X# compensate for this, but is not always
X# successful.
X#
X
X#
X# This makefile is automatically generated by imake... do not modify
X# or you may lose your changes when imake generates makefiles again.
X# Ignore this message if you are not using imake.
X#
X
X            TOP = /usr/src/X.V11R2
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
X         RANLIB = ranlib
X             AR = ar clq
X             LS = ls
X       LINTOPTS = -axz
X    LINTLIBFLAG = -C
X           MAKE = make
X    STD_DEFINES =
X    CDEBUGFLAGS = -g
X        DESTDIR = /usr/X11
X
X        PATHSEP = /
X         DEPEND = $(DEPENDSRC)/makedepend
X          IMAKE = $(IMAKESRC)/imake
X            RGB = $(RGBSRC)/rgb
X         CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
X      LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
X        LDFLAGS = $(CDEBUGFLAGS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
X   INSTUIDFLAGS = -m 4755
X   INSTLIBFLAGS = -m 0664
X   INSTINCFLAGS = -m 0444
X   INSTMANFLAGS = -m 0444
X   INSTAPPFLAGS = -m 0444
X
X      USRLIBDIR = $(DESTDIR)/lib
X         BINDIR = $(DESTDIR)
X         LIBDIR = $(USRLIBDIR)
X     LINTLIBDIR = $(USRLIBDIR)/lint
X         INCDIR = $(DESTDIR)/usr/include/X11
X        FONTDIR = $(LIBDIR)/fonts
X         AWMDIR = $(LIBDIR)/awm
X         UWMDIR = $(LIBDIR)/uwm
X         MANDIR = $(DESTDIR)/usr/man/mann
X    XAPPLOADDIR = $(LIBDIR)/app-defaults
X         ADMDIR = $(DESTDIR)/usr/adm
X
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     EXAMPLESRC = $(TOP)/examples
X     CONTRIBSRC = $(TOP)/contrib
X         DOCSRC = $(TOP)/doc
X      DEPENDSRC = $(UTILSRC)/makedepend
X       IMAKESRC = $(UTILSRC)/imake
X       IRULESRC = $(UTILSRC)/imake.includes
X         RGBSRC = $(UTILSRC)/rgb
X        XLIBSRC = $(LIBSRC)/X
X     TOOLKITSRC = $(LIBSRC)/Xt
X     AWIDGETSRC = $(LIBSRC)/Xaw
X     OLDXLIBSRC = $(LIBSRC)/oldX
X   EXTENSIONSRC = $(TOP)/extensions
X        XMANSRC = $(DOCSRC)/Xlib/Xman
X   EXTENSIONLIB = $(EXTENSIONSRC)/lib/libXext.a
X           XLIB = $(XLIBSRC)/libX11.a
X        OLDXLIB = $(OLDXLIBSRC)/liboldX.a
X       XTOOLLIB = $(TOOLKITSRC)/libXt.a
X         XAWLIB = $(AWIDGETSRC)/libXaw.a
X       LINTXLIB = $(XLIBSRC)/llib-lX11.ln
X      LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln
X        LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln
X       INCLUDES = -I$(TOP)
X      MACROFILE = Sun.macros
X      IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl \
X			-I$(NEWTOP)$(IRULESRC) \
X			-s Makefile
X         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
X			tags TAGS make.log
X
X       MENU_LIB = menus
X      MENU_ARCH = $(MENU_LIB)/rtlmenu.a
X     NEATEN_LIB = /grgr/neaten
X    NEATEN_ARCH = $(NEATEN_LIB)/neaten.a
X  SYS_LIBRARIES = -ll
X      OTHERSRCS = gram.y lex.l
X         YFLAGS = -d
X
X# Use these macros if you want the RTL Neaten package.
X# Also make sure that NEATEN_LIB points to the right place. See the README
X# file for instructions (though you can just define this and give it a shot).
X#       DEFINES = -DSYSFILE=\"$(AWMDIR)$(PATHSEP)system.awmrc\" -DNEATEN
X#       LOCAL_LIBRARIES = $(NEATEN_ARCH) $(MENU_ARCH) $(XLIB)
X
X# Use these macros if you don't want the RTL Neaten package.
X        DEFINES = -DSYSFILE=\"$(AWMDIR)$(PATHSEP)system.awmrc\"
X        LOCAL_LIBRARIES = $(MENU_ARCH) $(XLIB)
X
SRCS=	globals.c Beep.c Bindings.c CircleDown.c CircleUp.c\
X	Cursors.c Focus.c GetButton.c  GridBox.c Iconify.c Icons.c Lower.c\
X	Menu.c Move.c MoveOpaque.c NewIconify.c Pause.c Push.c Error.c\
X	Raise.c Refresh.c Resize.c Restart.c RubberBand.c StoreBox.c \
X	StoreZap.c XError.c awm.c FocusChng.c Titlebar.c errHndlr.c \
X	Grab.c menu_sup.c Gadget.c support.c exp_path.c Neaten.c
X
OBJS=	gram.o lex.o globals.o Beep.o Bindings.o CircleDown.o CircleUp.o\
X	Cursors.o Focus.o GetButton.o GridBox.o Iconify.o Icons.o Lower.o\
X	Menu.o Move.o MoveOpaque.o NewIconify.o Pause.o Push.o Error.o\
X	Raise.o Refresh.o Resize.o Restart.o RubberBand.o StoreBox.o \
X	StoreZap.o XError.o awm.o FocusChng.o Titlebar.o errHndlr.o \
X	Grab.o menu_sup.o Gadget.o support.o exp_path.o Neaten.o
X
X PROGRAM = awm
X
all:: awm
X
awm: $(OBJS) $(LOCAL_LIBRARIES)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LDFLAGS)
X
relink::
X	$(RM) $(PROGRAM)
X	$(MAKE) $(MFLAGS) $(PROGRAM)
X
install:: awm
X	$(INSTALL) -c $(INSTALLFLAGS) awm $(BINDIR)
X
install:: awm.man
X	$(INSTALL) -c $(INSTMANFLAGS) awm.man $(MANDIR)/awm.n
X
depend:: $(DEPEND)
X
depend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
X
X$(DEPEND):
X	@echo "making $(DEPENDSRC)"; \
X	cd $(DEPENDSRC); $(MAKE)
X
clean::
X	$(RM) $(PROGRAM)
X
install:: def.awmrc
X	$(INSTALL) -c $(INSTALLFLAGS) def.awmrc  $(LIBDIR)
X
X$(MENU_ARCH)::
X	@echo Making menu package...
X	@(cd $(MENU_LIB); make)
X	@echo done.
X
X$(NEATEN_ARCH)::
X	cp Makefile.rtl $(NEATEN_LIB)/Makefile
X	@echo Making Neaten package
X	@(cd $(NEATEN_LIB); make -f Makefile)
X	@echo done.
X
clean::
X	@echo Cleaning menus...
X	@(cd $(MENU_LIB); make clean)
X	@echo done.
X	rm -f y.tab.h
X
clean::
X	$(RM_CMD) \#*
X
Makefile:: $(IMAKE)
X
Makefile:: Imakefile \
X	$(IRULESRC)/Imake.tmpl \
X	$(IRULESRC)/Imake.rules \
X	$(IRULESRC)/$(MACROFILE)
X	-$(RM) Makefile.bak; $(MV) Makefile Makefile.bak
X	$(IMAKE_CMD) -DTOPDIR=$(TOP)
X
X$(IMAKE):
X	@echo "making $(IMAKESRC)"; \
X	cd $(IMAKESRC); $(MAKE)
X
tags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
install::
X	@echo "install done"
X
Makefiles::
X
END_OF_FILE
if test 5768 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
chmod +x 'Makefile'
# end of 'Makefile'
fi
if test -f 'Menu.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Menu.c'\"
else
echo shar: Extracting \"'Menu.c'\" \(3447 characters\)
sed "s/^X//" >'Menu.c' <<'END_OF_FILE'
X#ifndef lint
X     static char *rcsid_Menu_c = "$Header: Menu.c,v 1.11 87/08/03 13:08:09 swick Exp $";
X#endif	lint
X
X#include <signal.h>
X#include "X11/copyright.h"
X#include "X11/cursorfont.h"
X
X/*
X * MODIFICATION HISTORY
X *
X * 000 -- J.Hubbard, Ardent Computer.
X * 	This file bears little resemblance to its former namesake.
X *	Because of massive changes to support RTL menus, the Menu()
X *      function is now little more than a bootstrap for RTL.
X */
X
X#ifndef lint
static char *sccsid = "@(#)Menu.c	3.8	1/24/86";
X#endif
X
X#include "awm.h"
X
Boolean DoMenu(window, mask, button, x, y, menu)
Window window;				/* Event window. */
int mask;				/* Button/key mask. */
int button;				/* Button event detail. */
int x, y;				/* Event mouse position. */
RTLMenu menu;
X{
X     RTLPoint pos;
X     
X     Entry("DoMenu")
X	  
X     pos.x = x;
X     pos.y = y;
X     
X     RTLMenu_Enter(menu, button, 0, window, pos);
X     Leave(TRUE)
X}
X
Boolean DoAction(window, mask, button, x, y, menu, action)
Window window;				/* Event window. */
int mask;				/* Button/key mask. */
int button;				/* Button event detail. */
int x, y;				/* Event mouse position. */
RTLMenu menu;
ActionLine *action;
X{
X     Boolean *tmp;
X     char *buff, *cmd;
X     int status, pid, w;
X     register int (*istat)(), (*qstat)();
X
X     Entry("DoAction")
X
X     switch(action->type) {
X     case IsText:
X	  XStoreBytes(dpy, action->text, strlen(action->text));
X	  break;
X
X     case IsTextNL:
X	  buff = (char *)malloc(strlen(action->text) + 2);
X	  strcpy(buff, action->text);
X	  strcat(buff, "\n");
X	  XStoreBytes(dpy, buff, strlen(buff));
X	  free(buff);
X	  break;
X
X     case IsShellCommand:
X	  cmd = action->text;
X	  if ((pid = fork()) == 0) {
X	       signal(SIGINT, SIG_IGN);
X	       signal(SIGQUIT, SIG_IGN);
X	       signal(SIGHUP, SIG_IGN);
X	       signal(SIGTSTP, SIG_IGN);
X	       execl("/bin/sh", "sh", "-c", cmd, 0);
X	       _exit(127);
X	  }
X	  istat = signal(SIGINT, SIG_IGN);
X	  qstat = signal(SIGQUIT, SIG_IGN);
X	  while ((w = wait(&status)) != pid && w != -1);
X	  if (w == -1)
X	       status = -1;
X	  signal(SIGINT, istat);
X	  signal(SIGQUIT, qstat);
X	  break;
X
X     default:
X	  fprintf(stderr, "awm: Warning: Unknown action type %d (%s) invoked\n",
X		  action->type, action->text);
X	  break;
X     }
X}
X
X/*
X * Routine to let user select a window using the mouse
X */
X
Window Select_Window(x, y, button)
int *x, *y, *button;
X{
X     int status;
X     Cursor cursor;
X     XEvent event;
X     Window target_win, root;
X     int root_x, root_y, x2, y2, ptrmask;
X     AwmInfoPtr awi;
X     
X     Entry("Select_Window")
X	  
X     /* Make the target cursor */
X     if (XGrabPointer( dpy, RootWindow(dpy, scr),
X		      TRUE, EVENTMASK, GrabModeAsync,
X		      GrabModeAsync, None,
X		      TargetCursor, CurrentTime )
X	 != GrabSuccess ) {
X	  fprintf(stderr, "awm (Select_Window): Can't grab the mouse.");
X	  Cleanup();
X	  exit(1);
X     }
X     
X     /* Select a window */
X     while (TRUE) {
X	  XNextEvent(dpy, &event);
X	  if (event.type != ButtonPress)
X	       continue;
X	  XQueryPointer(dpy, RootWindow(dpy, scr), &root,
X			&target_win, &root_x, &root_y, &x2, &y2, &ptrmask);
X
X	  *x = root_x;
X	  *y = root_y;
X	  *button = event.xbutton.button;
X	  XUngrabPointer(dpy, CurrentTime);      /* Done with pointer */
X	  if (target_win == 0)
X	       target_win = event.xbutton.window;
X	  if (awi = GetAwmInfo(target_win))
X	       target_win = (awi->frame) ? awi->frame : awi->client;
X	  Leave(target_win)
X     }
X}
END_OF_FILE
if test 3447 -ne `wc -c <'Menu.c'`; then
    echo shar: \"'Menu.c'\" unpacked with wrong size!
fi
# end of 'Menu.c'
fi
if test -f 'MoveOpaque.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MoveOpaque.c'\"
else
echo shar: Extracting \"'MoveOpaque.c'\" \(4589 characters\)
sed "s/^X//" >'MoveOpaque.c' <<'END_OF_FILE'
X#ifndef lint
X     static char *rcsid_MoveOpaque_c = "$Header: MoveOpaque.c,v 1.8 87/08/25 11:26:34 swick Exp $";
X#endif	lint
X
X#include "X11/copyright.h"
X
X/*
X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
X *
X *                         All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of Digital Equipment
X * Corporation not be used in advertising or publicity pertaining to
X * distribution of the software without specific, written prior permission.
X *
X *
X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
X * SOFTWARE.
X */
X
X
X
X/*
X * MODIFICATION HISTORY
X *
X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
X Western Software Lab. Convert to X11.
X */
X
X#ifndef lint
static char *sccsid = "@(#)MoveOpaque.c	1.7	1/24/86";
X#endif
X
X#include "awm.h"
X
Boolean MoveOpaque(window, mask, button, x, y)
Window window;				/* Event window. */
int mask;				/* Button/key mask. */
int button;				/* Button event detail. */
int x, y;				/* Event mouse position. */
X{
X     int prev_x, prev_y;		/* Previous mouse location. */
X     int rbound, dbound;		/* potential right/down boundries */
X     int cur_x, cur_y;			/* Current mouse location. */
X     int win_x, win_y;			/* Current window location. */
X     int root_x;			/* Root window X location. */
X     int root_y;			/* Root window Y location. */
X     int ptrmask;			/* state of ptr when queried */
X     XWindowAttributes window_info;	/* Event window information. */
X     Window sub_window;			/* Query mouse event sub-window. */
X     Window root;			/* Query mouse event root. */
X     XEvent button_event;		/* Button event packet. */
X     
X     Entry("MoveOpaque")
X
X     /*
X      * Do not try to move the root window.
X      */
X     if (window == RootWindow(dpy, scr))
X	  Leave(FALSE)
X	    
X     /*
X      * Change the cursor.
X      */
X     grab_pointer();
X     
X     /*
X      * Gather info on the event window.
X      */
X     status = XGetWindowAttributes(dpy, window, &window_info);
X     if (status == FAILURE)
X	  Leave(FALSE)
X
X     /*
X      * Initialize movement variables.
X      */
X     prev_x = cur_x = x;
X     prev_y = cur_y = y;
X     win_x = window_info.x;
X     win_y = window_info.y;
X     rbound = ScreenWidth - (window_info.width + window_info.border_width);
X     dbound = ScreenHeight - (window_info.height + window_info.border_width);
X
X     /*
X      * Main loop.
X      */
X     while (TRUE) {
X	  
X	  /*
X	   * Check to see if we have a change in mouse button status.
X	   * This is how we get out of this "while" loop.
X	   */
X	  if (XCheckMaskEvent(dpy,
X			      ButtonPressMask | ButtonReleaseMask,
X			      &button_event)) {
X	       
X	       /*
X		* If the button event was something other than the
X		* release of the original button pressed, then move the
X		* window back to where it was originally.
X		*/
X	       if ((button_event.type != ButtonRelease) ||
X		   (((XButtonReleasedEvent *)&button_event)->button
X		    != button)) {
X		    ResetCursor(button);
X		    XMoveWindow(dpy, window, window_info.x, window_info.y);
X	       }
X	       ungrab_pointer();
X	       Leave(TRUE);
X	  }
X	  
X	  /*
X	   * Take care of all the little things that have changed; 
X	   * i.e., move the window, if necessary.
X	   */
X	  XQueryPointer(dpy, RootWindow(dpy, scr), 
X			&root, &sub_window, &root_x, &root_y, &cur_x, &cur_y, 
X			&ptrmask);
X	  if ((cur_x != prev_x) || (cur_y != prev_y)) {
X	       win_x += (cur_x - prev_x);
X	       win_y += (cur_y - prev_y);
X#ifdef titan /* align to 5x4 */
X	       win_x += (win_x % 5);
X	       win_y += (win_y % 4);
X#endif /* titan */
X	       if (Wall) {
X		    if (win_x < 0)
X			 win_x = 0;
X		    else if (win_x > rbound)
X			 win_x = rbound;
X		    if (win_y < 0)
X			 win_y = 0;
X		    else if (win_y > dbound)
X			 win_y = dbound;
X 	       }
X	       XMoveWindow(dpy, window, win_x, win_y);
X	       prev_x = cur_x;
X	       prev_y = cur_y;
X	  }
X     }
X}
END_OF_FILE
if test 4589 -ne `wc -c <'MoveOpaque.c'`; then
    echo shar: \"'MoveOpaque.c'\" unpacked with wrong size!
fi
# end of 'MoveOpaque.c'
fi
if test -f 'Push.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Push.c'\"
else
echo shar: Extracting \"'Push.c'\" \(4625 characters\)
sed "s/^X//" >'Push.c' <<'END_OF_FILE'
X#ifndef lint
static char *rcsid_Push_c = "$Header: Push.c,v 1.3 87/09/11 08:21:37 toddb Exp $";
X#endif	lint
X
X#include "X11/copyright.h"
X
X/*
X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
X *
X *                         All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of Digital Equipment
X * Corporation not be used in advertising or publicity pertaining to
X * distribution of the software without specific, written prior permission.
X *
X *
X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
X * SOFTWARE.
X */
X
X 
X
X/*
X * MODIFICATION HISTORY
X *
X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
X    Western Software Lab. Convert to X11.
X */
X
X#ifndef lint
static char *sccsid = "@(#)Push.c	3.8	1/24/86";
X#endif
X
X#include "awm.h"
X
X#define PUSH_DOWN	1
X#define PUSH_UP		2
X#define PUSH_LEFT	3
X#define PUSH_RIGHT	4
X
extern Boolean PushAll();
X
Boolean PushDown(window, mask, button, x, y)
Window window;				/* Event window. */
int mask;				/* Button/key mask. */
int button;				/* Button event detail. */
int x, y;				/* Event mouse position. */
X{
X    Entry("PushDown")
X
X    Leave(PushAll(window, PUSH_DOWN))
X}
X
Boolean PushUp(window, mask, button, x, y)
Window window;				/* Event window. */
int mask;				/* Button/key mask. */
int button;				/* Button event detail. */
int x, y;				/* Event mouse position. */
X{
X    Entry("PushUp")
X
X    Leave(PushAll(window, PUSH_UP))
X}
X
Boolean PushLeft(window, mask, button, x, y)
Window window;				/* Event window. */
int mask;				/* Button/key mask. */
int button;				/* Button event detail. */
int x, y;				/* Event mouse position. */
X{
X    Entry("PushLeft")
X
X    Leave(PushAll(window, PUSH_LEFT))
X}
X
Boolean PushRight(window, mask, button, x, y)
Window window;				/* Event window. */
int mask;				/* Button/key mask. */
int button;				/* Button event detail. */
int x, y;				/* Event mouse position. */
X{
X    Entry("PushRight")
X
X    Leave(PushAll(window, PUSH_RIGHT))
X}
X
Boolean PushAll(w, direction)
Window w;
int direction;
X{
X    XWindowAttributes winfo;			/* Event window information. */
X    XWindowAttributes rinfo;			/* Root window information. */
X    int xofs, yofs;			/* Movement offsets. */
X    int x, y;				/* New window position. */
X
X    Entry("PushAll")
X
X    /*
X     * Do not try to move the root window.
X     */
X    if (w == RootWindow(dpy, scr))
X        Leave(FALSE)
X
X    /*
X     * Gather info on the event window.
X     */
X    status = XGetWindowAttributes(dpy, w, &winfo);
X    if (status == FAILURE) Leave(FALSE)
X    if (!Pushval && Push)
X	 Pushval = DEF_PUSH;
X
X    /*
X     * Calculate the movement offsets.
X     */
X    switch(direction) {
X    case PUSH_DOWN:
X        xofs = 0;
X        yofs = Push ? (winfo.height / Pushval) : Pushval;
X        break;
X    case PUSH_UP:
X        xofs = 0;
X        yofs = 0 - (Push ? (winfo.height / Pushval) : Pushval);
X        break;
X    case PUSH_LEFT:
X        xofs = 0 - (Push ? (winfo.width / Pushval) : Pushval);
X        yofs = 0;
X        break;
X    case PUSH_RIGHT:
X        xofs = Push ? (winfo.width / Pushval) : Pushval;
X        yofs = 0;
X        break;
X    }
X
X    /*
X     * Calculate the new window position.
X     */
X    x = winfo.x + xofs;
X    y = winfo.y + yofs;
X
X    /*
X     * Normalize the new window coordinates so we don't
X     * lose the window off the edge of the screen.
X     */
X    if (x < (0 - winfo.width + CURSOR_WIDTH - (winfo.border_width << 1)))
X        x = 0 - winfo.width + CURSOR_WIDTH - (winfo.border_width << 1);
X    if (y < (0 - winfo.height + CURSOR_HEIGHT - (winfo.border_width << 1)))
X        y = 0 - winfo.height + CURSOR_HEIGHT - (winfo.border_width << 1);
X    if (x > (ScreenWidth - CURSOR_WIDTH))
X        x = ScreenWidth - CURSOR_WIDTH;
X    if (y > (ScreenHeight - CURSOR_HEIGHT))
X        y = ScreenHeight - CURSOR_HEIGHT;
X
X    /*
X     * Move the window into place.
X     */
X    XMoveWindow(dpy, w, x, y);
X
X    Leave(FALSE)
X}
END_OF_FILE
if test 4625 -ne `wc -c <'Push.c'`; then
    echo shar: \"'Push.c'\" unpacked with wrong size!
fi
# end of 'Push.c'
fi
if test -f 'Refresh.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Refresh.c'\"
else
echo shar: Extracting \"'Refresh.c'\" \(3589 characters\)
sed "s/^X//" >'Refresh.c' <<'END_OF_FILE'
X#ifndef lint
static char *rcsid_Refresh_c = "$Header: Refresh.c,v 1.4 87/08/21 13:29:10 swick Exp $";
X#endif	lint
X
X#include "X11/copyright.h"
X
X/*
X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
X *
X *                         All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of Digital Equipment
X * Corporation not be used in advertising or publicity pertaining to
X * distribution of the software without specific, written prior permission.
X *
X *
X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
X * SOFTWARE.
X */
X
X 
X
X/*
X * MODIFICATION HISTORY
X *
X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
X    Western Software Lab. Convert to X11.
X */
X
X#ifndef lint
static char *sccsid = "@(#)Refresh.c	3.8	1/24/86";
X#endif
X
X#include "awm.h"
X
Boolean Refresh(window, mask, button, x, y)
Window window;                          /* Event window. */
int mask;                               /* Button/key mask. */
int button;                           /* Button event detail. */
int x, y;                               /* Event mouse position. */
X{
X    Entry("Refresh")
X
X    Leave( Redraw(RootWindow(dpy,scr), mask, button, x, y) )
X}
X
X
X
Boolean Redraw(window, mask, button, x, y)
Window window;                          /* Event window. */
int mask;                               /* Button/key mask. */
int button;                             /* Button event detail. */
int x, y;                               /* Event mouse position. */
X{
X    XWindowAttributes winfo;		/* window info. */
X    XSetWindowAttributes swa;		/* New window info */
X    Window w;				/* Refresh window. */
X
X    Entry("Redraw")
X
X    /*
X     * Get info on the target window.
X     */
X    status = XGetWindowAttributes(dpy, window, &winfo);
X    if (status == FAILURE)
X	 Error("Refresh -> Can't query target window.");
X    /*
X     * Create and map a window which covers the target window, then destroy it.
X     */
X    swa.override_redirect = TRUE;
X    swa.background_pixel = 0;
X
X    /*
X     * What we have here is a failure to communicate. This window should
X     * more properly be created as a subwindow of "window", but
X     * when we do that, all events (Create, Map, Destroy) get reported
X     * as coming from "window", not the newly created one. This is
X     * very nasty when the DestroyNotify is received. For now, we'll
X     * create it on the RootWindow and take the chance of generating an
X     * expose on an overlapping window.
X     */
X    if ((w = XCreateWindow(dpy, RootWindow(dpy, scr), winfo.x, winfo.y, 
X			   winfo.width, winfo.height, 0,
X			   DefaultDepth(dpy, scr),
X			   CopyFromParent,
X			   DefaultVisual(dpy, scr),
X			   (CWOverrideRedirect | CWBackPixel),
X			   &swa)) == NULL)
X	 Error("Refresh -> Can't create refresh window.");
X    XMapWindow(dpy, w);
X    XDestroyWindow(dpy, w);
X    XFlush(dpy);
X    Leave(FALSE)
X}
END_OF_FILE
if test 3589 -ne `wc -c <'Refresh.c'`; then
    echo shar: \"'Refresh.c'\" unpacked with wrong size!
fi
# end of 'Refresh.c'
fi
if test -f 'Restart.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Restart.c'\"
else
echo shar: Extracting \"'Restart.c'\" \(3743 characters\)
sed "s/^X//" >'Restart.c' <<'END_OF_FILE'
X#include "X11/copyright.h"
X
X/*
X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
X *
X *                         All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of Digital Equipment
X * Corporation not be used in advertising or publicity pertaining to
X * distribution of the software without specific, written prior permission.
X *
X *
X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
X * SOFTWARE.
X */
X
X/*
X * MODIFICATION HISTORY
X *
X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
X    Western Software Lab. Convert to X11.
X * 002 -- Jordan Hubbard, U.C. Berkeley. Titlebar cleanup code.
X */
X
X#ifndef lint
static char *sccsid = "%W%	%G%";
X#endif
X
X#include "awm.h"
X#include "X11/Xutil.h"
X
extern XContext AwmContext;
X
Boolean Restart(window, mask, button, x, y)
Window window;                          /* Event window. */
int mask;                               /* Button/key mask. */
int button;                             /* Button event detail. */
int x, y;                               /* Event mouse position. */
X{
X    XButtonEvent button_event;
X
X    Entry("Restart")
X
X    XFreeFont(dpy, IFontInfo);
X    XFreeFont(dpy, PFontInfo);
X    XBell(dpy, VOLUME_PERCENTAGE(Volume));
X    XBell(dpy, VOLUME_PERCENTAGE(Volume));
X    XFlush(dpy);
X    Cleanup();
X    execvp(*Argv, Argv, Environ);
X    fprintf(stderr, "awm: Restart failed!\n");
X    exit(1);
X}
X
Boolean Quit(window, mask, button, x, y)
Window window;                          /* Event window. */
int mask;                               /* Button/key mask. */
int button;                             /* Button event detail. */
int x, y;                               /* Event mouse position. */
X{
X     Entry("Quit")
X
X     Cleanup();
X     exit(0);
X}
X
Boolean DestroyClient(window, mask, button, x, y)
Window window;
int mask;
int x, y;
X{
X     AwmInfoPtr awi;
X
X     Entry("DestroyClient")
X
X     if (window == RootWindow(dpy, scr))
X		Leave(FALSE)
X     awi = GetAwmInfo(window);
X     /*
X      * If it's a titled window or an icon (we don't want to nuke ourselves)
X      * we should get the client for it. We assume the subsequent destroy
X      * notify will tell us to reclaim our resources.
X      */
X     window = awi->client;
X     XKillClient(dpy, window);
X     Leave(TRUE)
X}
X
X/*
X * Put any necessary cleanup code here, it will be invoked when awm exits
X * or restarts. Currently just checks for title bar resources.
X */
Cleanup()
X{
X     Window junk, *windows;
X     int nwins;
X     AwmInfoPtr awi;
X
X     Entry("Cleanup");
X
X     if (XQueryTree(dpy, DefaultRootWindow(dpy), &junk, &junk, &windows, &nwins)
X	 != BadWindow) {
X	  unsigned int i;
X	  
X	  for (i = 0; i < nwins; i++) {
X	       awi = GetAwmInfo(windows[i]);
X	       if (!awi)
X		    continue;
X	       if (awi->state == ICON)
X		    XMapWindow(dpy, awi->client);
X	       RemoveIcon(windows[i]);
X	       DestroyTitle(windows[i]);
X	       XDeleteContext(dpy, awi->client, AwmContext);
X	       free(awi);
X	  }
X	  XFree(windows);
X     }
X     Leave_void
X}
END_OF_FILE
if test 3743 -ne `wc -c <'Restart.c'`; then
    echo shar: \"'Restart.c'\" unpacked with wrong size!
fi
# end of 'Restart.c'
fi
if test -f 'StoreBox.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'StoreBox.c'\"
else
echo shar: Extracting \"'StoreBox.c'\" \(4500 characters\)
sed "s/^X//" >'StoreBox.c' <<'END_OF_FILE'
X#ifndef lint
X     static char *rcsid_StoreBox_c = "$Header: StoreBox.c,v 1.3 87/09/11 08:21:43 toddb Exp $";
X#endif	lint
X
X#include "X11/copyright.h"
X
X/*
X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
X *
X *                         All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of Digital Equipment
X * Corporation not be used in advertising or publicity pertaining to
X * distribution of the software without specific, written prior permission.
X *
X *
X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
X * SOFTWARE.
X */
X
X
X
X/*
X * MODIFICATION HISTORY
X *
X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
X Western Software Lab. Convert to X11.
X */
X
X#ifndef lint
static char *sccsid = "@(#)StoreBox.c	3.8	1/24/86";
X#endif
X/*
X *	StoreBox - This subroutine is used by the X Window Manager (xwm)
X *	to store the vertices for the resize / movement box in a vertex list.
X */
X
X#include "awm.h"
X
extern int Fheight;
X
X/*
X * Store the vertices for the resize movement box (on a titled window)
X * in a vertex list.
X */
int StoreTitleBox(box, ulx, uly, lrx, lry)
register XSegment box[];
int ulx;			/* Upper left X coordinate. */
int uly;			/* Upper left Y coordinate. */
int lrx;			/* Lower right X coordinate. */
int lry;			/* Lower right Y coordinate. */
X{
X     Entry("StoreTitleBox");
X     
X     /*
X      * Xor in.
X      */
X     
X     box[0].x1 = ulx; box[0].y1 = uly;
X     box[0].x2 = lrx; box[0].y2 = uly;
X
X     box[1].x1 = ulx; box[1].y1 = uly + Fheight + 2;
X     box[1].x2 = lrx; box[1].y2 = uly + Fheight + 2;
X     
X     box[2].x1 = lrx; box[2].y1 = uly;
X     box[2].x2 = lrx; box[2].y2 = lry;
X     
X     box[3].x1 = lrx; box[3].y1 = lry;
X     box[3].x2 = ulx; box[3].y2 = lry;
X     
X     box[4].x1 = ulx; box[4].y1 = lry;
X     box[4].x2 = ulx; box[4].y2 = uly;
X
X     
X     /*
X      * If we freeze the screen, don't bother to xor out.
X      */
X     if (Freeze)
X	  Leave(5)
X     
X     /*
X      * Xor out.
X      */
X     box[4].x1 = ulx; box[4].y1 = uly;
X     box[4].x2 = lrx; box[4].y2 = uly;
X     
X     box[5].x1 = ulx; box[5].y1 = uly + Fheight + 2;
X     box[5].x2 = lrx; box[5].y2 = uly + Fheight + 2;
X     
X     box[6].x1 = lrx; box[6].y1 = uly;
X     box[6].x2 = lrx; box[6].y2 = lry;
X     
X     box[7].x1 = lrx; box[7].y1 = lry;
X     box[7].x2 = ulx; box[7].y2 = lry;
X     
X     box[8].x1 = ulx; box[8].y1 = lry;
X     box[8].x2 = ulx; box[8].y2 = uly;
X     
X     
X     /*
X      * Total number of vertices is 9.
X      */
X     Leave(9)
X}
X
X/*
X * Store the vertices for the resize movement box in a vertex list.
X */
int StoreBox(box, ulx, uly, lrx, lry)
register XSegment box[];
int ulx;			/* Upper left X coordinate. */
int uly;			/* Upper left Y coordinate. */
int lrx;			/* Lower right X coordinate. */
int lry;			/* Lower right Y coordinate. */
X{
X     Entry("StoreBox");
X     
X     /*
X      * Xor in.
X      */
X     
X     box[0].x1 = ulx; box[0].y1 = uly;
X     box[0].x2 = lrx; box[0].y2 = uly;
X     
X     box[1].x1 = lrx; box[1].y1 = uly;
X     box[1].x2 = lrx; box[1].y2 = lry;
X     
X     box[2].x1 = lrx; box[2].y1 = lry;
X     box[2].x2 = ulx; box[2].y2 = lry;
X     
X     box[3].x1 = ulx; box[3].y1 = lry;
X     box[3].x2 = ulx; box[3].y2 = uly;
X     
X     
X     /*
X      * If we freeze the screen, don't bother to xor out.
X      */
X     if (Freeze)
X	  Leave(4)
X     
X     /*
X      * Xor out.
X      */
X     box[4].x1 = ulx; box[4].y1 = uly;
X     box[4].x2 = lrx; box[4].y2 = uly;
X     
X     box[5].x1 = lrx; box[5].y1 = uly;
X     box[5].x2 = lrx; box[5].y2 = lry;
X     
X     box[6].x1 = lrx; box[6].y1 = lry;
X     box[6].x2 = ulx; box[6].y2 = lry;
X     
X     box[7].x1 = ulx; box[7].y1 = lry;
X     box[7].x2 = ulx; box[7].y2 = uly;
X     
X     
X     /*
X      * Total number of vertices is 8.
X      */
X     Leave(8)
X}
END_OF_FILE
if test 4500 -ne `wc -c <'StoreBox.c'`; then
    echo shar: \"'StoreBox.c'\" unpacked with wrong size!
fi
# end of 'StoreBox.c'
fi
if test -f 'exp_path.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'exp_path.c'\"
else
echo shar: Extracting \"'exp_path.c'\" \(3256 characters\)
sed "s/^X//" >'exp_path.c' <<'END_OF_FILE'
X#include <pwd.h>
X#include <stdio.h>
X#include <fcntl.h>
X#include "awm.h"
X
X/*
X * exp_path.c
X *
X *
X * Copyright 1988 by Jordan Hubbard & Ardent Computer Corporation, Sunnyvale,
X * Ca.
X *
X *                         All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of Ardent Computer
X * Corporation or the author not be used in advertising or publicity
X * pertaining to distribution of the software without specific, written
X * prior permission.
X *
X * Written: April 21st, 1988
X * Author: Jordan K. Hubbard
X * Revision: 1.0
X *
X */
X
X/*
X * WARNING: This code is obtuse.
X * Modify at your Own Risk.
X */
char *expand_file(s)
register char *s;
X{
X     static char tmp[256], *cp;
X
X     Entry("expand_file")
X     
X     /* zero tmp */
X     tmp[0] = 0;
X     if (*s == '/')
X	  Leave(s)
X     if (*s == '~') {
X	  if (s[1] == '/') { /* It's $HOME */
X	       if (!(cp = (char *)getenv("HOME"))) {
X		    fprintf(stderr, "expand: Can't find $HOME!\n");
X		    Leave(0)
X	       }
X	       strcpy(tmp, cp);
X	       strcat(tmp, s + 1);
X	       Leave(tmp)
X	  }
X	  else { /* it's another user */
X	       struct passwd *pwd;
X	       char uname[32];
X	       int i;
X	       
X	       for (i = 1; s[i] != '/'; i++)
X		    uname[i - 1] = s[i];
X	       uname[i] = '\0';
X	       pwd = getpwnam(uname);
X	       if (!pwd) {
X		    fprintf(stderr, "expand: user '%s' not found.\n", uname);
X		    Leave(0)
X	       }
X	       strcpy(tmp, pwd->pw_dir);
X	       strcat(tmp, s + i);
X	       Leave(tmp)
X	  }
X     }
X     else
X	  Leave(s)
X}
X
char *deblank(s)
register char *s;
X{
X     Entry("deblank")
X
X     if (!s)
X	  Leave(s)
X     while (*s && (*s == ' ' || *s == '\t'))
X	  s++;
X     Leave(s)
X}
X
char *expand_from_path(s)
register char *s;
X{
X     char tmp[256], *tm;
X     int i, plen;
X
X     Entry("expand_from_path")
X
X     tmp[0] = '\0';
X     s = deblank(s);
X     if (!s || !*s)
X	  Leave(0)
X     s = expand_file(s);
X     if (!s)
X	  Leave(0)
X     if (!access(s, R_OK))
X	  Leave(s)
X     /*
X      * If it starts with a slash, we know it either expanded and couldn't
X      * be found, or that it started with a slash in the first place and
X      * just plain couldn't be found.
X      */
X     if (*s == '/')
X	  Leave(0)
X     /*
X      * At this stage we haven't found the file by name, so it's time to
X      * search the path.
X      */
X     if (!awmPath || !*awmPath)
X	  Leave(0)
X     plen = strlen(awmPath);
X     i = 0;
X     while (1) {
X	  int p, l;
X	  
X	  tmp[0] = '\0';
X	  while (i < plen && awmPath[i] == ' ' || awmPath[i] == '\t')
X	       i++;
X	  for (p = i; p < plen && awmPath[p] != ' ' && awmPath[p] != '\t'; p++)
X	       tmp[p - i] = awmPath[p];
X	  if (!*tmp)
X	       Leave(0)
X	  tmp[p - i] = '\0';
X	  i = p;
X	  tm = expand_file(tmp);
X	  if (!tm || !*tm)
X	       continue;
X	  l = strlen(tm);
X	  if (l < 1)
X	       continue;
X	  if (tm[l - 1] != '/') { /* append / if necessary */
X	       tm[l] = '/';
X	       tm[++l] = '\0';
X	  }
X	  strcat(tm, s);
X	  if (!access(tm, R_OK))
X	       Leave(tm)
X     }
X}
END_OF_FILE
if test 3256 -ne `wc -c <'exp_path.c'`; then
    echo shar: \"'exp_path.c'\" unpacked with wrong size!
fi
# end of 'exp_path.c'
fi
if test -f 'menu_sup.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'menu_sup.c'\"
else
echo shar: Extracting \"'menu_sup.c'\" \(6030 characters\)
sed "s/^X//" >'menu_sup.c' <<'END_OF_FILE'
X/*
X * menu_support.c
X *
X *
X * Copyright 1988 by Jordan Hubbard & Ardent Computer Corporation, Sunnyvale,
X * Ca.
X *
X *                         All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of Ardent Computer
X * Corporation or the author not be used in advertising or publicity
X * pertaining to distribution of the software without specific, written
X * prior permission.
X *
X * Written: February 17, 1988.
X * Author: Jordan K. Hubbard
X * Revision: 1.0
X *
X */
X
X#include "awm.h"
X#include <signal.h>
X
X/* interface functions for RTL menus */
X
do_nothing()	/* like it says... */
X{
X}
X
Boolean check_booleans(menu, item)
RTLMenu menu;
RTLMenuItem item;
X{
X     Boolean *foo;
X
X     Entry("check_booleans")
X
X     foo = (Boolean *)RTLMenu_Data(menu, item);
X     Leave(*foo)
X}
X
Boolean toggle_booleans(menu, item)
RTLMenu menu;
RTLMenuItem item;
X{
X     Boolean *foo;
X
X     Entry("togglet_booleans")
X
X     foo = (Boolean *)RTLMenu_Data(menu, item);
X     *foo = !(*foo);
X     Leave(*foo)
X}
X
int do_shell(menu, item, window)	/* Do a shell command */
RTLMenu menu;
RTLMenuItem item;
Window window;			/* not used */
X{
X     char *cmd;
X     int status, pid, w;
X     register int (*istat)(), (*qstat)();
X
X     Entry("do_shell")
X
X     cmd = (char *)RTLMenu_Data(menu, item);
X     if ((pid = vfork()) == 0) {
X	  signal(SIGINT, SIG_DFL);
X	  signal(SIGQUIT, SIG_DFL);
X	  signal(SIGHUP, SIG_DFL);
X	  execl("/bin/sh", "sh", "-c", cmd, 0);
X	  _exit(127);
X     }
X     istat = signal(SIGINT, SIG_IGN);
X     qstat = signal(SIGQUIT, SIG_IGN);
X     while ((w = wait(&status)) != pid && w != -1);
X     if (w == -1)
X	  status = -1;
X     signal(SIGINT, istat);
X     signal(SIGQUIT, qstat);
X     Leave(status)
X}
X
int do_text(menu, item, window)
RTLMenu menu;
RTLMenuItem item;
Window window;
X{
X     char *buff;
X
X     Entry("do_text")
X
X     buff = (char *)RTLMenu_Data(menu, item);
X     XStoreBytes(dpy, buff, strlen(buff));
X     Leave_void
X}
X
int do_text_nl(menu, item, window)
RTLMenu menu;
RTLMenuItem item;
Window window;
X{
X     char *buff1, *buff2;
X
X     Entry("do_text_nl")
X
X     buff1 = (char *)RTLMenu_Data(menu, item);
X     buff2 = (char *)malloc(strlen(buff1) + 2);
X     strcpy(buff2, buff1);
X     strcat(buff2, "\n");
X     XStoreBytes(dpy, buff2, strlen(buff2));
X     free(buff2);
X     Leave_void
X}
X
int do_awm_func(menu, item, window)
RTLMenu menu;
RTLMenuItem item;
Window window;
X{
X     int x, y, button;
X     Boolean (*func)();
X
X     Entry("do_awm_func")
X
X     XSync(dpy, FALSE);
X     if (window == RootWindow(dpy, scr))
X          window = Select_Window(&x, &y, &button);
X     func = (Boolean(*)())RTLMenu_Data(menu, item);
X     Leave((*func)(window, 0, button, x, y))
X}
X
int do_imm_func(menu, item, window)
RTLMenu menu;
RTLMenuItem item;
Window window;
X{
X     Boolean (*func)();
X
X     Entry("do_imm_func")
X
X     func = (Boolean(*)())RTLMenu_Data(menu, item);
X     Leave((*func)(RootWindow(dpy, scr), 0, 0, 0, 0))
X}
X
MenuInfo *FindMenu(s)
register char *s;
X{
X     MenuLink *ml;
X
X     Entry("FindMenu")
X
X     for (ml = Menus; ml; ml = ml->next)
X	  if (!strcmp(s, ml->menu->name))
X	       Leave(ml->menu)
X     Leave((MenuInfo *) 0)
X}
X
RTLMenu create_menu(m)
MenuInfo *m;
X{
X     ActionLine *ln;
X     RTLMenuItem tmp;
X     MenuInfo *side_menu;
X
X     Entry("create_menu")
X
X     if (!m)
X	  yyerror("Internal error, create_menu passed null pointer");
X     /*
X      * Were we already created? This is possible if we were referenced
X      * by somebody created before us.
X      */
X     if (m->menu)
X	  Leave(m->menu)
X     m->menu = RTLMenu_Create();
X     /* make a name (or picture) label for this menu */
X     tmp = RTLMenu_Append_Call(m->menu, m->name, m->pixmapname, do_nothing, 0);
X     RTLMenu_Label_Entry(m->menu, tmp);
X     ln = m->line;
X     if (!ln) {
X	  yyerror("Internal error in create_menu.");
X	  fprintf(stderr, "Menu '%s' has no line list.\n", m->name);
X	  exit(1);
X     }
X     if (!ln->name && !ln->pixmapname) {
X	  fprintf(stderr, "awm: Action in menu '%s' has no name or backing pixmap\n",
X		  m->name);
X	  yyerror(".. aborting\n");
X	  exit(1);
X     }
X     while (ln) {
X	  switch (ln->type) {
X	  case IsVar:
X	       ln->item = RTLMenu_Append_Checkback(m->menu, ln->name,
X						   ln->pixmapname,
X						   check_booleans,
X						   toggle_booleans,
X						   ln->text);
X	       break;
X	       
X	  case IsImmFunction:
X	       ln->item = RTLMenu_Append_Call(m->menu, ln->name,
X					      ln->pixmapname,
X					      do_imm_func, ln->func);
X	       break;
X
X	  case IsUwmFunction:
X	       ln->item = RTLMenu_Append_Call(m->menu, ln->name,
X					      ln->pixmapname,
X					      do_awm_func, ln->func);
X	       break;
X
X	  case IsMenuFunction:
X	       if (!(side_menu = FindMenu(ln->text))) {
X		    fprintf(stderr, "Unknown menu \"%s\" referenced in ",
X			ln->text);
X		    yyerror(" ..");
X		    exit(1);
X	       }
X	       /* If we haven't created the referenced menu yet, create it now */
X	       if (!side_menu->menu)
X		    side_menu->menu = create_menu(side_menu);
X	       ln->item = RTLMenu_Append_Submenu(m->menu, ln->name,
X						 ln->pixmapname,
X						 side_menu->menu);
X	       break;
X	       
X	  case IsText:
X	       ln->item = RTLMenu_Append_Call(m->menu, ln->name,
X					      ln->pixmapname,
X					      do_text, ln->text);
X	       break;
X
X	  case IsTextNL:
X	       ln->item = RTLMenu_Append_Call(m->menu, ln->name,
X					      ln->pixmapname,
X					      do_text_nl, ln->text);
X	       break;
X	       
X	  case IsShellCommand:
X	       ln->item = RTLMenu_Append_Call(m->menu, ln->name,
X					      ln->pixmapname,
X					      do_shell, ln->text);
X	       break;
X	       
X	  default:
X	       fprintf(stderr, "create_menu, Unknown menu entry type %d\n",
X		  ln->type);
X	       break;
X	  }
X	  free(ln);
X	  ln = ln->next;
X     }
X     Leave(m->menu)
X}
END_OF_FILE
if test 6030 -ne `wc -c <'menu_sup.c'`; then
    echo shar: \"'menu_sup.c'\" unpacked with wrong size!
fi
# end of 'menu_sup.c'
fi
echo shar: End of archive 2 \(of 8\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 8 archives.
    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