[comp.windows.x] awm patch #5

jkh@ardent.UUCP (Jordan Hubbard) (07/25/88)

Here is awm patch #5. It appears short enough to be mailed, so with
crossed fingers... It will also be available on the usual internet ftp
servers in a couple of days. I'd like to mail this specifically to individuals
that request it (as I have done with patch #3), but I'll be leaving the country
at the end of the week and this just isn't possible. Support will pick
back up again once I have established myself at my new location. Bugs
should continue to go to the address given in the README.

					Jordan
----- patch #5 -----

/*
 * CHANGES:
 *
 * Handling of colors has changed significantly to deal with
 * alternate colormaps. Colors are now allocated on the fly from
 * the client's colormap. The maxColors variable has also now gone away.
 * Awm will install colormaps for windows if the new boolean installColormap
 * is set.
 * The wm_option set of resources has been expanded and made more robust.
 * It's now possible to turn different decorations on and off for individual
 * windows, classes or awm itself.
 * Undecorated windows should now behave properly (I.E. awm will "recognise"
 * them).
 * Many nits beaten into submission.
 *
 * UPDATED:
 *
 * FocusChng.c now rev 1.5
 * Gadget.c now rev 1.3
 * GetButton.c now rev 1.4
 * Iconify.c now rev 1.3
 * NewIconify.c now rev 1.2
 * Restart.c now rev 1.2
 * TitleBar.c now rev 1.3
 * awm.c now rev 1.3
 * awm.h now rev 1.2
 * globals.c now rev 1.3
 * gram.y now rev 1.3
 * support.h now rev 1.2
 */

diff -c awm.dst/FocusChng.c awm/FocusChng.c
*** awm.dst/FocusChng.c	Tue Jul  5 21:26:25 1988
--- awm/FocusChng.c	Sun Jul 24 18:14:00 1988
***************
*** 3,9 ****
  
  
  #ifndef lint
! static char *rcsid_FocusChng_c = "$Header: FocusChng.c,v 1.4 88/07/02 01:26:00 jkh Exp $";
  #endif	lint
  
  #include "X11/copyright.h"
--- 3,9 ----
  
  
  #ifndef lint
! static char *rcsid_FocusChng_c = "$Header: FocusChng.c,v 1.5 88/07/23 17:36:00 jkh Exp $";
  #endif	lint
  
  #include "X11/copyright.h"
***************
*** 36,43 ****
--- 36,45 ----
   *   Window pixmap changes on focus in/out.
   * 1.4 -- Fixed Focus In/Out handling. Created LightsOn() and LightsOff()
   * to break out the actual process of "highlighting".
+  * 1.5 -- Added dynamic installation of colormaps.
   */
  
+ 
  #include "awm.h"
  
  #if defined(sun) || defined(ibm032) || defined(titan) || defined(vax)
***************
*** 55,64 ****
       Window w = e->window;
       AwmInfoPtr awi;
       XEvent event;
!      
       Entry("HandleFocusIn")
  
!      if (!(Hilite || Autoraise) || Snatched)
  	 Leave(FALSE)
  
       awi = GetAwmInfo(w);
--- 57,66 ----
       Window w = e->window;
       AwmInfoPtr awi;
       XEvent event;
! 
       Entry("HandleFocusIn")
  
!      if (!(Hilite || Autoraise || InstallColormap) || Snatched)
  	 Leave(FALSE)
  
       awi = GetAwmInfo(w);
***************
*** 65,70 ****
--- 67,73 ----
       if (!awi)  /* probably a menu or something */
           Leave(FALSE)
       w = (FrameFocus && awi->frame) ? awi->frame : awi->client;
+ 
       if (e->detail != NotifyInferior && (e->focus || FrameFocus)) {
  	  struct timeval foo;
  
***************
*** 77,85 ****
  		*/
  	       select(0, 0, 0, 0, &foo);
  	       /* Did we leave this window already? */
! 	       if (XCheckTypedWindowEvent(dpy, w, LeaveNotify, &event)) {
  		    if (event.xcrossing.detail != NotifyInferior)
  			 Leave(FALSE)
  	       }
  	       if (!FocusSetByUser && FocusWindow != awi->client &&
  		   (awi->attrs & AT_INPUT)) {
--- 80,93 ----
  		*/
  	       select(0, 0, 0, 0, &foo);
  	       /* Did we leave this window already? */
! 	       if (XCheckTypedWindowEvent(dpy, w, LeaveNotify, &event))
  		    if (event.xcrossing.detail != NotifyInferior)
  			 Leave(FALSE)
+ 	       if (InstallColormap) {
+ 		    XWindowAttributes xwa;
+ 
+ 		    XGetWindowAttributes(dpy, w, &xwa);
+ 		    XInstallColormap(dpy, xwa.colormap);
  	       }
  	       if (!FocusSetByUser && FocusWindow != awi->client &&
  		   (awi->attrs & AT_INPUT)) {
***************
*** 97,102 ****
--- 105,111 ----
  	       FocusWindow = awi->client;
  	       FocusSetByWM = FALSE;
  	  }
+ 
  	  /*
  	   * If Autoraise is set, raise that puppy..
  	   */
***************
*** 121,127 ****
       if (!awi) /* probably a menu or something */
           Leave(FALSE)
  
!      if (!(Hilite || Autoraise) || Snatched)
  	 Leave(FALSE)
  
       w =  (FrameFocus && awi->frame) ? awi->frame : awi->client;
--- 130,136 ----
       if (!awi) /* probably a menu or something */
           Leave(FALSE)
  
!      if (!(Hilite || Autoraise || InstallColormap) || Snatched)
  	 Leave(FALSE)
  
       w =  (FrameFocus && awi->frame) ? awi->frame : awi->client;
***************
*** 147,152 ****
--- 156,163 ----
  	       FocusWindow = RootWindow(dpy, scr);
  	       FocusSetByWM = FALSE;
  	  }
+ 	  if (InstallColormap)
+ 	       XInstallColormap(dpy, DefaultColormap(dpy, scr));
  	  LightsOff(awi);
       }
       Leave(FALSE)
***************
*** 168,174 ****
  	       if (awi->back && awi->title)
  		    XSetWindowBackgroundPixmap(dpy, awi->title,
  					       awi->back);
! 	       if (awi->BC_back && BContext) {
  		    XSetWindowBackgroundPixmap(dpy, awi->frame,
  					       awi->BC_back);
  		    XClearWindow(dpy, awi->frame);
--- 179,185 ----
  	       if (awi->back && awi->title)
  		    XSetWindowBackgroundPixmap(dpy, awi->title,
  					       awi->back);
! 	       if (awi->BC_back && (awi->attrs & AT_BORDER)) {
  		    XSetWindowBackgroundPixmap(dpy, awi->frame,
  					       awi->BC_back);
  		    XClearWindow(dpy, awi->frame);
***************
*** 199,205 ****
  					       awi->bold);
  		    PaintTitle(awi->title, TRUE);
  	       }
! 	       if (awi->BC_bold && BContext) {
  		    XSetWindowBackgroundPixmap(dpy, awi->frame,
  					       awi->BC_bold);
  		    XClearWindow(dpy, awi->frame);
--- 210,216 ----
  					       awi->bold);
  		    PaintTitle(awi->title, TRUE);
  	       }
! 	       if (awi->BC_bold && (awi->attrs & AT_BORDER)) {
  		    XSetWindowBackgroundPixmap(dpy, awi->frame,
  					       awi->BC_bold);
  		    XClearWindow(dpy, awi->frame);
diff -c awm.dst/Gadget.c awm/Gadget.c
*** awm.dst/Gadget.c	Sat Jul  2 16:57:21 1988
--- awm/Gadget.c	Sun Jul 24 17:30:40 1988
***************
*** 3,9 ****
  
  
  #ifndef lint
! static char *rcsid_Gadget_c = "$Header: Gadget.c,v 1.2 88/06/17 15:26:00 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
--- 3,9 ----
  
  
  #ifndef lint
! static char *rcsid_Gadget_c = "$Header: Gadget.c,v 1.3 88/07/23 17:26:00 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
***************
*** 35,40 ****
--- 35,41 ----
   * 1.2 -- Jordan Hubbard, Ardent Computer.
   *  GadgetBorders used in placement calculations, initial
   *  gadget positions calculated correcly. (Chris Thewalt fixes).
+  * 1.3 -- Color handling changed to deal with multiple colormaps.
   *
   */
  
***************
*** 68,75 ****
  }
  
  /*
!  * This routine adds and gadgets onto title bar 'w' (though just
!  * about any window would do, I suppose). 
   */
  int PutGadgets(w)
  Window w;
--- 69,75 ----
  }
  
  /*
!  * This routine adds and/or places  gadgets onto a title bar.
   */
  int PutGadgets(w)
  Window w;
***************
*** 78,83 ****
--- 78,84 ----
       int rx, lx, nx, ny;
       XWindowAttributes xwa;
       XSetWindowAttributes swa;
+      Colormap cmap;
       unsigned long valuemask;
       GadgetDecl *gdec;
       AwmInfo *awi;
***************
*** 94,101 ****
       /* does this window have a title? */
       if (!(awi = IsTitled(w)))
  	  Leave_void
!      else
! 	  w = awi->title;
       if (!(awi->attrs & AT_GADGETS))
  	  Leave_void
       /* if the window already has gadgets, this is a reshuffle */
--- 95,101 ----
       /* does this window have a title? */
       if (!(awi = IsTitled(w)))
  	  Leave_void
! 
       if (!(awi->attrs & AT_GADGETS))
  	  Leave_void
       /* if the window already has gadgets, this is a reshuffle */
***************
*** 107,114 ****
  	  fprintf(stderr, "PutGadgets: Can't allocate memory for gadgets!\n");
            Leave(FALSE)
       }
!      if (XGetWindowAttributes(dpy, w, &xwa) == BadWindow) {
! 	  fprintf(stderr, "PutGadgets: Can't get attributes for title window %x\n",
  		  w);
  	  Leave_void
       }
--- 107,114 ----
  	  fprintf(stderr, "PutGadgets: Can't allocate memory for gadgets!\n");
            Leave(FALSE)
       }
!      if (XGetWindowAttributes(dpy, awi->title, &xwa) == BadWindow) {
! 	  fprintf(stderr, "PutGadgets: Can't get attrs for client window %x\n",
  		  w);
  	  Leave_void
       }
***************
*** 116,123 ****
       dir = RightGadgetGravity;
       lx = 0;
       rx = xwa.width;
!      valuemask = CWBackPixel | CWEventMask;
       swa.event_mask = (ButtonPressMask | ButtonReleaseMask | ExposureMask);
       for (i = 0; i < NumGadgets && Gadgets[i]; i++) {
  	  XGCValues gcv;
  
--- 116,125 ----
       dir = RightGadgetGravity;
       lx = 0;
       rx = xwa.width;
!      cmap = xwa.colormap;
!      valuemask = CWBackPixel | CWEventMask | CWColormap;
       swa.event_mask = (ButtonPressMask | ButtonReleaseMask | ExposureMask);
+      swa.colormap = cmap;
       for (i = 0; i < NumGadgets && Gadgets[i]; i++) {
  	  XGCValues gcv;
  
***************
*** 136,153 ****
  	  if (ny < 0)
  	       ny = 0;
  	  if (dir == LeftGadgetGravity) {
! 	       nx = lx + gdec->offset;
  	       if (lx != 0) /* not first time through, add pad */
  		    nx = lx + GadgetPad;
  	       if (nx < 0)
  		    nx = 0;
! 	       lx = nx + gdec->wide + GadgetBorder;
                 dir = RightGadgetGravity;
  	  }
  	  else if (dir == RightGadgetGravity) {	
! 	       nx = rx - gdec->wide - gdec->offset;
  	       if (rx != xwa.width)
! 		    nx -= (2 * GadgetBorder + GadgetPad);
  	       rx = nx - GadgetBorder;
                 dir = LeftGadgetGravity;
  	  }
--- 138,155 ----
  	  if (ny < 0)
  	       ny = 0;
  	  if (dir == LeftGadgetGravity) {
! 	       nx = lx + gdec->offset + GadgetBorder;
  	       if (lx != 0) /* not first time through, add pad */
  		    nx = lx + GadgetPad;
  	       if (nx < 0)
  		    nx = 0;
! 	       lx = nx + gdec->wide;
                 dir = RightGadgetGravity;
  	  }
  	  else if (dir == RightGadgetGravity) {	
! 	       nx = rx - gdec->wide - gdec->offset - (2 * GadgetBorder);
  	       if (rx != xwa.width)
! 		    nx -= GadgetPad;
  	       rx = nx - GadgetBorder;
                 dir = LeftGadgetGravity;
  	  }
***************
*** 154,166 ****
  	  else /* Center Gravity */
  	       nx = ((xwa.width - gdec->wide) / 2) + gdec->offset;
  	  if (change == FALSE || !awi->gadgets[i]) {
! 	       swa.background_pixel = gdec->backcolor;
! 	       tmp = awi->gadgets[i] = XCreateWindow(dpy, w, nx, ny, gdec->wide,
! 					    gdec->high, GadgetBorder,
! 					    xwa.depth, xwa.class,
! 					    xwa.visual, valuemask, &swa);
  	       if (!tmp) {
! 		    fprintf(stderr, "PutGadgets: Unable to create gadget window #%d\n",
  			    i);
  		    Leave_void
  	       }
--- 156,170 ----
  	  else /* Center Gravity */
  	       nx = ((xwa.width - gdec->wide) / 2) + gdec->offset;
  	  if (change == FALSE || !awi->gadgets[i]) {
! 	       swa.background_pixel = GetPixel(gdec->backcolor, cmap);
! 	       tmp = awi->gadgets[i] = XCreateWindow(dpy, awi->title, nx, ny,
! 						     gdec->wide, gdec->high,
! 						     GadgetBorder,
! 						     xwa.depth, xwa.class,
! 						     xwa.visual, valuemask,
! 						     &swa);
  	       if (!tmp) {
! 		    fprintf(stderr, "PutGadgets: Can't create gadget #%d\n",
  			    i);
  		    Leave_void
  	       }
***************
*** 169,175 ****
  
  		    pix = XCreatePixmapFromBitmapData(dpy, tmp, gdec->data,
  						      gdec->wide, gdec->high,
! 						      gdec->forecolor, gdec->backcolor,
  						      xwa.depth);
  		    if (!pix) {
  			 fprintf(stderr, "PutGadgets: Unable to create pixmap for #%d\n",
--- 173,180 ----
  
  		    pix = XCreatePixmapFromBitmapData(dpy, tmp, gdec->data,
  						      gdec->wide, gdec->high,
! 						      GetPixel(gdec->forecolor, cmap),
! 						      GetPixel(gdec->backcolor, cmap),
  						      xwa.depth);
  		    if (!pix) {
  			 fprintf(stderr, "PutGadgets: Unable to create pixmap for #%d\n",
***************
*** 201,214 ****
  	  XFree(Gadgets[n]->data);
       if (Gadgets[n]->name)
  	  free(Gadgets[n]->name);
-      /* They tell me that this is not necessary for read-only cells. True?
-      if (Gadgets[n]->forecolor)
- 	  XFreeColors(dpy, DefaultColormap(dpy, scr),
- 		      &(Gadgets[n]->forecolor), 1, AllPlanes);
-      if (Gadgets[n]->backcolor)
- 	  XFreeColors(dpy, DefaultColormap(dpy, scr),
- 		      &(Gadgets[n]->backcolor), 1, AllPlanes);
-      */ /* color free's commented out */
  }
  
  int CheckGadgets()
--- 206,211 ----
***************
*** 269,274 ****
--- 266,272 ----
       int i, y, x = 0;
       AwmInfoPtr awi;
       GadgetDecl *gdec;
+      XWindowAttributes xwa;
  
       Entry("PaintGadgets")
  
***************
*** 276,281 ****
--- 274,280 ----
  	  Leave_void
       if (!awi->gadgets)
  	  Leave_void
+      XGetWindowAttributes(dpy, awi->client, &xwa);
       for (i = 0; i < NumGadgets && Gadgets[i]; i++) {
  	  gdec = Gadgets[i];
  	  if (!gdec->data) {
***************
*** 282,291 ****
  	       XGCValues gcv;
  
  	       gcv.font = gdec->fontInfo->fid;
! 	       gcv.foreground = gdec->forecolor;
! 	       gcv.background = gdec->backcolor;
! 	       XChangeGC(dpy, awi->winGC, (GCFont | GCForeground | GCBackground),
! 			 &gcv);
  	       if (strlen(gdec->name) == 1) { /* it's a glyph (we think) */
  		    XFontStruct *real_font;
  		    XCharStruct char_info;
--- 281,290 ----
  	       XGCValues gcv;
  
  	       gcv.font = gdec->fontInfo->fid;
! 	       gcv.foreground = GetPixel(gdec->forecolor, xwa.colormap);
! 	       gcv.background = GetPixel(gdec->backcolor, xwa.colormap);
! 	       XChangeGC(dpy, awi->winGC, (GCFont | GCForeground |
! 					   GCBackground), &gcv);
  	       if (strlen(gdec->name) == 1) { /* it's a glyph (we think) */
  		    XFontStruct *real_font;
  		    XCharStruct char_info;
***************
*** 320,326 ****
  			 }
  			 char_info = real_font->per_char[index];
  		    }
! 		    x = GadgetBorder - char_info.lbearing;
  		    y = char_info.ascent;
  	       }
  	       else {
--- 319,325 ----
  			 }
  			 char_info = real_font->per_char[index];
  		    }
! 		    x = 1 - GadgetBorder - char_info.lbearing;
  		    y = char_info.ascent;
  	       }
  	       else {
diff -c awm.dst/GetButton.c awm/GetButton.c
*** awm.dst/GetButton.c	Tue Jul  5 21:26:30 1988
--- awm/GetButton.c	Sun Jul 24 17:32:23 1988
***************
*** 3,9 ****
  
  
  #ifndef lint
! static char *rcsid_GetButton_c = "$Header: GetButton.c,v 1.3 88/07/05 21:20:45 jjkh Exp $";
  #endif	lint
  
  #include "X11/copyright.h"
--- 3,9 ----
  
  
  #ifndef lint
! static char *rcsid_GetButton_c = "$Header: GetButton.c,v 1.4 88/07/23 18:20:45 jkh Exp $";
  #endif	lint
  
  #include "X11/copyright.h"
***************
*** 129,137 ****
        * The event occured on the root window, check for substructure
        * changes. Otherwise, it must be a mouse button event. 
        */
-      win = b_ev->xany.window;
  
!      if (win == RootWindow(dpy, scr)) {
  	  switch (b_ev->xany.type) {
  	  case CreateNotify:
  	  case UnmapNotify:
--- 129,136 ----
        * The event occured on the root window, check for substructure
        * changes. Otherwise, it must be a mouse button event. 
        */
  
!      if (b_ev->xany.window == RootWindow(dpy, scr)) {
  	  switch (b_ev->xany.type) {
  	  case CreateNotify:
  	  case UnmapNotify:
***************
*** 201,207 ****
        * If it's a Notify, we've probably frobbed a titled window.
        */
       
-      awi = GetAwmInfo(win);
       switch (b_ev->type) {
  	  XEvent e_fake;
  
--- 200,205 ----
***************
*** 215,221 ****
  	  if (!FocusSetByWM) {
  	       e_fake.xcrossing.type = FocusIn;
  	       e_fake.xcrossing.focus = TRUE;
! 	       e_fake.xcrossing.window = win;
  	       HandleFocusIn(&e_fake);
  	  }
  	  Leave(FALSE)
--- 213,219 ----
  	  if (!FocusSetByWM) {
  	       e_fake.xcrossing.type = FocusIn;
  	       e_fake.xcrossing.focus = TRUE;
! 	       e_fake.xcrossing.window = b_ev->xcrossing.window;
  	       HandleFocusIn(&e_fake);
  	  }
  	  Leave(FALSE)
***************
*** 225,231 ****
  	  if (!FocusSetByWM) {
  	       e_fake.xcrossing.type = FocusOut;
  	       e_fake.xcrossing.focus = TRUE;
! 	       e_fake.xcrossing.window = win;
  	       HandleFocusOut(&e_fake);
  	  }
  	  Leave(FALSE)
--- 223,229 ----
  	  if (!FocusSetByWM) {
  	       e_fake.xcrossing.type = FocusOut;
  	       e_fake.xcrossing.focus = TRUE;
! 	       e_fake.xcrossing.window = b_ev->xcrossing.window;
  	       HandleFocusOut(&e_fake);
  	  }
  	  Leave(FALSE)
***************
*** 248,290 ****
  	  Leave(FALSE);
  
       case MapNotify:
!           if (!awi)
                Leave(FALSE)
  	  if (IsIcon(win, FALSE))
  	      Leave(FALSE)
!           if (awi->frame)
!               XMapWindow(dpy, awi->frame);
!           else
!               XMapWindow(dpy, awi->client);
            Leave(FALSE)
  	  break;
  	  
       case UnmapNotify:
!           if (!awi)
!                Leave(FALSE)
  	  if (IsIcon(win, FALSE))
  	       Leave(FALSE)
!           if (awi->frame)
! 	       XUnmapWindow(dpy, awi->frame);
!           else
! 	       XUnmapWindow(dpy, awi->client);
  	  Leave(FALSE)
  	  break;
  
       case DestroyNotify:
!           if (!awi)
                Leave(FALSE)
! 	  /* remove any icon associated with this window */
! 	  RemoveIcon(win);
! 	  /* remove the frame/titlebar (if present) */
! 	  DestroyFrame(win);
! 	  /* punt the rest of the per-window info */
! 	  XDeleteContext(dpy, awi->client, AwmContext);
! 	  free(awi);
            Leave(FALSE)
  
       case PropertyNotify:
!           if (!awi)
                 Leave(FALSE)
  	  switch(b_ev->xproperty.atom) {
  
--- 246,290 ----
  	  Leave(FALSE);
  
       case MapNotify:
! 	  win = b_ev->xmap.window;
!           if (!(awi = GetAwmInfo(win)))
                Leave(FALSE)
  	  if (IsIcon(win, FALSE))
  	      Leave(FALSE)
!           XMapWindow(dpy, awi->frame);
! 	  XMapWindow(dpy, awi->client);
            Leave(FALSE)
  	  break;
  	  
       case UnmapNotify:
! 	  win = b_ev->xunmap.window;
!           if (!(awi = GetAwmInfo(win)))
!               Leave(FALSE)
! 
  	  if (IsIcon(win, FALSE))
  	       Leave(FALSE)
! 	   XUnmapWindow(dpy, awi->frame);
  	  Leave(FALSE)
  	  break;
  
       case DestroyNotify:
! 	  win = b_ev->xdestroywindow.window;
!           if (!(awi = GetAwmInfo(win)))
                Leave(FALSE)
! 	  if (win != awi->title) {
! 	       /* remove any icon associated with this window */
! 	       RemoveIcon(win);
! 	       /* remove the frame/titlebar (if present) */
! 	       NoDecorate(win, TRUE);
! 	       /* punt the rest of the per-window info */
! 	       XDeleteContext(dpy, awi->client, AwmContext);
! 	       free(awi);
! 	  }
            Leave(FALSE)
  
       case PropertyNotify:
! 	  win = b_ev->xproperty.window;
!           if (!(awi = GetAwmInfo(win)))
                 Leave(FALSE)
  	  switch(b_ev->xproperty.atom) {
  
***************
*** 353,359 ****
  	  
  	  
       case Expose:
!           if (!awi) /* probably a menu */
                 Leave(FALSE)
  	  if (awi->title == win) {
  	       if (b_ev->xexpose.count == 0) {
--- 353,360 ----
  	  
  	  
       case Expose:
! 	  win = b_ev->xexpose.window;
!           if (!(awi = GetAwmInfo(win))) /* probably a menu */
                 Leave(FALSE)
  	  if (awi->title == win) {
  	       if (b_ev->xexpose.count == 0) {
***************
*** 377,384 ****
       /*
        * If we got this far, the event must be for an icon.
        */
!      
!      if (!awi)
            Leave(FALSE)
       status = XGetWindowAttributes(dpy, win, &win_info);
       if (status == FAILURE)
--- 378,385 ----
       /*
        * If we got this far, the event must be for an icon.
        */
!      win = b_ev->xany.window;
!      if (!(awi = GetAwmInfo(win)))
            Leave(FALSE)
       status = XGetWindowAttributes(dpy, win, &win_info);
       if (status == FAILURE)
***************
*** 598,604 ****
  	       awi = RegisterWindow(window);
  	       Decorate(awi->client);
  	       event_mask = PropertyChangeMask | FocusChangeMask;
! 	       if (!awi->frame || !FrameFocus)
  		    event_mask |= (EnterWindowMask | LeaveWindowMask);
  	       XSelectInput(dpy, window, event_mask);
  	       SetBorderPixmaps(dpy, GrayPixmap);
--- 599,605 ----
  	       awi = RegisterWindow(window);
  	       Decorate(awi->client);
  	       event_mask = PropertyChangeMask | FocusChangeMask;
! 	       if (!FrameFocus)
  		    event_mask |= (EnterWindowMask | LeaveWindowMask);
  	       XSelectInput(dpy, window, event_mask);
  	       SetBorderPixmaps(dpy, GrayPixmap);
***************
*** 620,631 ****
       if (awi->state & ST_WINDOW) {
  	  if (!transient_for)
  	       PlaceWindow(window);
! 	  if (awi->frame) {
! 	       XMapRaised(dpy, awi->frame);
! 	       XMapWindow(dpy, awi->client);
! 	  }
! 	  else
! 	       XMapRaised(dpy, awi->client);
  	  XSync(dpy, 0);
       }
       Leave_void
--- 621,628 ----
       if (awi->state & ST_WINDOW) {
  	  if (!transient_for)
  	       PlaceWindow(window);
! 	  XMapRaised(dpy, awi->frame);
! 	  XMapWindow(dpy, awi->client);
  	  XSync(dpy, 0);
       }
       Leave_void
***************
*** 696,702 ****
  	  if (y < 0)
  	       y += DisplayHeight(dpy, scr) - h - (border_width<<1);
       }
!      if (IsTitled(window))
  	  XSetSizeHints(dpy, awi->frame, &wsh, XA_WM_NORMAL_HINTS);
       XSetSizeHints(dpy, awi->client, &wsh, XA_WM_NORMAL_HINTS);
  #ifdef titan /* 5x4 alignment */
--- 693,699 ----
  	  if (y < 0)
  	       y += DisplayHeight(dpy, scr) - h - (border_width<<1);
       }
!      if (awi->frame)
  	  XSetSizeHints(dpy, awi->frame, &wsh, XA_WM_NORMAL_HINTS);
       XSetSizeHints(dpy, awi->client, &wsh, XA_WM_NORMAL_HINTS);
  #ifdef titan /* 5x4 alignment */
***************
*** 718,723 ****
--- 715,721 ----
  {
       XWindowAttributes xwa;
       AwmInfoPtr awi;
+      int height, width, x, y;
       int bch = 0, bcv = 0;
       Entry("ConfigureWindow")
  
***************
*** 729,777 ****
  	  bcv = BContext + 1;
  	  bch = bcv * 2;
       }
-      if (awi->frame) {
- 	  int height, width, x, y;
  
! 	  height = xwc->height;
! 	  width = xwc->width;
!           x = y = 0;
! 	  /* width */
! 	  xwc->width += bch;
! 	  if (awi->title)
! 	       XResizeWindow(dpy, awi->title, xwc->width, titleHeight);
! 	  /* height */
! 	  if (awi->attrs & AT_TITLE) {
! 	       y = titleHeight + 2;
! 	       xwc->height += y;
  	  }
! 	  if (awi->attrs & AT_BORDER) {
! 	       if (!(awi->attrs & AT_TITLE)) {
! 		    xwc->height += (bcv * 2);
! 		    y = bcv;
! 	       }
! 	       else
! 		    xwc->height += bcv;
! 	       xwc->x -= (BContext + (awi->border_width ? awi->border_width :
! 			  1));
! 	       x = BContext;
! 	  }
! 	  if (PushDown == FALSE) {
! 	       if (awi->attrs & AT_TITLE)
! 		    xwc->y -= (titleHeight + 2);
! 	       else if (awi->attrs & AT_BORDER)
! 		    xwc->y -= (BContext + (awi->border_width ?
! 					   awi->border_width : 1));
! 	  }
! 	  if (xwc->y < 0)
! 	       xwc->y = 0;
! 	  XConfigureWindow(dpy, awi->frame, mask, xwc);
! 	  if (awi->gadgets)
! 	       PutGadgets(w);
! 	  xwc->width = width;
! 	  xwc->height = height;
! 	  xwc->x = x;
! 	  xwc->y = y;
       }
       XConfigureWindow(dpy, awi->client, mask, xwc);
       Leave(TRUE)
  }
--- 727,769 ----
  	  bcv = BContext + 1;
  	  bch = bcv * 2;
       }
  
!      height = xwc->height;
!      width = xwc->width;
!      x = y = 0;
!      /* width */
!      xwc->width += bch;
!      if (awi->title)
! 	  XResizeWindow(dpy, awi->title, xwc->width, titleHeight);
!      /* height */
!      if (awi->attrs & AT_TITLE) {
! 	  y = titleHeight + 2;
! 	  xwc->height += y;
!      }
!      if (awi->attrs & AT_BORDER) {
! 	  if (!(awi->attrs & AT_TITLE)) {
! 	       xwc->height += (bcv * 2);
! 	       y = bcv;
  	  }
! 	  else
! 	       xwc->height += bcv;
! 	  xwc->x -= (BContext + (awi->border_width ? awi->border_width : 1));
! 	  x = BContext;
       }
+      if (PushDown == FALSE) {
+ 	  if (awi->attrs & AT_TITLE)
+ 	       xwc->y -= (titleHeight + 2);
+ 	  else if (awi->attrs & AT_BORDER)
+ 	       xwc->y -= (BContext + (awi->border_width ?
+ 				      awi->border_width : 1));
+      }
+      XConfigureWindow(dpy, awi->frame, mask, xwc);
+      if (awi->gadgets)
+ 	  PutGadgets(w);
+      xwc->width = width;
+      xwc->height = height;
+      xwc->x = x;
+      xwc->y = y;
       XConfigureWindow(dpy, awi->client, mask, xwc);
       Leave(TRUE)
  }
diff -c awm.dst/Icons.c awm/Icons.c
*** awm.dst/Icons.c	Sat Jul  2 16:57:26 1988
--- awm/Icons.c	Sun Jul 24 18:02:19 1988
***************
*** 3,9 ****
  
  
  #ifndef lint
! static char *rcsid_Iconify_c = "$Header: Iconify.c,v 1.2 88/06/17 17:24:56 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
--- 3,9 ----
  
  
  #ifndef lint
! static char *rcsid_Icons_c = "$Header: Iconify.c,v 1.3 88/07/23 17:24:56 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
***************
*** 61,66 ****
--- 61,67 ----
   * 1.2 -- Jordan Hubbard, Ardent Computer.
   * vPad and hPad usage corrected (Chris Thewalt fix).
   * Clipping now set on right GC. 
+  * 1.3 -- Changed the way icon button events are handled.
   */
   
  #include "awm.h"
***************
*** 190,196 ****
  	       if (awi->iconPixmap != IBackPixmap)
  		    XFreePixmap(dpy, awi->iconPixmap);
  	  }
! 	  awi->icon = 0;
  	  awi->state |= ST_WINDOW;
       }
       Leave_void
--- 191,198 ----
  	       if (awi->iconPixmap != IBackPixmap)
  		    XFreePixmap(dpy, awi->iconPixmap);
  	  }
! 	  awi->icon = (Drawable)NULL;
! 	  awi->state ^= ST_ICON;
  	  awi->state |= ST_WINDOW;
       }
       Leave_void
***************
*** 356,368 ****
        * Select "key pressed", "window exposure" and "unmap window"
        * events for the icon window.
        */
!      XSelectInput(dpy, icon, mask);
!      /*
!       * Handle any registered grabs for the icon window.
!       */
!      for (bptr = Blist; bptr; bptr = bptr->next)
! 	  if (bptr->context & ICON)
! 	       Grab(bptr->mask, icon);
       awi = GetAwmInfo(window);
       awi->icon = icon;
       awi->own = own;
--- 358,365 ----
        * Select "key pressed", "window exposure" and "unmap window"
        * events for the icon window.
        */
!      XSelectInput(dpy, icon, mask | ButtonPressMask | ButtonReleaseMask);
! 
       awi = GetAwmInfo(window);
       awi->icon = icon;
       awi->own = own;
diff -c awm.dst/Imakefile awm/Imakefile
*** awm.dst/Imakefile	Sat Jul  2 16:57:27 1988
--- awm/Imakefile	Sun Jul 24 13:52:44 1988
***************
*** 44,50 ****
  
  ComplexProgramTarget(awm)
  
! InstallNonExec(system.awmrc, $(LIBDIR))
  
  $(MENU_ARCH)::
  	@echo Making menu package...
--- 44,50 ----
  
  ComplexProgramTarget(awm)
  
! InstallNonExec(system.awmrc, $(AWMDIR))
  
  $(MENU_ARCH)::
  	@echo Making menu package...
diff -c awm.dst/Makefile awm/Makefile
*** awm.dst/Makefile	Sat Jul  2 16:57:28 1988
--- awm/Makefile	Sun Jul 24 13:52:58 1988
***************
*** 167,173 ****
  	$(RM) $(PROGRAM)
  
  install:: system.awmrc
! 	$(INSTALL) -c $(INSTALLFLAGS) system.awmrc  $(LIBDIR)
  
  $(MENU_ARCH)::
  	@echo Making menu package...
--- 167,173 ----
  	$(RM) $(PROGRAM)
  
  install:: system.awmrc
! 	$(INSTALL) -c $(INSTALLFLAGS) system.awmrc  $(AWMDIR)
  
  $(MENU_ARCH)::
  	@echo Making menu package...
diff -c awm.dst/Menu.c awm/Menu.c
*** awm.dst/Menu.c	Sat Jul  2 16:57:29 1988
--- awm/Menu.c	Tue Jul 19 17:25:16 1988
***************
*** 58,64 ****
  	  
       pos.x = x;
       pos.y = y;
!      
       RTLMenu_Enter(menu, button, 0, window, pos);
       Leave(TRUE)
  }
--- 58,65 ----
  	  
       pos.x = x;
       pos.y = y;
!      if (!menu)
! 	Leave(FALSE)
       RTLMenu_Enter(menu, button, 0, window, pos);
       Leave(TRUE)
  }
***************
*** 140,147 ****
  		      TargetCursor, CurrentTime )
  	 != GrabSuccess ) {
  	  fprintf(stderr, "awm (Select_Window): Can't grab the mouse.");
! 	  Cleanup();
! 	  exit(1);
       }
       Snatched = TRUE;
       /* Select a window */
--- 141,147 ----
  		      TargetCursor, CurrentTime )
  	 != GrabSuccess ) {
  	  fprintf(stderr, "awm (Select_Window): Can't grab the mouse.");
! 	  Leave(RootWindow(dpy, scr))
       }
       Snatched = TRUE;
       /* Select a window */
diff -c awm.dst/NewIconify.c awm/NewIconify.c
*** awm.dst/NewIconify.c	Sat Jul  2 16:57:32 1988
--- awm/NewIconify.c	Sun Jul 24 18:02:34 1988
***************
*** 3,9 ****
  
  
  #ifndef lint
! static char *rcsid_NewIconify_c = "$Header: NewIconify.c,v 1.1 88/06/15 15:24:56 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
--- 3,9 ----
  
  
  #ifndef lint
! static char *rcsid_NewIconify_c = "$Header: NewIconify.c,v 1.2 88/07/23 17:24:56 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
***************
*** 339,345 ****
       if (awi->state & ST_ICON) {
  	  awi->state ^= ST_ICON;
  	  awi->state |= (ST_WINDOW | ST_PLACED);
! 	  if (!awi->title)
  	       XRemoveFromSaveSet(dpy, awi->client);
       }
       else if (awi->state & ST_WINDOW) {
--- 339,345 ----
       if (awi->state & ST_ICON) {
  	  awi->state ^= ST_ICON;
  	  awi->state |= (ST_WINDOW | ST_PLACED);
! 	  if (!awi->frame)
  	       XRemoveFromSaveSet(dpy, awi->client);
       }
       else if (awi->state & ST_WINDOW) {
diff -c awm.dst/Resize.c awm/Resize.c
*** awm.dst/Resize.c	Sat Jul  2 16:57:37 1988
--- awm/Resize.c	Thu Jul 14 16:53:54 1988
***************
*** 136,154 ****
  
       if (awi->frame) { /* we have to compensate */
  	  status = XGetWindowAttributes(dpy, awi->frame, &frame_info);
  	  if (status == FAILURE)
  	       Leave(FALSE)
  	  if (awi->attrs & AT_TITLE)
! 	       client_info.y = frame_info.y + titleHeight + 2;
  	  if (awi->attrs & AT_BORDER) {
! 	       client_info.x = frame_info.x + BContext + 1;
  	       if (!(awi->attrs & AT_TITLE))
! 		    client_info.y = frame_info.y + BContext + 1;
  	  }
       }
  
       /*
!       * Clear the vector buffers.
        */
       bzero(box, sizeof(box));
       if (Zap)
--- 136,156 ----
  
       if (awi->frame) { /* we have to compensate */
  	  status = XGetWindowAttributes(dpy, awi->frame, &frame_info);
+ 	  client_info.y = frame_info.y;
+ 	  client_info.x = frame_info.x;
  	  if (status == FAILURE)
  	       Leave(FALSE)
  	  if (awi->attrs & AT_TITLE)
! 	       client_info.y += titleHeight + 2;
  	  if (awi->attrs & AT_BORDER) {
! 	       client_info.x += BContext + 1;
  	       if (!(awi->attrs & AT_TITLE))
! 		    client_info.y += BContext + 1;
  	  }
       }
  
       /*
!       * Clear The vector buffers.
        */
       bzero(box, sizeof(box));
       if (Zap)
diff -c awm.dst/Restart.c awm/Restart.c
*** awm.dst/Restart.c	Sat Jul  2 16:57:38 1988
--- awm/Restart.c	Sun Jul 24 17:31:14 1988
***************
*** 3,9 ****
  
  
  #ifndef lint
! static char *rcsid_Restart_c = "$Header: Restart.c,v 1.1 88/06/15 15:24:56 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
--- 3,9 ----
  
  
  #ifndef lint
! static char *rcsid_Restart_c = "$Header: Restart.c,v 1.2 88/07/23 17:24:56 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
***************
*** 136,149 ****
  	  unsigned int i;
  	  
  	  for (i = 0; i < nwins; i++) {
  	       awi = GetAwmInfo(windows[i]);
  	       if (!awi)
  		    continue;
  	       if (awi->state & ST_ICON)
  		    XMapWindow(dpy, awi->client);
  	       RemoveIcon(windows[i]);
! 	       DestroyFrame(windows[i]);
! 	       XDeleteContext(dpy, awi->client, AwmContext);
  	       free(awi);
  	  }
  	  XFree(windows);
--- 136,164 ----
  	  unsigned int i;
  	  
  	  for (i = 0; i < nwins; i++) {
+ 	       XWindowAttributes xwa;
+ 	       int bw;
+ 
  	       awi = GetAwmInfo(windows[i]);
  	       if (!awi)
  		    continue;
+ 	       bw = awi->border_width;
  	       if (awi->state & ST_ICON)
  		    XMapWindow(dpy, awi->client);
  	       RemoveIcon(windows[i]);
! 	       XGetWindowAttributes(dpy, awi->frame, &xwa);
! 	       if (PushDown == FALSE) {
! 		    if (awi->attrs & AT_TITLE)
! 			 xwa.y += (titleHeight + 2);
! 		    else if (awi->attrs & AT_BORDER)
! 			 xwa.y += BContext;
! 	       }
! 	       if (awi->attrs & AT_BORDER)
! 		    xwa.x -= (BContext + (bw ? bw : 1));
! 	       XReparentWindow(dpy, awi->client, RootWindow(dpy, scr),
! 			       xwa.x, xwa.y);
! 	       XRemoveFromSaveSet(dpy, awi->client);
! 	       XSetWindowBorderWidth(dpy, awi->client, awi->border_width);
  	       free(awi);
  	  }
  	  XFree(windows);
diff -c awm.dst/Titlebar.c awm/Titlebar.c
*** awm.dst/Titlebar.c	Tue Jul  5 21:26:34 1988
--- awm/Titlebar.c	Sun Jul 24 17:28:55 1988
***************
*** 3,9 ****
  
  
  #ifndef lint
! static char *rcsid_TitleBar_c = "$Header: TitleBar.c,v 1.2 88/07/02 02:26:00 jkh Exp $";
  #endif	lint
  
  #include "X11/copyright.h"
--- 3,9 ----
  
  
  #ifndef lint
! static char *rcsid_TitleBar_c = "$Header: TitleBar.c,v 1.3 88/07/23 17:26:00 jkh Exp $";
  #endif	lint
  
  #include "X11/copyright.h"
***************
*** 34,39 ****
--- 34,41 ----
   Title bar support routines.
   * 1.2 -- Fairly major restructuring to uncouple title bars and
   * border contexts.
+  * 1.3 -- Handling of colors revamped significantly to deal with
+  * different colormaps.
   */
  
  #include "awm.h"
***************
*** 61,70 ****
       TBackPixmapData = GetPixmapDataRes("title.pixmap", &TB_wide, &TB_high);
       TBoldPixmapData = GetPixmapDataRes("title.boldPixmap", &TBB_wide,
  					&TBB_high);
!      TForeground = GetColorRes("title.foreground", ForeColor);
!      TBackground = GetColorRes("title.background", BackColor);
!      TTextForeground = GetColorRes("title.text.foreground", TForeground);
!      TTextBackground = GetColorRes("title.text.background", TBackground);
  
       TCursor = GetIntRes("title.cursor", DEF_TITLE_CURSOR);
  
--- 63,72 ----
       TBackPixmapData = GetPixmapDataRes("title.pixmap", &TB_wide, &TB_high);
       TBoldPixmapData = GetPixmapDataRes("title.boldPixmap", &TBB_wide,
  					&TBB_high);
!      TForeground = GetStringRes("title.foreground", Foreground);
!      TBackground = GetStringRes("title.background", Background);
!      TTextForeground = GetStringRes("title.text.foreground", TForeground);
!      TTextBackground = GetStringRes("title.text.background", TBackground);
  
       TCursor = GetIntRes("title.cursor", DEF_TITLE_CURSOR);
  
***************
*** 108,115 ****
       
       Entry("Init_Frames")
  
!      BForeground = GetColorRes("borderContext.foreground", ForeColor);
!      BBackground = GetColorRes("borderContext.background", BackColor);
  
       BCursor = GetIntRes("borderContext.cursor", DEF_BCONTEXT_CURSOR);
  
--- 110,117 ----
       
       Entry("Init_Frames")
  
!      BForeground = GetStringRes("borderContext.foreground", Foreground);
!      BBackground = GetStringRes("borderContext.background", Background);
  
       BCursor = GetIntRes("borderContext.cursor", DEF_BCONTEXT_CURSOR);
  
***************
*** 155,161 ****
  /*
   * Reparent window 'w' into a frame, making the frame the right
   * size to hold any other window related decorations that may be
!  * added later.
   */
  Window Reparent(w)
  Window w;
--- 157,164 ----
  /*
   * Reparent window 'w' into a frame, making the frame the right
   * size to hold any other window related decorations that may be
!  * added later. If window 'w' already has a frame, then it resizes
!  * it if necessary.
   */
  Window Reparent(w)
  Window w;
***************
*** 171,176 ****
--- 174,182 ----
       int bch, bcv, x, y, bw, width, height;
       int clnt_x, clnt_y;
       unsigned long valuemask;
+      Boolean decorated = FALSE;
+      Colormap cmap;
+      Pixel bfore, bback;
  
       Entry("Reparent")
  
***************
*** 179,198 ****
  	  fprintf(stderr, "Reparent: Window %x isn't registered!\n", w);
  	  Leave((Window)NULL)
       }
!      if (awi->frame) {
! 	  fprintf(stderr, "Reparent: Window %x already has a frame.\n", w);
  	  Leave((Window)NULL)
-      }
-      if (!(awi->attrs & AT_BORDER) && !(awi->attrs & AT_TITLE))
- 	  Leave((Window)NULL)
  
       if (awi->attrs & AT_BORDER && !Frame_res)
  	  Init_Frames();
       if (awi->attrs & AT_TITLE && !Title_res)
  	  Init_Titles();
  
!      XGetWindowAttributes(dpy, awi->client, &xwa);
!      valuemask = CWEventMask | CWBorderPixel | CWBackPixel;
       swa.event_mask = (SubstructureRedirectMask | SubstructureNotifyMask);
       bw = xwa.border_width;
       x = xwa.x;
--- 185,204 ----
  	  fprintf(stderr, "Reparent: Window %x isn't registered!\n", w);
  	  Leave((Window)NULL)
       }
!      if (awi->frame && (awi->state & ST_DECORATED))
  	  Leave((Window)NULL)
  
       if (awi->attrs & AT_BORDER && !Frame_res)
  	  Init_Frames();
+ 
       if (awi->attrs & AT_TITLE && !Title_res)
  	  Init_Titles();
  
!      if (!awi->frame)
! 	  XGetWindowAttributes(dpy, awi->client, &xwa);
!      else
! 	  XGetWindowAttributes(dpy, awi->frame, &xwa);
!      valuemask = CWEventMask | CWBorderPixel | CWBackPixel | CWColormap;
       swa.event_mask = (SubstructureRedirectMask | SubstructureNotifyMask);
       bw = xwa.border_width;
       x = xwa.x;
***************
*** 199,204 ****
--- 205,214 ----
       y = xwa.y;
       height = xwa.height;
       width = xwa.width;
+      cmap = xwa.colormap;
+      bfore = GetPixel(BForeground, cmap);
+      bback = GetPixel(BBackground, cmap);
+      clnt_y = clnt_x = 0;
       if (awi->attrs & AT_BORDER) {
  	  XSetWindowAttributes cswa;
       
***************
*** 215,232 ****
       if (FrameFocus)
  	  swa.event_mask |= (LeaveWindowMask | EnterWindowMask);
       if (awi->attrs & AT_BORDER) {
! 	  swa.background_pixel = BBackground;
! 	  swa.border_pixel = BForeground;
       }
       else {
! 	  swa.background_pixel = TBackground;
! 	  swa.border_pixel = TForeground;
       }
       if (PushDown == FALSE) {
  	  if (awi->attrs & AT_TITLE)
  	       y -= (titleHeight + 2);
  	  else if (awi->attrs & AT_BORDER)
! 	       y -= (BContext + (bw ? bw : 1));
       }
       /* calculate size for frame */
       if (awi->attrs & AT_TITLE)
--- 225,248 ----
       if (FrameFocus)
  	  swa.event_mask |= (LeaveWindowMask | EnterWindowMask);
       if (awi->attrs & AT_BORDER) {
! 	  swa.background_pixel = bfore;
! 	  swa.border_pixel = bback;
! 	  decorated = TRUE;
       }
+      else if (awi->attrs & AT_TITLE) {
+ 	  swa.background_pixel = GetPixel(TBackground, cmap);
+ 	  swa.border_pixel = GetPixel(TForeground, cmap);
+      }
       else {
! 	  swa.background_pixel = GetPixel(Background, cmap);
! 	  swa.border_pixel = GetPixel(Foreground, cmap);
       }
+      swa.colormap = cmap;
       if (PushDown == FALSE) {
  	  if (awi->attrs & AT_TITLE)
  	       y -= (titleHeight + 2);
  	  else if (awi->attrs & AT_BORDER)
! 	       y -= BContext;
       }
       /* calculate size for frame */
       if (awi->attrs & AT_TITLE)
***************
*** 238,308 ****
  	       height += bcv;
  	  width += bch;
       }
-      if (y < 0)
- 	  y = 0;
-      foster = XCreateWindow(dpy, RootWindow(dpy, scr), x, y, width,
-                             height, (bw ? bw : 1), xwa.depth, xwa.class,
- 			    xwa.visual, valuemask, &swa);
-      if (!foster)
- 	  Error("Reparent: Can't create foster parent!");
-      if (BBackPixmapData) { /* we have a border context tile */
- 	  awi->BC_back = GetPixmapFromCache(foster,
- 					    BBackPixmapData,
- 					    BC_wide, BC_high,
- 					    BForeground, BBackground,
- 					    xwa.depth);
- 	  if (!awi->BC_back)
- 	       Error("Reparent: Can't get pixmap for border context.");
- 	  else
- 	       XSetWindowBackgroundPixmap(dpy, foster, awi->BC_back);
-      }
-      if (BBoldPixmapData) { /* we have a bold border context tile */
- 	  awi->BC_bold = GetPixmapFromCache(foster,
- 					    BBoldPixmapData,
- 					    BCB_wide, BCB_high,
- 					    BForeground, BBackground,
- 					    xwa.depth);
- 	  if (!awi->BC_bold)
- 	       Error("Reparent: Can't get bold pixmap for border context.");
-      }
-      clnt_y = BContext;
-      clnt_x = 0;
- 
       if (awi->attrs & AT_TITLE)
  	  clnt_y = titleHeight + 2;
! 
       if (awi->attrs & AT_BORDER) {
  	  clnt_x = BContext;
-      
- 	  XDefineCursor(dpy, foster, FrameCursor);
       }
-      XAddToSaveSet(dpy, awi->client);
-      XReparentWindow(dpy, awi->client, foster, clnt_x, clnt_y);
  
!      XMapWindow(dpy, awi->client);
!      XSync(dpy, FALSE);
!      awi->frame = foster;
!      awi->border_width = bw;
!      awi->name = GetTitleName(awi->client);
!      /* Make titlebar "frame" inherit characteristics of victim */
!      XStoreName(dpy, foster, awi->name);
!      if (XGetIconName(dpy, w, &icon_name)) {
! 	  XSetIconName(dpy, foster, icon_name);
! 	  free(icon_name);
       }
!      if (wm_hints = XGetWMHints(dpy, awi->client)) {
! 	  XSetWMHints(dpy, foster, wm_hints);
! 	  XFree(wm_hints);
       }
!      XGetNormalHints(dpy, awi->client, &sz_hints);
!      XSetNormalHints(dpy, foster, &sz_hints);
!      XGetZoomHints(dpy, awi->client, &sz_hints);
!      XSetZoomHints(dpy, foster, &sz_hints);
!      class_hints.res_name = class_hints.res_class = (char *)NULL;
!      if (XGetClassHint(dpy, awi->client, &class_hints) == Success)
!      	  XSetClassHint(dpy, foster, &class_hints);
! 
!      XSaveContext(dpy, foster, AwmContext, awi);
       Leave(foster)
  }
       
--- 254,336 ----
  	       height += bcv;
  	  width += bch;
       }
       if (awi->attrs & AT_TITLE)
  	  clnt_y = titleHeight + 2;
!      
       if (awi->attrs & AT_BORDER) {
+ 	  if (!(awi->attrs & AT_TITLE))
+ 	       clnt_y = BContext;
  	  clnt_x = BContext;
       }
  
!      if (!awi->frame) {
! 	  foster = XCreateWindow(dpy, RootWindow(dpy, scr), x, y, width,
! 				 height, (bw ? bw : 1), xwa.depth, xwa.class,
! 				 xwa.visual, valuemask, &swa);
! 	  if (!foster)
! 	       Error("Reparent: Can't create foster parent!");
! 
! 	  if (awi->attrs & AT_BORDER)
! 	       XDefineCursor(dpy, foster, FrameCursor);
! 
! 	  XAddToSaveSet(dpy, awi->client);
! 	  XReparentWindow(dpy, awi->client, foster, clnt_x, clnt_y);
! 	  XMapWindow(dpy, awi->client);
! 	  XSync(dpy, FALSE);
! 
! 	  if (BBackPixmapData) { /* we have a border context tile */
! 	       awi->BC_back = GetPixmapFromCache(foster,
! 						 BBackPixmapData,
! 						 BC_wide, BC_high,
! 						 bfore, bback,
! 						 xwa.depth);
! 	       if (!awi->BC_back)
! 		    Error("Reparent: Can't get pixmap for border context.");
! 	       else
! 		    XSetWindowBackgroundPixmap(dpy, foster, awi->BC_back);
! 	  }
! 	  if (BBoldPixmapData) { /* we have a bold border context tile */
! 	       awi->BC_bold = GetPixmapFromCache(foster,
! 						 BBoldPixmapData,
! 						 BCB_wide, BCB_high,
! 						 bfore, bback,
! 						 xwa.depth);
! 	       if (!awi->BC_bold)
! 		    Error("Reparent: Can't get bold pixmap for border context.");
! 	  }
! 	  awi->frame = foster;
! 	  awi->border_width = bw;
! 	  awi->name = GetTitleName(awi->client);
! 
! 	  /* Make titlebar "frame" inherit characteristics of victim */
! 	  XStoreName(dpy, foster, awi->name);
! 	  if (XGetIconName(dpy, w, &icon_name)) {
! 	       XSetIconName(dpy, foster, icon_name);
! 	       free(icon_name);
! 	  }
! 	  if (wm_hints = XGetWMHints(dpy, awi->client)) {
! 	       XSetWMHints(dpy, foster, wm_hints);
! 	       XFree(wm_hints);
! 	  }
! 	  XGetNormalHints(dpy, awi->client, &sz_hints);
! 	  XSetNormalHints(dpy, foster, &sz_hints);
! 	  XGetZoomHints(dpy, awi->client, &sz_hints);
! 	  XSetZoomHints(dpy, foster, &sz_hints);
! 	  class_hints.res_name = class_hints.res_class = (char *)NULL;
! 	  if (XGetClassHint(dpy, awi->client, &class_hints) == Success)
! 	       XSetClassHint(dpy, foster, &class_hints);
! 	  
! 	  XSaveContext(dpy, foster, AwmContext, awi);
       }
!      else {
! 	  XMoveResizeWindow(dpy, awi->frame, xwa.x, xwa.y, width, height);
! 	  XMoveWindow(dpy, awi->client, clnt_x, clnt_y);
! 	  if (awi->attrs & AT_BORDER)
! 	       decorated = TRUE;
! 	  foster = awi->frame;
       }
!      if (decorated)
! 	  awi->state |= ST_DECORATED;
       Leave(foster)
  }
       
***************
*** 316,321 ****
--- 344,350 ----
       XWindowAttributes xwa;
       XSetWindowAttributes swa;
       XWindowChanges wc;
+      Pixel tfore, tback;
  
       Entry("AddTitle")
  
***************
*** 325,345 ****
  	  fprintf(stderr, "AddTitle: Window %x is not registered!\n", w);
  	  Leave_void
       }
!      if (!awi->frame) {
! 	  fprintf(stderr, "AddTitle: Window %x doesn't have a frame!\n", w);
  	  Leave_void
!      }
!      if (awi->title) {
! 	  fprintf(stderr, "AddTitle: Window %x already has a title!\n", w);
  	  Leave_void
-      }
       if (!(awi->attrs & AT_TITLE))
  	  Leave_void
  
       XGetWindowAttributes(dpy, awi->client, &xwa);
-      swa.bit_gravity = CenterGravity;
       swa.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
!      valuemask |= CWBitGravity;
       if (awi->attrs & AT_BORDER)
  	  bch = (BContext * 2) + 2;
       else
--- 354,374 ----
  	  fprintf(stderr, "AddTitle: Window %x is not registered!\n", w);
  	  Leave_void
       }
!      if (!awi->frame) 
  	  Leave_void
!      if (awi->title)
  	  Leave_void
       if (!(awi->attrs & AT_TITLE))
  	  Leave_void
  
       XGetWindowAttributes(dpy, awi->client, &xwa);
       swa.event_mask = (ExposureMask | ButtonPressMask | ButtonReleaseMask);
!      swa.colormap = xwa.colormap;
!      tfore = GetPixel(TForeground, xwa.colormap);
!      tback = GetPixel(TBackground, xwa.colormap);
!      swa.background_pixel = tback;
!      swa.border_pixel = tfore;
!      valuemask = (CWEventMask | CWColormap | CWBackPixel | CWBorderPixel);
       if (awi->attrs & AT_BORDER)
  	  bch = (BContext * 2) + 2;
       else
***************
*** 346,352 ****
  	  bch = 0;
       title = XCreateWindow(dpy, awi->frame, 0, 0, (xwa.width - 2) + bch,
  			   titleHeight,
! 			   1, 0, CopyFromParent, CopyFromParent,
  			   valuemask, &swa);
       if (!title)
  	  Error("AddTitle: Can't create title bar!");
--- 375,381 ----
  	  bch = 0;
       title = XCreateWindow(dpy, awi->frame, 0, 0, (xwa.width - 2) + bch,
  			   titleHeight,
! 			   1, xwa.depth, xwa.class, xwa.visual,
  			   valuemask, &swa);
       if (!title)
  	  Error("AddTitle: Can't create title bar!");
***************
*** 353,359 ****
       if (TBackPixmapData) {
  	  awi->back = GetPixmapFromCache(title, TBackPixmapData,
  					 TB_wide, TB_high,
! 					 TForeground, TBackground,
  					 xwa.depth);
  	  if (!awi->back)
  	       Error("AddTitle: Can't create pixmap for title background");
--- 382,388 ----
       if (TBackPixmapData) {
  	  awi->back = GetPixmapFromCache(title, TBackPixmapData,
  					 TB_wide, TB_high,
! 					 tfore, tback,
  					 xwa.depth);
  	  if (!awi->back)
  	       Error("AddTitle: Can't create pixmap for title background");
***************
*** 363,375 ****
       if (TBoldPixmapData) {
  	  awi->bold = GetPixmapFromCache(title, TBoldPixmapData,
  					 TBB_wide, TBB_high,
! 					 TForeground, TBackground,
  					 xwa.depth);
  	  if (!awi->bold)
  	       Error("AddTitle: Can't create pixmap for bold background");
       }
       XSetWindowBorderWidth(dpy, awi->client,
! 			   (awi->attrs & AT_BORDER ? 1 : 0));
       wc.sibling = awi->client;
       wc.stack_mode = Above;
       XConfigureWindow(dpy, title, CWSibling|CWStackMode, &wc);
--- 392,404 ----
       if (TBoldPixmapData) {
  	  awi->bold = GetPixmapFromCache(title, TBoldPixmapData,
  					 TBB_wide, TBB_high,
! 					 tfore, tback,
  					 xwa.depth);
  	  if (!awi->bold)
  	       Error("AddTitle: Can't create pixmap for bold background");
       }
       XSetWindowBorderWidth(dpy, awi->client,
! 			   ((awi->attrs & AT_BORDER) ? 1 : 0));
       wc.sibling = awi->client;
       wc.stack_mode = Above;
       XConfigureWindow(dpy, title, CWSibling|CWStackMode, &wc);
***************
*** 378,383 ****
--- 407,413 ----
  		       ButtonReleaseMask));
       XMapWindow(dpy, title);
       awi->title = title;
+      awi->state |= ST_DECORATED;
       XSaveContext(dpy, title, AwmContext, awi);
  }
  
***************
*** 389,410 ****
  	  
       if (w == RootWindow(dpy, scr))
  	  Leave(FALSE)
!      DestroyFrame(w, FALSE);
       Leave(TRUE)
  }
  
! void DestroyFrame(w)
  Window w;
  {
       XWindowAttributes xwa;
       AwmInfoPtr awi;
-      
-      Entry("DestroyFrame")
  
       awi = GetAwmInfo(w);
       if (!awi || !awi->frame)
  	 Leave_void
!      XGetWindowAttributes(dpy, awi->frame, &xwa);
       if (awi->gadgets)
  	  DestroyGadgets(w);
       if (awi->title) {
--- 419,443 ----
  	  
       if (w == RootWindow(dpy, scr))
  	  Leave(FALSE)
!      NoDecorate(w, FALSE);
       Leave(TRUE)
  }
  
! void NoDecorate(w, destroy)
  Window w;
+ Boolean destroy;
  {
       XWindowAttributes xwa;
       AwmInfoPtr awi;
  
+      Entry("NoDecorate")
+ 
       awi = GetAwmInfo(w);
       if (!awi || !awi->frame)
  	 Leave_void
! 
!      if (!(awi->state & ST_DECORATED))
! 	 Leave_void
       if (awi->gadgets)
  	  DestroyGadgets(w);
       if (awi->title) {
***************
*** 414,443 ****
  	  if (awi->bold)
  	       FreePixmapFromCache(awi->bold);
  	  XDestroyWindow(dpy, awi->title);
! 	  awi->title = (Drawable)NULL;
       }
!      if (awi->BC_back)
! 	  FreePixmapFromCache(awi->BC_back);
!      if (awi->BC_bold)
! 	  FreePixmapFromCache(awi->BC_bold);
!      free(awi->name);
!      if (PushDown == FALSE) {
! 	  if (awi->attrs & AT_TITLE)
! 	       xwa.y += (titleHeight + 2);
! 	  else if (awi->attrs & AT_BORDER)
! 	       xwa.y += (BContext +
! 			 (awi->border_width ? awi->border_width : 1));
       }
!      XReparentWindow(dpy, awi->client, RootWindow(dpy, scr), xwa.x,
! 	xwa.y);
!      XDeleteContext(dpy, awi->frame, AwmContext);
!      XDestroyWindow(dpy, awi->frame);
!      XSetWindowBorderWidth(dpy, awi->client, awi->border_width);
!      if (!(awi->state & ST_ICON))
! 	  XRemoveFromSaveSet(dpy, awi->client);
!      awi->frame = awi->back = awi->bold =
! 	  awi->BC_back = awi->BC_bold = (Drawable)NULL;
!      awi->name = (char *)NULL;
       XSync(dpy, FALSE);
       Leave_void
  }
--- 447,471 ----
  	  if (awi->bold)
  	       FreePixmapFromCache(awi->bold);
  	  XDestroyWindow(dpy, awi->title);
! 	  awi->title = awi->back = awi->bold = (Drawable)NULL;
       }
!      if (destroy) {
! 	  XDeleteContext(dpy, awi->frame, AwmContext);
! 	  if (awi->BC_back)
! 	       FreePixmapFromCache(awi->BC_back);
! 	  if (awi->BC_bold)
! 	       FreePixmapFromCache(awi->BC_bold);
! 	  free(awi->name);
! 	  awi->name = (char *)NULL;
! 	  XDestroyWindow(dpy, awi->frame);
! 	  awi->frame = awi->BC_back = awi->BC_bold = (Drawable)NULL;
       }
!      else {
! 	  XGetWindowAttributes(dpy, awi->client, &xwa);
! 	  XResizeWindow(dpy, awi->frame, xwa.width, xwa.height);
! 	  XMoveWindow(dpy, awi->client, 0, 0);
! 	  awi->state ^= ST_DECORATED;
!      }
       XSync(dpy, FALSE);
       Leave_void
  }
***************
*** 465,470 ****
--- 493,499 ----
  Window w;
  {
       Window ret;
+      AwmInfoPtr awi;
  
       Entry("Decorate")
  
***************
*** 487,492 ****
--- 516,522 ----
       XFontStruct *f_info;
       AwmInfoPtr awi;
       XGCValues gcv;
+      Colormap cmap;
  
       Entry("PaintTitle")
  
***************
*** 493,498 ****
--- 523,529 ----
       if (!(awi = IsTitled(w)))
  	 Leave_void
       XGetWindowAttributes(dpy, awi->title, &xwa);
+      cmap = xwa.colormap;
       if (reversed && TFontBoldInfo)
  	  f_info = TFontBoldInfo;
       else
***************
*** 499,507 ****
  	  f_info = TFontInfo;
       gcv.font = f_info->fid;
       gcv.foreground = (reversed && !TFontBoldInfo) ?
! 	  TTextBackground : TTextForeground;
       gcv.background = (reversed && !TFontBoldInfo) ?
! 	  TTextForeground : TTextBackground;
       XChangeGC(dpy, awi->winGC, (GCFont | GCForeground | GCBackground), &gcv);
       XClearWindow(dpy, awi->title);
       if (ShowName) {	/* print window names? */
--- 530,538 ----
  	  f_info = TFontInfo;
       gcv.font = f_info->fid;
       gcv.foreground = (reversed && !TFontBoldInfo) ?
! 	  GetPixel(TTextBackground, cmap) : GetPixel(TTextForeground, cmap);
       gcv.background = (reversed && !TFontBoldInfo) ?
! 	  GetPixel(TTextForeground, cmap) : GetPixel(TTextBackground, cmap);
       XChangeGC(dpy, awi->winGC, (GCFont | GCForeground | GCBackground), &gcv);
       XClearWindow(dpy, awi->title);
       if (ShowName) {	/* print window names? */
diff -c awm.dst/awm.c awm/awm.c
*** awm.dst/awm.c	Tue Jul  5 21:26:38 1988
--- awm/awm.c	Sun Jul 24 17:24:11 1988
***************
*** 3,9 ****
  
  
  #ifndef lint
! static char *rcsid_awm_c = "$Header: awm.c,v 1.2 88/07/02 01:24:56 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
--- 3,9 ----
  
  
  #ifndef lint
! static char *rcsid_awm_c = "$Header: awm.c,v 1.3 88/07/23 17:24:56 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
***************
*** 204,210 ****
  	  fprintf(stderr, "awm: Unable to open display\n");
  	  exit(1);
       }
!      scr = DefaultScreen(dpy); 
       
       /*
        * Set XErrorFunction to be non-terminating.
--- 204,211 ----
  	  fprintf(stderr, "awm: Unable to open display\n");
  	  exit(1);
       }
! 
!      scr = DefaultScreen(dpy);
       
       /*
        * Set XErrorFunction to be non-terminating.
***************
*** 271,279 ****
  	  if (Startup_File_Error)
  	       Error("Bad startup file...aborting");
       }
!      
       if (Startup_File_Error)
  	  Error("Bad startup file...aborting");
       /*
        * Catch some of the basic signals so we don't get rudely killed without
        * cleaning up first.
--- 272,281 ----
  	  if (Startup_File_Error)
  	       Error("Bad startup file...aborting");
       }
! 
       if (Startup_File_Error)
  	  Error("Bad startup file...aborting");
+ 
       /*
        * Catch some of the basic signals so we don't get rudely killed without
        * cleaning up first.
***************
*** 282,288 ****
       signal(SIGTERM, Quit);
       signal(SIGQUIT, Quit);
       signal(SIGINT, Quit);
!      
       /*
        * If the root window has not been named, name it.
        */
--- 284,290 ----
       signal(SIGTERM, Quit);
       signal(SIGQUIT, Quit);
       signal(SIGINT, Quit);
! 
       /*
        * If the root window has not been named, name it.
        */
***************
*** 289,307 ****
       status = XFetchName(dpy, RootWindow(dpy, scr), &root_name);
       if (root_name == NULL) 
  	  XStoreName(dpy, RootWindow(dpy, scr), " X Root Window ");
!      else free(root_name);
       /* register the root window */
       RegisterWindow(RootWindow(dpy, scr));
!      
       ScreenHeight = DisplayHeight(dpy, scr);
       ScreenWidth = DisplayWidth(dpy, scr);
!      
       /*
        * Create the menus. This function also sticks the RTL menu "handle"
        * into the appropriate binding after it's been created and initialized.
        */
       Create_Menus();
!      
       /*
        * check the gadgets.
        */
--- 291,310 ----
       status = XFetchName(dpy, RootWindow(dpy, scr), &root_name);
       if (root_name == NULL) 
  	  XStoreName(dpy, RootWindow(dpy, scr), " X Root Window ");
!      else
! 	  free(root_name);
       /* register the root window */
       RegisterWindow(RootWindow(dpy, scr));
! 
       ScreenHeight = DisplayHeight(dpy, scr);
       ScreenWidth = DisplayWidth(dpy, scr);
! 
       /*
        * Create the menus. This function also sticks the RTL menu "handle"
        * into the appropriate binding after it's been created and initialized.
        */
       Create_Menus();
! 
       /*
        * check the gadgets.
        */
***************
*** 310,316 ****
  	  Cleanup();
  	  exit(1);
       }
!      
       /*
        * Store all the cursors.
        */
--- 313,319 ----
  	  Cleanup();
  	  exit(1);
       }
! 
       /*
        * Store all the cursors.
        */
***************
*** 321,331 ****
        */
       Grab_Buttons();
       
-      /*
-       * Initialize titlebar data.
-       */
-      if (Titles)
- 	  Init_Titles();
       /* 
        * watch for initial window mapping and window destruction
        */
--- 324,329 ----
***************
*** 332,338 ****
       
       errorStatus = False;
       swa.event_mask = (SubstructureRedirectMask | FocusChangeMask |
! 		       (NeedRootInput ? EVENTMASK | OwnerGrabButtonMask : 0));
       XChangeWindowAttributes(dpy, RootWindow(dpy, scr), CWEventMask, &swa);
       XSync(dpy, False);
       if (errorStatus == True) {
--- 330,337 ----
       
       errorStatus = False;
       swa.event_mask = (SubstructureRedirectMask | FocusChangeMask |
! 		       (NeedRootInput ? EVENTMASK |
! 			OwnerGrabButtonMask : 0));
       XChangeWindowAttributes(dpy, RootWindow(dpy, scr), CWEventMask, &swa);
       XSync(dpy, False);
       if (errorStatus == True) {
***************
*** 410,423 ****
       /*
        * Create graphics context.
        */
-      xgc.foreground = ITextForeground;
-      xgc.background = ITextBackground;
       xgc.font = IFontInfo->fid;
       xgc.graphics_exposures = FALSE;
       IconGC = XCreateGC(dpy, 
  			RootWindow(dpy, scr),
! 			(GCForeground|GCBackground|GCGraphicsExposures|GCFont),
! 			&xgc);
       
       xgc.foreground = PForeground;
       xgc.background = PBackground;
--- 409,422 ----
       /*
        * Create graphics context.
        */
       xgc.font = IFontInfo->fid;
       xgc.graphics_exposures = FALSE;
+      xgc.foreground = IForeground;
+      xgc.background = IBackground;
       IconGC = XCreateGC(dpy, 
  			RootWindow(dpy, scr),
! 			(GCForeground | GCBackground | GCGraphicsExposures |
! 			 GCFont), &xgc);
       
       xgc.foreground = PForeground;
       xgc.background = PBackground;
***************
*** 424,437 ****
       xgc.font = PFontInfo->fid;
       PopGC = XCreateGC(dpy, 
  		       RootWindow(dpy, scr),
! 		       (GCForeground|GCBackground|GCFont), &xgc);
       xgc.line_width = DRAW_WIDTH;
       xgc.foreground = DRAW_VALUE;
       xgc.function = DRAW_FUNC;
       xgc.subwindow_mode = IncludeInferiors;
       DrawGC = XCreateGC(dpy, RootWindow(dpy, scr), 
! 			GCLineWidth|GCForeground|GCFunction|GCSubwindowMode,
! 			&xgc);
  
       /*
        * As our last "startup" task, invoke the execfile if was specified.
--- 423,436 ----
       xgc.font = PFontInfo->fid;
       PopGC = XCreateGC(dpy, 
  		       RootWindow(dpy, scr),
! 		       (GCForeground | GCBackground | GCFont), &xgc);
       xgc.line_width = DRAW_WIDTH;
       xgc.foreground = DRAW_VALUE;
       xgc.function = DRAW_FUNC;
       xgc.subwindow_mode = IncludeInferiors;
       DrawGC = XCreateGC(dpy, RootWindow(dpy, scr), 
! 			GCLineWidth | GCForeground | GCFunction |
! 			GCSubwindowMode, &xgc);
  
       /*
        * As our last "startup" task, invoke the execfile if was specified.
***************
*** 492,497 ****
--- 491,499 ----
  	       continue;
  	  
  	  awi = GetAwmInfo(bwin);
+ 	  if (!awi)
+ 	       continue;
+ 
            if (awi->frame == bwin)
                 context = BORDER;
  	  else if (awi->title == bwin)
***************
*** 506,511 ****
--- 508,514 ----
  	  }
  	  else
  	       context = WINDOW;
+ 
  	  /*
  	   * Get the button event detail.
  	   */
***************
*** 520,528 ****
  		   (((int)bptr->mask & ModMask) != hi))
  		    continue;
  	       
! 	       if ((bptr->context & context) != context)
  		    continue;
! 	       
  	       if (!(bptr->mask & ButtonDown))
  		    continue;
  	       
--- 523,531 ----
  		   (((int)bptr->mask & ModMask) != hi))
  		    continue;
  	       
! 	       if ((bptr->context & context) != context) {
  		    continue;
!                }
  	       if (!(bptr->mask & ButtonDown))
  		    continue;
  	       
***************
*** 549,555 ****
  		*/
  	       if (XPending(dpy) && GetButton(&button_event)) {
  		    bwin = button_event.xbutton.window;
- 		    
  		    /*
  		     * If it's not a release of button that was pressed,
  		     * don't do the function bound to 'ButtonUp'.
--- 552,557 ----
***************
*** 572,579 ****
  						   &event_win);
  		    if (status == BadWindow)
  			 break;
- 		    
  		    awi = GetAwmInfo(bwin);
  		    if (awi->frame == bwin)
  			 context = BORDER;
  		    else if (awi->title == bwin)
--- 574,582 ----
  						   &event_win);
  		    if (status == BadWindow)
  			 break;
  		    awi = GetAwmInfo(bwin);
+ 		    if (!awi)
+ 			 continue;
  		    if (awi->frame == bwin)
  			 context = BORDER;
  		    else if (awi->title == bwin)
***************
*** 580,588 ****
  			 context = TITLE;
  		    else if (IsGadgetWin(bwin, &num))
  			 context = GADGET | (1 << (num + BITS_USED));
! 		    else if (bwin == awi->icon)
  			 context = ICON;
! 		    else if (!event_win || awi->client == RootWindow(dpy, scr)) {
  			 event_win = RootWindow(dpy, scr);
  			 context = ROOT;
  		    }
--- 583,591 ----
  			 context = TITLE;
  		    else if (IsGadgetWin(bwin, &num))
  			 context = GADGET | (1 << (num + BITS_USED));
! 		    else if (awi->icon == bwin)
  			 context = ICON;
! 		    else if (awi->client == RootWindow(dpy, scr)) {
  			 event_win = RootWindow(dpy, scr);
  			 context = ROOT;
  		    }
***************
*** 597,604 ****
  			     (((int)bptr->mask & ModMask) != hi))
  			      continue;
  			 
! 			 if (!((bptr->context & context) == context))
  			      continue;
  			 
  			 if (!(bptr->mask & ButtonUp))
  			      continue;
--- 600,608 ----
  			     (((int)bptr->mask & ModMask) != hi))
  			      continue;
  			 
! 			 if (!((bptr->context & context) == context)) {
  			      continue;
+                          }
  			 
  			 if (!(bptr->mask & ButtonUp))
  			      continue;
***************
*** 636,652 ****
  						   &junk);
  		    if (status == BadWindow)
  			 break;
  		    /*
  		     * Determine the event window and context.
  		     */
! 		    if (awi->title == bwin)
  			 context = TITLE;
  		    else if (IsGadgetWin(bwin, &num))
  			 context = GADGET | (1 << (num + BITS_USED));
- 		    else if (event_win == RootWindow(dpy, scr))
- 			 context = ROOT;
  		    else if (awi->icon == bwin)
  			 context = ICON;
  		    else
  			 context = WINDOW;
  		    /*
--- 640,661 ----
  						   &junk);
  		    if (status == BadWindow)
  			 break;
+ 
  		    /*
  		     * Determine the event window and context.
  		     */
! 		    if (awi->frame == bwin)
! 			 context = BORDER;
! 		    else if (awi->title == bwin)
  			 context = TITLE;
  		    else if (IsGadgetWin(bwin, &num))
  			 context = GADGET | (1 << (num + BITS_USED));
  		    else if (awi->icon == bwin)
  			 context = ICON;
+ 		    else if (awi->client == RootWindow(dpy, scr)) {
+ 			 event_win = RootWindow(dpy, scr);
+ 			 context = ROOT;
+ 		    }
  		    else
  			 context = WINDOW;
  		    /*
***************
*** 701,713 ****
--- 710,737 ----
        * Get the pixmap search path, if it exists.
        */
       awmPath = GetStringRes("path", NULL);
+ 
+      /* Default foreground/background colors (text) */
+      Foreground = GetStringRes("foreground", "black");
+      Background = GetStringRes("background", "white");
       
+      if (Reverse) { /* Swap the foreground and background */
+ 	  char *tmp;
+ 	  
+ 	  tmp = Foreground;
+ 	  Foreground = Background;
+           Background = tmp;
+      }
+      WBorder = GetStringRes("border.foreground", Foreground);
+      
       Autoselect = GetBoolRes("autoselect", FALSE);
       Autoraise = GetBoolRes("autoraise", FALSE);
+      Borders = GetBoolRes("borderContexts", FALSE);
       ConstrainResize = GetBoolRes("constrainResize", FALSE);
       FrameFocus = GetBoolRes("frameFocus", FALSE);
       Freeze = GetBoolRes("freeze", FALSE);
       Grid = GetBoolRes("grid", FALSE);
+      InstallColormap = GetBoolRes("installColormap", FALSE);
       Titles = GetBoolRes("titles", FALSE);
       PushDown = GetBoolRes("title.push", FALSE);
       UseGadgets = GetBoolRes("gadgets", FALSE);
***************
*** 730,736 ****
       HIconPad = GetIntRes("icon.hPad", DEF_ICON_PAD);
       VIconPad = GetIntRes("icon.vPad", DEF_ICON_PAD);
       RaiseDelay = GetIntRes("raiseDelay", DEF_RAISE_DELAY);
-      MaxColors = GetIntRes("maxColors", DEF_MAX_COLORS);
       PBorderWidth = GetIntRes("popup.borderWidth", DEF_POP_BORDER_WIDTH);
       IBorderWidth = GetIntRes("icon.borderWidth", DEF_ICON_BORDER_WIDTH);
       PPadding = GetIntRes("popup.pad", DEF_POP_PAD);
--- 754,759 ----
***************
*** 742,764 ****
       Volume = GetIntRes("volume", DEF_VOLUME);
       Pushval = GetIntRes("push", DEF_PUSH);
       BContext = GetIntRes("borderContext.width", DEF_BCONTEXT_WIDTH);
!      
!      /*
!       * Retrieve the information structure for the specifed fonts and
!       * set the global font information pointers.
!       */
!      /* Default foreground/background colors */
       ForeColor = GetColorRes("foreground", BlackPixel(dpy, scr));
       BackColor = GetColorRes("background", WhitePixel(dpy, scr));
!      
!      if (Reverse) { /* Swap the forecolor and backcolor */
! 	  Pixel tmp;
! 	  
! 	  tmp = ForeColor;
! 	  ForeColor = BackColor;
!           BackColor = tmp;
!      }
!      
       /*
        * Create and store the grey and solid pixmaps
        */
--- 765,785 ----
       Volume = GetIntRes("volume", DEF_VOLUME);
       Pushval = GetIntRes("push", DEF_PUSH);
       BContext = GetIntRes("borderContext.width", DEF_BCONTEXT_WIDTH);
! 
       ForeColor = GetColorRes("foreground", BlackPixel(dpy, scr));
       BackColor = GetColorRes("background", WhitePixel(dpy, scr));
!      IForeground = GetColorRes("icon.foreground", ForeColor);
!      IBackground = GetColorRes("icon.background", BackColor);
!      IBorder = GetColorRes("icon.border", IForeground);
!      ITextForeground = GetColorRes("icon.text.foreground", IForeground);
!      ITextBackground = GetColorRes("icon.text.background", IBackground);
!      PBorder = GetColorRes("popup.border", ForeColor);
!      PForeground = GetColorRes("popup.foreground", PBorder);
!      PBackground = GetColorRes("popup.background", BackColor);
!      MForeground = GetColorRes("menu.foreground", ForeColor);
!      MBackground = GetColorRes("menu.background", BackColor);
!      MBorder = GetColorRes("menu.border", MForeground);
! 
       /*
        * Create and store the grey and solid pixmaps
        */
***************
*** 781,798 ****
       MFontInfo = GetFontRes("menu.font", DEF_MENU_FONT);
       MBoldFontInfo = GetFontRes("menu.boldFont", DEF_BOLD_FONT);
  
-      WBorder = GetColorRes("border.foreground", ForeColor);
-      IForeground = GetColorRes("icon.foreground", ForeColor);
-      IBackground = GetColorRes("icon.background", BackColor);
-      IBorder = GetColorRes("icon.border", IForeground);
-      ITextForeground = GetColorRes("icon.text.foreground", IForeground);
-      ITextBackground = GetColorRes("icon.text.background", IBackground);
-      PBorder = GetColorRes("popup.border", ForeColor);
-      PForeground = GetColorRes("popup.foreground", PBorder);
-      PBackground = GetColorRes("popup.background", BackColor);
-      MForeground = GetColorRes("menu.foreground", ForeColor);
-      MBackground = GetColorRes("menu.background", BackColor);
-      MBorder = GetColorRes("menu.border", MForeground);
       
       IBackPixmap = GetPixmapRes("icon.pixmap", GrayPixmap, IForeground,
  				IBackground);
--- 802,807 ----
***************
*** 849,855 ****
       
       if ((cp = XGetDefault(dpy, NAME, string)) ||
  	 (cp = XGetDefault(dpy, CLASS, string)))
! 	  if (Pred(cp, TRUE))
  		def_val = TRUE;
       Leave(def_val)
  }
--- 858,864 ----
       
       if ((cp = XGetDefault(dpy, NAME, string)) ||
  	 (cp = XGetDefault(dpy, CLASS, string)))
! 	  if (Pred(cp) > 0)
  		def_val = TRUE;
       Leave(def_val)
  }
***************
*** 944,950 ****
  
  /*
   * Try to allocate color resource named by "string", return "color"
!  * if not found.
   */
  Pixel GetColorRes(string, color)
  char *string;
--- 953,960 ----
  
  /*
   * Try to allocate color resource named by "string", return "color"
!  * if not found.This routine is only used for allocating colors from
!  * the default colormap.
   */
  Pixel GetColorRes(string, color)
  char *string;
***************
*** 952,963 ****
  {
       char *cp;
       Pixel tmp_color;
       
       Entry("GetColorRes")
       
       if ((cp = XGetDefault(dpy, NAME, string)) ||
  	 (cp = XGetDefault(dpy, CLASS, string))) {
! 	  if ((tmp_color = LookupColor(cp)) != NOCOLOR)
  	       Leave(tmp_color)
  	  else
  	       tmp_color = color;
--- 962,975 ----
  {
       char *cp;
       Pixel tmp_color;
+      Boolean status;
       
       Entry("GetColorRes")
       
       if ((cp = XGetDefault(dpy, NAME, string)) ||
  	 (cp = XGetDefault(dpy, CLASS, string))) {
! 	  tmp_color = LookupColor(cp, DefaultColormap(dpy, scr), &status);
! 	  if (!status) /* lookup succeeded */
  	       Leave(tmp_color)
  	  else
  	       tmp_color = color;
***************
*** 1020,1025 ****
--- 1032,1038 ----
       AwmInfoPtr tmp;
       XClassHint clh;
       XWMHints *wm_hints;
+      char *cp;
  
       Entry("RegisterWindow")
       
***************
*** 1035,1042 ****
       tmp->winGC = XCreateGC(dpy, w, (unsigned long)0, 0);
       /*
        * Determine attribute set by first turning on all attributes
!       * that are set by booleans and then selectively turning off the
!       * ones that windows "reject".
        */
       tmp->attrs = AT_NONE;
       if (Titles)
--- 1048,1055 ----
       tmp->winGC = XCreateGC(dpy, w, (unsigned long)0, 0);
       /*
        * Determine attribute set by first turning on all attributes
!       * that are set by booleans and then (possibly) override them
!       * by checking to see what an individual window might want.
        */
       tmp->attrs = AT_NONE;
       if (Titles)
***************
*** 1043,1049 ****
  	  tmp->attrs |= AT_TITLE;
       if (UseGadgets)
  	  tmp->attrs |= AT_GADGETS;
!      if (BContext)
  	  tmp->attrs |= AT_BORDER;
       if (Autoraise)
  	  tmp->attrs |= AT_RAISE;
--- 1056,1062 ----
  	  tmp->attrs |= AT_TITLE;
       if (UseGadgets)
  	  tmp->attrs |= AT_GADGETS;
!      if (Borders)
  	  tmp->attrs |= AT_BORDER;
       if (Autoraise)
  	  tmp->attrs |= AT_RAISE;
***************
*** 1054,1131 ****
       }
       clh.res_name = clh.res_class = (char *)NULL;
       XGetClassHint(dpy, w, &clh);
-      if (clh.res_name) {
- 	  if (Pred(XGetDefault(dpy, clh.res_name, "wm_option.title"),
- 		   FALSE))
- 	       tmp->attrs ^= AT_TITLE;
- 	  if (Pred(XGetDefault(dpy, clh.res_name, "wm_option.gadgets"),
- 		   FALSE))
- 	       tmp->attrs ^= AT_GADGETS;
- 	  if (Pred(XGetDefault(dpy, clh.res_name, "wm_option.borderContext"),
- 		   FALSE))
- 	       tmp->attrs ^= AT_BORDER;
- 	  if (Pred(XGetDefault(dpy, clh.res_name, "wm_option.autoRaise"),
- 		   FALSE))
- 	       tmp->attrs ^= AT_RAISE;
-      }
       if (clh.res_class) {
! 	  if (Pred(XGetDefault(dpy, clh.res_class, "wm_option.title"),
! 		   FALSE))
! 	       tmp->attrs ^= AT_TITLE;
! 	  if (Pred(XGetDefault(dpy, clh.res_class, "wm_option.gadgets"),
! 		   FALSE))
! 	       tmp->attrs ^= AT_GADGETS;
! 	  if (Pred(XGetDefault(dpy, clh.res_class, "wm_option.borderContext"),
! 		   FALSE))
! 	       tmp->attrs ^= AT_BORDER;
! 	  if (Pred(XGetDefault(dpy, clh.res_class, "wm_option.autoRaise"),
! 		   FALSE))
! 	       tmp->attrs ^= AT_RAISE;
       }
       XSaveContext(dpy, w, AwmContext, tmp);
       Leave(tmp)
  }
  
! /* check whether a string denotes an "on" or "off" value */
! Boolean Pred(s, bval)
  char *s;
- Boolean bval;
  {
       int i, len;
       char *tmp;
!      Boolean ret = FALSE;
       Entry("Pred")
  
       if (!s)
! 	  Leave(FALSE)
       len = strlen(s);
       if (!len)
! 	  Leave(FALSE)
       tmp = (char *)malloc(len + 1);
       if (!tmp) {
  	  fprintf(stderr, "awm: Pred: Can't allocate storage for '%s'!\n", s);
! 	  Leave(FALSE)
       }
       strcpy(tmp, s);
       for (i = 0; i < len; i++)
  	  if (tmp[i] >= 'A' && tmp[i] <= 'Z')
  	       tmp[i] += 32;
!      if (bval == TRUE) { /* check for "on" */
! 	  if (*tmp == 'y' || !strcmp(tmp, "on")
! 	      || !strcmp(tmp, "true")
! 	      || !strcmp(tmp, "enable"))
! 	       ret = TRUE;
!      }
!      else { /* check for "off" */
! 	  if (*tmp == 'n' || !strcmp(tmp, "off")
  	      || !strcmp(tmp, "false")
  	      || !strcmp(tmp, "disable"))
! 	       ret = TRUE;
!      }
       free(tmp);
       Leave(ret)
  }
- 	  
  
  /*
   * Initialize the default bindings.  First, write the character array
--- 1067,1167 ----
       }
       clh.res_name = clh.res_class = (char *)NULL;
       XGetClassHint(dpy, w, &clh);
       if (clh.res_class) {
! 	  if (cp = (XGetDefault(dpy, clh.res_class, "wm_option.title")))
! 	       tmp->attrs = SetOptFlag(tmp->attrs, AT_TITLE, Pred(cp));
! 	  
! 	  if (cp = (XGetDefault(dpy, clh.res_class, "wm_option.gadgets")))
! 	       tmp->attrs = SetOptFlag(tmp->attrs, AT_GADGETS, Pred(cp));
! 
! 	  if (cp = (XGetDefault(dpy, clh.res_class,"wm_option.borderContext")))
! 	       tmp->attrs = SetOptFlag(tmp->attrs, AT_BORDER, Pred(cp));
! 
! 	  if (cp = (XGetDefault(dpy, clh.res_class, "wm_option.autoRaise")))
! 	       tmp->attrs = SetOptFlag(tmp->attrs, AT_RAISE, Pred(cp));
       }
+      if (clh.res_name) {
+ 	  if (cp = (XGetDefault(dpy, clh.res_name, "wm_option.title")))
+ 	       tmp->attrs = SetOptFlag(tmp->attrs, AT_TITLE, Pred(cp));
+ 	  
+ 	  if (cp = (XGetDefault(dpy, clh.res_name, "wm_option.gadgets")))
+ 	       tmp->attrs = SetOptFlag(tmp->attrs, AT_GADGETS, Pred(cp));
+ 
+ 	  if (cp = (XGetDefault(dpy, clh.res_name, "wm_option.borderContext")))
+ 	       tmp->attrs = SetOptFlag(tmp->attrs, AT_BORDER, Pred(cp));
+ 
+ 	  if (cp = (XGetDefault(dpy, clh.res_name, "wm_option.autoRaise")))
+ 	       tmp->attrs = SetOptFlag(tmp->attrs, AT_RAISE, Pred(cp));
+      }
       XSaveContext(dpy, w, AwmContext, tmp);
       Leave(tmp)
  }
  
! /*
!  * Sets bit "flag" conditionally, based on state of "mask" and
!  * "predicate" (mask denotes current state, predicate denotes
!  * whether change is desired).
!  */
! int SetOptFlag(mask, flag, predicate)
! int mask, flag, predicate;
! {
!      Entry("SetOptFlag")
! 
!      switch (predicate) {
!      case -1:
! 	  Leave(mask)
!           break;
! 
!      case 0:
!           if (mask & flag)
! 	       Leave(mask ^ flag)
!           else
! 	       Leave(mask)
! 	  break;
! 
!      case 1:
! 	  Leave(mask | flag)
! 	  break;
!      }
! }
! 
! /*
!  * check whether a string denotes an "on" or "off" value. Return 0
!  * if "off", 1 if "on" and -1 if undefined (or null).
!  */
! Pred(s)
  char *s;
  {
       int i, len;
       char *tmp;
!      Boolean ret = -1;
       Entry("Pred")
  
       if (!s)
! 	  Leave(-1)
       len = strlen(s);
       if (!len)
! 	  Leave(-1)
       tmp = (char *)malloc(len + 1);
       if (!tmp) {
  	  fprintf(stderr, "awm: Pred: Can't allocate storage for '%s'!\n", s);
! 	  Leave(-1)
       }
       strcpy(tmp, s);
       for (i = 0; i < len; i++)
  	  if (tmp[i] >= 'A' && tmp[i] <= 'Z')
  	       tmp[i] += 32;
!      if (*tmp == 'y' || !strcmp(tmp, "on")
! 	 || !strcmp(tmp, "true")
! 	 || !strcmp(tmp, "enable"))
! 	  ret = 1;
!      else if (*tmp == 'n' || !strcmp(tmp, "off")
  	      || !strcmp(tmp, "false")
  	      || !strcmp(tmp, "disable"))
! 	  ret = 0;
       free(tmp);
       Leave(ret)
  }
  
  /*
   * Initialize the default bindings.  First, write the character array
diff -c awm.dst/awm.h awm/awm.h
*** awm.dst/awm.h	Sat Jul  2 16:57:45 1988
--- awm/awm.h	Sun Jul 24 17:25:16 1988
***************
*** 3,9 ****
  
  
  #ifndef lint
! static char *rcsid_awm_h = "$Header: awm.h,v 1.1 88/06/15 15:26:00 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
--- 3,9 ----
  
  
  #ifndef lint
! static char *rcsid_awm_h = "$Header: awm.h,v 1.2 88/07/23 17:26:00 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
***************
*** 171,176 ****
--- 171,177 ----
  #define ST_WINDOW	0x1
  #define ST_ICON		0x2
  #define ST_PLACED	0x4
+ #define ST_DECORATED	0x8
  
  /* Window attributes */
  #define AT_NONE		0x0
***************
*** 338,345 ****
  typedef struct _gadgetdecl {	/*   Declaration (type) information */
       unsigned char *name;	/* Either text label or pixmap file name */
       unsigned char *data;	/* If pixmap file, this is the data from it */
!      unsigned long forecolor;	/* foreground color for pixmap */
!      unsigned long backcolor;	/* background color for pixmap */
       XFontStruct *fontInfo;	/* font for text */
       int high, wide;		/* width and height of pixmap or text */
       int gravity;		/* stick to the left or right? */
--- 339,346 ----
  typedef struct _gadgetdecl {	/*   Declaration (type) information */
       unsigned char *name;	/* Either text label or pixmap file name */
       unsigned char *data;	/* If pixmap file, this is the data from it */
!      char *forecolor;		/* foreground color for pixmap */
!      char *backcolor;		/* background color for pixmap */
       XFontStruct *fontInfo;	/* font for text */
       int high, wide;		/* width and height of pixmap or text */
       int gravity;		/* stick to the left or right? */
***************
*** 405,422 ****
  extern Pixmap GrayPixmap;	/* Gray pixmap. */
  extern Pixmap SolidPixmap;
  extern Pixmap IBackPixmap;	/* Icon window background pixmap. */
! extern Pixel BForeground;	/* Border Context (pixmap) foreground pixel */
! extern Pixel BBackground;	/* Border Context (pixmap) background pixel */
  extern Pixel ITextForeground;	/* Icon window text forground color. */
  extern Pixel ITextBackground;	/* Icon window text background color. */
  extern Pixel IForeground;	/* Icon pixmap foreground color */
  extern Pixel IBackground;	/* Icon pixmap background color */
- extern Pixel IBorder;		/* Icon window border pixel. */
- extern Pixel WBorder;		/* Window border pixel */
- extern Pixel TTextForeground;	/* Title text foreground pixel */
- extern Pixel TTextBackground;	/* Title text background pixel */
- extern Pixel TForeground;	/* Title (pixmap) foreground pixel */
- extern Pixel TBackground;	/* Title (pixmap) background pixel */
  extern Pixel PForeground;	/* Pop-up window forground color. */
  extern Pixel PBackground;	/* Pop-up window background color. */
  extern Pixel PBorder;		/* Pop-Up Window border pixel. */
--- 406,425 ----
  extern Pixmap GrayPixmap;	/* Gray pixmap. */
  extern Pixmap SolidPixmap;
  extern Pixmap IBackPixmap;	/* Icon window background pixmap. */
! extern char *BForeground;	/* Border Context (pixmap) foreground pixel */
! extern char *BBackground;	/* Border Context (pixmap) background pixel */
! extern char *WBorder;		/* Window border pixel */
! extern char *TTextForeground;	/* Title text foreground pixel */
! extern char *TTextBackground;	/* Title text background pixel */
! extern char *TForeground;	/* Title (pixmap) foreground pixel */
! extern char *TBackground;	/* Title (pixmap) background pixel */
! extern char *Foreground;	/* default forground color (text) */
! extern char *Background;	/* default background color (text) */
! extern Pixel IBorder;		/* Icon window border pixel. */
  extern Pixel ITextForeground;	/* Icon window text forground color. */
  extern Pixel ITextBackground;	/* Icon window text background color. */
  extern Pixel IForeground;	/* Icon pixmap foreground color */
  extern Pixel IBackground;	/* Icon pixmap background color */
  extern Pixel PForeground;	/* Pop-up window forground color. */
  extern Pixel PBackground;	/* Pop-up window background color. */
  extern Pixel PBorder;		/* Pop-Up Window border pixel. */
***************
*** 450,456 ****
  extern int Delta;		/* Mouse movement slop. */
  extern int HIconPad;		/* Icon horizontal padding. */
  extern int VIconPad;		/* Icon vertical padding. */
- extern int MaxColors;		/* Maximum number of colors to use. */
  extern int Pushval;		/* Number of pixels to push window by. */
  extern int BContext;		/* Width of border context area in pixels */
  extern int RaiseDelay;		/* Delay in milliseconds before autoraising windows */
--- 453,458 ----
***************
*** 473,478 ****
--- 475,481 ----
  
  extern Boolean Autoraise;	/* Raise window on input focus? */
  extern Boolean Autoselect;	/* Warp mouse to default menu selection? */
+ extern Boolean Borders;		/* Display border context areas? */
  extern Boolean ConstrainResize;	/* Don't resize until pointer leaves window */
  extern Boolean Freeze;		/* Freeze server during move/resize? */
  extern Boolean Grid;		/* Should the m/r box contain a 9 seg. grid. */
***************
*** 483,488 ****
--- 486,492 ----
  extern Boolean NWindow;		/* Normalize windows? */
  extern Boolean NIcon;		/* Normalize icons? */
  extern Boolean RootResizeBox;	/* Should resize box obscure window? */
+ extern Boolean InstallColormap;	/* Install colormap for clients? */
  extern Boolean Push;		/* Relative=TRUE, Absolute=FALSE. */
  extern Boolean ResizeRelative;	/* Relative=TRUE, Absolute=FALSE. */
  extern Boolean Reverse;		/* Reverse video? */
***************
*** 559,565 ****
  extern Boolean ShoveLeft();
  extern Boolean ShoveRight();
  extern Boolean ShoveUp();
- extern Boolean Pred();
  extern Boolean Quit();
  extern Boolean Raise();
  extern Boolean Redraw();
--- 563,568 ----
***************
*** 593,598 ****
--- 596,602 ----
  extern char *GetPixmapDataRes();
  extern Pixmap GetPixmapRes();
  extern Pixel GetColorRes();
+ extern Pixel GetPixel();
  extern XFontStruct *GetFontRes();
  extern Drawable GetPixmapFromCache();
  extern AwmInfoPtr GetAwmInfo();
***************
*** 601,608 ****
  extern AwmInfoPtr IsGadgetWin();
  
  extern void Init_Titles(), Init_Frames();
! extern void DestroyFrame();
! extern void AddTitle();
  extern void PaintTitle();
  extern void SetBorderPixmaps();
  extern void FreePixmapFromCache();
--- 605,611 ----
  extern AwmInfoPtr IsGadgetWin();
  
  extern void Init_Titles(), Init_Frames();
! extern void NoDecorate();
  extern void PaintTitle();
  extern void SetBorderPixmaps();
  extern void FreePixmapFromCache();
diff -c awm.dst/awm.man awm/awm.man
*** awm.dst/awm.man	Sat Jul  2 16:57:47 1988
--- awm/awm.man	Sun Jul 24 17:21:35 1988
***************
*** 11,17 ****
  .if n .sp 1
  .if t .sp .5
  ..
! .TH AWM 1 "13 June 1988" "X Version 11"
  .SH NAME
  .PP
  awm - Window Manager X Client Application
--- 11,17 ----
  .if n .sp 1
  .if t .sp .5
  ..
! .TH AWM 1 "23 July 1988" "X Version 11"
  .SH NAME
  .PP
  awm - Window Manager X Client Application
***************
*** 116,123 ****
  \fBCenterGravity\fP to the center.
  .IP
  \fIforeground\fP and \fIbackground\fP specify the colors used to
! tile the gadget or draw the text. If the number of colors
! exceeds \fBmaxColors\fP, black and white will be used.
  .IP
  \fIfont\fP is the name of the font you want the gadget's name
  drawn in. This overrides the \fBgadget.font\fP setting for this
--- 116,122 ----
  \fBCenterGravity\fP to the center.
  .IP
  \fIforeground\fP and \fIbackground\fP specify the colors used to
! tile the gadget or draw the text.
  .IP
  \fIfont\fP is the name of the font you want the gadget's name
  drawn in. This overrides the \fBgadget.font\fP setting for this
***************
*** 487,495 ****
  .IP 3)
  If you omit a foreground or background color.
  .IP 4)
- If the total number of colors specified in the resource database
- exceeds the number specified in the \fImaxColors\fP variable.
- .IP 5)
  If you specify no colors in the resource database.
  .bp
  .SH X DEFAULTS
--- 486,491 ----
***************
*** 636,644 ****
  specific pictures in it. More typically, this will be a cross
  hatch pattern or some similar background weave.
  See also: \fBpath\fP, \fBicon.foreground\fP, \fBicon.background\fP.
! .IP "\fBmaxColors\fP (int) ``0''"
! Don't allow \fIawm\fP to eat any more than this many colors.
! A value of 0 allows \fIawm\fP to use as many colors as it wants.
  .IP "\fBmenu.background\fP (string) ``\fBbackground\fP''"
  Menu background color.
  .IP "\fBmenu.boldFont\fP (string) ``8x13bold''"
--- 632,640 ----
  specific pictures in it. More typically, this will be a cross
  hatch pattern or some similar background weave.
  See also: \fBpath\fP, \fBicon.foreground\fP, \fBicon.background\fP.
! .IP "\fBinstallColormap\fP (boolean) ``false''"
! Install a given window's colormap when the pointer enters it.
! When the pointer leaves, the default colormap is installed.
  .IP "\fBmenu.background\fP (string) ``\fBbackground\fP''"
  Menu background color.
  .IP "\fBmenu.boldFont\fP (string) ``8x13bold''"
***************
*** 835,856 ****
  
  These resources determine whether or not a given application really wants
  a title, gadgets, border context area or to be auto-raised.
! The application's NAME and CLASS (in the WM_CLASS property) are checked
  against the string supplied for \fIname\fP (for example:
  Xclock*wm_option.title:  off).
  .IP
! Note that the "main" boolean resources (I.E. \fBtitles\fP, \fBautoRaise\fP)
! are the final arbiters of whether or not a given resource is set.
! For instance, it is a noop to specify something like
! .EX
! xterm*wm_option.title:	on
! .EE
! .IP
! if \fBtitles\fP is off. In short, using this mechanism to do anything
! but turn an attribute off for a given application is generally useless.
! The rationale behind this is that the set of applications that are known not
! to want attributes is probably smaller than the (potentially infinite)
! set of applications that do or don't care either way.
  .IP
  These resources are ``special'' as they are checked for under the
  application's name, not \fIawm\fP's; I.E. \fBxclock.wm_option.autoRaise\fP
--- 831,847 ----
  
  These resources determine whether or not a given application really wants
  a title, gadgets, border context area or to be auto-raised.
! The application's CLASS and NAME (in the WM_CLASS property) are checked
  against the string supplied for \fIname\fP (for example:
  Xclock*wm_option.title:  off).
  .IP
! Specifying one of these resources overrides any other boolean
! settings (I.E. \fBawm.titles\fP or \fBawm.gadgets\fP) and
! may be used to turn things on and off at the application and/or
! class level for applications, regardless of \fBawm\fP's settings.
! 
! Note: Both class and name resources are checked, and in that order. Thus
! specific applications may override settings for their class, if desired.
  .IP
  These resources are ``special'' as they are checked for under the
  application's name, not \fIawm\fP's; I.E. \fBxclock.wm_option.autoRaise\fP
diff -c awm.dst/errHndlr.c awm/errHndlr.c
*** awm.dst/errHndlr.c	Sat Jul  2 16:57:47 1988
--- awm/errHndlr.c	Wed Jul 13 19:38:16 1988
***************
*** 1,7 ****
  #ident   "%W% %G%"
  
- 
- 
  #ifndef lint
  static char *rcsid_errHndlr_c = "$Header: errHndlr.c,v 1.1 88/06/15 15:26 :00 jkh Exp $";
  #endif  lint
--- 1,5 ----
***************
*** 52,64 ****
  #ifdef DEBUG
      char *buffer[BUFSIZ];
      XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
! 	(void) fprintf(stderr, "Hey!\n");
!     (void) fprintf(stderr, "X Error: %s\n", buffer);
!     (void) fprintf(stderr, "  Request Major code: %d\n", event->request_code);
!     (void) fprintf(stderr, "  Request Minor code: %d\n", event->minor_code);
!     (void) fprintf(stderr, "  ResourceId 0x%x\n", event->resourceid);
!     (void) fprintf(stderr, "  Error Serial #%d\n", event->serial);
!     (void) fprintf(stderr, "  Current Serial #%d\n", dpy->request);
  #endif
      errorStatus = True;
      return 0;
--- 50,62 ----
  #ifdef DEBUG
      char *buffer[BUFSIZ];
      XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
!     (void) debug("Hey!\n");
!     (void) debug("X Error: %s\n", buffer);
!     (void) debug("  Request Major code: %d\n", event->request_code);
!     (void) debug("  Request Minor code: %d\n", event->minor_code);
!     (void) debug("  ResourceId 0x%x\n", event->resourceid);
!     (void) debug("  Error Serial #%d\n", event->serial);
!     (void) debug("  Current Serial #%d\n", dpy->request);
  #endif
      errorStatus = True;
      return 0;
diff -c awm.dst/globals.c awm/globals.c
*** awm.dst/globals.c	Sat Jul  2 16:57:49 1988
--- awm/globals.c	Sun Jul 24 17:23:12 1988
***************
*** 3,9 ****
  
  
  #ifndef lint
! static char *rcsid_globals_c = "$Header: globals.c,v 1.2 88/07/02 01:26:00 jkh Exp $";
  #endif  lint
   
  #include "X11/copyright.h"
--- 3,9 ----
  
  
  #ifndef lint
! static char *rcsid_globals_c = "$Header: globals.c,v 1.3 88/07/23 17:26:00 jkh Exp $";
  #endif  lint
   
  #include "X11/copyright.h"
***************
*** 79,98 ****
  Pixel ForeColor;		/* Generic foreground color */
  Pixel BackColor;		/* Generic background color */
  Pixel IBorder;			/* Icon window border color. */
- Pixel PBorder;			/* Pop-Up Window border color. */
- Pixel WBorder;			/* Window border color */
- Pixel BBackground;		/* Border context background color */
- Pixel BForeground;		/* Border context foreground color */
  Pixel PBackground;		/* Pop-up Window background color. */
  Pixel PForeground;		/* Pop-up Window foregrould color */
! Pixel TBackground;		/* Titlebar background color */
! Pixel TForeground;		/* Titlebar foreground color */
! Pixel TTextBackground;		/* Titlebar text background color */
! Pixel TTextForeground;		/* Titlebar text foreground color */
  Pixel IBackground;		/* Icon background (for pixmap) color */
  Pixel IForeground;		/* Icon foreground (for pixmap) color */
  Pixel ITextForeground;		/* Icon text foreground color */
  Pixel ITextBackground;		/* Icon text background color */
  Cursor ArrowCrossCursor;	/* Arrow cross cursor. */
  Cursor TextCursor;		/* Text cursor used in icon windows. */
  Cursor IconCursor;		/* Icon Cursor. */
--- 79,100 ----
  Pixel ForeColor;		/* Generic foreground color */
  Pixel BackColor;		/* Generic background color */
  Pixel IBorder;			/* Icon window border color. */
  Pixel PBackground;		/* Pop-up Window background color. */
  Pixel PForeground;		/* Pop-up Window foregrould color */
! Pixel PBorder;			/* Pop-Up Window border color. */
  Pixel IBackground;		/* Icon background (for pixmap) color */
  Pixel IForeground;		/* Icon foreground (for pixmap) color */
  Pixel ITextForeground;		/* Icon text foreground color */
  Pixel ITextBackground;		/* Icon text background color */
+ char *Foreground;		/* foreground color (text) */
+ char *Background;		/* background color (text) */
+ char *WBorder;			/* Window border color */
+ char *BBackground;		/* Border context background color */
+ char *BForeground;		/* Border context foreground color */
+ char *TBackground;		/* Titlebar background color */
+ char *TForeground;		/* Titlebar foreground color */
+ char *TTextBackground;		/* Titlebar text background color */
+ char *TTextForeground;		/* Titlebar text foreground color */
  Cursor ArrowCrossCursor;	/* Arrow cross cursor. */
  Cursor TextCursor;		/* Text cursor used in icon windows. */
  Cursor IconCursor;		/* Icon Cursor. */
***************
*** 118,124 ****
  int Delta;			/* Mouse movement slop. */
  int HIconPad;			/* Icon horizontal padding. */
  int VIconPad;			/* Icon vertical padding. */
- int MaxColors;			/* Maximum number of colors to use. */
  int Pushval;			/* Number of pixels to push window by. */
  int BContext;			/* Border context area width (in pixels) */
  int RaiseDelay;			/* Number of milliseconds delay before autoraise */
--- 120,125 ----
***************
*** 139,144 ****
--- 140,146 ----
  
  Boolean Autoselect;		/* Warp mouse to default menu selection? */
  Boolean Autoraise;		/* Raise window on input focus? */
+ Boolean Borders;		/* Display border context areas? */
  Boolean ConstrainResize;	/* Don't resize until pointer leaves window */
  Boolean Freeze;			/* Freeze server during move/resize? */
  Boolean Grid;			/* Should the m/r box contain a 9 seg. grid. */
***************
*** 145,150 ****
--- 147,153 ----
  Boolean ShowName;		/* If True, print window names in titlebars */
  Boolean Hilite;			/* Should we highlight titles on focus? */
  Boolean BorderHilite;		/* Should we highlight borders on focus? */
+ Boolean InstallColormap;	/* Should we install colormaps for clients? */
  Boolean NWindow;		/* Normalize windows? */
  Boolean NIcon;			/* Normalize icons? */
  Boolean Push;			/* Relative=TRUE, Absolute=FALSE. */
diff -c awm.dst/gram.y awm/gram.y
*** awm.dst/gram.y	Sat Jul  2 16:57:50 1988
--- awm/gram.y	Sun Jul 24 17:29:24 1988
***************
*** 59,65 ****
  
  
  #ifndef lint
! static char *rcsid_gram_y = "$Header: gram.y,v 1.2 88/06/17 15:01:04 jkh Exp $";
  #endif	lint
  
  #include "X11/Xlib.h"
--- 59,65 ----
  
  
  #ifndef lint
! static char *rcsid_gram_y = "$Header: gram.y,v 1.3 88/07/23 18:01:04 jkh Exp $";
  #endif	lint
  
  #include "X11/Xlib.h"
***************
*** 81,88 ****
       static int gadgnum;		/* # of gadget we're initing */
       static int g_offset;		/* The gadget offset specified */
       static int g_gravity;		/* The gadget gravity specified */
!      static long g_forecolor;		/* gadget foreground color */
!      static long g_backcolor;		/* gadget background color */
       static XFontStruct *g_font;	/* gadget font */
       static int bkmask;			/* Button/key mask. */
       static int cmask;			/* Context mask. */
--- 81,88 ----
       static int gadgnum;		/* # of gadget we're initing */
       static int g_offset;		/* The gadget offset specified */
       static int g_gravity;		/* The gadget gravity specified */
!      static char *g_forecolor;		/* gadget foreground color */
!      static char *g_backcolor;		/* gadget background color */
       static XFontStruct *g_font;	/* gadget font */
       static int bkmask;			/* Button/key mask. */
       static int cmask;			/* Context mask. */
***************
*** 275,282 ****
  {
       $$ = C_STRING;
       /* just in case it's a gadget, set defaults */
!      g_forecolor = ForeColor;
!      g_backcolor = BackColor;
       g_gravity = NoGadgetGravity;
       g_offset = 0;
       g_font = 0;
--- 275,282 ----
  {
       $$ = C_STRING;
       /* just in case it's a gadget, set defaults */
!      g_forecolor = Foreground;
!      g_backcolor = Background;
       g_gravity = NoGadgetGravity;
       g_offset = 0;
       g_font = 0;
***************
*** 285,292 ****
  {
       $$ = C_PIXMAP;
       /* just in case it's a gadget, set defaults */
!      g_forecolor = ForeColor;
!      g_backcolor = BackColor;
       g_gravity = NoGadgetGravity;
       g_offset = 0;
       g_font = 0;
--- 285,292 ----
  {
       $$ = C_PIXMAP;
       /* just in case it's a gadget, set defaults */
!      g_forecolor = Foreground;
!      g_backcolor = Background;
       g_gravity = NoGadgetGravity;
       g_offset = 0;
       g_font = 0;
***************
*** 304,311 ****
  {
  	g_offset = y_atoi($1);
  	g_gravity = NoGadgetGravity;
! 	g_forecolor = ForeColor;
! 	g_backcolor = BackColor;
  	g_font = (XFontStruct *)NULL;
  }
  ;
--- 304,311 ----
  {
  	g_offset = y_atoi($1);
  	g_gravity = NoGadgetGravity;
! 	g_forecolor = Foreground;
! 	g_backcolor = Background;
  	g_font = (XFontStruct *)NULL;
  }
  ;
***************
*** 314,338 ****
  | STRING
  {
  	g_gravity = gravitylookup($1);
! 	g_forecolor = ForeColor;
! 	g_backcolor = BackColor;
  	g_font = (XFontStruct *)NULL;
  }
  ;
   forecolor: /* empty */
! { g_forecolor = ForeColor; }
  | STRING
  {
! 	g_forecolor = LookupColor($1);
! 	g_backcolor = BackColor;
  	g_font = (XFontStruct *)NULL;
  }
  ;
   backcolor: /* empty */
! { g_backcolor = BackColor; }
  | STRING
  {
! 	g_backcolor = LookupColor($1);
  	g_font = (XFontStruct *)NULL;
  }
  ;
--- 314,338 ----
  | STRING
  {
  	g_gravity = gravitylookup($1);
! 	g_forecolor = Foreground;
! 	g_backcolor = Background;
  	g_font = (XFontStruct *)NULL;
  }
  ;
   forecolor: /* empty */
! { g_forecolor = Foreground; }
  | STRING
  {
! 	g_forecolor = $1;
! 	g_backcolor = Background;
  	g_font = (XFontStruct *)NULL;
  }
  ;
   backcolor: /* empty */
! { g_backcolor = Background; }
  | STRING
  {
! 	g_backcolor = $1;
  	g_font = (XFontStruct *)NULL;
  }
  ;
***************
*** 538,564 ****
  /*
   * Look up color named by "string" and return pixel value.
   */
! Pixel LookupColor(string)
  char *string;
  {
       XColor vis_ret, act_ret;
-      static int ncolors = 0;
  
!      Entry("LookupColor");
  
!      if (MaxColors && ncolors >= MaxColors) {
! 	  sprintf(msg, "Can't allocate color '%s', MaxColors (%d) exceeded\n",
! 		  string, MaxColors);
! 	  yywarn(msg);
! 	  Leave(NOCOLOR)
!      }
!      if (!XAllocNamedColor(dpy, DefaultColormap(dpy, scr), string,
! 			  &vis_ret, &act_ret)) {
  	 sprintf(msg, "Can't allocate color '%s', using default\n", string);
  	 yywarn(msg);
! 	 Leave(NOCOLOR)
       }
!      ncolors++;
       Leave(vis_ret.pixel)
  }
  
--- 538,578 ----
  /*
   * Look up color named by "string" and return pixel value.
   */
! Pixel LookupColor(string, cmap, fail)
  char *string;
+ Colormap cmap;
+ Boolean *fail;
  {
       XColor vis_ret, act_ret;
  
!      Entry("LookupColor")
  
!      if (!XAllocNamedColor(dpy, cmap, string, &vis_ret, &act_ret)) {
  	 sprintf(msg, "Can't allocate color '%s', using default\n", string);
  	 yywarn(msg);
! 	 if (fail)
! 	      *fail = TRUE;
! 	 Leave((Pixel)0)
       }
!      if (fail)
! 	  *fail = FALSE;
!      Leave(vis_ret.pixel)
! }
! 
! /*
!  * Like LookupColor, but provides its own fallback in case of failure
!  * (currently 0).
!  */
! Pixel GetPixel(string, cmap)
! char *string;
! Colormap cmap;
! {
!      XColor vis_ret, act_ret;
! 
!      Entry("GetPixel")
! 
!      if (!XAllocNamedColor(dpy, cmap, string, &vis_ret, &act_ret))
! 	 Leave((Pixel)0)
       Leave(vis_ret.pixel)
  }
  
diff -c awm.dst/support.h awm/support.h
*** awm.dst/support.h	Sat Jul  2 16:57:58 1988
--- awm/support.h	Sun Jul 24 17:33:01 1988
***************
*** 1,7 ****
  #ident   "%W% %G%"
  
  #ifndef lint
! static char *rcsid_support_h = "$Header: support.h,v 1.1 88/06/15 15:26:00 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
--- 1,7 ----
  #ident   "%W% %G%"
  
  #ifndef lint
! static char *rcsid_support_h = "$Header: support.h,v 1.2 88/07/23 17:26:00 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
***************
*** 25,35 ****
   *
   */
  
  #undef TRACE
  
  #ifdef TRACE
! #define Entry(s) push_rtn(s);
! #define Leave(s) { pop_rtn(); return(s); }
  #define Leave_void { pop_rtn(); return; }
  #define Trace_on _rtn_trace = 1;
  #define Trace_off _rtn_trace = 0;
--- 25,46 ----
   *
   */
  
+ #undef STACK_RTNAMES
  #undef TRACE
  
  #ifdef TRACE
! #define Entry(woo) { printf("Pushing to %s\n", woo); push_rtn(woo); }
! #define Leave(woo) { printf("Pop from %s with %x\n", curr_rtn(), woo); pop_rtn(); return(woo); }
! #define Leave_void { printf("Pop from %s (void)\n", curr_rtn()); pop_rtn(); return; }
! #define Trace_on _rtn_trace = 1;
! #define Trace_off _rtn_trace = 0;
! extern char *curr_rtn();
! extern int _rtn_level;
! extern int _rtn_trace;
! #else
! #ifdef SAVERTNAME
! #define Entry(woo) push_rtn(woo);
! #define Leave(woo) { pop_rtn(); return(woo); }
  #define Leave_void { pop_rtn(); return; }
  #define Trace_on _rtn_trace = 1;
  #define Trace_off _rtn_trace = 0;
***************
*** 43,46 ****
  #define Trace_on
  #define Trace_off
  #define Curr_rtn()
! #endif
--- 54,58 ----
  #define Trace_on
  #define Trace_off
  #define Curr_rtn()
! #endif /* SAVERTNAME */
! #endif /* TRACE */