[comp.windows.x] awm patch #4 again

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

It looks like my earlier message got eaten. If you've applied
patch #3, please apply this patch as well. It fixes an evil
bug with window positioning.

				Jordan

----- cut here -----

---- patch 04 ----
/*
 * CHANGES:
 *
 * Fixed serious problem in GetButton.c which caused window positions
 * to be incorrectly calculated. Cleaned up a few nits in the code
 * that were wasting cycles.
 *
 * UPDATED:
 *
 * GetButton.c now rev 1.3
 *
 */


diff -c awm.dst/FocusChng.c awm/FocusChng.c
*** awm.dst/FocusChng.c	Sat Jul  2 16:57:20 1988
--- awm/FocusChng.c	Tue Jul  5 19:03:21 1988
***************
*** 64,72 ****
       awi = GetAwmInfo(w);
       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;
  
--- 64,70 ----
diff -c awm.dst/GetButton.c awm/GetButton.c
*** awm.dst/GetButton.c	Sat Jul  2 16:57:22 1988
--- awm/GetButton.c	Tue Jul  5 21:23:01 1988
***************
*** 3,9 ****
  
  
  #ifndef lint
! static char *rcsid_GetButton_c = "$Header: GetButton.c,v 1.2 88/06/22 17:20:45 jjkh Exp $";
  #endif	lint
  
  #include "X11/copyright.h"
--- 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"
***************
*** 615,625 ****
  	       XFree(wmhints);
  	  }
       }
!      else
! 	  if ((awi = GetAwmInfo(window)) == NULL)
! 	       awi = RegisterWindow(window);
       if (awi->state & ST_WINDOW) {
! 	  PlaceWindow(window);
  	  if (awi->frame) {
  	       XMapRaised(dpy, awi->frame);
  	       XMapWindow(dpy, awi->client);
--- 615,625 ----
  	       XFree(wmhints);
  	  }
       }
!      else if ((awi = GetAwmInfo(window)) == NULL)
! 	  awi = RegisterWindow(window);
       if (awi->state & ST_WINDOW) {
! 	  if (!transient_for)
! 	       PlaceWindow(window);
  	  if (awi->frame) {
  	       XMapRaised(dpy, awi->frame);
  	       XMapWindow(dpy, awi->client);
***************
*** 718,724 ****
  {
       XWindowAttributes xwa;
       AwmInfoPtr awi;
-      Boolean adjust = FALSE;
       int bch = 0, bcv = 0;
       Entry("ConfigureWindow")
  
--- 718,723 ----
***************
*** 725,755 ****
       awi = GetAwmInfo(w);
       if (!awi)
            Leave(FALSE)
!      if (w == awi->client) {
! 	  adjust = TRUE;
! 	  if (awi->attrs & AT_BORDER) {
! 	       bcv = BContext + 1;
! 	       bch = bcv * 2;
! 	  }
       }
!      if (awi->frame && adjust) {
! 	  int height, width;
  
  	  height = xwc->height;
  	  width = xwc->width;
! 
  	  /* width */
  	  xwc->width += bch;
  	  if (awi->title)
  	       XResizeWindow(dpy, awi->title, xwc->width, titleHeight);
  	  /* height */
! 	  if (awi->attrs & AT_TITLE)
! 	       xwc->height += titleHeight + 2;
  	  if (awi->attrs & AT_BORDER) {
! 	       if (!(awi->attrs & AT_TITLE))
  		    xwc->height += (bcv * 2);
  	       else
  		    xwc->height += bcv;
  	  }
  	  if (PushDown == FALSE) {
  	       if (awi->attrs & AT_TITLE)
--- 724,759 ----
       awi = GetAwmInfo(w);
       if (!awi)
            Leave(FALSE)
! 
!      if (awi->attrs & AT_BORDER) {
! 	  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)
***************
*** 761,771 ****
  	  if (xwc->y < 0)
  	       xwc->y = 0;
  	  XConfigureWindow(dpy, awi->frame, mask, xwc);
- 	  xwc->width = width;
- 	  xwc->height = height;
- 	  mask ^= (CWX | CWY);
  	  if (awi->gadgets)
  	       PutGadgets(w);
       }
       XConfigureWindow(dpy, awi->client, mask, xwc);
       Leave(TRUE)
--- 765,776 ----
  	  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)
diff -c awm.dst/Titlebar.c awm/Titlebar.c
*** awm.dst/Titlebar.c	Sat Jul  2 16:57:41 1988
--- awm/Titlebar.c	Tue Jul  5 18:54:14 1988
***************
*** 238,244 ****
  	       height += bcv;
  	  width += bch;
       }
! 
       foster = XCreateWindow(dpy, RootWindow(dpy, scr), x, y, width,
                              height, (bw ? bw : 1), xwa.depth, xwa.class,
  			    xwa.visual, valuemask, &swa);
--- 238,245 ----
  	       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);
***************
*** 492,500 ****
       if (!(awi = IsTitled(w)))
  	 Leave_void
       XGetWindowAttributes(dpy, awi->title, &xwa);
-      XQueryPointer(dpy, awi->frame, &junk, &chld, &ijunk, &ijunk,
-                    &ijunk, &ijunk, &ijunk);
- 
       if (reversed && TFontBoldInfo)
  	  f_info = TFontBoldInfo;
       else
--- 493,498 ----
diff -c awm.dst/awm.c awm/awm.c
*** awm.dst/awm.c	Sat Jul  2 16:57:44 1988
--- awm/awm.c	Tue Jul  5 21:12:27 1988
***************
*** 184,190 ****
  	       }
  	       /* Destroyed arg, skip over what used to be filename for -e */
  	       else if (!(strcmp(*argv, "--"))) {
! 		    argv++; argc--;
  		    continue;
  	       }
  	       else if (!(strcmp(*argv, "-b")))
--- 184,190 ----
  	       }
  	       /* Destroyed arg, skip over what used to be filename for -e */
  	       else if (!(strcmp(*argv, "--"))) {
! 		    argv += 2; argc -= 2;
  		    continue;
  	       }
  	       else if (!(strcmp(*argv, "-b")))
***************
*** 326,335 ****
        */
       if (Titles)
  	  Init_Titles();
-      /*
-       * Set initial focus to PointerRoot.
-       */
-      XSetInputFocus(dpy, PointerRoot, None, CurrentTime);
       /* 
        * watch for initial window mapping and window destruction
        */
--- 326,331 ----
***************
*** 436,441 ****
--- 432,438 ----
       DrawGC = XCreateGC(dpy, RootWindow(dpy, scr), 
  			GCLineWidth|GCForeground|GCFunction|GCSubwindowMode,
  			&xgc);
+ 
       /*
        * As our last "startup" task, invoke the execfile if was specified.
        */