[comp.windows.x] awm kit, Part04

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 4 (of 8)."
# Contents:  Makefile.rtl RubberBand.c Titlebar.c globals.c
# Wrapped by jkh@ardent on Sun Jun  5 18:56:31 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile.rtl' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile.rtl'\"
else
echo shar: Extracting \"'Makefile.rtl'\" \(10660 characters\)
sed "s/^X//" >'Makefile.rtl' <<'END_OF_FILE'
X# makefile generated by mkold
X
XXDIR = /usr/src/X.V11R2
X
COM.00 = $(XDIR)/lib
DIR.00 = $(COM.00)/oldX
DIR.01 = $(COM.00)/X
X
NEATENOBJS =  \
X	check_can_mod.o check_grow.o check_shrink.o \
X	commit_op.o goal.o gravity.o mem.o state.o \
X	tilwin_close.o tilwin_create.o tilwin_desk.o \
X	tilwin_dump.o tilwin_init.o tilwin_list.o tilwin_misc.o \
X	tilwin_open.o tilwin_resat.o tilwin_resize.o \
X	tilwin_set.o tilwin_tmp.o tilwin_undo.o trial_grow.o \
X	trial_place.o trial_satisfy.o trial_slide.o \
X	tilwin_slide.o trial_edge_sweep.o win.o tilwin_thread.o \
X	init_tws.o pieces_enum.o pieces_merge.o pieces_split.o \
X	pieces_update.o tile_create.o tile_delete.o \
X	tile_enlarge.o tile_find.o tile_nbrs.o tile_panic.o \
X	tile_shrink.o tileopts.o userglobals.o neaten.o
X
neaten.a: $(NEATENOBJS)
X	ar qcv neaten.a $(NEATENOBJS)
X	ranlib neaten.a
X
check_can_mod.o : check_can_mod.c tilwin.extern.h state.extern.h \
X		state.h tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
X		std_defs.h tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c check_can_mod.c
X
check_grow.o : check_grow.c win.extern.h tile.extern.h tile.h \
X		basetype.h std_defs.h state.extern.h state.h \
X		tilwin.intern.h tilwin.h tilwinopts.h tilwin.extern.h \
X		tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c check_grow.c
X
check_shrink.o : check_shrink.c goal.extern.h tilwin.extern.h \
X		state.extern.h state.h tilwin.intern.h tilwin.h \
X		tilwinopts.h basetype.h std_defs.h tilwin.define.h \
X		tileopts.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c check_shrink.c
X
commit_op.o : commit_op.c win.extern.h tile.extern.h tile.h basetype.h \
X		std_defs.h state.extern.h state.h tilwin.intern.h \
X		tilwin.h tilwinopts.h tilwin.define.h tileopts.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c commit_op.c
X
goal.o : goal.c tilwin.define.h tileopts.h tilwin.intern.h tilwin.h \
X		tilwinopts.h basetype.h std_defs.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c goal.c
X
gravity.o : gravity.c tilwin.extern.h state.extern.h state.h \
X		tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
X		std_defs.h tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c gravity.c
X
mem.o : mem.c tile.h basetype.h std_defs.h tilwin.intern.h tilwin.h \
X		tilwinopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c mem.c
X
state.o : state.c tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
X		std_defs.h state.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c state.c
X
tilwin_close.o : tilwin_close.c state.extern.h state.h tilwin.intern.h \
X		tilwin.h tilwinopts.h basetype.h std_defs.h win.extern.h \
X		tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_close.c
X
tilwin_create.o : tilwin_create.c mem.extern.h state.extern.h state.h \
X		tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
X		std_defs.h tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_create.c
X
tilwin_desk.o : tilwin_desk.c gravity.extern.h basetype.h std_defs.h \
X		tile.extern.h tile.h tilwin.extern.h state.extern.h \
X		state.h tilwin.intern.h tilwin.h tilwinopts.h \
X		copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_desk.c
X
tilwin_dump.o : tilwin_dump.c win.extern.h tilwin.extern.h \
X		state.extern.h state.h tilwin.intern.h tilwin.h \
X		tilwinopts.h basetype.h std_defs.h tilwin.define.h \
X		tileopts.h tile.extern.h tile.h tile.define.h \
X		tile.intern.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_dump.c
X
tilwin_init.o : tilwin_init.c tile.intern.h tile.h basetype.h \
X		std_defs.h tilwin.intern.h tilwin.h tilwinopts.h \
X		copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_init.c
X
tilwin_list.o : tilwin_list.c state.extern.h state.h tilwin.intern.h \
X		tilwin.h tilwinopts.h basetype.h std_defs.h \
X		tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_list.c
X
tilwin_misc.o : tilwin_misc.c win.extern.h tile.extern.h tile.h \
X		basetype.h std_defs.h tile.define.h tile.intern.h \
X		state.extern.h state.h tilwin.intern.h tilwin.h \
X		tilwinopts.h tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_misc.c
X
tilwin_open.o : tilwin_open.c win.extern.h gravity.extern.h basetype.h \
X		std_defs.h commit.extern.h trial.extern.h trial.h \
X		state.extern.h state.h tilwin.intern.h tilwin.h \
X		tilwinopts.h tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_open.c
X
tilwin_resat.o : tilwin_resat.c win.extern.h commit.extern.h \
X		trial.extern.h trial.h state.extern.h state.h \
X		tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
X		std_defs.h tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_resat.c
X
tilwin_resize.o : tilwin_resize.c gravity.extern.h basetype.h \
X		std_defs.h win.extern.h commit.extern.h trial.extern.h \
X		trial.h state.extern.h state.h tilwin.intern.h tilwin.h \
X		tilwinopts.h tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_resize.c
X
tilwin_set.o : tilwin_set.c trial.extern.h trial.h state.extern.h \
X		state.h tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
X		std_defs.h tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_set.c
X
tilwin_tmp.o : tilwin_tmp.c trial.h state.extern.h state.h \
X		tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
X		std_defs.h trial.extern.h tilwin.define.h tileopts.h \
X		copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_tmp.c
X
tilwin_undo.o : tilwin_undo.c win.extern.h state.extern.h state.h \
X		tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
X		std_defs.h tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_undo.c
X
trial_grow.o : trial_grow.c check.extern.h gravity.extern.h basetype.h \
X		std_defs.h tilwin.extern.h state.extern.h state.h \
X		tilwin.intern.h tilwin.h tilwinopts.h tilwin.define.h \
X		tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_grow.c
X
trial_place.o : trial_place.c check.extern.h gravity.extern.h \
X		basetype.h std_defs.h tilwin.extern.h state.extern.h \
X		state.h tilwin.intern.h tilwin.h tilwinopts.h \
X		tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_place.c
X
trial_satisfy.o : trial_satisfy.c check.extern.h gravity.extern.h \
X		basetype.h std_defs.h tilwin.extern.h state.extern.h \
X		state.h tilwin.intern.h tilwin.h tilwinopts.h \
X		tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_satisfy.c
X
trial_slide.o : trial_slide.c trial.extern.h trial.h tilwin.extern.h \
X		state.extern.h state.h tilwin.intern.h tilwin.h \
X		tilwinopts.h basetype.h std_defs.h tilwin.define.h \
X		tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_slide.c
X
tilwin_slide.o : tilwin_slide.c trial.extern.h trial.h tilwin.extern.h \
X		state.extern.h state.h tilwin.intern.h tilwin.h \
X		tilwinopts.h basetype.h std_defs.h tilwin.define.h \
X		tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_slide.c
X
trial_edge_sweep.o : trial_edge_sweep.c tilwin.extern.h state.extern.h \
X		state.h tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
X		std_defs.h tile.extern.h tile.h tile.define.h \
X		tile.intern.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_edge_sweep.c
X
win.o : win.c gravity.extern.h basetype.h std_defs.h state.extern.h \
X		state.h tilwin.intern.h tilwin.h tilwinopts.h \
X		tile.define.h tile.intern.h tile.h tile.extern.h \
X		tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c win.c
X
tilwin_thread.o : tilwin_thread.c state.extern.h state.h \
X		tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
X		std_defs.h tilwin.define.h tileopts.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_thread.c
X
init_tws.o : init_tws.c tile-list.h tile.define.h tile.intern.h tile.h \
X		basetype.h std_defs.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c init_tws.c
X
pieces_enum.o : pieces_enum.c tile.extern.h tile.h basetype.h \
X		std_defs.h tile-list.h tile.define.h tile.intern.h \
X		copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c pieces_enum.c
X
pieces_merge.o : pieces_merge.c tile-list.h tile.define.h tile.intern.h \
X		tile.h basetype.h std_defs.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c pieces_merge.c
X
pieces_split.o : pieces_split.c tile.extern.h tile.h basetype.h \
X		std_defs.h tile-list.h tile.define.h tile.intern.h \
X		copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c pieces_split.c
X
pieces_update.o : pieces_update.c tile-list.h tile.define.h \
X		tile.intern.h tile.h basetype.h std_defs.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c pieces_update.c
X
tile_create.o : tile_create.c tile.extern.h tile.h basetype.h \
X		std_defs.h tile.define.h tile.intern.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_create.c
X
tile_delete.o : tile_delete.c tile.extern.h tile.h basetype.h \
X		std_defs.h tile-list.h tile.define.h tile.intern.h \
X		copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_delete.c
X
tile_enlarge.o : tile_enlarge.c tile.extern.h tile.h basetype.h \
X		std_defs.h tile.define.h tile.intern.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_enlarge.c
X
tile_find.o : tile_find.c tilwin.extern.h state.extern.h state.h \
X		tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
X		std_defs.h tile.define.h tile.intern.h tile.h \
X		copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_find.c
X
tile_nbrs.o : tile_nbrs.c tile-list.h tile.extern.h tile.h basetype.h \
X		std_defs.h tile.define.h tile.intern.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_nbrs.c
X
tile_panic.o : tile_panic.c copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_panic.c
X
tile_shrink.o : tile_shrink.c tile.define.h tile.intern.h tile.h \
X		basetype.h std_defs.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_shrink.c
X
tileopts.o : tileopts.c tileopts.h basetype.h std_defs.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tileopts.c
X
userglobals.o : userglobals.c explicitopts.h uservals.h useropts.h \
X		basetype.h std_defs.h copyright.h
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c userglobals.c
X
neaten.o : neaten.c neaten.define.h tilwin.define.h tileopts.h \
X		tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
X		std_defs.h userwin.define.h tilwin.extern.h \
X		state.extern.h state.h userglobals.define.h userwin.h \
X		explicitwinopts.h userwinopts.h 
X	 $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c neaten.c
END_OF_FILE
if test 10660 -ne `wc -c <'Makefile.rtl'`; then
    echo shar: \"'Makefile.rtl'\" unpacked with wrong size!
fi
# end of 'Makefile.rtl'
fi
if test -f 'RubberBand.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'RubberBand.c'\"
else
echo shar: Extracting \"'RubberBand.c'\" \(11218 characters\)
sed "s/^X//" >'RubberBand.c' <<'END_OF_FILE'
X/* $Header: RubberBand.c,v 1.20 87/09/02 15:28:22 swick Exp $ */
X/* derived from XCreateTerm.c */
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 * MODIFICATION HISTORY
X *
X * 000 -- Loretta Guarino Reid, DEC Ultrix Engineering Group
X * 001 -- Ralph R. Swick, DEC/MIT Project Athena
X *	  tailor to uwm; use global resources created by uwm
X */
X
X#include "awm.h"
X#include "X11/Xutil.h"
X#include "X11/cursorfont.h"
X
X#define max(a,b) ( (a) > (b) ? (a) : (b) )
X#define min(a,b) ( (a) > (b) ? (b) : (a) )
X#define abs(a) ( (a) > 0 ? (a) : -(a))
X#define makemult(a, b) ((b==1) ? (a) : (((int)((a) / (b))) * (b)) )
X
X#define DCOUNT 2
X#define PCOUNT 1 + (4 * 2 * DCOUNT)
X
X#define BW	PBorderWidth		/* pop-up window border width */
X#define IBW	PPadding		/* internal border width for pop-up */
X
AskUser(dpy, scr, window, x, y, width, height, hints)
Display *dpy;
int scr;
Window window;
int *x, *y, *width, *height;
XXSizeHints *hints;
X{
X     Cursor ur, ul, ll, lr;          /* cursors for rubber banding    */
X     int change_cursor = FALSE;
X     int current_cursor;
X     char *text;			/* text for prompt string       */
X     int nz;                         /* count where zeros are        */
X     int popw, poph;                 /* width and height of prompt window*/
X#define invertGC DrawGC
X     int x1, y1;                     /* location of mouse            */
X     int x2, y2;                     /* other corner of box          */
X     int rootx, rooty, mask;         /* for XQueryPointer          */
X     Window root, subw;		/* for XQueryPointer */
X     int xa = -1, ya = -1, xb = -1, yb = -1;
X     int xinc, yinc;
X     int minwidth, minheight;
X     int maxwidth, maxheight;
X     int defwidth, defheight;
X     int chosen = -1;
X     int stop = FALSE;
X     int changed = TRUE;
X     int doit = FALSE;
X     int dx, dy;
X     int delta;
X     XPoint box[PCOUNT];
X     int hsize, vsize;
X     int zero = '0';                 /* zero offset for char conversion  */
X     XEvent e;                 /* someplace to put the event   */
X     int events;                     /* what events we want.             */
X     Window pop;                     /* pop up prompt window         */
X     int i;
X     char *name;
X     int width_offset, height_offset; /* to subtract if resize increments */
X     
X     Entry("AskUser")
X     
X     if ((hints->flags & USPosition) && (hints->flags & USSize)) {
X	  *x = hints->x;
X	  *y = hints->y;
X	  *width = hints->width;
X	  *height = hints->height;
X	  Leave_void
X     }
X     if (!XFetchName(dpy, window, &name)) 
X	  name = "Unnamed Window";
X     
X     ur = XCreateFontCursor(dpy, XC_ur_angle);
X     ul = XCreateFontCursor(dpy, XC_ul_angle);
X     ll = XCreateFontCursor(dpy, XC_ll_angle);
X     lr = XCreateFontCursor(dpy, XC_lr_angle);
X     current_cursor = ul;
X     
X     events = ButtonPressMask | ButtonReleaseMask;
X     
X     /* 
X      * go get the mouse as soon as you can 
X      */
X     
X     while (1) {
X	  int res;
X	  if ((res = XGrabPointer (dpy, RootWindow(dpy, scr), FALSE, events, 
X				   GrabModeAsync, GrabModeAsync, None, ul,
X				   CurrentTime )) == GrabSuccess)
X	       break;
X	  sleep (1);
X     }
X     nz = strlen(name);		/* compute number of characters */
X     text = (char *)malloc( nz + 11 );
X     (void) strcpy(text, name);
X     (void) strcat(text, ": 000x000");
X     nz += 9;
X     popw = XTextWidth (PFontInfo, text, nz) + 2 * IBW;
X     poph = PFontInfo->ascent+PFontInfo->descent + 2 * IBW;
X     
X     pop = XCreateSimpleWindow(dpy, RootWindow(dpy, scr), 
X			       0, 0, popw, poph, BW, PBorder, PBackground);
X     XMapWindow (dpy, pop);
X     
X     if (hints->flags & PMinSize) {
X	  minwidth = hints->min_width;
X	  minheight = hints->min_height;
X     } else {
X	  minwidth = 0;
X	  minheight = 0;
X     }
X     if (hints->flags & PMaxSize) {
X	  maxwidth = max(hints->max_width, minwidth);
X	  maxheight = max(hints->max_height, minheight);
X     } else {
X	  maxwidth = DisplayWidth(dpy, scr);
X	  maxheight = DisplayHeight(dpy, scr);
X     }
X     if (hints->flags & PResizeInc) {
X	  xinc = hints->width_inc;
X	  yinc = hints->height_inc;
X     } else {
X	  xinc = 1;
X	  yinc = 1;
X     }
X     if (hints->flags & PSize || hints->flags & USSize) {
X	  defwidth = hints->width;
X	  defheight = hints->height;
X     } else if (hints->flags&PMinSize) {
X	  defwidth = hints->min_width;
X	  defheight = hints->min_height;
X     } else if (hints->flags&PMaxSize) {
X	  defwidth = hints->max_width;
X	  defheight = hints->max_height;
X     } else {
X	  long dummy;
X	  XGetGeometry(dpy, window, &dummy, &dummy, &dummy,
X		       &defwidth, &defheight, &dummy, &dummy);
X     }
X     
X     /* until there are better WM_HINTS, we'll assume that the client's
X      * minimum width and height are the appropriate offsets to subtract
X      * when resizing with an explicit resize increment.
X      */
X     if (hints->flags & PMinSize && hints->flags & PResizeInc) {
X	  width_offset = hints->min_width;
X	  height_offset = hints->min_height;
X     } else
X	  width_offset = height_offset = 0;
X     
X     
X     XQueryPointer (dpy, RootWindow(dpy, scr), &root, &subw, 
X		    &rootx, &rooty, &x1, &y1, &mask);
X     hsize = minwidth; 
X     vsize = minheight;
X     x2 = x1+hsize; 
X     y2 = y1+vsize;
X     
X     while (stop == FALSE) {
X	  if ( (xb != max (x1, x2)) || (yb != max (y1, y2))
X	      ||(xa != min (x1, x2)) || (ya != min (y1, y2)) ) {
X	       xa = min (x1, x2);
X	       ya = min (y1, y2);
X	       xb = max (x1, x2);
X	       yb = max (y1, y2);
X	       for ( i = 0; i < PCOUNT; i += 4) {
X                    box[i].x = xa; box[i].y = ya;
X                    if (i+1 == PCOUNT) break;
X                    box[i+1].x = xb; box[i+1].y = ya;
X                    box[i+2].x = xb; box[i+2].y = yb;
X                    box[i+3].x = xa; box[i+3].y = yb;
X	       }
X	       doit = TRUE;
X	  }
X	  if (changed) {
X	       int Hsize = (hsize - width_offset) / xinc;
X	       int Vsize = (vsize - height_offset) / yinc;
X	       int pos = 3;
X	       
X	       changed = FALSE;
X	       text[nz - 7] = (Hsize>99) ? (Hsize / 100 + zero)	: ' ';
X	       text[nz - 6] = (Hsize>9)  ? ((Hsize / 10) % 10 + zero)  : ' ';
X	       text[nz - 5] = Hsize % 10 + zero;
X	       if (Vsize>99) text[nz - pos--] = Vsize / 100 + zero;
X	       if (Vsize>9)  text[nz - pos--] = (Vsize / 10) % 10 + zero;
X	       text[nz - pos--]     = Vsize % 10 + zero;
X	       while (pos>0) text[nz - pos--] = ' ';
X	       XDrawImageString(dpy, pop, PopGC, IBW, IBW+PFontInfo->ascent,
X				text, nz);
X	  }
X	  if (doit) {
X	       XDrawLines(dpy, RootWindow(dpy, scr), invertGC, box, PCOUNT, 
X			  CoordModeOrigin);
X	  }
X	  if (XPending(dpy) &&
X	      XCheckMaskEvent(dpy, ButtonPressMask|ButtonReleaseMask, &e)) {
X	       if ((chosen < 0) && (e.type == ButtonPress)) {
X		    x1 = x2 = ((XButtonEvent *)&e)->x;
X		    y1 = y2 = ((XButtonEvent *)&e)->y;
X		    chosen = ((XButtonEvent *)&e)->button;
X		    if (chosen == Button2)
X			 change_cursor = TRUE;
X	       }
X	       else if ((e.type == ButtonRelease) &&
X                        ((((XButtonEvent *)&e)->button) == chosen)) {
X		    x2 = ((XButtonEvent *)&e)->x;
X		    y2 = ((XButtonEvent *)&e)->y;
X		    stop = TRUE;
X	       }
X	       else
X		    XQueryPointer (dpy, RootWindow(dpy, scr), &root, 
X				   &subw, &rootx, &rooty, &x2, &y2, &mask);
X	  }
X	  else        XQueryPointer (dpy, RootWindow(dpy, scr), &root, 
X				     &subw, &rootx, &rooty, &x2, &y2, &mask);
X	  if (change_cursor) {
X	       if ((x2 >= x1) && (y2 >= y1) &&
X		   current_cursor != lr) {
X                    XChangeActivePointerGrab (dpy, events, lr, CurrentTime );
X                    current_cursor = lr;
X               }
X	       else if ((x2 >= x1) && (y2 < y1) &&
X			current_cursor != ur) {
X                    XChangeActivePointerGrab (dpy, events, ur, CurrentTime );
X                    current_cursor = ur;
X	       }
X	       else if ((x2 < x1) && (y2 >= y1) &&
X			current_cursor != ll) {
X                    XChangeActivePointerGrab (dpy, events, ll, CurrentTime );
X                    current_cursor = ll;
X	       }
X	       else if ((x2 < x1) && (y2 < y1) &&
X			(current_cursor != ul)) {
X                    XChangeActivePointerGrab (dpy, events, ul, CurrentTime );
X                    current_cursor = ul;
X	       }
X	  }
X	  if (chosen != Button2) {
X	       x1 = x2;
X	       y1 = y2;
X	       if (chosen >= 0) {
X		    x2 = defwidth;
X		    if (chosen == Button1)
X			 y2 = defheight;
X		    else
X			 y2 = (DisplayHeight(dpy, scr) - y1);
X		    x2 = x1 + x2;
X		    y2 = y1 + y2;
X	       }
X	  }
X	  
X	  dx = max(min(abs (x2 - x1), maxwidth), minwidth);
X	  dx = makemult(dx-minwidth, xinc)+minwidth; 
X	  dy = max(min(abs(y2 - y1), maxheight), minheight);
X	  dy = makemult(dy-minheight, yinc)+minheight; 
X	  
X	  if (hints->flags & PAspect) {
X	       if ((dx * hints->max_aspect.y > dy * hints->max_aspect.x)) {
X		    delta = makemult((dx * hints->max_aspect.y /
X				      hints->max_aspect.x) - dy, yinc); 
X		    if ((dy + delta) <= maxheight)
X			 dy += delta;
X		    else {
X			 delta = makemult(dx - hints->max_aspect.x
X					  * dy/hints->max_aspect.y, xinc);
X			 if ((dx - delta) >= minwidth)
X			      dx -= delta;
X		    }
X	       }
X	       if (dx * hints->min_aspect.y < dy * hints->min_aspect.x) {
X		    delta = makemult((hints->min_aspect.x *
X				      dy/hints->min_aspect.y) - dx, xinc);
X		    if (dx + delta <= maxwidth)
X			 dx += delta;
X		    else {
X			 delta = makemult(dy - (dx * hints->min_aspect.y /
X						hints->min_aspect.x), yinc); 
X			 if ((dy - delta) >= minheight)
X			      dy -= delta; 
X		    }
X	       }
X	       
X	  }
X	  
X	  if (dx != hsize) {
X	       hsize = dx;
X	       changed = TRUE;
X	  }
X	  if (dy != vsize) {
X	       vsize = dy;
X	       changed = TRUE;
X	  }
X	  if (x2 < x1)
X	       x2 = x1 - dx;
X	  else
X	       x2 = x1 + dx;
X	  
X	  if (y2 < y1)
X	       y2 = y1 - dy;
X	  else
X	       y2 = y1 + dy;
X     }
X     XUngrabPointer(dpy, CurrentTime);
X     
X     XDestroyWindow (dpy, pop);
X     XFreeCursor (dpy, ur);
X     XFreeCursor (dpy, ul);
X     XFreeCursor (dpy, lr);
X     XFreeCursor (dpy, ll);
X     free(name);
X     free(text);
X     *x = min(x1, x2);
X     *y = min(y1, y2);
X     *width = hsize;
X     *height = vsize;
X     XSync(dpy, FALSE);
X     Leave_void
X}
END_OF_FILE
if test 11218 -ne `wc -c <'RubberBand.c'`; then
    echo shar: \"'RubberBand.c'\" unpacked with wrong size!
fi
# end of 'RubberBand.c'
fi
if test -f 'Titlebar.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Titlebar.c'\"
else
echo shar: Extracting \"'Titlebar.c'\" \(12143 characters\)
sed "s/^X//" >'Titlebar.c' <<'END_OF_FILE'
X#ifndef lint
static char *rcsid_TitleBar_c = "$Header: TitleBar.c,v 1.0 87/12/02 03:26:00 jkh Exp $";
X#endif	lint
X
X/*
X * MODIFICATION HISTORY
X *
X * 002 -- Jordan Hubbard, U.C. Berkeley.
X Title bar support routines.
X */
X
X#include "awm.h"
X#include "X11/Xutil.h"
X
int Pad;
int Fheight;
static Boolean init_done = False;
Cursor TitleCursor, FrameCursor;
int TB_wide, TB_high, TBB_wide, TBB_high, BC_wide, BC_high;
int BCB_wide, BCB_high;
X
extern XContext AwmContext;
X
X#define BLANK_WIDE	16
X#define BLANK_HIGH	16
static char blank_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
X
void Init_Titles()
X{
X     int t_wide, t_high, junk;
X     register char *cp;
X     
X     Entry("Init_Titles")
X
X     TFontInfo = GetFontRes("title.font", DEF_TITLE_FONT);
X     TFontBoldInfo = GetFontRes("title.boldFont", NULL);
X     TBackPixmapData = GetPixmapDataRes("title.pixmap", &TB_wide, &TB_high);
X     TBoldPixmapData = GetPixmapDataRes("title.boldPixmap", &TBB_wide,
X					&TBB_high);
X     BBackPixmapData = GetPixmapDataRes("BC.pixmap", &BC_wide, &BC_high);
X     BBoldPixmapData = GetPixmapDataRes("BC.boldPixmap", &BCB_wide, &BCB_high);
X     TForeground = GetColorRes("title.foreground", ForeColor);
X     TBackground = GetColorRes("title.background", BackColor);
X     TTextForeground = GetColorRes("title.text.foreground", TForeground);
X     TTextBackground = GetColorRes("title.text.background", TBackground);
X     Pad = GetIntRes("title.pad", 2);
X     Fheight = TFontInfo->max_bounds.ascent +
X	  TFontInfo->max_bounds.descent + (Pad * 2);
X     /* we've specified a bold pixmap, but no back pixmap. Use blank. */
X     if (TBoldPixmapData && !TBackPixmapData) {
X	  TBackPixmapData = blank_bits;
X	  TB_wide = BLANK_WIDE;
X	  TB_high = BLANK_HIGH;
X     }
X     /* we've specified a bold BC pixmap, but no back pixmap. Use blank. */
X     if (BBoldPixmapData && !BBackPixmapData) {
X	  BBackPixmapData = blank_bits;
X	  BC_wide = BLANK_WIDE;
X	  BC_high = BLANK_HIGH;
X     }
X     if (TFontBoldInfo) {
X	  int foo;
X	  
X	  foo = TFontBoldInfo->max_bounds.ascent +
X	       TFontBoldInfo->max_bounds.descent + (Pad * 2);
X	  if (foo > Fheight)
X	       Fheight = foo;
X     }
X     TitleCursor = XCreateFontCursor(dpy, TCursor);
X     if (BContext) {
X          FrameCursor = XCreateFontCursor(dpy, BCursor);
X          if (!FrameCursor)
X               Error("Init_Titles: Can't get border cursor #%d!\n", BCursor);
X     }
X     if (!TitleCursor)
X	  Error("Init_Titles: Can't get title cursor #%d!\n", TCursor);
X     init_done = True;
X     Leave_void
X}
X
char *GetTitleName(w)
Window w;
X{
X     char *cp = 0, *tmp;
X     
X     Entry("GetTitleName")
X	  
X     if (!XFetchName(dpy, w, &cp) || !cp)
X	  cp = "Untitled Window";
X     tmp = (char *)malloc(strlen(cp) + 3);
X     
X     /*
X      * We add a space on both ends for asthetic effect
X      * (only apparent if we're using inverse video).
X      */
X     tmp[0] = ' ';
X     strcpy(tmp + 1, cp);
X     strcat(tmp, " ");
X     free(cp);
X     Leave(tmp)
X}
X
X/* Function for f.title */
Boolean FAddTitle(w, mask, button, x, y)
Window w;
int mask, button, x, y;
X{
X     Entry("FAddTitle")
X	  
X     if (w == RootWindow(dpy, scr))
X	  Leave(FALSE)
X     XMapWindow(dpy, AddTitle(w));
X     XSync(dpy, FALSE);
X     Leave(TRUE)
X}
X
Window AddTitle(w)
Window w;
X{
X     Window root;
X     int x, y, width, height, bw, depth, status, bch, bcv;
X     Window foster, title;
X     AwmInfoPtr awi;
X     char *icon_name, *cp = 0;
X     char *class_string = 0;
X     char *name = 0, *class;
X     XWMHints *wm_hints;
X     XSizeHints sz_hints;
X     XClassHint class_hints;
X     Binding *bptr;
X     unsigned long valuemask;
X     XWindowAttributes xwa;
X     XSetWindowAttributes swa;
X     XWindowChanges wc;
X     unsigned long form, len, after;
X     Atom a_type;
X
X     Entry("AddTitle")
X
X    /*
X     * First we see if this window even wants a title.
X     */
X     if (IsTitled(w))
X	  Leave((Window)NULL)
X     awi = GetAwmInfo(w);
X     status = XGetWindowProperty(dpy, w, XA_WM_CLASS, 0, 256, False,
X				 XA_STRING, &a_type, &form, &len, &after,
X				 &class_string);
X     if (status == Success && form == 8 && len && class_string && !after) {
X     	  class_string[len] = '\0';
X	  class = class_string;
X	  if (len > strlen(class_string))
X	       name = class_string + strlen(class_string) + 1;
X	  if (name) {
X	       if (cp = XGetDefault(dpy, name, "showTitle"))
X		    if (*cp == 'n' || *cp == 'N' || !strcmp(cp, "off") ||
X			!strcmp(cp, "Off"))
X			 Leave((Window)NULL)
X	  }
X	  if (cp = XGetDefault(dpy, class, "showTitle"))
X	       if (*cp == 'n' || *cp == 'N' || !strcmp(cp, "off") ||
X		   !strcmp(cp, "Off"))
X		    Leave((Window)NULL)
X     }
X     if (!awi) {
X	  fprintf(stderr, "AddTitle: Window %x is not registered!\n", w);
X	  Leave((Window)NULL)
X     }
X     XAddToSaveSet(dpy, awi->client);
X     if (!init_done)
X	  Init_Titles();
X     XGetGeometry(dpy, (Drawable)awi->client, &root, &x, &y, &width, &height,
X		  &bw, &depth);
X     XGetWindowAttributes(dpy, awi->client, &xwa);
X     valuemask = CWEventMask | CWBorderPixel | CWBackPixel;
X     swa.event_mask = (SubstructureRedirectMask | SubstructureNotifyMask);
X     if (BContext) {
X          swa.event_mask |= (ButtonPressMask | ButtonReleaseMask);
X          bch = (BContext * 2) + 2;
X          bcv = BContext + 1;
X          {
X	       XSetWindowAttributes cswa;
X
X	       cswa.do_not_propagate_mask =
X		    (ButtonPressMask | ButtonReleaseMask);
X	       XChangeWindowAttributes(dpy, awi->client, CWDontPropagate,
X				       &cswa);
X	  }
X
X     }
X     else
X          bch = bcv = 0;
X     swa.background_pixel = TBackground;
X     swa.border_pixel = TForeground;
X     if (TitlePush == FALSE)
X	  x -= (Fheight + 2); /* put title above, don't push window down */
X     foster = XCreateWindow(dpy, RootWindow(dpy, scr), x, y, width + bch,
X                            height + Fheight + 2 + bcv,
X			    (bw ? bw : 1), xwa.depth, xwa.class, xwa.visual,
X			    valuemask, &swa);
X     if (!foster)
X	  Error("AddTitle: Can't create foster parent!");
X     if (BBackPixmapData) { /* we have a border context tile */
X	  awi->BC_back = XCreatePixmapFromBitmapData(dpy, foster,
X						     BBackPixmapData,
X						     BC_wide, BC_high,
X						     BForeground,
X						     BBackground, xwa.depth);
X	  if (!awi->BC_back)
X	       Error("AddTitle: Can't create pixmap for border context background");
X	  else
X	       XSetWindowBackgroundPixmap(dpy, foster, awi->BC_back);
X     }
X     if (BBoldPixmapData) { /* we have a bold border context tile */
X	  awi->BC_bold = XCreatePixmapFromBitmapData(dpy, foster,
X						     BBoldPixmapData,
X						     BCB_wide, BCB_high,
X						     BForeground,
X						     BBackground, xwa.depth);
X	  if (!awi->BC_bold)
X	       Error("AddTitle: Can't create bold pixmap for border context background");
X     }
X	  
X     swa.bit_gravity = CenterGravity;
X     swa.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
X     valuemask |= CWBitGravity;
X     title = XCreateWindow(dpy, foster, 0, 0, (width - 2) + bch, Fheight,
X			   1, 0, CopyFromParent, CopyFromParent,
X			   valuemask, &swa);
X     if (!title)
X	  Error("AddTitle: Can't create title bar!");
X     if (TBackPixmapData) {
X	  awi->back = XCreatePixmapFromBitmapData(dpy, title, TBackPixmapData,
X						  TB_wide, TB_high,
X						  TForeground,
X						  TBackground, xwa.depth);
X	  if (!awi->back)
X	       Error("AddTitle: Can't create pixmap for title background");
X	  else
X	       XSetWindowBackgroundPixmap(dpy, title, awi->back);
X     }
X     if (TBoldPixmapData) {
X	  awi->bold = XCreatePixmapFromBitmapData(dpy, title, TBoldPixmapData,
X						  TBB_wide, TBB_high,
X						  TForeground,
X						  TBackground, xwa.depth);
X	  if (!awi->bold)
X	       Error("AddTitle: Can't create pixmap for bold background");
X     }
X     XSetWindowBorderWidth(dpy, awi->client, (BContext) ? 1 : 0);
X     wc.sibling = awi->client;
X     wc.stack_mode = Above;
X     XConfigureWindow(dpy, foster, CWSibling|CWStackMode, &wc);
X     swa.bit_gravity = CenterGravity;
X     XChangeWindowAttributes(dpy, title, CWBitGravity, &swa);
X     XDefineCursor(dpy, title, TitleCursor);
X     XDefineCursor(dpy, foster, FrameCursor);
X     XSelectInput(dpy, title, (ExposureMask | ButtonPressMask |
X			       ButtonReleaseMask));
X     XMapWindow(dpy, title);
X     if (!BContext)
X          XReparentWindow(dpy, awi->client, foster, 0, Fheight + 2);
X     else
X          XReparentWindow(dpy, awi->client, foster, BContext, Fheight + 2);
X     XMapWindow(dpy, awi->client);
X     awi->title = title;
X     awi->frame = foster;
X     awi->border_width = bw;
X     awi->name = GetTitleName(awi->client);
X     /* Make titlebar "frame" inherit characteristics of victim */
X     XStoreName(dpy, foster, awi->name);
X     if (XGetIconName(dpy, w, &icon_name)) {
X	  XSetIconName(dpy, foster, icon_name);
X	  free(icon_name);
X     }
X     if (wm_hints = XGetWMHints(dpy, awi->client)) {
X	  XSetWMHints(dpy, foster, wm_hints);
X	  XFree(wm_hints);
X     }
X     XGetNormalHints(dpy, awi->client, &sz_hints);
X     XSetNormalHints(dpy, foster, &sz_hints);
X     XGetZoomHints(dpy, awi->client, &sz_hints);
X     XSetZoomHints(dpy, foster, &sz_hints);
X     XGetClassHint(dpy, awi->client, &class_hints);
X     XSetClassHint(dpy, foster, &class_hints);
X
X     XSaveContext(dpy, title, AwmContext, awi);
X     XSaveContext(dpy, foster, AwmContext, awi);
X     Leave(foster)
X}
X
Boolean FDestroyTitle(w, mask, button, x, y)
Window w;
int mask, button, x, y;
X{
X     Entry("FDestroyTitle")
X	  
X     if (w == RootWindow(dpy, scr))
X	  Leave(FALSE)
X     DestroyTitle(w, FALSE);
X     Leave(TRUE)
X}
X
void DestroyTitle(w)
Window w;
X{
X     XWindowAttributes xwa;
X     AwmInfoPtr awi;
X     
X     Entry("DestroyTitle")
X
X     if (!(awi = IsTitled(w)))
X	 Leave_void
X     XGetWindowAttributes(dpy, awi->frame, &xwa);
X     /* put away our toys when we're done playing with them */
X     if (TitlePush == FALSE)
X	  xwa.y += (Fheight + 2);
X     XReparentWindow(dpy, awi->client, RootWindow(dpy, scr), xwa.x,
X	xwa.y);
X     XSetWindowBorderWidth(dpy, awi->client, awi->border_width);
X     DestroyGadgets(w);
X     XDeleteContext(dpy, awi->frame, AwmContext);
X     XDeleteContext(dpy, awi->title, AwmContext);
X     XDestroyWindow(dpy, awi->title);
X     XDestroyWindow(dpy, awi->frame);
X     XSync(dpy, FALSE);
X     if (awi->state != ICON)
X	  XRemoveFromSaveSet(dpy, awi->client);
X     if (awi->back)
X	  XFreePixmap(dpy, awi->back);
X     if (awi->bold)
X	  XFreePixmap(dpy, awi->bold);
X     free(awi->name);
X     awi->frame = awi->title = awi->back = awi->bold = 0;
X     awi->name = (char *)NULL;
X     Leave_void
X}
X
void PaintTitle(w)
Window w;
X{
X     static GC gc, rgc;
X     int x, y, ijunk;
X     XWindowAttributes xwa;
X     Window junk, chld;
X     Boolean reversed;
X     XFontStruct *f_info;
X     AwmInfoPtr awi;
X     XGCValues gcv;
X
X     Entry("PaintTitle")
X
X     if (!(awi = IsTitled(w)))
X	 Leave_void
X     XGetWindowAttributes(dpy, awi->title, &xwa);
X     XQueryPointer(dpy, awi->frame, &junk, &chld, &ijunk, &ijunk,
X		   &ijunk, &ijunk, &ijunk);
X     reversed = (chld == awi->client && Hilite);
X     if (reversed && TFontBoldInfo)
X	  f_info = TFontBoldInfo;
X     else
X	  f_info = TFontInfo;
X     gcv.font = f_info->fid;
X     gcv.foreground = (reversed && !TFontBoldInfo) ?
X	  TTextBackground : TTextForeground;
X     gcv.background = (reversed && !TFontBoldInfo) ?
X	  TTextForeground : TTextBackground;
X     XChangeGC(dpy, awi->winGC, (GCFont | GCForeground | GCBackground), &gcv);
X     XClearWindow(dpy, awi->title);
X     if (ShowName) {	/* print window names? */
X	  x = (xwa.width - XTextWidth(f_info, awi->name,
X				      strlen(awi->name))) / 2;
X	  y = ((f_info->max_bounds.ascent + f_info->max_bounds.descent +
X		xwa.height - 1) / 2) - (Pad * 2);
X	  XDrawImageString(dpy, awi->title, awi->winGC, x, y, awi->name,
X			   strlen(awi->name));
X     }
X     Leave_void
X}
X
AwmInfoPtr IsTitled(w)
Window w;
X{
X     AwmInfoPtr tmp;
X
X     Entry("IsTitled")
X
X     if (!XFindContext(dpy, w, AwmContext, &tmp)) {
X	  if (tmp->title)
X	       Leave(tmp)
X     }
X     Leave((AwmInfoPtr)NULL)
X}
END_OF_FILE
if test 12143 -ne `wc -c <'Titlebar.c'`; then
    echo shar: \"'Titlebar.c'\" unpacked with wrong size!
fi
# end of 'Titlebar.c'
fi
if test -f 'globals.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'globals.c'\"
else
echo shar: Extracting \"'globals.c'\" \(11599 characters\)
sed "s/^X//" >'globals.c' <<'END_OF_FILE'
X/* $Header: globals.c,v 1.4 87/08/21 13:29:42 swick Exp $ */
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 * MODIFICATION HISTORY
X *
X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
X * 001 -- R. Kittell, DEC Storage A/D May 19, 1986
X *  Added global vars for warp options.
X * 002 -- Loretta Guarino Reid, DEC Ultrix Engineering Group 
X *  Western Software Lab. April 17, 1987
X *  Convert to X11
X * 003 -- Jordan Hubbard, U.C. Berkeley. Misc new vars.
X */
X 
X#ifndef lint
static char *sccsid = "%W%	%G%";
X#endif
X/*
X * globals.c - window manager global data
X *
X */
X 
X#include "awm.h"
X#include "X11/Xutil.h"
X 
Window Pop;			/* Pop up dimension display window. */
Window Frozen;			/* Contains window id of "gridded" window. */
XXFontStruct *IFontInfo;		/* Icon text font information. */
XXFontStruct *PFontInfo;		/* Pop-up text font information. */
XXFontStruct *TFontInfo;		/* Title text font information. */
XXFontStruct *TFontBoldInfo;	/* Title text (bold) font information. */
XXFontStruct *GFontInfo;		/* Gadget box text font */
Pixmap GrayPixmap;		/* Gray pixmap. */
Pixmap IBackPixmap;		/* Icon window background pixmap. */
Pixel IBorder;			/* Icon window border color. */
Pixel PBorder;			/* Pop-Up Window border color. */
Pixel BBackground;		/* Border context background color */
Pixel BForeground;		/* Border context foreground color */
Pixel PBackground;		/* Pop-up Window background color. */
Pixel PForeground;		/* Pop-up Window foregrould color */
Pixel TBackground;		/* Titlebar background color */
Pixel TForeground;		/* Titlebar foreground color */
Pixel TTextBackground;		/* Titlebar text background color */
Pixel TTextForeground;		/* Titlebar text foreground color */
Pixel IBackground;		/* Icon background (for pixmap) color */
Pixel IForeground;		/* Icon foreground (for pixmap) color */
Pixel ITextForeground;		/* Icon text foreground color */
Pixel ITextBackground;		/* Icon text background color */
Cursor ArrowCrossCursor;	/* Arrow cross cursor. */
Cursor TextCursor;		/* Text cursor used in icon windows. */
Cursor IconCursor;		/* Icon Cursor. */
Cursor LeftButtonCursor;	/* Left button main cursor. */
Cursor MiddleButtonCursor;	/* Middle button main cursor. */
Cursor RightButtonCursor;	/* Right button main cursor. */
Cursor TargetCursor;		/* Target (select-a-window) cursor. */
int ScreenWidth;		/* Display screen width. */
int ScreenHeight;		/* Display screen height. */
int IBorderWidth;		/* Icon window border width. */
int PWidth;			/* Pop-up window width. */
int PHeight;			/* Pop-up window height. */
int PBorderWidth;		/* Pop-up window border width. */
int PPadding;			/* Pop-up window padding. */
int Delta;			/* Mouse movement slop. */
int HIconPad;			/* Icon horizontal padding. */
int VIconPad;			/* Icon vertical padding. */
int MaxColors;			/* Maximum number of colors to use. */
int Pushval;			/* Number of pixels to push window by. */
int BContext;			/* Border context area width (in pixels) */
int RaiseDelay;			/* Number of milliseconds delay before autoraise */
int NumGadgets;			/* Number of gadgets we're using */
int GadgetPad;			/* Amount of padding for gadgets */
int Volume;			/* Audible alarm volume. */
int status;			/* Routine return status. */
int Maxfd;			/* Maximum file descriptors for select(2). */
int BCursor;			/* Border context cursor */
int TCursor;			/* Title context cursor */
MenuLink *Menus;		/* Linked list of menus. */
GC  IconGC;			/* graphics context for icon */
GC  PopGC;			/* graphics context for pop */
GC  DrawGC;			/* graphics context for drawing */
Binding *Blist;			/* Button/key binding list. */
X
XXContext AwmContext;		/* Main context for awm */
X
Boolean Autoselect;		/* Warp mouse to default menu selection? */
Boolean Autoraise;		/* Raise window on input focus? */
Boolean Freeze;			/* Freeze server during move/resize? */
Boolean Grid;			/* Should the m/r box contain a 9 seg. grid. */
Boolean ShowName;		/* If True, print window names in titlebars */
Boolean Hilite;			/* Should we highlight window borders on focus? */
Boolean NWindow;		/* Normalize windows? */
Boolean NIcon;			/* Normalize icons? */
Boolean Push;			/* Relative=TRUE, Absolute=FALSE. */
Boolean RootResizeBox;		/* Resize window is placed over sized window? */
Boolean ResizeRelative;		/* resizes should be relative to window edge */
Boolean Titles;			/* Title bar frob on windows? */
Boolean UseGadgets;		/* Gadget bars on titles? */
Boolean Reverse;		/* Reverse video? */
Boolean SaveUnder;		/* Save unders? */
Boolean TitlePush;		/* Down=TRUE, Up=FALSE */
Boolean Wall;			/* restrict to root window boundries? */
Boolean WarpOnRaise;		/* Warp to upper right corner on raise. */
Boolean WarpOnIconify;          /* Warp to icon center on iconify. */
Boolean WarpOnDeIconify;        /* Warp to upper right corner on de-iconify. */
Boolean FocusSetByUser;         /* True if f.focus called */
Boolean Zap;			/* Should the the zap effect be used. */
X 
char PText[7] = INIT_PTEXT;	/* Pop-up window dummy text. */
int PTextSize = sizeof(PText);	/* Pop-up window dummy text size. */
X 
int Lineno = 1;			/* Line count for parser. */
Boolean Startup_File_Error = FALSE;/* Startup file error flag. */
char Startup_File[NAME_LEN] = "";/* Startup file name. */
char *TBackPixmapData;		/* Bitmap data file title background */
char *TBoldPixmapData;		/* ditto, except highlighted */
char *BBackPixmapData;		/* Border context background pixmap data */
char *BBoldPixmapData;		/* Border context bold pixmap data */
char *awmPath;			/* Optional pathlist to search for pixmaps */
char **Argv;			/* Pointer to command line parameters. */
char **Environ;			/* Pointer to environment. */
X
int scr;
Display *dpy;
X
X#ifdef NEATEN
int AbsMinWidth;
int AbsMinHeight;
Boolean RetainSize;
Boolean KeepOpen;
Boolean Fill;
Boolean UsePriorities;
Boolean FixTopOfStack;
char *PrimaryIconPlacement;
char *SecondaryIconPlacement;
X#endif
X
X/*
X * Keyword lookup table for parser.
X */
Keyword KeywordTable[] =
X{
X    { "autoselect",	IsBoolean,	&Autoselect, 0 },
X    { "autoraise",	IsBoolean,	&Autoraise, 0 },
X    { "freeze",		IsBoolean,	&Freeze, 0 },
X    { "hilite",		IsBoolean,	&Hilite, 0 },
X    { "rootResizeBox",	IsBoolean,	&RootResizeBox, 0 },
X    { "titles",		IsBoolean,	&Titles, 0 },
X    { "gadgets",	IsBoolean,	&UseGadgets, 0 },
X    { "grid",		IsBoolean,	&Grid, 0 },
X    { "showName",	IsBoolean,	&ShowName, 0,},
X    { "normali",	IsBoolean,	&NIcon, 0 },
X    { "normalw",	IsBoolean,	&NWindow, 0 },
X    { "pushRelative",	IsBoolean,	&Push, 0 },
X    { "reverse",	IsBoolean,	&Reverse, 0 },
X    { "wall",		IsBoolean,	&Wall, 0 },
X    { "warpOnIconify",	IsBoolean,	&WarpOnIconify, 0 },
X    { "warpOnDeIconify",IsBoolean,	&WarpOnDeIconify, 0 },
X    { "warpOnRaise",	IsBoolean,	&WarpOnRaise, 0 },
X#ifdef NEATEN
X    { "retainSize",	IsBoolean,	&RetainSize, 0 },
X    { "keepOpen",	IsBoolean,	&KeepOpen, 0 },
X    { "fill",		IsBoolean,	&Fill, 0 },
X    { "usePriorities",	IsBoolean,	&UsePriorities },
X    { "fixTopOfStack",	IsBoolean,	&FixTopOfStack },
X#endif
X    { "zap",		IsBoolean,	&Zap, 0 },
X    { "gadget",		IsGadget,	0, 0 },
X    { "f.beep",		IsImmFunction,	0, Beep },
X    { "f.circledown",	IsImmFunction,	0, CircleDown },
X    { "f.circleup",	IsImmFunction,	0, CircleUp },
X    { "f.continue",	IsImmFunction,	0, Continue },
X    { "f.exit",		IsQuitFunction,	0, Quit },
X    { "f.focus",	IsFunction,	0, Focus },
X    { "f.iconify",	IsFunction,	0, Iconify },
X    { "f.lower",	IsFunction,	0, Lower },
X    { "f.menu",		IsMenuMap,	0, DoMenu },
X    { "f.action",	IsAction,	0, DoAction },
X    { "f.move",		IsDownFunction,	0, Move },
X    { "f.moveopaque",	IsDownFunction,	0, MoveOpaque },
X    { "f.newiconify",	IsDownFunction,	0, NewIconify },
X    { "f.neaten",	IsImmFunction,	0, Neaten },
X    { "f.pause",	IsImmFunction,	0, Pause },
X    { "f.pushdown",	IsFunction,	0, PushDown },
X    { "f.pushleft",	IsFunction,	0, PushLeft },
X    { "f.pushright",	IsFunction,	0, PushRight },
X    { "f.pushup",	IsFunction,	0, PushUp },
X    { "f.raise",	IsFunction,	0, Raise },
X    { "f.redraw",	IsDownFunction,	0, Redraw },
X    { "f.refresh",	IsImmFunction,	0, Refresh },
X    { "f.resize",	IsDownFunction,	0, Resize },
X    { "f.restart",	IsQuitFunction,	0, Restart },
X    { "f.destroy",      IsDownFunction, 0, DestroyClient },
X    { "f.title",        IsFunction,     0, FAddTitle },
X    { "f.gadgets",	IsFunction,	0, FPutGadgets },
X    { "f.notitle",      IsFunction,     0, FDestroyTitle },
X    { "f.nogadgets",	IsFunction,	0, FDestroyGadgets },
X    { "menu",		IsMenu,		0, 0 },
X    { "resetbindings",	IsParser,	0, ResetBindings },
X    { "resetmenus",	IsParser,	0, ResetMenus },
X    { "resetgadgets",	IsParser,	0, ResetGadgets },
X    { NULL,		NULL,		NULL, NULL }
X};
X 
X/*
X * Key expression table for parser.
X */
KeyExpr KeyExprTbl[] = {
X    { "ctrl", ControlMask },
X    { "c", ControlMask },
X    { "lock", LockMask },
X    { "l", LockMask },
X    { "meta", Mod1Mask },
X    { "m", Mod1Mask },
X    { "shift", ShiftMask },
X    { "s", ShiftMask },
X    { "mod1", Mod1Mask },
X    { "mod2", Mod2Mask },
X    { "mod3", Mod3Mask },
X    { "mod4", Mod4Mask },
X    { "mod5", Mod5Mask },
X    { NULL, NULL }
X};
X 
X/*
X * Context expression table for parser.
X */
ContExpr ContExprTbl[] = {
X    { "icon", ICON },
X    { "i", ICON },
X    { "root", ROOT },
X    { "r", ROOT },
X    { "window", WINDOW },
X    { "w", WINDOW },
X    { "t", TITLE },
X    { "title", TITLE },
X    { "g", GADGET },
X    { "gadget", GADGET },
X    { "border", BORDER },
X    { "b", BORDER },
X    { NULL, NULL }
X};
X
X/*
X * Gravity expressions for parser.
X */
GravityExpr GravityExprTbl[] = {
X    { "noGravity", NoGadgetGravity },
X    { "nogravity", NoGadgetGravity },
X    { "NoGravity", NoGadgetGravity },
X    { "leftGravity", LeftGadgetGravity },
X    { "leftgravity", LeftGadgetGravity },
X    { "LeftGravity", LeftGadgetGravity },
X    { "rightGravity", RightGadgetGravity },
X    { "rightgravity", RightGadgetGravity },
X    { "RightGravity", RightGadgetGravity }
X};
X
X/*
X * Button expression table for parser.
X */
ButtonModifier ButtModTbl[] = {
X    { "left", LeftMask },
X    { "leftbutton", LeftMask },
X    { "l", LeftMask },
X    { "middle", MiddleMask },
X    { "middlebutton", MiddleMask },
X    { "m", MiddleMask },
X    { "right", RightMask },
X    { "rightbutton", RightMask },
X    { "r", RightMask },
X    { "move", DeltaMotion },
X    { "motion", DeltaMotion },
X    { "delta", DeltaMotion },
X    { "boogie", DeltaMotion },
X    { "truckin", DeltaMotion }, /* it's been a silly day... */
X    { "down", ButtonDown },
X    { "d", ButtonDown },
X    { "up", ButtonUp },
X    { "u", ButtonUp },
X    { NULL, NULL }
X};
X 
END_OF_FILE
if test 11599 -ne `wc -c <'globals.c'`; then
    echo shar: \"'globals.c'\" unpacked with wrong size!
fi
# end of 'globals.c'
fi
echo shar: End of archive 4 \(of 8\).
cp /dev/null ark4isdone
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