[comp.sources.x] v09i006: TWM with a virtual root window, Part05/09

toml@marvin.Solbourne.COM (Tom LaStrange) (08/30/90)

Submitted-by: toml@marvin.Solbourne.COM (Tom LaStrange)
Posting-number: Volume 9, Issue 6
Archive-name: tvtwm/part05

#! /bin/sh
# This is a shell archive, meaning:
# 1.  Remove everything above the #! /bin/sh line.
# 2.  Save the resulting test in a file
# 3.  Execute the file with /bin/sh (not csh) to create the files:
#
#parse.c
#resize.c
#
# Created by toml () on Wed Aug 29 08:43:34 MDT 1990
#
if test -f 'parse.c'
then
    echo shar: will not over-write existing file "parse.c"
else
echo extracting "parse.c"
sed 's/^X//' >parse.c <<'SHAR_EOF'
X/*****************************************************************************/
X/**       Copyright 1988 by Evans & Sutherland Computer Corporation,        **/
X/**                          Salt Lake City, Utah                           **/
X/**  Portions Copyright 1989 by the Massachusetts Institute of Technology   **/
X/**                        Cambridge, Massachusetts                         **/
X/**                                                                         **/
X/**                           All Rights Reserved                           **/
X/**                                                                         **/
X/**    Permission to use, copy, modify, and distribute this software and    **/
X/**    its documentation  for  any  purpose  and  without  fee is hereby    **/
X/**    granted, provided that the above copyright notice appear  in  all    **/
X/**    copies and that both  that  copyright  notice  and  this  permis-    **/
X/**    sion  notice appear in supporting  documentation,  and  that  the    **/
X/**    names of Evans & Sutherland and M.I.T. not be used in advertising    **/
X/**    in publicity pertaining to distribution of the  software  without    **/
X/**    specific, written prior permission.                                  **/
X/**                                                                         **/
X/**    EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD    **/
X/**    TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES  OF  MERCHANT-    **/
X/**    ABILITY  AND  FITNESS,  IN  NO  EVENT SHALL EVANS & SUTHERLAND OR    **/
X/**    M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL  DAM-    **/
X/**    AGES OR  ANY DAMAGES WHATSOEVER  RESULTING FROM LOSS OF USE, DATA    **/
X/**    OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER    **/
X/**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
X/**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
X/*****************************************************************************/
X
X
X/***********************************************************************
X *
X * $XConsortium: parse.c,v 1.45 90/03/15 14:23:02 jim Exp $
X *
X * parse the .twmrc file
X *
X * 17-Nov-87 Thomas E. LaStrange		File created
X *
X ***********************************************************************/
X
X#if !defined(lint) && !defined(SABER)
Xstatic char RCSinfo[]=
X"$XConsortium: parse.c,v 1.45 90/03/15 14:23:02 jim Exp $";
X#endif
X
X#include <stdio.h>
X#include <X11/Xos.h>
X#include <X11/Xmu/CharSet.h>
X#include "twm.h"
X#include "screen.h"
X#include "menus.h"
X#include "util.h"
X#include "gram.h"
X#include "parse.h"
X#include "vdt.h"
X
X#ifndef SYSTEM_INIT_FILE
X#define SYSTEM_INIT_FILE "/usr/lib/X11/twm/system.twmrc"
X#endif
X#define BUF_LEN 300
X
Xstatic FILE *twmrc;
Xstatic int ptr = 0;
Xstatic int len = 0;
Xstatic char buff[BUF_LEN+1];
Xstatic char overflowbuff[20];		/* really only need one */
Xstatic int overflowlen;
Xstatic char **stringListSource, *currentString;
Xstatic int ParseUsePPosition();
Xstatic int ParseState();
X
Xextern int yylineno;
Xextern int mods;
X
Xint ConstrainedMoveTime = 400;		/* milliseconds, event times */
X
Xstatic int twmFileInput(), twmStringListInput();
Xvoid twmUnput();
Xint (*twmInputFunc)();
X
Xextern char *defTwmrc[];		/* default bindings */
X
X
X/***********************************************************************
X *
X *  Procedure:
X *	ParseTwmrc - parse the .twmrc file
X *
X *  Inputs:
X *	filename  - the filename to parse.  A NULL indicates $HOME/.twmrc
X *
X ***********************************************************************
X */
X
Xstatic int doparse (ifunc, srctypename, srcname)
X    int (*ifunc)();
X    char *srctypename;
X    char *srcname;
X{
X    mods = 0;
X    ptr = 0;
X    len = 0;
X    yylineno = 1;
X    ParseError = FALSE;
X    twmInputFunc = ifunc;
X    overflowlen = 0;
X
X    yyparse();
X
X    if (ParseError) {
X	fprintf (stderr, "%s:  errors found in twm %s",
X		 ProgramName, srctypename);
X	if (srcname) fprintf (stderr, " \"%s\"", srcname);
X	fprintf (stderr, "\n");
X    }
X    return (ParseError ? 0 : 1);
X}
X
X
Xint ParseTwmrc (filename)
X    char *filename;
X{
X    int i;
X    char *home = NULL;
X    int homelen = 0;
X    char *cp = NULL;
X    char tmpfilename[257];
X
X    /*
X     * If filename given, try it, else try ~/.twmrc.# then ~/.twmrc.  Then
X     *   0.  -f filename
X     *   1.  .tvtwmrc.#
X     *   2.  .tvtwmrc
X     *   3.  .twmrc.#
X     *   4.  .twmrc
X     *   5.  system.twmrc
X     */
X    for (twmrc = NULL, i = 0; !twmrc && i < 6; i++) {
X	switch (i) {
X	  case 0:			/* -f filename */
X	    cp = filename;
X	    break;
X
X	  case 1:			/* ~/.twmrc.screennum */
X	    if (!filename) {
X		home = getenv ("HOME");
X		if (home) {
X		    homelen = strlen (home);
X		    cp = tmpfilename;
X		    (void) sprintf (tmpfilename, "%s/.tvtwmrc.%d",
X				    home, Scr->screen);
X		    break;
X		}
X	    }
X	    continue;
X
X	  case 2:			/* ~/.tvtwmrc */
X	    if (home) {
X		tmpfilename[homelen + 9] = '\0';
X	    }
X	    break;
X
X	  case 3:			/* ~/.twmrc.screennum */
X	    if (!filename) {
X		home = getenv ("HOME");
X		if (home) {
X		    homelen = strlen (home);
X		    cp = tmpfilename;
X		    (void) sprintf (tmpfilename, "%s/.twmrc.%d",
X				    home, Scr->screen);
X		    break;
X		}
X	    }
X	    continue;
X
X	  case 4:			/* ~/.twmrc */
X	    if (home) {
X		tmpfilename[homelen + 7] = '\0';
X	    }
X	    break;
X
X	  case 5:			/* system.twmrc */
X	    cp = SYSTEM_INIT_FILE;
X	    break;
X	}
X
X	if (cp) twmrc = fopen (cp, "r");
X    }
X
X    if (twmrc) {
X	int status;
X
X	if (filename && cp != filename) {
X	    fprintf (stderr,
X		     "%s:  unable to open twmrc file %s, using %s instead\n",
X		     ProgramName, filename, cp);
X	}
X	status = doparse (twmFileInput, "file", cp);
X	fclose (twmrc);
X	return status;
X    } else {
X	if (filename) {
X	    fprintf (stderr,
X	"%s:  unable to open twmrc file %s, using built-in defaults instead\n",
X		     ProgramName, filename);
X	}
X	return ParseStringList (defTwmrc);
X    }
X}
X
Xint ParseStringList (sl)
X    char **sl;
X{
X    stringListSource = sl;
X    currentString = *sl;
X    return doparse (twmStringListInput, "string list", (char *)NULL);
X}
X
X
X/***********************************************************************
X *
X *  Procedure:
X *	twmFileInput - redefinition of the lex input routine for file input
X *
X *  Returned Value:
X *	the next input character
X *
X ***********************************************************************
X */
X
Xstatic int twmFileInput()
X{
X    if (overflowlen) return (int) overflowbuff[--overflowlen];
X
X    while (ptr == len)
X    {
X	if (fgets(buff, BUF_LEN, twmrc) == NULL)
X	    return NULL;
X
X	yylineno++;
X
X	ptr = 0;
X	len = strlen(buff);
X    }
X    return ((int)buff[ptr++]);
X}
X
Xstatic int twmStringListInput()
X{
X    if (overflowlen) return (int) overflowbuff[--overflowlen];
X
X    /*
X     * return the character currently pointed to
X     */
X    if (currentString) {
X	unsigned int c = (unsigned int) *currentString++;
X
X	if (c) return c;		/* if non-nul char */
X	currentString = *++stringListSource;  /* advance to next bol */
X	return '\n';			/* but say that we hit last eol */
X    }
X    return 0;				/* eof */
X}
X
X
X/***********************************************************************
X *
X *  Procedure:
X *	twmUnput - redefinition of the lex unput routine
X *
X *  Inputs:
X *	c	- the character to push back onto the input stream
X *
X ***********************************************************************
X */
X
Xvoid twmUnput (c)
X    int c;
X{
X    if (overflowlen < sizeof overflowbuff) {
X	overflowbuff[overflowlen++] = (char) c;
X    } else {
X	twmrc_error_prefix ();
X	fprintf (stderr, "unable to unput character (%d)\n",
X		 c);
X    }
X}
X
X
X/***********************************************************************
X *
X *  Procedure:
X *	TwmOutput - redefinition of the lex output routine
X *
X *  Inputs:
X *	c	- the character to print
X *
X ***********************************************************************
X */
X
Xvoid
XTwmOutput(c)
X{
X    putchar(c);
X}
X
X
X/**********************************************************************
X *
X *  Parsing table and routines
X * 
X ***********************************************************************/
X
Xtypedef struct _TwmKeyword {
X    char *name;
X    int value;
X    int subnum;
X} TwmKeyword;
X
X#define kw0_NoDefaults			1
X#define kw0_AutoRelativeResize		2
X#define kw0_ForceIcons			3
X#define kw0_NoIconManagers		4
X#define kw0_OpaqueMove			5
X#define kw0_InterpolateMenuColors	6
X#define kw0_NoVersion			7
X#define kw0_SortIconManager		8
X#define kw0_NoGrabServer		9
X#define kw0_NoMenuShadows		10
X#define kw0_NoRaiseOnMove		11
X#define kw0_NoRaiseOnResize		12
X#define kw0_NoRaiseOnDeiconify		13
X#define kw0_DontMoveOff			14
X#define kw0_NoBackingStore		15
X#define kw0_NoSaveUnders		16
X#define kw0_RestartPreviousState	17
X#define kw0_ClientBorderWidth		18
X#define kw0_NoTitleFocus		19
X#define kw0_RandomPlacement		20
X#define kw0_DecorateTransients		21
X#define kw0_ShowIconManager		22
X#define kw0_NoCaseSensitive		23
X#define kw0_NoRaiseOnWarp		24
X#define kw0_WarpUnmapped		25
X
X#define kws_UsePPosition		1
X#define kws_IconFont			2
X#define kws_ResizeFont			3
X#define kws_MenuFont			4
X#define kws_TitleFont			5
X#define kws_IconManagerFont		6
X#define kws_UnknownIcon			7
X#define kws_IconDirectory		8
X#define kws_MaxWindowSize		9
X#define kws_VirtualDesktop		10
X#define kws_PannerState			11
X#define kws_PannerGeometry		12
X#define kws_VirtualDesktopBackgroundPixmap 13
X#define kws_PannerBackgroundPixmap	14
X
X#define kwn_ConstrainedMoveTime		1
X#define kwn_MoveDelta			2
X#define kwn_XorValue			3
X#define kwn_FramePadding		4
X#define kwn_TitlePadding		5
X#define kwn_ButtonIndent		6
X#define kwn_BorderWidth			7
X#define kwn_IconBorderWidth		8
X#define kwn_TitleButtonBorderWidth	9
X#define kwn_PannerScale			10
X
X#define kwcl_BorderColor		1
X#define kwcl_IconManagerHighlight	2
X#define kwcl_BorderTileForeground	3
X#define kwcl_BorderTileBackground	4
X#define kwcl_TitleForeground		5
X#define kwcl_TitleBackground		6
X#define kwcl_IconForeground		7
X#define kwcl_IconBackground		8
X#define kwcl_IconBorderColor		9
X#define kwcl_IconManagerForeground	10
X#define kwcl_IconManagerBackground	11
X
X#define kwc_DefaultForeground		1
X#define kwc_DefaultBackground		2
X#define kwc_MenuForeground		3
X#define kwc_MenuBackground		4
X#define kwc_MenuTitleForeground		5
X#define kwc_MenuTitleBackground		6
X#define kwc_MenuShadowColor		7
X#define kwc_VirtualDesktopForeground	8
X#define kwc_VirtualDesktopBackground	9
X#define kwc_PannerForeground		10
X#define kwc_PannerBackground		11
X
X
X/*
X * The following is sorted alphabetically according to name (which must be
X * in lowercase and only contain the letters a-z).  It is fed to a binary
X * search to parse keywords.
X */
Xstatic TwmKeyword keytable[] = { 
X    { "all",			ALL, 0 },
X    { "autoraise",		AUTO_RAISE, 0 },
X    { "autorelativeresize",	KEYWORD, kw0_AutoRelativeResize },
X    { "bordercolor",		CLKEYWORD, kwcl_BorderColor },
X    { "bordertilebackground",	CLKEYWORD, kwcl_BorderTileBackground },
X    { "bordertileforeground",	CLKEYWORD, kwcl_BorderTileForeground },
X    { "borderwidth",		NKEYWORD, kwn_BorderWidth },
X    { "button",			BUTTON, 0 },
X    { "buttonindent",		NKEYWORD, kwn_ButtonIndent },
X    { "c",			CONTROL, 0 },
X    { "center",			JKEYWORD, J_CENTER },
X    { "clientborderwidth",	KEYWORD, kw0_ClientBorderWidth },
X    { "color",			COLOR, 0 },
X    { "constrainedmovetime",	NKEYWORD, kwn_ConstrainedMoveTime },
X    { "control",		CONTROL, 0 },
X    { "cursors",		CURSORS, 0 },
X    { "decoratetransients",	KEYWORD, kw0_DecorateTransients },
X    { "defaultbackground",	CKEYWORD, kwc_DefaultBackground },
X    { "defaultforeground",	CKEYWORD, kwc_DefaultForeground },
X    { "defaultfunction",	DEFAULT_FUNCTION, 0 },
X    { "destroy",		KILL, 0 },
X    { "donticonifybyunmapping",	DONT_ICONIFY_BY_UNMAPPING, 0 },
X    { "dontmoveoff",		KEYWORD, kw0_DontMoveOff },
X    { "dontsqueezetitle",	DONT_SQUEEZE_TITLE, 0 },
X    { "east",			DKEYWORD, D_EAST },
X    { "f",			FRAME, 0 },
X    { "f.autoraise",		FKEYWORD, F_AUTORAISE },
X    { "f.backiconmgr",		FKEYWORD, F_BACKICONMGR },
X    { "f.beep",			FKEYWORD, F_BEEP },
X    { "f.bottomzoom",		FKEYWORD, F_BOTTOMZOOM },
X    { "f.circledown",		FKEYWORD, F_CIRCLEDOWN },
X    { "f.circleup",		FKEYWORD, F_CIRCLEUP },
X    { "f.colormap",		FSKEYWORD, F_COLORMAP },
X    { "f.cut",			FSKEYWORD, F_CUT },
X    { "f.cutfile",		FKEYWORD, F_CUTFILE },
X    { "f.deiconify",		FKEYWORD, F_DEICONIFY },
X    { "f.delete",		FKEYWORD, F_DELETE },
X    { "f.deltastop",		FKEYWORD, F_DELTASTOP },
X    { "f.destroy",		FKEYWORD, F_DESTROY },
X    { "f.downiconmgr",		FKEYWORD, F_DOWNICONMGR },
X    { "f.exec",			FSKEYWORD, F_EXEC },
X    { "f.file",			FSKEYWORD, F_FILE },
X    { "f.focus",		FKEYWORD, F_FOCUS },
X    { "f.forcemove",		FKEYWORD, F_FORCEMOVE },
X    { "f.forwiconmgr",		FKEYWORD, F_FORWICONMGR },
X    { "f.fullzoom",		FKEYWORD, F_FULLZOOM },
X    { "f.function",		FSKEYWORD, F_FUNCTION },
X    { "f.hbzoom",		FKEYWORD, F_BOTTOMZOOM },
X    { "f.hideiconmgr",		FKEYWORD, F_HIDELIST },
X    { "f.horizoom",		FKEYWORD, F_HORIZOOM },
X    { "f.htzoom",		FKEYWORD, F_TOPZOOM },
X    { "f.hzoom",		FKEYWORD, F_HORIZOOM },
X    { "f.iconify",		FKEYWORD, F_ICONIFY },
X    { "f.identify",		FKEYWORD, F_IDENTIFY },
X    { "f.lefticonmgr",		FKEYWORD, F_LEFTICONMGR },
X    { "f.leftzoom",		FKEYWORD, F_LEFTZOOM },
X    { "f.lower",		FKEYWORD, F_LOWER },
X    { "f.menu",			FSKEYWORD, F_MENU },
X    { "f.move",			FKEYWORD, F_MOVE },
X    { "f.nexticonmgr",		FKEYWORD, F_NEXTICONMGR },
X    { "f.nop",			FKEYWORD, F_NOP },
X    { "f.pandown",		FKEYWORD, F_SCROLLDOWN },
X    { "f.panleft",		FKEYWORD, F_SCROLLLEFT },
X    { "f.panner",		FKEYWORD, F_PANNER },
X    { "f.panright",		FKEYWORD, F_SCROLLRIGHT },
X    { "f.panup",		FKEYWORD, F_SCROLLUP },
X    { "f.previconmgr",		FKEYWORD, F_PREVICONMGR },
X    { "f.quit",			FKEYWORD, F_QUIT },
X    { "f.raise",		FKEYWORD, F_RAISE },
X    { "f.raiselower",		FKEYWORD, F_RAISELOWER },
X    { "f.refresh",		FKEYWORD, F_REFRESH },
X    { "f.resize",		FKEYWORD, F_RESIZE },
X    { "f.restart",		FKEYWORD, F_RESTART },
X    { "f.righticonmgr",		FKEYWORD, F_RIGHTICONMGR },
X    { "f.rightzoom",		FKEYWORD, F_RIGHTZOOM },
X    { "f.saveyourself",		FKEYWORD, F_SAVEYOURSELF },
X    { "f.scrolldown",		FKEYWORD, F_SCROLLDOWN },
X    { "f.scrollhome",		FKEYWORD, F_SCROLLHOME },
X    { "f.scrollleft",		FKEYWORD, F_SCROLLLEFT },
X    { "f.scrollright",		FKEYWORD, F_SCROLLRIGHT },
X    { "f.scrollup",		FKEYWORD, F_SCROLLUP },
X    { "f.showiconmgr",		FKEYWORD, F_SHOWLIST },
X    { "f.sorticonmgr",		FKEYWORD, F_SORTICONMGR },
X    { "f.source",		FSKEYWORD, F_BEEP },  /* XXX - don't work */
X    { "f.stick",		FKEYWORD, F_STICK },
X    { "f.title",		FKEYWORD, F_TITLE },
X    { "f.topzoom",		FKEYWORD, F_TOPZOOM },
X    { "f.twmrc",		FKEYWORD, F_RESTART },
X    { "f.unfocus",		FKEYWORD, F_UNFOCUS },
X    { "f.upiconmgr",		FKEYWORD, F_UPICONMGR },
X    { "f.version",		FKEYWORD, F_VERSION },
X    { "f.vlzoom",		FKEYWORD, F_LEFTZOOM },
X    { "f.vrzoom",		FKEYWORD, F_RIGHTZOOM },
X    { "f.warpring",		FSKEYWORD, F_WARPRING },
X    { "f.warpto",		FSKEYWORD, F_WARPTO },
X    { "f.warptoiconmgr",	FSKEYWORD, F_WARPTOICONMGR },
X    { "f.warptoscreen",		FSKEYWORD, F_WARPTOSCREEN },
X    { "f.winrefresh",		FKEYWORD, F_WINREFRESH },
X    { "f.zoom",			FKEYWORD, F_ZOOM },
X    { "forceicons",		KEYWORD, kw0_ForceIcons },
X    { "frame",			FRAME, 0 },
X    { "framepadding",		NKEYWORD, kwn_FramePadding },
X    { "function",		FUNCTION, 0 },
X    { "i",			ICON, 0 },
X    { "icon",			ICON, 0 },
X    { "iconbackground",		CLKEYWORD, kwcl_IconBackground },
X    { "iconbordercolor",	CLKEYWORD, kwcl_IconBorderColor },
X    { "iconborderwidth",	NKEYWORD, kwn_IconBorderWidth },
X    { "icondirectory",		SKEYWORD, kws_IconDirectory },
X    { "iconfont",		SKEYWORD, kws_IconFont },
X    { "iconforeground",		CLKEYWORD, kwcl_IconForeground },
X    { "iconifybyunmapping",	ICONIFY_BY_UNMAPPING, 0 },
X    { "iconmanagerbackground",	CLKEYWORD, kwcl_IconManagerBackground },
X    { "iconmanagerdontshow",	ICONMGR_NOSHOW, 0 },
X    { "iconmanagerfont",	SKEYWORD, kws_IconManagerFont },
X    { "iconmanagerforeground",	CLKEYWORD, kwcl_IconManagerForeground },
X    { "iconmanagergeometry",	ICONMGR_GEOMETRY, 0 },
X    { "iconmanagerhighlight",	CLKEYWORD, kwcl_IconManagerHighlight },
X    { "iconmanagers",		ICONMGRS, 0 },
X    { "iconmanagershow",	ICONMGR_SHOW, 0 },
X    { "iconmgr",		ICONMGR, 0 },
X    { "iconregion",		ICON_REGION, 0 },
X    { "icons",			ICONS, 0 },
X    { "interpolatemenucolors",	KEYWORD, kw0_InterpolateMenuColors },
X    { "l",			LOCK, 0 },
X    { "left",			JKEYWORD, J_LEFT },
X    { "lefttitlebutton",	LEFT_TITLEBUTTON, 0 },
X    { "lock",			LOCK, 0 },
X    { "m",			META, 0 },
X    { "maketitle",		MAKE_TITLE, 0 },
X    { "maxwindowsize",		SKEYWORD, kws_MaxWindowSize },
X    { "menu",			MENU, 0 },
X    { "menubackground",		CKEYWORD, kwc_MenuBackground },
X    { "menufont",		SKEYWORD, kws_MenuFont },
X    { "menuforeground",		CKEYWORD, kwc_MenuForeground },
X    { "menushadowcolor",	CKEYWORD, kwc_MenuShadowColor },
X    { "menutitlebackground",	CKEYWORD, kwc_MenuTitleBackground },
X    { "menutitleforeground",	CKEYWORD, kwc_MenuTitleForeground },
X    { "meta",			META, 0 },
X    { "mod",			META, 0 },  /* fake it */
X    { "monochrome",		MONOCHROME, 0 },
X    { "move",			MOVE, 0 },
X    { "movedelta",		NKEYWORD, kwn_MoveDelta },
X    { "nobackingstore",		KEYWORD, kw0_NoBackingStore },
X    { "nocasesensitive",	KEYWORD, kw0_NoCaseSensitive },
X    { "nodefaults",		KEYWORD, kw0_NoDefaults },
X    { "nograbserver",		KEYWORD, kw0_NoGrabServer },
X    { "nohighlight",		NO_HILITE, 0 },
X    { "noiconmanagers",		KEYWORD, kw0_NoIconManagers },
X    { "nomenushadows",		KEYWORD, kw0_NoMenuShadows },
X    { "noraiseondeiconify",	KEYWORD, kw0_NoRaiseOnDeiconify },
X    { "noraiseonmove",		KEYWORD, kw0_NoRaiseOnMove },
X    { "noraiseonresize",	KEYWORD, kw0_NoRaiseOnResize },
X    { "noraiseonwarp",		KEYWORD, kw0_NoRaiseOnWarp },
X    { "north",			DKEYWORD, D_NORTH },
X    { "nosaveunders",		KEYWORD, kw0_NoSaveUnders },
X    { "nostackmode",		NO_STACKMODE, 0 },
X    { "notitle",		NO_TITLE, 0 },
X    { "notitlefocus",		KEYWORD, kw0_NoTitleFocus },
X    { "notitlehighlight",	NO_TITLE_HILITE, 0 },
X    { "noversion",		KEYWORD, kw0_NoVersion },
X    { "opaquemove",		KEYWORD, kw0_OpaqueMove },
X    { "pannerbackground",	CKEYWORD, kwc_PannerBackground },
X    { "pannerbackgroundpixmap",	SKEYWORD, kws_PannerBackgroundPixmap },
X    { "pannerforeground",	CKEYWORD, kwc_PannerForeground },
X    { "pannergeometry",		SKEYWORD, kws_PannerGeometry },
X    { "pannerscale",		NKEYWORD, kwn_PannerScale },
X    { "pannerstate",		SKEYWORD, kws_PannerState },
X    { "pixmaps",		PIXMAPS, 0 },
X    { "r",			ROOT, 0 },
X    { "randomplacement",	KEYWORD, kw0_RandomPlacement },
X    { "resize",			RESIZE, 0 },
X    { "resizefont",		SKEYWORD, kws_ResizeFont },
X    { "restartpreviousstate",	KEYWORD, kw0_RestartPreviousState },
X    { "right",			JKEYWORD, J_RIGHT },
X    { "righttitlebutton",	RIGHT_TITLEBUTTON, 0 },
X    { "root",			ROOT, 0 },
X    { "s",			SHIFT, 0 },
X    { "select",			SELECT, 0 },
X    { "shift",			SHIFT, 0 },
X    { "showiconmanager",	KEYWORD, kw0_ShowIconManager },
X    { "sorticonmanager",	KEYWORD, kw0_SortIconManager },
X    { "south",			DKEYWORD, D_SOUTH },
X    { "squeezetitle",		SQUEEZE_TITLE, 0 },
X    { "starticonified",		START_ICONIFIED, 0 },
X    { "sticky",			STICKY, 0 },
X    { "t",			TITLE, 0 },
X    { "title",			TITLE, 0 },
X    { "titlebackground",	CLKEYWORD, kwcl_TitleBackground },
X    { "titlebuttonborderwidth",	NKEYWORD, kwn_TitleButtonBorderWidth },
X    { "titlefont",		SKEYWORD, kws_TitleFont },
X    { "titleforeground",	CLKEYWORD, kwcl_TitleForeground },
X    { "titlehighlight",		TITLE_HILITE, 0 },
X    { "titlepadding",		NKEYWORD, kwn_TitlePadding },
X    { "unknownicon",		SKEYWORD, kws_UnknownIcon },
X    { "usepposition",		SKEYWORD, kws_UsePPosition },
X    { "virtualdesktop",		SKEYWORD, kws_VirtualDesktop },
X    { "virtualdesktopbackground",CKEYWORD, kwc_VirtualDesktopBackground },
X    { "virtualdesktopbackgroundpixmap",SKEYWORD,
X				    kws_VirtualDesktopBackgroundPixmap },
X    { "virtualdesktopforeground",CKEYWORD, kwc_VirtualDesktopForeground },
X    { "w",			WINDOW, 0 },
X    { "wait",			WAIT, 0 },
X    { "warpcursor",		WARP_CURSOR, 0 },
X    { "warpunmapped",		KEYWORD, kw0_WarpUnmapped },
X    { "west",			DKEYWORD, D_WEST },
X    { "window",			WINDOW, 0 },
X    { "windowfunction",		WINDOW_FUNCTION, 0 },
X    { "windowring",		WINDOW_RING, 0 },
X    { "xorvalue",		NKEYWORD, kwn_XorValue },
X    { "zoom",			ZOOM, 0 },
X};
X
Xstatic int numkeywords = (sizeof(keytable)/sizeof(keytable[0]));
X
Xint parse_keyword (s, nump)
X    char *s;
X    int *nump;
X{
X    register int lower = 0, upper = numkeywords - 1;
X
X    XmuCopyISOLatin1Lowered (s, s);
X    while (lower <= upper) {
X        int middle = (lower + upper) / 2;
X	TwmKeyword *p = &keytable[middle];
X        int res = strcmp (p->name, s);
X
X        if (res < 0) {
X            lower = middle + 1;
X        } else if (res == 0) {
X	    *nump = p->subnum;
X            return p->value;
X        } else {
X            upper = middle - 1;
X        }
X    }
X    return ERRORTOKEN;
X}
X
X
X
X/*
X * action routines called by grammar
X */
X
Xint do_single_keyword (keyword)
X    int keyword;
X{
X    switch (keyword) {
X      case kw0_NoDefaults:
X	Scr->NoDefaults = TRUE;
X	return 1;
X
X      case kw0_AutoRelativeResize:
X	Scr->AutoRelativeResize = TRUE;
X	return 1;
X
X      case kw0_ForceIcons:
X	if (Scr->FirstTime) Scr->ForceIcon = TRUE;
X	return 1;
X
X      case kw0_NoIconManagers:
X	Scr->NoIconManagers = TRUE;
X	return 1;
X
X      case kw0_OpaqueMove:
X	Scr->OpaqueMove = TRUE;
X	return 1;
X
X      case kw0_InterpolateMenuColors:
X	if (Scr->FirstTime) Scr->InterpolateMenuColors = TRUE;
X	return 1;
X
X      case kw0_NoVersion:
X	/* obsolete */
X	return 1;
X
X      case kw0_SortIconManager:
X	if (Scr->FirstTime) Scr->SortIconMgr = TRUE;
X	return 1;
X
X      case kw0_NoGrabServer:
X	Scr->NoGrabServer = TRUE;
X	return 1;
X
X      case kw0_NoMenuShadows:
X	if (Scr->FirstTime) Scr->Shadow = FALSE;
X	return 1;
X
X      case kw0_NoRaiseOnMove:
X	if (Scr->FirstTime) Scr->NoRaiseMove = TRUE;
X	return 1;
X
X      case kw0_NoRaiseOnResize:
X	if (Scr->FirstTime) Scr->NoRaiseResize = TRUE;
X	return 1;
X
X      case kw0_NoRaiseOnDeiconify:
X	if (Scr->FirstTime) Scr->NoRaiseDeicon = TRUE;
X	return 1;
X
X      case kw0_DontMoveOff:
X	Scr->DontMoveOff = TRUE;
X	return 1;
X
X      case kw0_NoBackingStore:
X	Scr->BackingStore = FALSE;
X	return 1;
X
X      case kw0_NoSaveUnders:
X	Scr->SaveUnder = FALSE;
X	return 1;
X
X      case kw0_RestartPreviousState:
X	RestartPreviousState = True;
X	return 1;
X
X      case kw0_ClientBorderWidth:
X	if (Scr->FirstTime) Scr->ClientBorderWidth = TRUE;
X	return 1;
X
X      case kw0_NoTitleFocus:
X	Scr->TitleFocus = FALSE;
X	return 1;
X
X      case kw0_RandomPlacement:
X	Scr->RandomPlacement = TRUE;
X	return 1;
X
X      case kw0_DecorateTransients:
X	Scr->DecorateTransients = TRUE;
X	return 1;
X
X      case kw0_ShowIconManager:
X	Scr->ShowIconManager = TRUE;
X	return 1;
X
X      case kw0_NoCaseSensitive:
X	Scr->CaseSensitive = FALSE;
X	return 1;
X
X      case kw0_NoRaiseOnWarp:
X	Scr->NoRaiseWarp = TRUE;
X	return 1;
X
X      case kw0_WarpUnmapped:
X	Scr->WarpUnmapped = TRUE;
X	return 1;
X    }
X
X    return 0;
X}
X
X
Xint do_string_keyword (keyword, s)
X    int keyword;
X    char *s;
X{
X    switch (keyword) {
X      case kws_VirtualDesktopBackgroundPixmap:
X	Scr->vdtPixmap = s;
X	return 1;
X
X      case kws_PannerBackgroundPixmap:
X	Scr->PannerPixmap = s;
X	return 1;
X
X      case kws_VirtualDesktop:
X	{
X	    int status, width, height, x, y;
X
X	    status = XParseGeometry(s, &x, &y, &width, &height);
X	    if ((status & (WidthValue & HeightValue)) != (WidthValue & HeightValue)) {
X		twmrc_error_prefix();
X		fprintf (stderr,
X			 "ignoring invalid VirtualDesktop geometry \"%s\"\n", s);
X	    } else {
X	   	Scr->VirtualDesktop = True; 
X		Scr->vdtWidth = width;
X		Scr->vdtHeight = height;
X	    }
X	    return 1;
X	}
X
X      case kws_PannerState:
X	{
X	    int state = ParseState(s);
X	    if (state < 0) {
X		twmrc_error_prefix();
X		fprintf (stderr,
X			 "ignoring invalid PannerState argument \"%s\"\n", s);
X	    } else {
X		Scr->PannerState = state;
X	    }
X	    return 1;
X	}
X
X      case kws_PannerGeometry:
X	{
X	    int status, width, height, x, y;
X	    status = XParseGeometry(s, &x, &y, &width, &height);
X	    if ((status & (XValue & YValue)) != (XValue & YValue)) {
X		twmrc_error_prefix();
X		fprintf (stderr,
X			 "ignoring invalid PannerGeometry \"%s\"\n", s);
X	    } else {
X		Scr->PannerGeometry = s;
X	    }
X	    return 1;
X	}
X
X      case kws_UsePPosition:
X	{ 
X	    int ppos = ParseUsePPosition (s);
X	    if (ppos < 0) {
X		twmrc_error_prefix();
X		fprintf (stderr,
X			 "ignoring invalid UsePPosition argument \"%s\"\n", s);
X	    } else {
X		Scr->UsePPosition = ppos;
X	    }
X	    return 1;
X	}
X
X      case kws_IconFont:
X	if (!Scr->HaveFonts) Scr->IconFont.name = s;
X	return 1;
X
X      case kws_ResizeFont:
X	if (!Scr->HaveFonts) Scr->SizeFont.name = s;
X	return 1;
X
X      case kws_MenuFont:
X	if (!Scr->HaveFonts) Scr->MenuFont.name = s;
X	return 1;
X
X      case kws_TitleFont:
X	if (!Scr->HaveFonts) Scr->TitleBarFont.name = s;
X	return 1;
X
X      case kws_IconManagerFont:
X	if (!Scr->HaveFonts) Scr->IconManagerFont.name = s;
X	return 1;
X
X      case kws_UnknownIcon:
X	if (Scr->FirstTime) GetUnknownIcon (s);
X	return 1;
X
X      case kws_IconDirectory:
X	if (Scr->FirstTime) Scr->IconDirectory = ExpandFilename (s);
X	return 1;
X
X      case kws_MaxWindowSize:
X	JunkMask = XParseGeometry (s, &JunkX, &JunkY, &JunkWidth, &JunkHeight);
X	if ((JunkMask & (WidthValue | HeightValue)) != 
X	    (WidthValue | HeightValue)) {
X	    twmrc_error_prefix();
X	    fprintf (stderr, "bad MaxWindowSize \"%s\"\n", s);
X	    return 0;
X	}
X	if (JunkWidth <= 0 || JunkHeight <= 0) {
X	    twmrc_error_prefix();
X	    fprintf (stderr, "MaxWindowSize \"%s\" must be positive\n", s);
X	    return 0;
X	}
X	Scr->MaxWindowWidth = JunkWidth;
X	Scr->MaxWindowHeight = JunkHeight;
X	return 1;
X    }
X
X    return 0;
X}
X
X
Xint do_number_keyword (keyword, num)
X    int keyword;
X    int num;
X{
X    switch (keyword) {
X      case kwn_PannerScale:
X	if (num > 0)
X	    Scr->PannerScale = num;
X	return 1;
X
X      case kwn_ConstrainedMoveTime:
X	ConstrainedMoveTime = num;
X	return 1;
X
X      case kwn_MoveDelta:
X	Scr->MoveDelta = num;
X	return 1;
X
X      case kwn_XorValue:
X	if (Scr->FirstTime) Scr->XORvalue = num;
X	return 1;
X
X      case kwn_FramePadding:
X	if (Scr->FirstTime) Scr->FramePadding = num;
X	return 1;
X
X      case kwn_TitlePadding:
X	if (Scr->FirstTime) Scr->TitlePadding = num;
X	return 1;
X
X      case kwn_ButtonIndent:
X	if (Scr->FirstTime) Scr->ButtonIndent = num;
X	return 1;
X
X      case kwn_BorderWidth:
X	if (Scr->FirstTime) Scr->BorderWidth = num;
X	return 1;
X
X      case kwn_IconBorderWidth:
X	if (Scr->FirstTime) Scr->IconBorderWidth = num;
X	return 1;
X
X      case kwn_TitleButtonBorderWidth:
X	if (Scr->FirstTime) Scr->TBInfo.border = num;
X	return 1;
X
X    }
X
X    return 0;
X}
X
Xname_list **do_colorlist_keyword (keyword, colormode, s)
X    int keyword;
X    int colormode;
X    char *s;
X{
X    switch (keyword) {
X      case kwcl_BorderColor:
X	GetColor (colormode, &Scr->BorderColor, s);
X	return &Scr->BorderColorL;
X
X      case kwcl_IconManagerHighlight:
X	GetColor (colormode, &Scr->IconManagerHighlight, s);
X	return &Scr->IconManagerHighlightL;
X
X      case kwcl_BorderTileForeground:
X	GetColor (colormode, &Scr->BorderTileC.fore, s);
X	return &Scr->BorderTileForegroundL;
X
X      case kwcl_BorderTileBackground:
X	GetColor (colormode, &Scr->BorderTileC.back, s);
X	return &Scr->BorderTileBackgroundL;
X
X      case kwcl_TitleForeground:
X	GetColor (colormode, &Scr->TitleC.fore, s);
X	return &Scr->TitleForegroundL;
X
X      case kwcl_TitleBackground:
X	GetColor (colormode, &Scr->TitleC.back, s);
X	return &Scr->TitleBackgroundL;
X
X      case kwcl_IconForeground:
X	GetColor (colormode, &Scr->IconC.fore, s);
X	return &Scr->IconForegroundL;
X
X      case kwcl_IconBackground:
X	GetColor (colormode, &Scr->IconC.back, s);
X	return &Scr->IconBackgroundL;
X
X      case kwcl_IconBorderColor:
X	GetColor (colormode, &Scr->IconBorderColor, s);
X	return &Scr->IconBorderColorL;
X
X      case kwcl_IconManagerForeground:
X	GetColor (colormode, &Scr->IconManagerC.fore, s);
X	return &Scr->IconManagerFL;
X
X      case kwcl_IconManagerBackground:
X	GetColor (colormode, &Scr->IconManagerC.back, s);
X	return &Scr->IconManagerBL;
X    }
X
X    return NULL;
X}
X
Xint do_color_keyword (keyword, colormode, s)
X    int keyword;
X    int colormode;
X    char *s;
X{
X    switch (keyword) {
X      case kwc_PannerBackground:
X	GetColor (colormode, &Scr->PannerC.back, s);
X	Scr->PannerBackgroundSet = True;
X	return 1;
X
X      case kwc_PannerForeground:
X	GetColor (colormode, &Scr->PannerC.fore, s);
X	return 1;
X
X      case kwc_VirtualDesktopBackground:
X	GetColor (colormode, &Scr->vdtC.back, s);
X	Scr->vdtBackgroundSet = True;
X	return 1;
X
X      case kwc_VirtualDesktopForeground:
X	GetColor (colormode, &Scr->vdtC.fore, s);
X	return 1;
X
X      case kwc_DefaultForeground:
X	GetColor (colormode, &Scr->DefaultC.fore, s);
X	return 1;
X
X      case kwc_DefaultBackground:
X	GetColor (colormode, &Scr->DefaultC.back, s);
X	return 1;
X
X      case kwc_MenuForeground:
X	GetColor (colormode, &Scr->MenuC.fore, s);
X	return 1;
X
X      case kwc_MenuBackground:
X	GetColor (colormode, &Scr->MenuC.back, s);
X	return 1;
X
X      case kwc_MenuTitleForeground:
X	GetColor (colormode, &Scr->MenuTitleC.fore, s);
X	return 1;
X
X      case kwc_MenuTitleBackground:
X	GetColor (colormode, &Scr->MenuTitleC.back, s);
X	return 1;
X
X      case kwc_MenuShadowColor:
X	GetColor (colormode, &Scr->MenuShadowColor, s);
X	return 1;
X
X    }
X
X    return 0;
X}
X
X
Xstatic int ParseUsePPosition (s)
X    register char *s;
X{
X    XmuCopyISOLatin1Lowered (s, s);
X
X    if (strcmp (s, "off") == 0) {
X	return PPOS_OFF;
X    } else if (strcmp (s, "on") == 0) {
X	return PPOS_ON;
X    } else if (strcmp (s, "non-zero") == 0 ||
X	       strcmp (s, "nonzero") == 0) {
X	return PPOS_NON_ZERO;
X    }
X
X    return -1;
X}
X
Xstatic int ParseState (s)
X    register char *s;
X{
X    XmuCopyISOLatin1Lowered (s, s);
X
X    if (strcmp (s, "withdrawn") == 0) {
X	return WithdrawnState;
X    } else if (strcmp (s, "normal") == 0) {
X	return NormalState;
X    } else if (strcmp (s, "iconic") == 0) {
X	return IconicState;
X    }
X
X    return -1;
X}
X
X
Xdo_squeeze_entry (list, name, justify, num, denom)
X    name_list **list;			/* squeeze or dont-squeeze list */
X    char *name;				/* window name */
X    int justify;			/* left, center, right */
X    int num;				/* signed num */
X    int denom;				/* 0 or indicates fraction denom */
X{
X    int absnum = (num < 0 ? -num : num);
X
X    if (denom < 0) {
X	twmrc_error_prefix();
X	fprintf (stderr, "negative SqueezeTitle denominator %d\n", denom);
X	return;
X    }
X    if (absnum > denom && denom != 0) {
X	twmrc_error_prefix();
X	fprintf (stderr, "SqueezeTitle fraction %d/%d outside window\n",
X		 num, denom);
X	return;
X    }
X    if (denom == 1) {
X	twmrc_error_prefix();
X	fprintf (stderr, "useless SqueezeTitle faction %d/%d, assuming 0/0\n",
X		 num, denom);
X	num = 0;
X	denom = 0;
X    }
X
X#ifdef SHAPE
X    if (HasShape) {
X	SqueezeInfo *sinfo;
X	sinfo = (SqueezeInfo *) malloc (sizeof(SqueezeInfo));
X
X	if (!sinfo) {
X	    twmrc_error_prefix();
X	    fprintf (stderr, "unable to allocate %d bytes for squeeze info\n",
X		     sizeof(SqueezeInfo));
X	    return;
X	}
X	sinfo->justify = justify;
X	sinfo->num = num;
X	sinfo->denom = denom;
X	AddToList (list, name, (char *) sinfo);
X    }
X#endif
X}
SHAR_EOF
if test 31268 -ne "`wc -c < parse.c`"
then
    echo shar: error transmitting "parse.c" '(should have been 31268 characters)'
fi
fi
if test -f 'resize.c'
then
    echo shar: will not over-write existing file "resize.c"
else
echo extracting "resize.c"
sed 's/^X//' >resize.c <<'SHAR_EOF'
X/*****************************************************************************/
X/**       Copyright 1988 by Evans & Sutherland Computer Corporation,        **/
X/**                          Salt Lake City, Utah                           **/
X/**  Portions Copyright 1989 by the Massachusetts Institute of Technology   **/
X/**                        Cambridge, Massachusetts                         **/
X/**                                                                         **/
X/**                           All Rights Reserved                           **/
X/**                                                                         **/
X/**    Permission to use, copy, modify, and distribute this software and    **/
X/**    its documentation  for  any  purpose  and  without  fee is hereby    **/
X/**    granted, provided that the above copyright notice appear  in  all    **/
X/**    copies and that both  that  copyright  notice  and  this  permis-    **/
X/**    sion  notice appear in supporting  documentation,  and  that  the    **/
X/**    names of Evans & Sutherland and M.I.T. not be used in advertising    **/
X/**    in publicity pertaining to distribution of the  software  without    **/
X/**    specific, written prior permission.                                  **/
X/**                                                                         **/
X/**    EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD    **/
X/**    TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES  OF  MERCHANT-    **/
X/**    ABILITY  AND  FITNESS,  IN  NO  EVENT SHALL EVANS & SUTHERLAND OR    **/
X/**    M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL  DAM-    **/
X/**    AGES OR  ANY DAMAGES WHATSOEVER  RESULTING FROM LOSS OF USE, DATA    **/
X/**    OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER    **/
X/**    TORTIOUS ACTION, ARISING OUT OF OR IN  CONNECTION  WITH  THE  USE    **/
X/**    OR PERFORMANCE OF THIS SOFTWARE.                                     **/
X/*****************************************************************************/
X
X
X/***********************************************************************
X *
X * $XConsortium: resize.c,v 1.69 90/03/27 11:55:03 jim Exp $
X *
X * window resizing borrowed from the "wm" window manager
X *
X * 11-Dec-87 Thomas E. LaStrange                File created
X *
X ***********************************************************************/
X
X#if !defined(lint) && !defined(SABER)
Xstatic char RCSinfo[]=
X"$XConsortium: resize.c,v 1.69 90/03/27 11:55:03 jim Exp $";
X#endif
X
X#include <stdio.h>
X#include "twm.h"
X#include "parse.h"
X#include "util.h"
X#include "resize.h"
X#include "add_window.h"
X#include "screen.h"
X
X#define MINHEIGHT 0     /* had been 32 */
X#define MINWIDTH 0      /* had been 60 */
X
Xstatic int dragx;       /* all these variables are used */
Xstatic int dragy;       /* in resize operations */
Xstatic int dragWidth;
Xstatic int dragHeight;
X
Xstatic int origx;
Xstatic int origy;
Xstatic int origWidth;
Xstatic int origHeight;
X
Xstatic int clampTop;
Xstatic int clampBottom;
Xstatic int clampLeft;
Xstatic int clampRight;
Xstatic int clampDX;
Xstatic int clampDY;
X
Xstatic int last_width;
Xstatic int last_height;
X
X
Xstatic void do_auto_clamp (tmp_win, evp)
X    TwmWindow *tmp_win;
X    XEvent *evp;
X{
X    Window junkRoot;
X    int x, y, h, v, junkbw;
X    unsigned int junkMask;
X
X    switch (evp->type) {
X      case ButtonPress:
X	x = evp->xbutton.x_root;
X	y = evp->xbutton.y_root;
X	break;
X      case KeyPress:
X	x = evp->xkey.x_root;
X	y = evp->xkey.y_root;
X	break;
X      default:
X	if (!XQueryPointer (dpy, Scr->Root, &junkRoot, &junkRoot,
X			    &x, &y, &junkbw, &junkbw, &junkMask))
X	  return;
X    }
X
X    h = ((x - dragx) / (dragWidth < 3 ? 1 : (dragWidth / 3)));
X    v = ((y - dragy - tmp_win->title_height) / 
X	 (dragHeight < 3 ? 1 : (dragHeight / 3)));
X	
X    if (h <= 0) {
X	clampLeft = 1;
X	clampDX = (x - dragx);
X    } else if (h >= 2) {
X	clampRight = 1;
X	clampDX = (x - dragx - dragWidth);
X    }
X
X    if (v <= 0) {
X	clampTop = 1;
X	clampDY = (y - dragy);
X    } else if (v >= 2) {
X	clampBottom = 1;
X	clampDY = (y - dragy - dragHeight);
X    }
X}
X
X
X/***********************************************************************
X *
X *  Procedure:
X *      StartResize - begin a window resize operation
X *
X *  Inputs:
X *      ev      - the event structure (button press)
X *      tmp_win - the TwmWindow pointer
X *      fromtitlebar - action invoked from titlebar button
X *
X ***********************************************************************
X */
X
Xvoid
XStartResize(evp, tmp_win, fromtitlebar)
XXEvent *evp;
XTwmWindow *tmp_win;
XBool fromtitlebar;
X{
X    Window      junkRoot;
X    unsigned int junkbw, junkDepth;
X
X    ResizeWindow = tmp_win->frame;
X    XGrabServer(dpy);
X    XGrabPointer(dpy, Scr->Root, True,
X        ButtonPressMask | ButtonReleaseMask,
X        GrabModeAsync, GrabModeAsync,
X        Scr->Root, Scr->ResizeCursor, CurrentTime);
X
X    XGetGeometry(dpy, (Drawable) tmp_win->frame, &junkRoot,
X        &dragx, &dragy, (unsigned int *)&dragWidth, (unsigned int *)&dragHeight, &junkbw,
X                 &junkDepth);
X    dragx += tmp_win->frame_bw;
X    dragy += tmp_win->frame_bw;
X    origx = dragx;
X    origy = dragy;
X    origWidth = dragWidth;
X    origHeight = dragHeight;
X    clampTop = clampBottom = clampLeft = clampRight = clampDX = clampDY = 0;
X
X    if (Scr->AutoRelativeResize && !fromtitlebar)
X      do_auto_clamp (tmp_win, evp);
X
X    Scr->SizeStringOffset = SIZE_HINDENT;
X    XResizeWindow (dpy, Scr->SizeWindow,
X		   Scr->SizeStringWidth + SIZE_HINDENT * 2, 
X		   Scr->SizeFont.height + SIZE_VINDENT * 2);
X    XMapRaised(dpy, Scr->SizeWindow);
X    InstallRootColormap();
X    last_width = 0;
X    last_height = 0;
X    DisplaySize(tmp_win, origWidth, origHeight);
X    MoveOutline (Scr->Root, dragx - tmp_win->frame_bw,
X		 dragy - tmp_win->frame_bw, dragWidth + 2 * tmp_win->frame_bw,
X		 dragHeight + 2 * tmp_win->frame_bw,
X		 tmp_win->frame_bw, tmp_win->title_height);
X}
X
X/***********************************************************************
X *
X *  Procedure:
X *      AddStartResize - begin a window resize operation from AddWindow
X *
X *  Inputs:
X *      tmp_win - the TwmWindow pointer
X *
X ***********************************************************************
X */
X
Xvoid
XAddStartResize(tmp_win, x, y, w, h)
XTwmWindow *tmp_win;
Xint x, y, w, h;
X{
X    XGrabServer(dpy);
X    XGrabPointer(dpy, Scr->Root, True,
X        ButtonReleaseMask,
X        GrabModeAsync, GrabModeAsync,
X        Scr->Root, Scr->ResizeCursor, CurrentTime);
X
X    dragx = x + tmp_win->frame_bw;
X    dragy = y + tmp_win->frame_bw;
X    origx = dragx;
X    origy = dragy;
X    dragWidth = origWidth = w - 2 * tmp_win->frame_bw;
X    dragHeight = origHeight = h - 2 * tmp_win->frame_bw;
X    clampTop = clampBottom = clampLeft = clampRight = clampDX = clampDY = 0;
X
X    if (Scr->AutoRelativeResize) {
X	clampRight = clampBottom = 1;
X    }
X
X    last_width = 0;
X    last_height = 0;
X    DisplaySize(tmp_win, origWidth, origHeight);
X}
X
X/***********************************************************************
X *
X *  Procedure:
X *      DoResize - move the rubberband around.  This is called for
X *                 each motion event when we are resizing
X *
X *  Inputs:
X *      x_root  - the X corrdinate in the root window
X *      y_root  - the Y corrdinate in the root window
X *      tmp_win - the current twm window
X *
X ***********************************************************************
X */
X
Xvoid
XDoResize(x_root, y_root, tmp_win)
Xint x_root;
Xint y_root;
XTwmWindow *tmp_win;
X{
X    int action;
X
X    action = 0;
X
X    x_root -= clampDX;
X    y_root -= clampDY;
X
X    if (clampTop) {
X        int         delta = y_root - dragy;
X        if (dragHeight - delta < MINHEIGHT) {
X            delta = dragHeight - MINHEIGHT;
X            clampTop = 0;
X        }
X        dragy += delta;
X        dragHeight -= delta;
X        action = 1;
X    }
X    else if (y_root <= dragy/* ||
X             y_root == findRootInfo(root)->rooty*/) {
X        dragy = y_root;
X        dragHeight = origy + origHeight -
X            y_root;
X        clampBottom = 0;
X        clampTop = 1;
X	clampDY = 0;
X        action = 1;
X    }
X    if (clampLeft) {
X        int         delta = x_root - dragx;
X        if (dragWidth - delta < MINWIDTH) {
X            delta = dragWidth - MINWIDTH;
X            clampLeft = 0;
X        }
X        dragx += delta;
X        dragWidth -= delta;
X        action = 1;
X    }
X    else if (x_root <= dragx/* ||
X             x_root == findRootInfo(root)->rootx*/) {
X        dragx = x_root;
X        dragWidth = origx + origWidth -
X            x_root;
X        clampRight = 0;
X        clampLeft = 1;
X	clampDX = 0;
X        action = 1;
X    }
X    if (clampBottom) {
X        int         delta = y_root - dragy - dragHeight;
X        if (dragHeight + delta < MINHEIGHT) {
X            delta = MINHEIGHT - dragHeight;
X            clampBottom = 0;
X        }
X        dragHeight += delta;
X        action = 1;
X    }
X    else if (y_root >= dragy + dragHeight - 1/* ||
X           y_root == findRootInfo(root)->rooty
X           + findRootInfo(root)->rootheight - 1*/) {
X        dragy = origy;
X        dragHeight = 1 + y_root - dragy;
X        clampTop = 0;
X        clampBottom = 1;
X	clampDY = 0;
X        action = 1;
X    }
X    if (clampRight) {
X        int         delta = x_root - dragx - dragWidth;
X        if (dragWidth + delta < MINWIDTH) {
X            delta = MINWIDTH - dragWidth;
X            clampRight = 0;
X        }
X        dragWidth += delta;
X        action = 1;
X    }
X    else if (x_root >= dragx + dragWidth - 1/* ||
X             x_root == findRootInfo(root)->rootx +
X             findRootInfo(root)->rootwidth - 1*/) {
X        dragx = origx;
X        dragWidth = 1 + x_root - origx;
X        clampLeft = 0;
X        clampRight = 1;
X	clampDX = 0;
X        action = 1;
X    }
X
X    if (action) {
X        ConstrainSize (tmp_win, &dragWidth, &dragHeight);
X        if (clampLeft)
X            dragx = origx + origWidth - dragWidth;
X        if (clampTop)
X            dragy = origy + origHeight - dragHeight;
X        MoveOutline(Scr->Root,
X            dragx - tmp_win->frame_bw,
X            dragy - tmp_win->frame_bw,
X            dragWidth + 2 * tmp_win->frame_bw,
X            dragHeight + 2 * tmp_win->frame_bw,
X	    tmp_win->frame_bw, tmp_win->title_height);
X    }
X
X    DisplaySize(tmp_win, dragWidth, dragHeight);
X}
X
X/***********************************************************************
X *
X *  Procedure:
X *      DisplaySize - display the size in the dimensions window
X *
X *  Inputs:
X *      tmp_win - the current twm window
X *      width   - the width of the rubber band
X *      height  - the height of the rubber band
X *
X ***********************************************************************
X */
X
Xvoid
XDisplaySize(tmp_win, width, height)
XTwmWindow *tmp_win;
Xint width;
Xint height;
X{
X    char str[100];
X    int dwidth;
X    int dheight;
X
X    if (last_width == width && last_height == height)
X        return;
X
X    last_width = width;
X    last_height = height;
X
X    dheight = height - tmp_win->title_height;
X    dwidth = width;
X
X    /*
X     * ICCCM says that PMinSize is the default is no PBaseSize is given,
X     * and vice-versa.
X     */
X    if (tmp_win->hints.flags&(PMinSize|PBaseSize) && tmp_win->hints.flags & PResizeInc)
X    {
X	if (tmp_win->hints.flags & PBaseSize) {
X	    dwidth -= tmp_win->hints.base_width;
X	    dheight -= tmp_win->hints.base_height;
X	} else {
X	    dwidth -= tmp_win->hints.min_width;
X	    dheight -= tmp_win->hints.min_height;
X	}
X    }
X
X    if (tmp_win->hints.flags & PResizeInc)
X    {
X        dwidth /= tmp_win->hints.width_inc;
X        dheight /= tmp_win->hints.height_inc;
X    }
X
X    if (tmp_win->w == Scr->Panner) {
X	dwidth *= Scr->PannerScale;
X	dheight *= Scr->PannerScale;
X    }
X    (void) sprintf (str, " %4d x %-4d ", dwidth, dheight);
X    XRaiseWindow(dpy, Scr->SizeWindow);
X    FBF(Scr->DefaultC.fore, Scr->DefaultC.back, Scr->SizeFont.font->fid);
X    XDrawImageString (dpy, Scr->SizeWindow, Scr->NormalGC,
X		      Scr->SizeStringOffset,
X		      Scr->SizeFont.font->ascent + SIZE_VINDENT,
X		      str, 13);
X}
X
X/***********************************************************************
X *
X *  Procedure:
X *      EndResize - finish the resize operation
X *
X ***********************************************************************
X */
X
Xvoid
XEndResize()
X{
X    TwmWindow *tmp_win;
X
X#ifdef DEBUG
X    fprintf(stderr, "EndResize\n");
X#endif
X
X    MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
X    XUnmapWindow(dpy, Scr->SizeWindow);
X
X    XFindContext(dpy, ResizeWindow, TwmContext, (caddr_t *)&tmp_win);
X
X    ConstrainSize (tmp_win, &dragWidth, &dragHeight);
X
X    if (dragWidth != tmp_win->frame_width ||
X        dragHeight != tmp_win->frame_height)
X            tmp_win->zoomed = ZOOM_NONE;
X
X    SetupWindow (tmp_win, dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw,
X		 dragWidth, dragHeight, -1);
X
X    if (tmp_win->iconmgr)
X    {
X	int ncols = tmp_win->iconmgrp->cur_columns;
X	if (ncols == 0) ncols = 1;
X
X	tmp_win->iconmgrp->width = (int) ((dragWidth *
X					   (long) tmp_win->iconmgrp->columns)
X					  / ncols);
X        PackIconManager(tmp_win->iconmgrp);
X    }
X
X    if (!Scr->NoRaiseResize)
X        RaiseFrame(dpy, tmp_win);
X
X    UninstallRootColormap();
X
X    ResizeWindow = NULL;
X}
X
X/***********************************************************************
X *
X *  Procedure:
X *      AddEndResize - finish the resize operation for AddWindow
X *
X ***********************************************************************
X */
X
Xvoid
XAddEndResize(tmp_win)
XTwmWindow *tmp_win;
X{
X
X#ifdef DEBUG
X    fprintf(stderr, "AddEndResize\n");
X#endif
X
X    ConstrainSize (tmp_win, &dragWidth, &dragHeight);
X    AddingX = dragx;
X    AddingY = dragy;
X    AddingW = dragWidth + (2 * tmp_win->frame_bw);
X    AddingH = dragHeight + (2 * tmp_win->frame_bw);
X}
X
X/***********************************************************************
X *
X *  Procedure:
X *      ConstrainSize - adjust the given width and height to account for the
X *              constraints imposed by size hints
X *
X *      The general algorithm, especially the aspect ratio stuff, is
X *      borrowed from uwm's CheckConsistency routine.
X * 
X ***********************************************************************/
X
XConstrainSize (tmp_win, widthp, heightp)
X    TwmWindow *tmp_win;
X    int *widthp, *heightp;
X{
X#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
X#define _min(a,b) (((a) < (b)) ? (a) : (b))
X
X    int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
X    int baseWidth, baseHeight;
X    int dwidth = *widthp, dheight = *heightp;
X
X
X    dheight -= tmp_win->title_height;
X
X    if (tmp_win->hints.flags & PMinSize) {
X        minWidth = tmp_win->hints.min_width;
X        minHeight = tmp_win->hints.min_height;
X    } else if (tmp_win->hints.flags & PBaseSize) {
X        minWidth = tmp_win->hints.base_width;
X        minHeight = tmp_win->hints.base_height;
X    } else
X        minWidth = minHeight = 1;
X
X    if (tmp_win->hints.flags & PBaseSize) {
X	baseWidth = tmp_win->hints.base_width;
X	baseHeight = tmp_win->hints.base_height;
X    } else if (tmp_win->hints.flags & PMinSize) {
X	baseWidth = tmp_win->hints.min_width;
X	baseHeight = tmp_win->hints.min_height;
X    } else
X	baseWidth = baseHeight = 0;
X
X
X    if (tmp_win->hints.flags & PMaxSize) {
X        maxWidth = _min (Scr->MaxWindowWidth, tmp_win->hints.max_width);
X        maxHeight = _min (Scr->MaxWindowHeight, tmp_win->hints.max_height);
X    } else {
X        maxWidth = Scr->MaxWindowWidth;
X	maxHeight = Scr->MaxWindowHeight;
X    }
X
X    if (tmp_win->hints.flags & PResizeInc) {
X        xinc = tmp_win->hints.width_inc;
X        yinc = tmp_win->hints.height_inc;
X    } else
X        xinc = yinc = 1;
X
X    /*
X     * First, clamp to min and max values
X     */
X    if (dwidth < minWidth) dwidth = minWidth;
X    if (dheight < minHeight) dheight = minHeight;
X
X    if (dwidth > maxWidth) dwidth = maxWidth;
X    if (dheight > maxHeight) dheight = maxHeight;
X
X
X    /*
X     * Second, fit to base + N * inc
X     */
X    dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
X    dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
X
X
X    /*
X     * Third, adjust for aspect ratio
X     */
X#define maxAspectX tmp_win->hints.max_aspect.x
X#define maxAspectY tmp_win->hints.max_aspect.y
X#define minAspectX tmp_win->hints.min_aspect.x
X#define minAspectY tmp_win->hints.min_aspect.y
X    if (tmp_win->hints.flags & PAspect)
X    {
X        if (dwidth * maxAspectX > dheight * maxAspectY)
X        {
X            delta = makemult(dwidth * maxAspectY / maxAspectX - dheight,
X                             yinc);
X            if (dheight + delta <= maxHeight) dheight += delta;
X            else
X            {
X                delta = makemult(dwidth - maxAspectX*dheight/maxAspectY,
X                                 xinc);
X                if (dwidth - delta >= minWidth) dwidth -= delta;
X            }
X        }
X
X        if (dwidth * minAspectX < dheight * minAspectY)
X        {
X            delta = makemult(minAspectX * dheight / minAspectY - dwidth,
X                             xinc);
X            if (dwidth + delta <= maxWidth) dwidth += delta;
X            else
X            {
X                delta = makemult(dheight - dwidth*minAspectY/minAspectX,
X                                 yinc);
X                if (dheight - delta >= minHeight) dheight -= delta;
X            }
X        }
X    }
X
X
X    /*
X     * Fourth, account for border width and title height
X     */
X    *widthp = dwidth;
X    *heightp = dheight + tmp_win->title_height;
X}
X
X
X/***********************************************************************
X *
X *  Procedure:
X *      SetupWindow - set window sizes, this was called from either
X *              AddWindow, EndResize, or HandleConfigureNotify.
X *
X *  Inputs:
X *      tmp_win - the TwmWindow pointer
X *      x       - the x coordinate of the upper-left outer corner of the frame
X *      y       - the y coordinate of the upper-left outer corner of the frame
X *      w       - the width of the frame window w/o border
X *      h       - the height of the frame window w/o border
X *      bw      - the border width of the frame window or -1 not to change
X *
X *  Special Considerations:
X *      This routine will check to make sure the window is not completely
X *      off the display, if it is, it'll bring some of it back on.
X *
X *      The tmp_win->frame_XXX variables should NOT be updated with the
X *      values of x,y,w,h prior to calling this routine, since the new
X *      values are compared against the old to see whether a synthetic
X *      ConfigureNotify event should be sent.  (It should be sent if the
X *      window was moved but not resized.)
X *
X ***********************************************************************
X */
X
Xvoid SetupWindow (tmp_win, x, y, w, h, bw)
X    TwmWindow *tmp_win;
X    int x, y, w, h, bw;
X{
X    SetupFrame (tmp_win, x, y, w, h, bw, False);
X}
X
Xvoid SetupFrame (tmp_win, x, y, w, h, bw, sendEvent)
X    TwmWindow *tmp_win;
X    int x, y, w, h, bw;
X    Bool sendEvent;			/* whether or not to force a send */
X{
X    XWindowChanges frame_wc, xwc;
X    unsigned long frame_mask, xwcm;
X    int title_width, title_height;
X#ifdef SHAPE
X    int reShape;
X#endif
X
X#ifdef DEBUG
X    fprintf (stderr, "SetupWindow: x=%d, y=%d, w=%d, h=%d, bw=%d\n",
X	     x, y, w, h, bw);
X#endif
X
X    if (!Scr->VirtualDesktop) {
X	if (x >= Scr->MyDisplayWidth)
X	  x = Scr->MyDisplayWidth - 16;		/* one "average" cursor width */
X	if (y >= Scr->MyDisplayHeight)
X	  y = Scr->MyDisplayHeight - 16;	/* one "average" cursor width */
X    }
X    if (bw < 0)
X      bw = tmp_win->frame_bw;		/* -1 means current frame width */
X
X    if (tmp_win->iconmgr) {
X	tmp_win->iconmgrp->width = w;
X        h = tmp_win->iconmgrp->height + tmp_win->title_height;
X    }
X
X    /*
X     * According to the July 27, 1988 ICCCM draft, we should send a
X     * "synthetic" ConfigureNotify event to the client if the window
X     * was moved but not resized.
X     */
X    if (((x != tmp_win->frame_x || y != tmp_win->frame_y) &&
X	 (w == tmp_win->frame_width && h == tmp_win->frame_height)) ||
X	(bw != tmp_win->frame_bw))
X      sendEvent = TRUE;
X
X    xwcm = CWWidth;
X    title_width = xwc.width = w;
X    title_height = Scr->TitleHeight + bw;
X
X    ComputeWindowTitleOffsets (tmp_win, xwc.width, True);
X
X#ifdef SHAPE
X    reShape = (tmp_win->wShaped ? TRUE : FALSE);
X    if (tmp_win->squeeze_info)		/* check for title shaping */
X    {
X	title_width = tmp_win->rightx + Scr->TBInfo.rightoff;
X	if (title_width < xwc.width)
X	{
X	    xwc.width = title_width;
X	    if (tmp_win->frame_height != h ||
X	    	tmp_win->frame_width != w ||
X		tmp_win->frame_bw != bw ||
X	    	title_width != tmp_win->title_width)
X	    	reShape = TRUE;
X	}
X	else
X	{
X	    if (!tmp_win->wShaped) reShape = TRUE;
X	    title_width = xwc.width;
X	}
X    }
X#endif
X
X    tmp_win->title_width = title_width;
X    if (tmp_win->title_height) tmp_win->title_height = title_height;
X
X    if (tmp_win->title_w) {
X	if (bw != tmp_win->frame_bw) {
X	    xwc.border_width = bw;
X	    tmp_win->title_x = xwc.x = -bw;
X	    tmp_win->title_y = xwc.y = -bw;
X	    xwcm |= (CWX | CWY | CWBorderWidth);
X	}
X	
X	XConfigureWindow(dpy, tmp_win->title_w, xwcm, &xwc);
X    }
X
X    tmp_win->attr.width = w;
X    tmp_win->attr.height = h - tmp_win->title_height;
X
X    XMoveResizeWindow (dpy, tmp_win->w, 0, tmp_win->title_height,
X		       w, h - tmp_win->title_height);
X    if (tmp_win->w == Scr->Panner)
X	ResizeDesktop(w, h-tmp_win->title_height);
X
X    /* 
X     * fix up frame and assign size/location values in tmp_win
X     */
X    frame_mask = 0;
X    if (bw != tmp_win->frame_bw) {
X	frame_wc.border_width = tmp_win->frame_bw = bw;
X	frame_mask |= CWBorderWidth;
X    }
X    frame_wc.x = tmp_win->frame_x = x;
X    frame_wc.y = tmp_win->frame_y = y;
X    frame_wc.width = tmp_win->frame_width = w;
X    frame_wc.height = tmp_win->frame_height = h;
X    frame_mask |= (CWX | CWY | CWWidth | CWHeight);
X    XConfigureWindow (dpy, tmp_win->frame, frame_mask, &frame_wc);
X
X    if (tmp_win->virtualWindow) {
X	int width, height;
X	width = tmp_win->frame_width / Scr->PannerScale;
X	height = tmp_win->frame_height / Scr->PannerScale;
X	if (width <= 0)
X	    width = 1;
X	if (height <= 0)
X	    height = 1;
X	XMoveResizeWindow(dpy, tmp_win->virtualWindow,
X	    tmp_win->frame_x / Scr->PannerScale,
X	    tmp_win->frame_y / Scr->PannerScale,
X	    width, height);
X    }
X    /*
X     * fix up highlight window
X     */
X    if (tmp_win->title_height && tmp_win->hilite_w)
X    {
X	xwc.width = (tmp_win->rightx - tmp_win->highlightx);
X	if (Scr->TBInfo.nright > 0) xwc.width -= Scr->TitlePadding;
X        if (xwc.width <= 0) {
X            xwc.x = Scr->MyDisplayWidth;	/* move offscreen */
X            xwc.width = 1;
X        } else {
X            xwc.x = tmp_win->highlightx;
X        }
X
X        xwcm = CWX | CWWidth;
X        XConfigureWindow(dpy, tmp_win->hilite_w, xwcm, &xwc);
X    }
X
X#ifdef SHAPE
X    if (HasShape && reShape) {
X	SetFrameShape (tmp_win);
X    }
X#endif
X
X    if (sendEvent)
X	SendSyntheticConfigureNotify(tmp_win);
X}
X
Xvoid
XSendSyntheticConfigureNotify(tmp_win)
XTwmWindow *tmp_win;
X{
X    XEvent client_event;
X
X    client_event.type = ConfigureNotify;
X    client_event.xconfigure.display = dpy;
X    client_event.xconfigure.event = tmp_win->w;
X    client_event.xconfigure.window = tmp_win->w;
X    client_event.xconfigure.x = (tmp_win->frame_x + tmp_win->frame_bw - tmp_win->old_bw);
X    client_event.xconfigure.y = (tmp_win->frame_y + tmp_win->frame_bw +
X				 tmp_win->title_height - tmp_win->old_bw);
X    if (Scr->VirtualDesktop && !tmp_win->sticky) {
X	client_event.xconfigure.x -= Scr->vdtPositionX;
X	client_event.xconfigure.y -= Scr->vdtPositionY;
X    }
X    client_event.xconfigure.width = tmp_win->frame_width;
X    client_event.xconfigure.height = tmp_win->frame_height -
X	    tmp_win->title_height;
X    client_event.xconfigure.border_width = tmp_win->old_bw;
X    /* Real ConfigureNotify events say we're above title window, so ... */
X    /* what if we don't have a title ????? */
X    client_event.xconfigure.above = tmp_win->frame;
X    client_event.xconfigure.override_redirect = False;
X    XSendEvent(dpy, tmp_win->w, False, StructureNotifyMask, &client_event);
X}
X
X
X/**********************************************************************
X *  Rutgers mod #1   - rocky.
X *  Procedure:
X *         fullzoom - zooms window to full height of screen or
X *                    to full height and width of screen. (Toggles
X *                    so that it can undo the zoom - even when switching
X *                    between fullzoom and vertical zoom.)
X *
X *  Inputs:
X *         tmp_win - the TwmWindow pointer
X *
X *
X **********************************************************************
X */
X
Xvoid
Xfullzoom(tmp_win,flag)
XTwmWindow *tmp_win;
Xint flag;
X{
X    Window      junkRoot;
X    unsigned int junkbw, junkDepth;
X
X    XGetGeometry(dpy, (Drawable) tmp_win->frame, &junkRoot,
X        &dragx, &dragy, (unsigned int *)&dragWidth, (unsigned int *)&dragHeight, &junkbw,
X        &junkDepth);
X
X        if (tmp_win->zoomed == flag)
X        {
X            dragHeight = tmp_win->save_frame_height;
X            dragWidth = tmp_win->save_frame_width;
X            dragx = tmp_win->save_frame_x;
X            dragy = tmp_win->save_frame_y;
X            tmp_win->zoomed = ZOOM_NONE;
X        }
X        else
X        {
X                if (tmp_win->zoomed == ZOOM_NONE)
X                {
X                        tmp_win->save_frame_x = dragx;
X                        tmp_win->save_frame_y = dragy;
X                        tmp_win->save_frame_width = dragWidth;
X                        tmp_win->save_frame_height = dragHeight;
X                        tmp_win->zoomed = flag;
X                 }
X                  else
X                            tmp_win->zoomed = flag;
X
X
X        switch (flag)
X        {
X        case ZOOM_NONE:
X            break;
X        case F_ZOOM:
X            dragHeight = Scr->MyDisplayHeight;
X            dragy=0;
X            break;
X        case F_HORIZOOM:
X            dragx = 0;
X            dragWidth = Scr->MyDisplayWidth;
X            break;
X        case F_FULLZOOM:
X            dragx = 0;
X            dragy = 0;
X            dragHeight = Scr->MyDisplayHeight;
X            dragWidth = Scr->MyDisplayWidth;
X            break;
X        case F_LEFTZOOM:
X            dragx = 0;
X            dragy = 0;
X            dragHeight = Scr->MyDisplayHeight;
X            dragWidth = Scr->MyDisplayWidth/2;
X            break;
X        case F_RIGHTZOOM:
X            dragx = Scr->MyDisplayWidth/2;
X            dragy = 0;
X            dragHeight = Scr->MyDisplayHeight;
X            dragWidth = Scr->MyDisplayWidth/2;
X            break;
X        case F_TOPZOOM:
X            dragx = 0;
X            dragy = 0;
X            dragHeight = Scr->MyDisplayHeight/2;
X            dragWidth = Scr->MyDisplayWidth;
X            break;
X        case F_BOTTOMZOOM:
X            dragx = 0;
X            dragy = Scr->MyDisplayHeight/2;
X            dragHeight = Scr->MyDisplayHeight/2;
X            dragWidth = Scr->MyDisplayWidth;
X            break;
X         }
X      }
X
X    if (!Scr->NoRaiseResize)
X        RaiseFrame(dpy, tmp_win);
X
X    dragHeight -= tmp_win->title_height;
X
X    if (tmp_win->hints.flags&PMinSize && tmp_win->hints.flags & PResizeInc)
X    {
X        dragWidth -= tmp_win->hints.min_width;
X        dragHeight -= tmp_win->hints.min_height;
X    }
X
X    if (tmp_win->hints.flags & PResizeInc)
X    {
X        dragWidth /= tmp_win->hints.width_inc;
X        dragHeight /= tmp_win->hints.height_inc;
X
X        dragWidth *= tmp_win->hints.width_inc;
X        dragHeight *= tmp_win->hints.height_inc;
X    }
X
X    if (tmp_win->hints.flags&PMinSize && tmp_win->hints.flags & PResizeInc)
X    {
X        dragWidth += tmp_win->hints.min_width;
X        dragHeight += tmp_win->hints.min_height;
X    }
X
X    dragHeight += tmp_win->title_height;
X
X    SetupWindow (tmp_win, dragx , dragy , dragWidth, dragHeight, -1);
X    XUngrabPointer (dpy, CurrentTime);
X    XUngrabServer (dpy);
X}
X
X#ifdef SHAPE
XSetFrameShape (tmp)
X    TwmWindow *tmp;
X{
X    /*
X     * see if the titlebar needs to move
X     */
X    if (tmp->title_w) {
X	int oldx = tmp->title_x, oldy = tmp->title_y;
X	ComputeTitleLocation (tmp);
X	if (oldx != tmp->title_x || oldy != tmp->title_y)
X	  XMoveWindow (dpy, tmp->title_w, tmp->title_x, tmp->title_y);
X    }
X
X    /*
X     * The frame consists of the shape of the contents window offset by
X     * title_height or'ed with the shape of title_w (which is always
X     * rectangular).
X     */
X    if (tmp->wShaped) {
X	/*
X	 * need to do general case
X	 */
X	XShapeCombineShape (dpy, tmp->frame, ShapeBounding,
X			    0, tmp->title_height, tmp->w,
X			    ShapeBounding, ShapeSet);
X	if (tmp->title_w) {
X	    XShapeCombineShape (dpy, tmp->frame, ShapeBounding,
X				tmp->title_x + tmp->frame_bw,
X				tmp->title_y + tmp->frame_bw,
X				tmp->title_w, ShapeBounding,
X				ShapeUnion);
X	}
X    } else {
X	/*
X	 * can optimize rectangular contents window
X	 */
X	if (tmp->squeeze_info) {
X	    XRectangle  newBounding[2];
X	    XRectangle  newClip[2];
X	    int fbw2 = 2 * tmp->frame_bw;
X
X	    /*
X	     * Build the border clipping rectangles; one around title, one
X	     * around window.  The title_[xy] field already have had frame_bw
X	     * subtracted off them so that they line up properly in the frame.
X	     *
X	     * The frame_width and frame_height do *not* include borders.
X	     */
X	    /* border */
X	    newBounding[0].x = tmp->title_x;
X	    newBounding[0].y = tmp->title_y;
X	    newBounding[0].width = tmp->title_width + fbw2;
X	    newBounding[0].height = tmp->title_height;
X	    newBounding[1].x = -tmp->frame_bw;
X	    newBounding[1].y = Scr->TitleHeight;
X	    newBounding[1].width = tmp->attr.width + fbw2;
X	    newBounding[1].height = tmp->attr.height + fbw2;
X	    XShapeCombineRectangles (dpy, tmp->frame, ShapeBounding, 0, 0,
X				     newBounding, 2, ShapeSet, YXBanded);
X	    /* insides */
X	    newClip[0].x = tmp->title_x + tmp->frame_bw;
X	    newClip[0].y = 0;
X	    newClip[0].width = tmp->title_width;
X	    newClip[0].height = Scr->TitleHeight;
X	    newClip[1].x = 0;
X	    newClip[1].y = tmp->title_height;
X	    newClip[1].width = tmp->attr.width;
X	    newClip[1].height = tmp->attr.height;
X	    XShapeCombineRectangles (dpy, tmp->frame, ShapeClip, 0, 0,
X				     newClip, 2, ShapeSet, YXBanded);
X	} else {
X	    (void) XShapeCombineMask (dpy, tmp->frame, ShapeBounding, 0, 0,
X 				      None, ShapeSet);
X	    (void) XShapeCombineMask (dpy, tmp->frame, ShapeClip, 0, 0,
X				      None, ShapeSet);
X	}
X    }
X}
X#endif
X
X/*
X * Squeezed Title:
X * 
X *                         tmp->title_x
X *                   0     |
X *  tmp->title_y   ........+--------------+.........  -+,- tmp->frame_bw
X *             0   : ......| +----------+ |....... :  -++
X *                 : :     | |          | |      : :   ||-Scr->TitleHeight
X *                 : :     | |          | |      : :   ||
X *                 +-------+ +----------+ +--------+  -+|-tmp->title_height
X *                 | +---------------------------+ |  --+
X *                 | |                           | |
X *                 | |                           | |
X *                 | |                           | |
X *                 | |                           | |
X *                 | |                           | |
X *                 | +---------------------------+ |
X *                 +-------------------------------+
X * 
X * 
X * Unsqueezed Title:
X * 
X *                 tmp->title_x
X *                 | 0
X *  tmp->title_y   +-------------------------------+  -+,tmp->frame_bw
X *             0   | +---------------------------+ |  -+'
X *                 | |                           | |   |-Scr->TitleHeight
X *                 | |                           | |   |
X *                 + +---------------------------+ +  -+
X *                 |-+---------------------------+-|
X *                 | |                           | |
X *                 | |                           | |
X *                 | |                           | |
X *                 | |                           | |
X *                 | |                           | |
X *                 | +---------------------------+ |
X *                 +-------------------------------+
X * 
X * 
X * 
X * Dimensions and Positions:
X * 
X *     frame orgin                 (0, 0)
X *     frame upper left border     (-tmp->frame_bw, -tmp->frame_bw)
X *     frame size w/o border       tmp->frame_width , tmp->frame_height
X *     frame/title border width    tmp->frame_bw
X *     extra title height w/o bdr  tmp->title_height = TitleHeight + frame_bw
X *     title window height         Scr->TitleHeight
X *     title origin w/o border     (tmp->title_x, tmp->title_y)
X *     client origin               (0, Scr->TitleHeight + tmp->frame_bw)
X *     client size                 tmp->attr.width , tmp->attr.height
X * 
X * When shaping, need to remember that the width and height of rectangles
X * are really deltax and deltay to lower right handle corner, so they need
X * to have -1 subtracted from would normally be the actual extents.
X */
SHAR_EOF
if test 32907 -ne "`wc -c < resize.c`"
then
    echo shar: error transmitting "resize.c" '(should have been 32907 characters)'
fi
fi
# end of shell archive
exit 0

dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.