[comp.sources.x] v03i022: Ardent Window Manager, Patchlevel 9, Part06/12

mikew@wyse.wyse.com (Mike Wexler) (02/21/89)

Submitted-by: kmw@ardent (Ken Wallich)  
Posting-number: Volume 3, Issue 22
Archive-name: awm2/part06

#! /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 6 (of 12)."
# Contents:  Neaten.c Titlebar.c globals.c menus/rtlmnu.ext.h
# Wrapped by mikew@wyse on Fri Feb 17 10:50:24 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Neaten.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Neaten.c'\"
else
echo shar: Extracting \"'Neaten.c'\" \(14822 characters\)
sed "s/^X//" >'Neaten.c' <<'END_OF_FILE'
X
X
X
X#ifndef lint
Xstatic char *rcsid_Neaten_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/Neaten.c,v 1.2 89/02/07 21:23:05 jkh Exp $";
X#endif  lint
X
X#include "X11/copyright.h"
X/*
X *
X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
X *
X * Copyright 1987 by Jordan Hubbard.
X *
X *
X *                         All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of Ardent Computer
X * Corporation or Jordan Hubbard not be used in advertising or publicity
X * pertaining to distribution of the software without specific, written
X * prior permission.
X *
X */
X
X/*
X * MODIFICATION HISTORY
X *
X * 002 -- Jordan Hubbard, Ardent Computer.
X *  Changes to work with awm, specifically reparented windows.
X */
X
X#include "awm.h"
X     
X#ifdef NEATEN
X     
X#include "X11/Xutil.h"
X#include "X11/cursorfont.h"
X#include "neaten.ext.h"
X
Xstatic void GetIconHints();
Xstatic void GetName();
Xextern Boolean IsIcon();
Xextern int neaten_debug_level;
X
X#define TOP_LEVEL (awi->frame ? awi->frame : awi->client)
X
X/*ARGSUSED*/
XBoolean Neaten(window, mask, button, x, y)
XWindow window;                          /* Event window. */
Xint mask;                               /* Button/key mask. */
Xint button;   	                        /* Button event detail. */
Xint x, y;                               /* Event mouse position. */
X{
X     Window junk_window;
X     Window w;
X     Window icon_window;
X     Window stacktop;
X     Window *children;
X     XWindowAttributes attrs;
X     XSizeHints hints;
X     XWindowChanges  wc;
X     Status rstatus;
X     char name[50];
X     int junk;
X     int root_x, root_y;
X     int root_width, root_height;
X     int icon_x, icon_y;
X     int icon_width, icon_height;
X     int icon_border;
X     int window_x, window_y;
X     int window_width, window_height;
X     int rval;
X     int ix;
X     int iconic;
X     int tiled;
X     int adjustment;
X     int priority;
X     int priority_increment;
X     unsigned int nchildren;
X     unsigned int mapped_children = 0;
X     unsigned int opened_children = 0;
X     unsigned int  wcmask;
X     Placement primary;
X     Placement secondary;
X     Boolean is_iconic;
X     Cursor rtlcursor;
X     XFontStruct *font;
X     GC gc;
X     AwmInfoPtr awi;
X
X     Entry("Neaten")
X
X     font = (XFontStruct *) XLoadQueryFont(dpy, "cursor");
X     gc = DefaultGC(dpy, scr);
X     XSetFont(dpy, gc, font->fid);
X     
X     rtlcursor = XCreateFontCursor(dpy, XC_rtl_logo);
X     
X     XGrabPointer(dpy, RootWindow(dpy, scr), FALSE, (unsigned int) 0,
X		  GrabModeAsync, GrabModeAsync,
X		  (Window) None, rtlcursor, CurrentTime);
X     
X     if (AbsMinWidth == 0)
X	  AbsMinWidth = DEFAULT_ABS_MIN;
X     if (AbsMinHeight == 0)
X	  AbsMinHeight = DEFAULT_ABS_MIN;
X     
X     XGetGeometry(dpy, RootWindow(dpy, scr), &junk_window,
X		  &root_x, &root_y,
X		  &root_width, &root_height,
X		  &junk, &junk);
X     
X     Neaten_Initialize(root_width+SEPARATION,
X		       root_height+SEPARATION,
X		       AbsMinWidth, AbsMinHeight);
X     
X     if (strcmp(PrimaryIconPlacement, "Closest") == 0)
X	  primary = Place_Closest;
X     else if (strcmp(PrimaryIconPlacement, "Top") == 0)
X	  primary = Place_Top;
X     else if (strcmp(PrimaryIconPlacement, "Bottom") == 0)
X	  primary = Place_Bottom;
X     else if (strcmp(PrimaryIconPlacement, "Left") == 0)
X	  primary = Place_Left;
X     else if (strcmp(PrimaryIconPlacement, "Right") == 0)
X	  primary = Place_Right;
X     else
X	  primary = Place_Top;
X     
X     if (strcmp(SecondaryIconPlacement, "Closest") == 0)
X	  secondary = Place_Closest;
X     else if (strcmp(SecondaryIconPlacement, "Top") == 0)
X	  secondary = Place_Top;
X     else if (strcmp(SecondaryIconPlacement, "Bottom") == 0)
X	  secondary = Place_Bottom;
X     else if (strcmp(SecondaryIconPlacement, "Left") == 0)
X	  secondary = Place_Left;
X     else if (strcmp(SecondaryIconPlacement, "Right") == 0)
X	  secondary = Place_Right;
X     else if (strcmp(SecondaryIconPlacement, "Center") == 0)
X	  secondary = Place_Center;
X     else
X	  secondary = Place_Left;
X     
X     Neaten_Icon_Placement(primary, secondary);
X     
X     if (XQueryTree(dpy, RootWindow(dpy, scr), &junk_window,
X		    &junk_window, &children, &nchildren))
X     {
X	  for (ix = 0; ix < nchildren; ix++)
X	  {
X	       XGetWindowAttributes(dpy, children[ix], &attrs);	    
X	       
X	       if ((attrs.map_state != IsUnmapped) &&
X		   (attrs.override_redirect == False) &&
X		   (awi = GetAwmInfo(children[ix])))
X	       {
X		    w = children[ix];
X		    if (w != TOP_LEVEL && w != awi->icon)
X			 continue;
X		    mapped_children++;
X		    
X		    is_iconic = IsIcon(w, (Window *) NULL);
X		    
X		    if (is_iconic == TRUE)
X		    {
X			 window_x = window_y =
X			      window_width = window_height = 0;
X			 icon_x = attrs.x;
X			 icon_y = attrs.y;
X			 icon_width = attrs.width;
X			 icon_height = attrs.height;
X			 
X			 adjustment = SEPARATION;
X			 icon_width += adjustment;
X			 icon_height += adjustment;
X		    }
X		    else
X		    {
X			 window_x = attrs.x;
X			 window_y = attrs.y;
X			 window_width = attrs.width;
X			 window_height = attrs.height;
X			 
X			 window_x -= attrs.border_width;
X			 window_y -= attrs.border_width;
X			 
X			 adjustment = (2 * attrs.border_width) + SEPARATION;
X			 window_width += adjustment;
X			 window_height += adjustment;
X			 
X			 GetIconHints(w, &icon_x, &icon_y,
X				      &icon_width, &icon_height, &icon_border);
X			 
X			 icon_x -= icon_border;
X			 icon_y -= icon_border;
X			 icon_width += (2 * icon_border) + SEPARATION;
X			 icon_height += (2 * icon_border) + SEPARATION;
X			 
X			 opened_children++;
X			 stacktop = TOP_LEVEL;
X		    }
X		    
X		    GetName(w, name);
X		    if(neaten_debug_level)
X		    {
X			 printf("%s\ticonic = %s\n",
X				name, (is_iconic ? "TRUE" : "FALSE"));
X			 printf("\ticon: x = %d y = %d width = %d height = %d\n",
X				icon_x, icon_y, icon_width, icon_height);
X			 if (is_iconic != TRUE)
X			      printf("\twindow: x = %d y = %d width = %d height = %d\n",
X				     window_x, window_y, window_width,
X				     window_height);
X		    }
X		    
X		    Neaten_Identify((int) w, is_iconic,
X				    NEATEN_TRUE, NEATEN_FALSE,
X				    window_x, window_y,
X				    window_width, window_height,
X				    NEATEN_TRUE, NEATEN_FALSE,
X				    icon_x, icon_y,
X				    icon_width, icon_height,
X				    (unsigned long) adjustment);
X		    
X		    rstatus = XGetNormalHints(dpy, w, &hints);
X		    if (rstatus != (Status) 0 && is_iconic != TRUE)
X		    {
X			 if (hints.flags & PMinSize)
X			 {
X			      rval = Neaten_Set_Min((int) w,
X						    hints.min_width+adjustment,
X						    hints.min_height+adjustment);
X			      if(neaten_debug_level)
X				   printf("\tmin: width = %d height = %d status = %s\n",
X					  hints.min_width, hints.min_height,
X					  (rval ? "SUCCESS" : "FAILURE"));
X			 }
X			 if (hints.flags & PMaxSize) 
X			 {
X			      rval = Neaten_Set_Max((int) w,
X						    hints.max_width+adjustment,
X						    hints.max_height+adjustment);
X			      if(neaten_debug_level)
X				   printf("\tmax: width = %d height = %d status = %s\n",
X					  hints.max_width, hints.max_height,
X					  (rval ? "SUCCESS" : "FAILURE"));		    
X			 }
X			 if (hints.flags & (USSize | PSize))
X			 {
X			      rval = Neaten_Set_Desired((int) w,
X							hints.width+adjustment,
X							hints.height+adjustment);
X			      if(neaten_debug_level)
X				   printf("\tdes: width = %d height = %d status = %s\n",
X					  hints.width, hints.height,
X					  (rval ? "SUCCESS" : "FAILURE"));		    
X			 }
X			 
X			 /* if no max hints are given, set the max to the
X			    max of the desired and current size 
X			    */
X			 if (!(hints.flags & PMaxSize))
X			 {
X			      int desired_width = hints.width+adjustment;
X			      int desired_height = hints.height+adjustment;
X			      
X			      window_width = ((window_width > desired_width)
X					      ? window_width :
X					      desired_width);
X			      window_height = ((window_height > desired_height) 
X					       ? window_height :
X					       desired_height);
X			      rval = Neaten_Set_Max((int) w,
X						    window_width,
X						    window_height);
X			      if(neaten_debug_level)
X				   printf("\tmax: width = %d height = %d status = %s\n",
X					  window_width-adjustment, window_height-adjustment,
X					  (rval ? "SUCCESS" : "FAILURE"));
X			 }
X		    }
X	       }
X	  }
X	  
X	  if (UsePriorities == TRUE)
X	  {
X	       priority = MIN_PRIORITY;
X	       if (opened_children > 1)
X		    priority_increment = (MAX_PRIORITY - MIN_PRIORITY) /
X			 (opened_children - 1);
X	       for (ix = 0; ix < nchildren; ix++)
X	       {
X		    w = children[ix];
X		    awi = GetAwmInfo(w);
X		    if (!awi)
X			 continue;
X		    if (w != TOP_LEVEL && w != awi->icon)
X			 continue;
X		    is_iconic = IsIcon(w, (Window *) NULL);
X		    
X		    if (is_iconic != TRUE)
X		    {
X			 XGetWindowAttributes(dpy, w, &attrs);	    
X			 if ((attrs.map_state != IsUnmapped) &&
X			     (attrs.override_redirect == False))
X			 {
X			      Neaten_Set_Priorities((int) w, priority, priority);
X			      if (neaten_debug_level)
X			      {
X				   GetName(w, name);
X				   printf("%s: priority = %d\n", name, priority);
X			      }
X			      priority += priority_increment;
X			 }
X		    }
X	       }
X	  }
X	  
X	  if (FixTopOfStack == TRUE)
X	  {
X	       Neaten_Set_Options((int) stacktop, NEATEN_FALSE, NEATEN_TRUE);
X	       if (neaten_debug_level)
X	       {
X		    GetName(stacktop, name);
X		    printf("stacktop = %s\n", name);
X	       }
X	  }
X	  
X	  if(neaten_debug_level)
X	       printf("mapped children = %d\topened_children = %d\n",
X		      mapped_children, opened_children);
X	  
X	  Neaten_Desktop((RetainSize == FALSE), (KeepOpen == FALSE), Fill);
X	  
X	  for (ix = 0; ix < nchildren; ix++)
X	  {
X	       w = children[ix];
X	       awi = GetAwmInfo(w);
X	       if (!awi)
X		    continue;
X	       if (w != TOP_LEVEL && w != awi->icon)
X		    continue;
X	       if (Neaten_Get_Geometry((int) w, &iconic, &tiled,
X				       &window_x, &window_y,
X				       &window_width, &window_height,
X				       (unsigned long) &adjustment) == 0)
X		    continue;
X	       GetName(w, name);
X	       if(neaten_debug_level)
X	       {
X		    printf("%s iconic = %s  tiled = %s\n", name,
X			   (iconic ? "TRUE" : "FALSE"),
X			   (tiled ? "TRUE" : "FALSE"));
X		    printf("   x = %d, y = %d, width = %d, height = %d\n",
X			   window_x, window_y, window_width, window_height);
X	       }
X	       
X	       wc.x = window_x;
X	       wc.y = window_y;
X	       wc.width = window_width;
X	       wc.height = window_height;
X	       wcmask = CWX | CWY | CWWidth | CWHeight;
X	       
X	       if (iconic == NEATEN_TRUE)
X	       {
X		    is_iconic = IsIcon(w, &icon_window);
X		    if (is_iconic == TRUE)
X		    {
X			 wc.width -= adjustment;
X			 wc.height -= adjustment;
X			 
X			 XConfigureWindow(dpy, w, wcmask, &wc);
X			 if(tiled != NEATEN_TRUE)
X			      XRaiseWindow(dpy, w);
X		    }
X		    else
X		    {
X			 /* have to go to the server to get the info, this
X			    could have been avoided if the the variable
X			    adjustment was a pointer to a structure that
X			    contained the information for the icon and the
X			    information for the window.  However, I chose
X			    not to mess with all that memory management
X			    */
X			 GetIconHints(w, &icon_x, &icon_y,
X				      &icon_width, &icon_height, &icon_border);
X			 
X			 wc.x -= icon_border;
X			 wc.y -= icon_border;
X			 wc.width -= (2 * icon_border) + SEPARATION;
X			 wc.height -= (2 * icon_border) + SEPARATION;
X			 
X			 XAddToSaveSet(dpy, w);
X			 XUnmapWindow(dpy, TOP_LEVEL);
X			 XConfigureWindow(icon_window, wcmask, &wc);
X			 XMapWindow(dpy, icon_window);
X			 if (tiled != NEATEN_TRUE)
X			      XRaiseWindow(dpy, icon_window);
X		    }
X	       }
X	       else
X	       {
X		    wc.width -= adjustment;
X		    wc.height -= adjustment;
X		    adjustment -= SEPARATION;
X		    wc.x += adjustment/2;
X		    wc.y += adjustment/2;
X		    /* I think this will be the outer win */
X		    ConfigureWindow(w, wcmask, &wc);
X		    if(tiled != NEATEN_TRUE)
X			 XRaiseWindow(dpy, TOP_LEVEL);
X	       }
X	  }
X	  
X	  if (FixTopOfStack == TRUE)
X	       XRaiseWindow(dpy, stacktop);
X	  
X	  XFree(children);
X     }
X     
X     XBell(dpy, VOLUME_PERCENTAGE(Volume));
X     XUngrabPointer(dpy, CurrentTime);
X     Leave(FALSE)
X}
X
Xstatic void
X     GetIconHints(window, x, y, width, height, border)
XWindow window;
Xint *x, *y, *width, *height, *border;
X{
X     Window root;
X     XWMHints *wmhints;
X     XWindowAttributes attrs;
X     int junk;
X     
X     *border = *x = *y = 0;
X     /*
X      * Process window manager hints.
X      */ 
X     if (wmhints = XGetWMHints(dpy, window)) 
X     {
X	  if (wmhints->flags&IconWindowHint)
X	  {
X	       XGetWindowAttributes(dpy, wmhints->icon_window, &attrs);
X	       *x = attrs.x;
X	       *y = attrs.y;
X	       *width = attrs.width;
X	       *height = attrs.height;
X	       *border = attrs.border_width;
X	  }
X	  else if (wmhints->flags&IconPixmapHint) 
X	  {
X	       XGetWindowAttributes(dpy, wmhints->icon_pixmap, &attrs);
X	       *width = attrs.width;
X	       *height = attrs.height;
X	  }
X	  else
X	  {
X	       GetDefaultSize(window, width, height);
X	  }
X     }
X     else
X     {
X	  GetDefaultSize(window, width, height);
X     }
X     
X     /*
X      * Fix up sizes by padding.
X      */ 
X     if (!wmhints || !(wmhints->flags&(IconPixmapHint|IconWindowHint))) {
X	  *width += (HIconPad << 1);
X	  *height += (VIconPad << 1);
X     }
X     
X     if (wmhints && (wmhints->flags&IconPositionHint)) {
X	  *x = wmhints->icon_x;
X	  *y = wmhints->icon_y;
X     }
X}
X
Xstatic void
X     GetName(w, name)
XWindow w;
Xchar *name;
X{
X     Status rstatus;
X     char *s = (char *) NULL;
X     
X     
X     rstatus = XFetchName(dpy, w, &s);
X     
X     if (rstatus != (Status) 0 && s != (char *) NULL)
X     {
X	  strcpy(name, s);
X	  XFree(s);
X     }
X     else
X     {
X	  strcpy(name, "UNKNOWN");
X     }
X}
X
Xvoid NeatenDebug(window, left, top, width, height, adjustment)
Xint window;
Xint left, top;
Xint width, height;
Xunsigned long adjustment;
X{
X     Window w = (Window) window;
X     
X     left += (int) ((float)adjustment/2.0);
X     top += (int) ((float)adjustment/2.0);
X     
X     width -= adjustment;
X     height -= adjustment;
X     
X     XMoveResizeWindow(dpy, w, left, top, width, height);
X     XFlush(dpy);
X}
X#else /* NEATEN not installed */
X/*ARGSUSED*/
XBoolean Neaten(window, mask, button, x, y)
XWindow window;                          /* Event window. */
Xint mask;                               /* Button/key mask. */
Xint button;   	                        /* Button event detail. */
Xint x, y;                               /* Event mouse position. */
X{
X     fprintf(stderr, "awm: Warning: Neaten package not installed in ");
X     fprintf(stderr, "this version of of awm.\n");
X}
X#endif NEATEN
END_OF_FILE
if test 14822 -ne `wc -c <'Neaten.c'`; then
    echo shar: \"'Neaten.c'\" unpacked with wrong size!
fi
# end of 'Neaten.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'\" \(18829 characters\)
sed "s/^X//" >'Titlebar.c' <<'END_OF_FILE'
X
X
X
X#ifndef lint
Xstatic char *rcsid_TitleBar_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/Titlebar.c,v 1.2 89/02/07 21:23:59 jkh Exp $";
X#endif	lint
X
X#include "X11/copyright.h"
X/*
X *
X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
X *
X * Copyright 1987 by Jordan Hubbard.
X *
X *
X *                         All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of Ardent Computer
X * Corporation or Jordan Hubbard not be used in advertising or publicity
X * pertaining to distribution of the software without specific, written
X * prior permission.
X *
X */
X
X/*
X * MODIFICATION HISTORY
X *
X * 002 -- Jordan Hubbard, U.C. Berkeley.
X Title bar support routines.
X * 1.2 -- Fairly major restructuring to uncouple title bars and
X * border contexts.
X * 1.3 -- Handling of colors revamped significantly to deal with
X * different colormaps.
X */
X
X#include "awm.h"
X#include "X11/Xutil.h"
X#include "X11/cursorfont.h"
X
Xunsigned int TB_wide, TB_high, TBB_wide, TBB_high, BC_wide, BC_high;
Xunsigned int BCB_wide, BCB_high;
X
Xextern XContext AwmContext;
X
X#define BLANK_WIDE	16
X#define BLANK_HIGH	16
Xstatic 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
Xstatic Boolean Title_res, Frame_res;
X
Xvoid Init_Titles()
X{
X  extern XFontStruct *GetFontRes();
X
X     TFontInfo = GetFontRes("title.font", DEF_TITLE_FONT);
X     TFontBoldInfo = GetFontRes("title.boldFont", (char *) NULL);
X     TBackPixmapData = GetPixmapDataRes("title.pixmap", &TB_wide, &TB_high);
X     TBoldPixmapData = GetPixmapDataRes("title.boldPixmap", &TBB_wide,
X					&TBB_high);
X     TForeground = GetStringRes("title.foreground", Foreground);
X     TBackground = GetStringRes("title.background", Background);
X     TTextForeground = GetStringRes("title.text.foreground", TForeground);
X     TTextBackground = GetStringRes("title.text.background", TBackground);
X
X     TCursor = GetIntRes("title.cursor", DEF_TITLE_CURSOR);
X
X     TitleHeight = GetIntRes("title.height", 0);
X     TitlePad = GetIntRes("title.pad", DEF_TITLE_PAD);
X     NameOffset = GetIntRes("windowName.offset", 0);
X     titleHeight = TFontInfo->max_bounds.ascent +
X	  TFontInfo->max_bounds.descent + (TitlePad * 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     if (TFontBoldInfo) {
X	  int foo;
X	  
X	  foo = TFontBoldInfo->max_bounds.ascent +
X	       TFontBoldInfo->max_bounds.descent + (TitlePad * 2);
X	  if (foo > titleHeight)
X	       titleHeight = foo;
X     }
X     if (titleHeight < gadgetHeight)
X	  titleHeight = gadgetHeight;
X     if (TitleHeight) /* Specified height overrides derived height */
X	  titleHeight = TitleHeight;
X     TitleCursor = XCreateFontCursor(dpy, TCursor);
X     if (!TitleCursor) {
X       char temp[80];
X       sprintf("Init_Titles: Can't get title cursor #%d!\n", TCursor);
X       Error(temp);
X     }
X     /* Gadgets can't exist without titles, so we'll init them here */
X     GadgetPad = GetIntRes("gadget.pad", DEF_GADGET_PAD);
X     GadgetBorder = GetIntRes("gadget.border", DEF_GADGET_BORDER);
X
X     Title_res = TRUE;
X}
X
Xvoid Init_Frames()
X{
X     
X     Entry("Init_Frames")
X
X     BForeground = GetStringRes("borderContext.foreground", Foreground);
X     BBackground = GetStringRes("borderContext.background", Background);
X
X     BCursor = GetIntRes("borderContext.cursor", DEF_BCONTEXT_CURSOR);
X
X     BBackPixmapData = GetPixmapDataRes("borderContext.pixmap", &BC_wide,
X					&BC_high);
X     BBoldPixmapData = GetPixmapDataRes("borderContext.boldPixmap", &BCB_wide,
X					&BCB_high);
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     FrameCursor = XCreateFontCursor(dpy, BCursor);
X     if (!FrameCursor) {
X       char temp[80];
X       sprintf("Init_Frames: Can't get border cursor #%d!\n", BCursor);
X       Error(temp);
X     }
X     Frame_res = TRUE;
X     Leave_void
X}
X
Xchar *GetTitleName(w)
XWindow 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     Leave(tmp)
X}
X
X/*
X * Reparent window 'w' into a frame, making the frame the right
X * size to hold any other window related decorations that may be
X * added later. If window 'w' already has a frame, then it resizes
X * it if necessary.
X */
XWindow Reparent(w)
XWindow w;
X{
X     Window foster;
X     XWindowAttributes xwa;
X     XSetWindowAttributes swa;
X     XWMHints *wm_hints;
X     XSizeHints sz_hints;
X     XClassHint class_hints;
X     AwmInfoPtr awi;
X     char *icon_name;
X     int bch, bcv, x, y;
X     unsigned int width, height, bw;
X     int clnt_x, clnt_y;
X     unsigned long valuemask;
X     Boolean decorated = FALSE;
X     Colormap cmap;
X     Pixel bfore, bback;
X
X     Entry("Reparent")
X
X     awi = GetAwmInfo(w);
X     if (!awi) {
X	  fprintf(stderr, "Reparent: Window %x isn't registered!\n", w);
X	  Leave((Window)NULL)
X     }
X     if (awi->frame && (awi->state & ST_DECORATED))
X	  Leave((Window)NULL)
X
X     if (!Frame_res)
X	  Init_Frames();
X
X     if (awi->attrs & AT_TITLE && !Title_res)
X	  Init_Titles();
X
X     if (!awi->frame)
X	  XGetWindowAttributes(dpy, awi->client, &xwa);
X     else
X	  XGetWindowAttributes(dpy, awi->frame, &xwa);
X     valuemask = CWEventMask | CWBorderPixel | CWBackPixel | CWColormap;
X     swa.event_mask = (SubstructureRedirectMask | SubstructureNotifyMask);
X     bw = xwa.border_width;
X     x = xwa.x;
X     y = xwa.y;
X     height = xwa.height;
X     width = xwa.width;
X     cmap = xwa.colormap;
X     bfore = GetPixel(BForeground, cmap);
X     bback = GetPixel(BBackground, cmap);
X     clnt_y = clnt_x = 0;
X     if (awi->attrs & AT_BORDER) {
X	  XSetWindowAttributes cswa;
X     
X	  swa.event_mask |= (ButtonPressMask | ButtonReleaseMask);
X          bcv = BContext + 1;
X	  bch = bcv * 2;
X
X	  cswa.do_not_propagate_mask =
X	       (ButtonPressMask | ButtonReleaseMask);
X	  XChangeWindowAttributes(dpy, awi->client, CWDontPropagate, &cswa);
X     }
X     else
X          bch = bcv = 0;
X     if (FrameFocus)
X	  swa.event_mask |= (LeaveWindowMask | EnterWindowMask);
X     if (awi->attrs & AT_BORDER) {
X	  swa.background_pixel = bfore;
X	  swa.border_pixel = bback;
X	  decorated = TRUE;
X     }
X     else if (awi->attrs & AT_TITLE) {
X	  swa.background_pixel = GetPixel(TBackground, cmap);
X	  swa.border_pixel = GetPixel(TForeground, cmap);
X     }
X     else {
X	  swa.background_pixel = GetPixel(Background, cmap);
X	  swa.border_pixel = GetPixel(Foreground, cmap);
X     }
X     swa.colormap = cmap;
X     if (PushDown == FALSE) {
X	  if (awi->attrs & AT_TITLE)
X	       y -= (titleHeight + 2);
X	  else if (awi->attrs & AT_BORDER)
X	       y -= BContext;
X     }
X     /* calculate size for frame */
X     if (awi->attrs & AT_TITLE)
X	  height += titleHeight + 2;
X     if (awi->attrs & AT_BORDER) {
X	  if (!(awi->attrs & AT_TITLE))
X	       height += (bcv * 2);
X	  else
X	       height += bcv;
X	  width += bch;
X     }
X     if (awi->attrs & AT_TITLE)
X	  clnt_y = titleHeight + 2;
X     
X     if (awi->attrs & AT_BORDER) {
X	  if (!(awi->attrs & AT_TITLE))
X	       clnt_y = BContext;
X	  clnt_x = BContext;
X     }
X
X     if (!awi->frame) {
X	  foster = XCreateWindow(dpy, RootWindow(dpy, scr), x, y, width,
X				 height, (bw ? bw : (unsigned int) 1),
X				 xwa.depth, xwa.class,
X				 xwa.visual, valuemask, &swa);
X	  if (!foster)
X	       Error("Reparent: Can't create foster parent!");
X
X	  if (awi->attrs & AT_BORDER)
X	       XDefineCursor(dpy, foster, FrameCursor);
X
X	  XAddToSaveSet(dpy, awi->client);
X          XSetWindowBorderWidth(dpy, awi->client,
X			       (unsigned int)((awi->attrs&AT_BORDER) ? 1 : 0));
X	  XReparentWindow(dpy, awi->client, foster, clnt_x, clnt_y);
X	  XSync(dpy, FALSE);
X
X	  if (BBackPixmapData) { /* we have a border context tile */
X	       awi->BC_back = GetPixmapFromCache(foster,
X						 BBackPixmapData,
X						 BC_wide, BC_high,
X						 bfore, bback,
X						 xwa.depth);
X	       if (!awi->BC_back)
X		    Error("Reparent: Can't get pixmap for border context.");
X	       else
X		    XSetWindowBackgroundPixmap(dpy, foster, awi->BC_back);
X	  }
X	  if (BBoldPixmapData) { /* we have a bold border context tile */
X	       awi->BC_bold = GetPixmapFromCache(foster,
X						 BBoldPixmapData,
X						 BCB_wide, BCB_high,
X						 bfore, bback,
X						 xwa.depth);
X	       if (!awi->BC_bold)
X		    Error("Reparent: Can't get bold pixmap for border context.");
X	  }
X	  awi->frame = foster;
X	  awi->border_width = bw;
X	  awi->name = GetTitleName(awi->client);
X
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	       XFree(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	  class_hints.res_name = class_hints.res_class = (char *)NULL;
X	  if (XGetClassHint(dpy, awi->client, &class_hints) == Success) {
X	       if (class_hints.res_name || class_hints.res_class)
X		    XSetClassHint(dpy, foster, &class_hints);
X	  }
X	  XSaveContext(dpy, foster, AwmContext, (caddr_t) awi);
X     }
X     else {
X	  XMoveResizeWindow(dpy, awi->frame, xwa.x, xwa.y, width, height);
X	  XMoveWindow(dpy, awi->client, clnt_x, clnt_y);
X	  if (awi->attrs & AT_BORDER)
X	       decorated = TRUE;
X	  foster = awi->frame;
X     }
X#ifdef RAINBOW
X     if (BorderHilite)
X	  SetBorderPixmaps(awi, awi->grayPixmap);
X#endif
X     if (decorated)
X	  awi->state |= ST_DECORATED;
X     Leave(foster)
X}
X     
Xvoid AddTitle(w)
XWindow w;
X{
X     int bch;
X     Window title;
X     AwmInfoPtr awi;
X     unsigned long valuemask;
X     XWindowAttributes xwa;
X     XSetWindowAttributes swa;
X     XWindowChanges wc;
X     Pixel tfore, tback;
X
X     Entry("AddTitle")
X
X     awi = GetAwmInfo(w);
X
X     if (!awi) {
X	  fprintf(stderr, "AddTitle: Window %x is not registered!\n", w);
X	  Leave_void
X     }
X     if (!awi->frame) 
X	  Leave_void
X     if (awi->title)
X	  Leave_void
X     if (!(awi->attrs & AT_TITLE))
X	  Leave_void
X
X     XGetWindowAttributes(dpy, awi->client, &xwa);
X     swa.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
X     swa.colormap = xwa.colormap;
X     tfore = GetPixel(TForeground, xwa.colormap);
X     tback = GetPixel(TBackground, xwa.colormap);
X     swa.background_pixel = tback;
X     swa.border_pixel = tfore;
X     valuemask = (CWEventMask | CWColormap | CWBackPixel | CWBorderPixel);
X     if (awi->attrs & AT_BORDER)
X	  bch = (BContext * 2) + 2;
X     else
X	  bch = 0;
X     title = XCreateWindow(dpy, awi->frame, 0, 0, (xwa.width - 2) + bch,
X			   titleHeight,
X			   1, xwa.depth, xwa.class, xwa.visual,
X			   valuemask, &swa);
X     if (!title)
X	  Error("AddTitle: Can't create title bar!");
X     if (TBackPixmapData) {
X	  awi->back = GetPixmapFromCache(title, TBackPixmapData,
X					 TB_wide, TB_high,
X					 tfore, tback,
X					 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 = GetPixmapFromCache(title, TBoldPixmapData,
X					 TBB_wide, TBB_high,
X					 tfore, tback,
X					 xwa.depth);
X	  if (!awi->bold)
X	       Error("AddTitle: Can't create pixmap for bold background");
X     }
X     wc.sibling = awi->client;
X     wc.stack_mode = Above;
X     XConfigureWindow(dpy, title, CWSibling|CWStackMode, &wc);
X     XDefineCursor(dpy, title, TitleCursor);
X     XSelectInput(dpy, title, (ExposureMask | ButtonPressMask |
X		       ButtonReleaseMask));
X     XMapWindow(dpy, title);
X     awi->title = title;
X     awi->state |= ST_DECORATED;
X     XSaveContext(dpy, title, AwmContext, (caddr_t) awi);
X}
X
X/*ARGSUSED*/
XBoolean FNoDecorate(w, mask, button, x, y)
XWindow w;
Xint mask, button, x, y;
X{
X     Entry("FNoDecorate")
X	  
X     if (w == RootWindow(dpy, scr))
X	  Leave(FALSE)
X     NoDecorate(w, FALSE);
X     Leave(TRUE)
X}
X
Xvoid NoDecorate(w, destroy)
XWindow w;
XBoolean destroy;
X{
X     XWindowAttributes xwa;
X     AwmInfoPtr awi;
X     extern void DestroyGadgets();
X
X     Entry("NoDecorate")
X
X     awi = GetAwmInfo(w);
X     if (!awi || !awi->frame)
X	 Leave_void
X
X     if (!(awi->state & ST_DECORATED))
X	 Leave_void
X     if (awi->gadgets)
X	  DestroyGadgets(w);
X     if (awi->title) {
X	  XDeleteContext(dpy, awi->title, AwmContext);
X	  if (awi->back)
X	       FreePixmapFromCache(awi->back);
X	  if (awi->bold)
X	       FreePixmapFromCache(awi->bold);
X	  XDestroyWindow(dpy, awi->title);
X	  awi->title = awi->back = awi->bold = (Drawable)NULL;
X     }
X     if (destroy) {
X	  XDeleteContext(dpy, awi->frame, AwmContext);
X	  if (awi->BC_back)
X	       FreePixmapFromCache(awi->BC_back);
X	  if (awi->BC_bold)
X	       FreePixmapFromCache(awi->BC_bold);
X	  free(awi->name);
X	  awi->name = (char *)NULL;
X	  XDestroyWindow(dpy, awi->frame);
X	  awi->frame = awi->BC_back = awi->BC_bold = (Drawable)NULL;
X     }
X     else {
X	  XGetWindowAttributes(dpy, awi->client, &xwa);
X	  XResizeWindow(dpy, awi->frame, (unsigned int) xwa.width,
X			(unsigned int) xwa.height);
X	  XMoveWindow(dpy, awi->client, 0, 0);
X	  awi->state ^= ST_DECORATED;
X     }
X     XSync(dpy, FALSE);
X     Leave_void
X}
X
X/*ARGSUSED*/
XBoolean FDecorate(window, mask, button, x, y)
XWindow window;
Xint mask;
Xint button;
Xint x, y;
X{
X     Window fr;
X
X     Entry("FDecorate")
X
X     if (window == RootWindow(dpy, scr))
X	  Leave(FALSE)
X     fr = Decorate(window);
X     if (fr)
X	  XMapWindow(dpy, fr);
X     XSync(dpy, FALSE);
X     Leave(FALSE)
X}
X
XWindow Decorate(w)
XWindow w;
X{
X     Window ret;
X
X     Entry("Decorate")
X
X     ret = Reparent(w);
X     if (ret) {
X	  AddTitle(ret);
X	  PutGadgets(ret);
X     }
X     Leave(ret)
X}
X
X/*ARGSUSED*/
Xvoid PaintTitle(w, reversed)
XWindow w;
XBoolean reversed;
X{
X     int x, y;
X     XWindowAttributes xwa;
X     XFontStruct *f_info;
X     AwmInfoPtr awi;
X     XGCValues gcv;
X     Colormap cmap;
X
X     Entry("PaintTitle")
X
X     if (!(awi = IsTitled(w)))
X	 Leave_void
X     XGetWindowAttributes(dpy, awi->title, &xwa);
X     cmap = xwa.colormap;
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	  GetPixel(TTextBackground, cmap) : GetPixel(TTextForeground, cmap);
X     gcv.background = (reversed && !TFontBoldInfo) ?
X	  GetPixel(TTextForeground, cmap) : GetPixel(TTextBackground, cmap);
X     XChangeGC(dpy, awi->winGC, (GCFont | GCForeground | GCBackground), &gcv);
X     XClearWindow(dpy, awi->title);
X     if (ShowName) {	/* print window names? */
X	  int textlen;
X
X	  textlen = XTextWidth(f_info, awi->name, strlen(awi->name));
X
X	  if (!NameOffset)
X	       x = (xwa.width - textlen) / 2;
X	  else {
X	       if (NameOffset < 0)
X		    x = (xwa.width - textlen) + NameOffset;
X	       else
X		    x = NameOffset;
X	       if (x + textlen > xwa.width)
X		    x = (xwa.width - textlen) + 1;
X	  }
X	  y = (xwa.height + f_info->max_bounds.ascent -
X	       f_info->max_bounds.descent) / 2;
X
X	  XDrawImageString(dpy, awi->title, awi->winGC, x, y, awi->name,
X			   strlen(awi->name));
X     }
X     Leave_void
X}
X
XAwmInfoPtr IsTitled(w)
XWindow w;
X{
X     AwmInfoPtr tmp;
X
X     Entry("IsTitled")
X
X     if (tmp = GetAwmInfo(w))
X	  if (tmp->title)
X	       Leave(tmp)
X     Leave((AwmInfoPtr)NULL)
X}
X
X/*
X * These routines deal with a sort of "pixmap cache" that is needed
X * to minimize the number of pixmaps created by awm. Awm operates on the
X * assumption that the user may have an arbitrary number of windows at
X * arbitrary depths. Since awm likes to create resources at the same
X * depth as the client window, some sort of mechanism is needed to insure
X * that as few are created as possible.
X */
X
Xstruct _resInfo {
X     struct _resInfo *next;
X     Drawable res; 
X     char *res_data;
X     Pixel res_fore, res_back;
X     int res_depth;
X     int ref_count;
X} *CacheHead;
X
Xstruct _resInfo *allocResNode()
X{
X     struct _resInfo *ptr;
X
X     Entry("allocResNode")
X
X     ptr = (struct _resInfo *)malloc(sizeof(struct _resInfo));
X     if (!ptr)
X	  fprintf(stderr, "allocResNode: Out of memory!\n");
X     Leave(ptr)
X}
X
X/*
X * Look for pixmap in cache and returns it or allocate new pixmap,
X * store it in cache and return it.
X */
XDrawable GetPixmapFromCache(d, data, wide, high, fore, back, depth)
XDrawable d;
Xchar *data;
Xunsigned int wide, high;
XPixel fore, back;
Xint depth;
X{
X     struct _resInfo *cptr, *iptr;
X
X     cptr = iptr = CacheHead;
X     while (cptr) {
X	  if (cptr->res_depth > depth)
X	       break;
X	  if (cptr->res_depth == depth) {
X	       if (cptr->res_data > data)
X		    break;
X	       else if (cptr->res_data == data) {
X		    if (cptr->res_fore == fore && cptr->res_back == back) {
X			 cptr->ref_count++;
X			 Leave(cptr->res)
X		    }
X	       }
X	  }
X	  iptr = cptr;
X	  cptr = cptr->next;
X     }
X     /* fell through, create another resource */
X     if (!iptr || cptr == CacheHead)	/* need to initialize list */
X	  CacheHead = iptr = allocResNode();
X     else {
X	  iptr->next = allocResNode();
X	  iptr = iptr->next;
X     }
X     iptr->next = cptr;
X     iptr->res_depth = depth;
X     iptr->res_data = data;
X     iptr->res_fore = fore;
X     iptr->res_back = back;
X     iptr->res = XCreatePixmapFromBitmapData(dpy, d, data, wide, high,
X					     fore, back, (unsigned int) depth);
X     iptr->ref_count = 1;
X     Leave(iptr->res)
X}
X
X/*
X * Free pixmap (and associated cache cell) if no longer needed.
X */
Xvoid FreePixmapFromCache(pix)
XPixmap pix;
X{
X     struct _resInfo *ptr, *tmp;
X
X     ptr = tmp = CacheHead;
X     while (ptr) {
X	  if (ptr->res == pix)
X	       break;
X	  tmp = ptr;
X	  ptr = ptr->next;
X     }
X     if (!ptr)
X	  Leave_void
X     if (--ptr->ref_count == 0) { /* last ref */
X	  if (ptr == CacheHead)
X	       CacheHead = CacheHead->next;
X	  else
X	       tmp->next = ptr->next;
X	  XFreePixmap(dpy, ptr->res);
X	  free(ptr);
X     }
X}
END_OF_FILE
if test 18829 -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'\" \(15039 characters\)
sed "s/^X//" >'globals.c' <<'END_OF_FILE'
X
X
X
X#ifndef lint
Xstatic char *rcsid_globals_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/globals.c,v 1.2 89/02/07 21:24:58 jkh Exp $";
X#endif  lint
X 
X#include "X11/copyright.h"
X/*
X *
X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
X *
X * Copyright 1987 by Jordan Hubbard.
X *
X *
X *                         All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of Ardent Computer
X * Corporation or Jordan Hubbard not be used in advertising or publicity
X * pertaining to distribution of the software without specific, written
X * prior permission.
X *
X */
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 * 1.4 -- Vars added for new icon stuff.
X */
X 
X#include "awm.h"
X#include "X11/Xutil.h"
X 
XWindow Pop;			/* Pop up dimension display window. */
XWindow 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 */
XPixmap GrayPixmap;		/* Gray pixmap. */
XPixmap SolidPixmap;		/* Solid pixmap */
XPixmap IBackPixmap;		/* Icon window background pixmap. */
XPixmap IDefPixmap;		/* default icon pixmap for IconLabels */
XPixel ForeColor;		/* Generic foreground color */
XPixel BackColor;		/* Generic background color */
XPixel IBorder;			/* Icon window border color. */
XPixel PBackground;		/* Pop-up Window background color. */
XPixel PForeground;		/* Pop-up Window foregrould color */
XPixel PBorder;			/* Pop-Up Window border color. */
XPixel IBackground;		/* Icon background (for pixmap) color */
XPixel IForeground;		/* Icon foreground (for pixmap) color */
XPixel ITextForeground;		/* Icon text foreground color */
XPixel ITextBackground;		/* Icon text background color */
Xchar *Foreground;		/* foreground color (text) */
Xchar *Background;		/* background color (text) */
Xchar *WBorder;			/* Window border color */
Xchar *BBackground;		/* Border context background color */
Xchar *BForeground;		/* Border context foreground color */
Xchar *TBackground;		/* Titlebar background color */
Xchar *TForeground;		/* Titlebar foreground color */
Xchar *TTextBackground;		/* Titlebar text background color */
Xchar *TTextForeground;		/* Titlebar text foreground color */
XCursor ArrowCrossCursor;	/* Arrow cross cursor. */
XCursor TextCursor;		/* Text cursor used in icon windows. */
XCursor IconCursor;		/* Icon Cursor. */
XCursor LeftButtonCursor;	/* Left button main cursor. */
XCursor MiddleButtonCursor;	/* Middle button main cursor. */
XCursor RightButtonCursor;	/* Right button main cursor. */
XCursor TargetCursor;		/* Target (select-a-window) cursor. */
XCursor TitleCursor;		/* Titlebar cursor */
XCursor FrameCursor;		/* Border context cursor */
XCursor GumbyCursor;		/* Used in icons if not type-in */
Xunsigned int GadgetBorder;	/* Width of gadget borders */
Xint ScreenWidth;		/* Display screen width. */
Xint ScreenHeight;		/* Display screen height. */
Xint IBorderWidth;		/* Icon window border width. */
Xint TitleHeight;		/* Height of title bar(s) (in pixels) */
Xint titleHeight;		/* Derived height of title bar(s) in pixels */
Xint gadgetHeight;		/* Height of highest gadget */
Xint NameOffset;			/* Offset for window name */
Xint TitlePad;			/* Padding for titles */
Xint PWidth;			/* Pop-up window width. */
Xint PHeight;			/* Pop-up window height. */
Xunsigned int PBorderWidth;	/* Pop-up window border width. */
Xint PPadding;			/* Pop-up window padding. */
Xint Delta;			/* Mouse movement slop. */
Xint HIconPad;			/* Icon horizontal padding. */
Xint VIconPad;			/* Icon vertical padding. */
Xint Pushval;			/* Number of pixels to push window by. */
Xint BContext;			/* Border context area width (in pixels) */
Xint RaiseDelay;			/* Number of milliseconds delay before autoraise */
Xint NumGadgets;			/* Number of gadgets we're using */
Xint GadgetPad;			/* Amount of padding for gadgets */
Xint Volume;			/* Audible alarm volume. */
Xint status;			/* Routine return status. */
Xunsigned int BCursor;		/* Border context cursor */
Xunsigned int TCursor;		/* Title context cursor */
XMenuLink *Menus;		/* Linked list of menus. */
XGC  IconGC;			/* graphics context for icon */
XGC  PopGC;			/* graphics context for pop */
XGC  DrawGC;			/* graphics context for drawing */
XBinding *Blist;			/* Button/key binding list. */
X
XXContext AwmContext;		/* Main context for awm */
X
XBoolean Autoselect;		/* Warp mouse to default menu selection? */
XBoolean Autoraise;		/* Raise window on input focus? */
XBoolean Borders;		/* Display border context areas? */
XBoolean ConstrainResize;	/* Don't resize until pointer leaves window */
XBoolean Freeze;			/* Freeze server during move/resize? */
XBoolean Grid;			/* Should the m/r box contain a 9 seg. grid. */
XBoolean ShowName;		/* If True, print window names in titlebars */
XBoolean Hilite;			/* Should we highlight titles on focus? */
XBoolean BorderHilite;		/* Should we highlight borders on focus? */
XBoolean InstallColormap;	/* Should we install colormaps for clients? */
XBoolean NWindow;		/* Normalize windows? */
XBoolean NIcon;			/* Normalize icons? */
XBoolean Push;			/* Relative=TRUE, Absolute=FALSE. */
XBoolean RootResizeBox;		/* Resize window is placed over sized window? */
XBoolean ResizeRelative;		/* resizes should be relative to window edge */
XBoolean Titles;			/* Title bar frob on windows? */
XBoolean IconLabels;		/* icon labels? */
XBoolean ILabelTop;		/* icon label on top? */
XBoolean UseGadgets;		/* Gadget boxes on titles? */
XBoolean FrameFocus;		/* Treat the frame as part of the window? */
XBoolean Reverse;		/* Reverse video? */
XBoolean SaveUnder;		/* Save unders? */
XBoolean PushDown;		/* Down=TRUE, Up=FALSE */
XBoolean Wall;			/* restrict to root window boundries? */
XBoolean WarpOnRaise;		/* Warp to upper right corner on raise. */
XBoolean WarpOnIconify;          /* Warp to icon center on iconify. */
XBoolean WarpOnDeIconify;        /* Warp to upper right corner on de-iconify. */
XBoolean FocusSetByUser;         /* True if f.focus called */
XBoolean FocusSetByWM;		/* True if awm set the focus */
XBoolean Zap;			/* Should the the zap effect be used. */
X 
Xchar PText[7] = INIT_PTEXT;	/* Pop-up window dummy text. */
Xint PTextSize = sizeof(PText);	/* Pop-up window dummy text size. */
X 
Xint Lineno = 1;			/* Line count for parser. */
XBoolean Startup_File_Error = FALSE;/* Startup file error flag. */
Xchar Startup_File[NAME_LEN] = "";/* Startup file name. */
Xchar *TBackPixmapData;		/* Bitmap data file title background */
Xchar *TBoldPixmapData;		/* ditto, except highlighted */
Xchar *BBackPixmapData;		/* Border context background pixmap data */
Xchar *BBoldPixmapData;		/* Border context bold pixmap data */
Xchar *awmPath;			/* Optional pathlist to search for pixmaps */
Xchar **Argv;			/* Pointer to command line parameters. */
Xchar **Environ;			/* Pointer to environment. */
X
Xchar gray_bits[] = {
X     0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
X     0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
X     0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
X     0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa
X};
X
Xchar solid_bits[] = {
X     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
X     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
X     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
X     0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
X};
X
Xchar xlogo32_bits[] = {
X   0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x00, 0xc0, 0xfc, 0x03, 0x00, 0x60,
X   0xf8, 0x07, 0x00, 0x30, 0xf8, 0x07, 0x00, 0x18, 0xf0, 0x0f, 0x00, 0x0c,
X   0xe0, 0x1f, 0x00, 0x06, 0xc0, 0x3f, 0x00, 0x06, 0xc0, 0x3f, 0x00, 0x03,
X   0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00,
X   0x00, 0xfe, 0x31, 0x00, 0x00, 0xfc, 0x33, 0x00, 0x00, 0xf8, 0x1b, 0x00,
X   0x00, 0xf0, 0x0d, 0x00, 0x00, 0xf0, 0x0e, 0x00, 0x00, 0x60, 0x1f, 0x00,
X   0x00, 0xb0, 0x3f, 0x00, 0x00, 0x98, 0x7f, 0x00, 0x00, 0x98, 0x7f, 0x00,
X   0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x03, 0xfc, 0x03,
X   0x80, 0x01, 0xfc, 0x03, 0xc0, 0x00, 0xf8, 0x07, 0xc0, 0x00, 0xf0, 0x0f,
X   0x60, 0x00, 0xe0, 0x1f, 0x30, 0x00, 0xe0, 0x1f, 0x18, 0x00, 0xc0, 0x3f,
X   0x0c, 0x00, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff};
X
Xint scr;
XDisplay *dpy;
X
X#ifdef WMSTATE
XAtom wm_state_atom;
X#endif
X
X#ifdef NEATEN
Xint AbsMinWidth;
Xint AbsMinHeight;
XBoolean RetainSize;
XBoolean KeepOpen;
XBoolean Fill;
XBoolean UsePriorities;
XBoolean FixTopOfStack;
Xchar *PrimaryIconPlacement;
Xchar *SecondaryIconPlacement;
X#endif
X
X/*
X * Keyword lookup table for parser.
X */
XKeyword 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    { "frameFocus",	IsBoolean,	&FrameFocus, 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.decorate",	IsFunction,	0, FDecorate },
X    { "f.exit",		IsQuitFunction,	0, Quit },
X    { "f.focus",	IsFunction,	0, Focus },
X    { "f.unfocus",	IsImmFunction,	0, UnFocus },
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, ShoveDown },
X    { "f.pushleft",	IsFunction,	0, ShoveLeft },
X    { "f.pushright",	IsFunction,	0, ShoveRight },
X    { "f.pushup",	IsFunction,	0, ShoveUp },
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.nodecorate",   IsFunction,     0, FNoDecorate },
X    { "f.lock",   	IsImmFunction,  0, Lock },
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 */
XKeyExpr 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 */
XContExpr 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 */
XGravityExpr 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    { "centerGravity", CenterGadgetGravity },
X    { "centerGravity", CenterGadgetGravity },
X    { "CenterGravity", CenterGadgetGravity },
X    { NULL, NULL}
X};
X
X/*
X * Button expression table for parser.
X */
XButtonModifier 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 15039 -ne `wc -c <'globals.c'`; then
    echo shar: \"'globals.c'\" unpacked with wrong size!
fi
# end of 'globals.c'
fi
if test -f 'menus/rtlmnu.ext.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'menus/rtlmnu.ext.h'\"
else
echo shar: Extracting \"'menus/rtlmnu.ext.h'\" \(2298 characters\)
sed "s/^X//" >'menus/rtlmnu.ext.h' <<'END_OF_FILE'
X
X/*
X#ifndef lint
Xstatic char sccs_id[] = "@(#)rtlmenu.extern.h	2.1 12/16/87  Siemens Corporate Research and Support, Inc.";
X#endif
X*/
X
X
X/* 
X  RTL Menu Package Version 1.0
X  by Joe Camaratta and Mike Berman, Siemens RTL, Princeton NJ, 1987
X
X  rtlmenu.extern.h: external definitions for rtlmenu user
X*/
X
X/*
X *
X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
X *
X * Copyright 1987 by Jordan Hubbard.
X *
X *
X *                         All Rights Reserved
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation, and that the name of Ardent Computer
X * Corporation or Jordan Hubbard not be used in advertising or publicity
X * pertaining to distribution of the software without specific, written
X * prior permission.
X *
X */
X
X/*
XCopyright 1987 by
X	Siemens Corporate Research and Support, Inc., Princeton, New Jersey
X
XPermission to use, copy, modify, and distribute this software
Xand its documentation for any purpose and without fee is
Xhereby granted, provided that the above copyright notice
Xappear in all copies and that both that copyright notice and
Xthis permission notice appear in supporting documentation, and
Xthat the name of Siemens not be used in advertising or
Xpublicity pertaining to distribution of the software without
Xspecific, written prior permission.  Siemens makes no
Xrepresentations about the suitability of this software for any
Xpurpose.  It is provided "as is" without express or implied
Xwarranty.
X
X*/
X
Xextern void RTLMenu_Initialize(), RTLMenu_Destroy(),
X    RTLMenu_Replace_Data_Keyed_String(), RTLMenu_Activate_Entry(),
X    RTLMenu_Inactivate_Entry(), RTLMenu_Delete_Entries(),
X    RTLMenu_Delete_String(), RTLMenu_Delete_Data(),
X    RTLMenu_Enter(), RTLMenu_Generate_Items();
X    
Xextern Boolean RTLMenu_Has_Data();
X
Xextern RTLMenu RTLMenu_Create(), RTLMenu_Get_Submenu();
X
Xextern pointer RTLMenu_Data();
X
Xextern RTLMenuItem RTLMenu_Append_String(), RTLMenu_Append_Callback(),
X    RTLMenu_Append_Call(), RTLMenu_Append_Checkback(),
X    RTLMenu_Append_Submenu();
X
Xextern RTLPoint RTLMenu_Entry_Pos(); 
END_OF_FILE
if test 2298 -ne `wc -c <'menus/rtlmnu.ext.h'`; then
    echo shar: \"'menus/rtlmnu.ext.h'\" unpacked with wrong size!
fi
# end of 'menus/rtlmnu.ext.h'
fi
echo shar: End of archive 6 \(of 12\).
cp /dev/null ark6isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 12 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
Moderator of comp.sources.x