[comp.sources.x] v01i013: awm: Ardent Window Manager

mikew@wyse.wyse.com (Mike Wexler) (08/26/88)

Submitted-by: unido!meepmeep!jkh ( Jordan K. Hubbard )
Posting-number: Volume 1, Issue 13
Archive-name: awm/patch7

[The version I posted was already at patchlevel 6. -mcw]

Here is the last patch before R3. If you apply it (and the preceeding 6
patches) to the awm found on decwrl.dec.com, you'll have the complete
awm. I believe that you can do this to the one on expo too, I'm pretty
sure that it matches the decwrl version. If you have the awm that came
off of comp.sources.x, then just apply this patch.

All outstanding bugs have been fixed, there have been a few reports
of bizarre behaviour, but they couldn't be reproduced at all. I think
that some of them are due to operator error, some due to strange
compilation environments. It works fine on the Sun 3 (running SunOS 3.5),
the VAX and a few straight sysV machines.

Let me know if there's anything more I can do.

				Jordan


---- patch 07 ----
/*
 * CHANGES:
 *
 * Invalid free() removed from gram.y.
 * Transient window placement fixed.
 * Signal handling done correctly for system V.
 *
 *
 * UPDATED:
 *
 * awm.c now rev 1.5
 * gram.y now rev 1.5
 * GetButton.c now rev 1.5
 *
 */

diff -c awm/CHANGES awm.new/CHANGES
*** awm/CHANGES	Fri Aug 19 14:28:15 1988
--- awm.new/CHANGES	Wed Aug 17 13:25:32 1988
***************
*** 1,9 ****
! This file last changed: 7/2/88
  
  The most recent changes to awm include:
  
  Border/title context rationalized, you may now have border contexts without
! title bars and vice-versa.
  
  The whole paradigm for adding/removing various decorations has changed.
  Functions such as f.notitle and f.gadget have been replaced with the
--- 1,17 ----
! This file last changed: 8/17/88
  
  The most recent changes to awm include:
  
+ Invalid free() removed from gram.y.
+ Transient window placement fixed.
+ Signal handling done correctly for system V.
+ 
+ Previous changes to awm:
+ 
+ Changes as of 7/2/88:
+ 
  Border/title context rationalized, you may now have border contexts without
! ntitle bars and vice-versa.
  
  The whole paradigm for adding/removing various decorations has changed.
  Functions such as f.notitle and f.gadget have been replaced with the
***************
*** 30,38 ****
  including them in context information (for those who have removed them).
  
  Things have been sped up a bit.
- 
- 
- Previous changes to awm:
  
  Version numbers set to 1.1 in all files. Subsequent versions of awm will
  increment this accordingly (major_release.fix_level).
--- 38,43 ----
diff -c awm/Gadget.c awm.new/Gadget.c
*** awm/Gadget.c	Fri Aug 19 14:29:30 1988
--- awm.new/Gadget.c	Tue Aug 16 17:11:45 1988
***************
*** 138,144 ****
  	  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)
--- 138,144 ----
  	  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)
diff -c awm/GetButton.c awm.new/GetButton.c
*** awm/GetButton.c	Fri Aug 19 14:29:31 1988
--- awm.new/GetButton.c	Fri Aug 19 13:52:16 1988
***************
*** 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"
--- 3,9 ----
  
  
  #ifndef lint
! static char *rcsid_GetButton_c = "$Header: GetButton.c,v 1.5 88/08/19 15:55:45 jkh Exp $";
  #endif	lint
  
  #include "X11/copyright.h"
***************
*** 572,578 ****
       XWMHints *XGetWMHints();
       XWMHints *wmhints;
       int x, y, w, h;
!      Window transient_for;
       Window jW;
       int border_width, j;
       Binding *bptr;
--- 572,578 ----
       XWMHints *XGetWMHints();
       XWMHints *wmhints;
       int x, y, w, h;
!      Window transient_for = None;
       Window jW;
       int border_width, j;
       Binding *bptr;
***************
*** 616,628 ****
  	       XFree(wmhints);
  	  }
       }
!      else if ((awi = GetAwmInfo(window)) == NULL)
! 	  awi = RegisterWindow(window);
       if (awi->state & ST_WINDOW) {
! 	  if (!transient_for)
! 	       PlaceWindow(window);
! 	  XMapRaised(dpy, awi->frame);
! 	  XMapWindow(dpy, awi->client);
  	  XSync(dpy, 0);
       }
       Leave_void
--- 616,636 ----
  	       XFree(wmhints);
  	  }
       }
!      else { /* It's a transient */
! 	  if (!(awi = GetAwmInfo(window)))
! 	       awi = RegisterWindow(window);
! 	  awi->attrs = AT_NONE;
! 	  if (transient_for == None)
! 	       transient_for = RootWindow(dpy, scr);
!      }
       if (awi->state & ST_WINDOW) {
! 	  PlaceWindow(window, transient_for);
! 	  if (awi->frame) {
! 	       XMapRaised(dpy, awi->frame);
! 	       XMapWindow(dpy, awi->client);
! 	  }
! 	  else
! 	       XMapRaised(dpy, awi->client);
  	  XSync(dpy, 0);
       }
       Leave_void
***************
*** 660,667 ****
       Leave_void
  }
  
! PlaceWindow(window)
  Window window;
  {
       XSizeHints wsh;
       int x, y, w, h;
--- 668,676 ----
       Leave_void
  }
  
! PlaceWindow(window, transient)
  Window window;
+ Window transient;
  {
       XSizeHints wsh;
       int x, y, w, h;
***************
*** 675,681 ****
       awi = GetAwmInfo(window);
       XGetSizeHints(dpy, window, &wsh, XA_WM_NORMAL_HINTS);
       CheckConsistency(&wsh);
!      AskUser(dpy, scr, window, &x, &y, &w, &h, &wsh);
  
       wsh.flags |= (USPosition | USSize);
       wsh.x = x;
--- 684,690 ----
       awi = GetAwmInfo(window);
       XGetSizeHints(dpy, window, &wsh, XA_WM_NORMAL_HINTS);
       CheckConsistency(&wsh);
!      AskUser(dpy, scr, window, &x, &y, &w, &h, &wsh, transient);
  
       wsh.flags |= (USPosition | USSize);
       wsh.x = x;
***************
*** 730,736 ****
  
       height = xwc->height;
       width = xwc->width;
!      x = y = 0;
       /* width */
       xwc->width += bch;
       if (awi->title)
--- 739,750 ----
  
       height = xwc->height;
       width = xwc->width;
!      if (awi->frame)
! 	  x = y = 0;
!      else {
! 	  x = xwc->x;
! 	  y = xwc->y;
!      }
       /* width */
       xwc->width += bch;
       if (awi->title)
***************
*** 757,763 ****
  	       xwc->y -= (BContext + (awi->border_width ?
  				      awi->border_width : 1));
       }
!      XConfigureWindow(dpy, awi->frame, mask, xwc);
       if (awi->gadgets)
  	  PutGadgets(w);
       xwc->width = width;
--- 771,778 ----
  	       xwc->y -= (BContext + (awi->border_width ?
  				      awi->border_width : 1));
       }
!      if (awi->frame)
!           XConfigureWindow(dpy, awi->frame, mask, xwc);
       if (awi->gadgets)
  	  PutGadgets(w);
       xwc->width = width;
diff -c awm/Iconify.c awm.new/Iconify.c
*** awm/Iconify.c	Fri Aug 19 14:28:25 1988
--- awm.new/Iconify.c	Wed Aug 17 11:23:00 1988
***************
*** 127,133 ****
            from = awi->icon;
            to = (awi->frame) ? awi->frame : awi->client;
  	  if (!(awi->state & ST_PLACED))
! 	       PlaceWindow(to);
       }
       else if (awi->state & ST_WINDOW) {
            from = (awi->frame) ? awi->frame : awi->client;
--- 127,133 ----
            from = awi->icon;
            to = (awi->frame) ? awi->frame : awi->client;
  	  if (!(awi->state & ST_PLACED))
! 	       PlaceWindow(to, None);
       }
       else if (awi->state & ST_WINDOW) {
            from = (awi->frame) ? awi->frame : awi->client;
diff -c awm/README awm.new/README
*** awm/README	Fri Aug 19 14:29:59 1988
--- awm.new/README	Fri Aug 19 15:02:32 1988
***************
*** 1,3 ****
--- 1,24 ----
+ This file last changed August 19th, 1988.
+ 
+ Since the first netwide release, the author has fled the country
+ and is now residing in West Germany where he may sometimes be found sitting
+ atop a mountain in the alps, muttering to himself about the
+ ICCCM. Ardent Computer Corp (mentioned below) is the owner of
+ this code but the author has agreed to continue maintainance, where
+ practical, and should be contacted as well in case of difficulty.
+ Through the wonders of e-mail, even West Germany does not appear to
+ be far enought away to escape responsibility.
+ 
+ 				Jordan Hubbard
+                                 PCS Computer Systeme GmbH
+                                 Pfaelzer-Wald-Str. 36
+                                 D-8000 Muenchen 90.
+                                 West Germany
+ 				uunet!unido!pcsbst!jkh
+ 
+ -------
+ 
+ 
  This represents the first real release of the Ardent Window Manager (awm).
  It's being released on the same terms as its predecessor (uwm) with
  one additional request: Since this window manager is the "official"
diff -c awm/RubberBand.c awm.new/RubberBand.c
*** awm/RubberBand.c	Fri Aug 19 14:28:45 1988
--- awm.new/RubberBand.c	Thu Aug 18 11:48:22 1988
***************
*** 73,84 ****
  #define BW	PBorderWidth		/* pop-up window border width */
  #define IBW	PPadding		/* internal border width for pop-up */
  
! AskUser(dpy, scr, window, x, y, width, height, hints)
  Display *dpy;
  int scr;
  Window window;
  int *x, *y, *width, *height;
  XSizeHints *hints;
  {
       Cursor ur, ul, ll, lr;          /* cursors for rubber banding    */
       int change_cursor = FALSE;
--- 73,85 ----
  #define BW	PBorderWidth		/* pop-up window border width */
  #define IBW	PPadding		/* internal border width for pop-up */
  
! AskUser(dpy, scr, window, x, y, width, height, hints, transient)
  Display *dpy;
  int scr;
  Window window;
  int *x, *y, *width, *height;
  XSizeHints *hints;
+ Window transient;
  {
       Cursor ur, ul, ll, lr;          /* cursors for rubber banding    */
       int change_cursor = FALSE;
***************
*** 102,119 ****
       int doit = FALSE;
       int dx, dy;
       int delta;
       XPoint box[PCOUNT];
       int hsize, vsize;
       int zero = '0';                 /* zero offset for char conversion  */
       XEvent e;                 /* someplace to put the event   */
       int events;                     /* what events we want.             */
!      Window pop;                     /* pop up prompt window         */
       int i;
       char *name;
       int width_offset, height_offset; /* to subtract if resize increments */
       
       Entry("AskUser")
!      
       if ((hints->flags & USPosition) && (hints->flags & USSize)) {
  	  *x = hints->x;
  	  *y = hints->y;
--- 103,126 ----
       int doit = FALSE;
       int dx, dy;
       int delta;
+      int ijunk;
       XPoint box[PCOUNT];
       int hsize, vsize;
       int zero = '0';                 /* zero offset for char conversion  */
       XEvent e;                 /* someplace to put the event   */
       int events;                     /* what events we want.             */
!      Window pop, wjunk;                     /* pop up prompt window         */
       int i;
       char *name;
       int width_offset, height_offset; /* to subtract if resize increments */
       
       Entry("AskUser")
! 
!      if (transient) {
! 	  XGetGeometry( dpy, window, &wjunk, x, y, width, height,
! 		       &ijunk, &ijunk);
! 	  Leave_void
!      }
       if ((hints->flags & USPosition) && (hints->flags & USSize)) {
  	  *x = hints->x;
  	  *y = hints->y;
diff -c awm/XRdBitFD.c awm.new/XRdBitFD.c
*** awm/XRdBitFD.c	Fri Aug 19 14:28:52 1988
--- awm.new/XRdBitFD.c	Fri Aug 19 14:46:55 1988
***************
*** 31,37 ****
  
  #include "copyright.h"
  
! #include "Xos.h"
  #include "X11/Xlib.h"
  #include "X11/Xutil.h"
  #include "Xlibint.h"
--- 31,38 ----
  
  #include "copyright.h"
  
! /* Jim says Xos is in X11 now, so... */
! #include "X11/Xos.h"
  #include "X11/Xlib.h"
  #include "X11/Xutil.h"
  #include "Xlibint.h"
diff -c awm/awm.c awm.new/awm.c
*** awm/awm.c	Fri Aug 19 14:30:02 1988
--- awm.new/awm.c	Fri Aug 19 13:51:32 1988
***************
*** 3,9 ****
  
  
  #ifndef lint
! static char *rcsid_awm_c = "$Header: awm.c,v 1.4 88/07/24 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.5 88/08/19 15:55:56 jkh Exp $";
  #endif  lint
  
  #include "X11/copyright.h"
***************
*** 61,67 ****
--- 61,69 ----
   * 003 -- Jordan Hubbard, Ardent Computer. Added gadgets, border contexts.
   */
  
+ #ifndef PCS
  #include <sys/time.h>
+ #endif
  #include <signal.h>
  #if defined(vax)
  #include <sys/file.h>
***************
*** 73,78 ****
--- 75,84 ----
  #include "X11/Xutil.h"
  #include "X11/cursorfont.h"
  
+ #ifdef PCS
+ #include <unistd.h>
+ #include <bsd/sys/time.h>
+ #endif
  #ifdef PROFIL
  #include <signal.h>
  /*
***************
*** 287,296 ****
        * Catch some of the basic signals so we don't get rudely killed without
        * cleaning up first.
        */
!      signal(SIGHUP, Quit);
!      signal(SIGTERM, Quit);
!      signal(SIGQUIT, Quit);
!      signal(SIGINT, Quit);
  
       /*
        * If the root window has not been named, name it.
--- 293,306 ----
        * Catch some of the basic signals so we don't get rudely killed without
        * cleaning up first.
        */
!      if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
! 	  signal(SIGHUP, Quit);
!      if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
! 	  signal(SIGTERM, Quit);
!      if (signal(SIGQUIT, SIG_IGN) != SIG_IGN)
! 	  signal(SIGTERM, Quit);
!      if (signal(SIGINT, SIG_IGN) != SIG_IGN)
! 	  signal(SIGINT, Quit);
  
       /*
        * If the root window has not been named, name it.
***************
*** 896,902 ****
  int *wide, *high;
  {
       char *cp, *cp2;
!      
       Entry("GetPixmapDataRes")
       
       if ((cp = XGetDefault(dpy, NAME, string)) ||
--- 906,912 ----
  int *wide, *high;
  {
       char *cp, *cp2;
! 
       Entry("GetPixmapDataRes")
       
       if ((cp = XGetDefault(dpy, NAME, string)) ||
diff -c awm/awm.h awm.new/awm.h
*** awm/awm.h	Fri Aug 19 14:29:44 1988
--- awm.new/awm.h	Fri Aug 19 15:09:33 1988
***************
*** 66,72 ****
--- 66,76 ----
   
  #include <errno.h>
  #include <stdio.h>
+ #ifdef SYSV
+ #include <string.h>
+ #else
  #include <strings.h>
+ #endif
  #include "X11/Xlib.h"
  #include "X11/Intrinsic.h"
  #include "X11/Xatom.h"
diff -c awm/exp_path.c awm.new/exp_path.c
*** awm/exp_path.c	Fri Aug 19 14:29:04 1988
--- awm.new/exp_path.c	Wed Aug 10 13:30:17 1988
***************
*** 27,32 ****
--- 27,35 ----
   *
   */
  
+ #ifdef PCS
+ #include <unistd.h>
+ #endif
  #include <pwd.h>
  #include <stdio.h>
  #if defined(vax)
diff -c awm/gram.y awm.new/gram.y
*** awm/gram.y	Fri Aug 19 14:30:04 1988
--- awm.new/gram.y	Fri Aug 19 13:59:43 1988
***************
*** 59,65 ****
  
  
  #ifndef lint
! static char *rcsid_gram_y = "$Header: gram.y,v 1.4 88/07/24 01:01:04 jkh Exp $";
  #endif	lint
  
  #include "X11/Xlib.h"
--- 59,65 ----
  
  
  #ifndef lint
! static char *rcsid_gram_y = "$Header: gram.y,v 1.5 88/08/19 15:55:04 jkh Exp $";
  #endif	lint
  
  #include "X11/Xlib.h"
***************
*** 590,596 ****
       Entry("keywordlookup")
  
       for (i = 0; KeywordTable[i].name; i++) {
! 	  if (!strcmp(KeywordTable[i].name, string)) {
  	       free(string);
  	       Leave(i)
  	  }
--- 590,596 ----
       Entry("keywordlookup")
  
       for (i = 0; KeywordTable[i].name; i++) {
!           if (!strcmp(KeywordTable[i].name, string)) {
  	       free(string);
  	       Leave(i)
  	  }
***************
*** 1002,1008 ****
  	       tmp->high = gray_height;
  	       tmp->wide = gray_width;
  	  }
- 	  free(s);
  	  if (tmp->high > gadgetHeight)
  	       gadgetHeight = tmp->high;
       }
--- 1002,1007 ----
diff -c awm/lex.l awm.new/lex.l
*** awm/lex.l	Thu Jun 16 09:40:29 1988
--- awm.new/lex.l	Thu Aug 11 13:22:02 1988
***************
*** 93,98 ****
--- 93,100 ----
      char *ptr;
      char *malloc();
  
+     if (!s || !strlen(s))
+ 	return(NULL);
      ptr = malloc(strlen(s) + 1);
      if (ptr == NULL) {
          Error("out of space");

-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330