[comp.windows.x] uwm.new.patch5.

jkh@dana.UUCP (Jordan K. Hubbard) (12/16/87)

DESCRIPTION:
	Elimination of some unnecessary cruft. Fixed bug that caused coredump
	in PaintTitle. Startup is faster due to batching of MapWindow requests.
	(doesn't seem to be an XCreateWindows anymore... why?). Reverse now
	works properly for borders. Setting booleans from menus now works
	under Sun's braindamaged 3.4 compiler.

	P.S. Change TOPDIR in Makefile from /usr/src/X.V11R1 to ../../.
	Most people have probably changed this already, so I didn't include
	it as a patch.

FIXES:

*** uwm.new/FocusChange.c.old	Tue Dec 15 16:57:03 1987
--- uwm.new/FocusChange.c	Tue Dec 15 17:32:35 1987
***************
*** 10,16 ****
   */
  
  #include "uwm.h"
- #include "grey.b"
  
  #if defined(sun) || defined(ibmrt)
  #include <sys/time.h>
--- 10,15 ----
***************
*** 17,38 ****
  #else
  #include <time.h>
  #endif
- Pixmap greybordertile;
  
- /* get a grey pixmap for the border */
- Pixmap get_grey_pixmap()
- {
- 	Pixmap tmp;
- 
- 	tmp = XCreateBitmapFromData(dpy, DefaultRootWindow(dpy), grey_bits,
- 	  grey_width, grey_height);
- 	if (!tmp) {
- 		fprintf(stderr, "uwm: Can't allocate grey pixmap for border!\n");
- 		exit(1);
- 	}
- 	return(tmp);
- }
- 
  extern Bool Snatched;
  Bool Eventp();
  
--- 16,22 ----
***************
*** 63,70 ****
  		if ((dat = GetTitleInfo(w)) != NULL)
  			w = dat->parent;
  		/* light the border */
! 		if (Hilite == True) {
! 			XSetWindowBorder(dpy, w, WhitePixel(dpy, DefaultScreen(dpy)));
  			if (dat != NULL)
  				PaintTitle(dat);
  		}
--- 47,57 ----
  		if ((dat = GetTitleInfo(w)) != NULL)
  			w = dat->parent;
  		/* light the border */
! 		if (Hilite) {
! 			if (Reverse)
! 				XSetWindowBorder(dpy, w, WhitePixel(dpy, scr));
! 			else
! 				XSetWindowBorder(dpy, w, BlackPixel(dpy, scr));
  			if (dat != NULL)
  				PaintTitle(dat);
  		}
***************
*** 92,101 ****
  		/* set the window to grey */
  		if ((dat = GetTitleInfo(w)) != NULL)
  			w = dat->parent;
! 		if (Hilite == True) {
! 			if (!greybordertile)
! 				greybordertile = get_grey_pixmap();
! 			XSetWindowBorderPixmap(dpy, w, greybordertile);
  			if (dat != NULL)
  				PaintTitle(dat, False);
  		}
--- 79,86 ----
  		/* set the window to grey */
  		if ((dat = GetTitleInfo(w)) != NULL)
  			w = dat->parent;
! 		if (Hilite) {
! 			XSetWindowBorderPixmap(dpy, w, GrayPixmap);
  			if (dat != NULL)
  				PaintTitle(dat, False);
  		}
*** uwm.new/Menu.c.old	Tue Dec 15 15:31:00 1987
--- uwm.new/Menu.c	Tue Dec 15 17:01:57 1987
***************
*** 324,333 ****
  		             return(func_stat);
  		             break;
  
! 				 case IsVar:
! 					*(ml->text) = *ml->aux;
! 					UnmapMenu(menu);
! 					break;
  
  		         default:
   		            Error("Menu -> Internal type error.");
--- 324,333 ----
  		             return(func_stat);
  		             break;
  
! 			 case IsVar:
! 				*(ml->text) = (int)*(ml->aux);
! 				UnmapMenu(menu);
! 				break;
  
  		         default:
   		            Error("Menu -> Internal type error.");
*** uwm.new/TitleBar.c.old	Mon Dec 14 18:19:41 1987
--- uwm.new/TitleBar.c	Tue Dec 15 14:48:15 1987
***************
*** 118,124 ****
  	XAddToSaveSet(dpy, w);
   	XGetGeometry(dpy, (Drawable)w, &root, &x, &y, &width, &height, &bw,
        &depth);
! 	foster = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), x, y,
  	  width, height + Fheight + 2, (bw ? bw : 1), MBorder, MBackground);
  	if (!foster)
  		Error("AddTitle: Can't create foster parent!");
--- 118,124 ----
  	XAddToSaveSet(dpy, w);
   	XGetGeometry(dpy, (Drawable)w, &root, &x, &y, &width, &height, &bw,
        &depth);
! 	foster = XCreateSimpleWindow(dpy, RootWindow(dpy, scr), x, y,
  	  width, height + Fheight + 2, (bw ? bw : 1), MBorder, MBackground);
  	if (!foster)
  		Error("AddTitle: Can't create foster parent!");
***************
*** 225,232 ****
  	XGetWindowAttributes(dpy, t_data->title, &xwa);
  	XQueryPointer(dpy, t_data->parent, &junk, &chld, &ijunk, &ijunk,
  	  &ijunk, &ijunk, &ijunk);
! 	reversed = (chld == t_data->subwin);
! 	f_info = (reversed ? TFontBoldInfo : TFontInfo);
  	if (!gc) {
  		XGCValues gcv;
  
--- 225,235 ----
  	XGetWindowAttributes(dpy, t_data->title, &xwa);
  	XQueryPointer(dpy, t_data->parent, &junk, &chld, &ijunk, &ijunk,
  	  &ijunk, &ijunk, &ijunk);
! 	reversed = (chld == t_data->subwin && Hilite);
! 	if (reversed && TFontBoldInfo)
! 		f_info = TFontBoldInfo;
! 	else
! 		f_info = TFontInfo;
  	if (!gc) {
  		XGCValues gcv;
  
*** uwm.new/gram.y.old	Tue Dec 15 16:56:29 1987
--- uwm.new/gram.y	Tue Dec 15 16:56:52 1987
***************
*** 60,67 ****
  static MenuLine *ml_ptr;		/* Temporary menu line pointer. */
  static char *hcolors[4];		/* Color values used in menu hdrs. */
  static char *mcolors[2];		/* Color values used in menus. */
! Bool true = TRUE;			/* hack */
! Bool false = FALSE;			/* ditto */
  MenuLink *menu_link;			/* Temporary menu link pointer. */
  
  char *calloc();
--- 60,67 ----
  static MenuLine *ml_ptr;		/* Temporary menu line pointer. */
  static char *hcolors[4];		/* Color values used in menu hdrs. */
  static char *mcolors[2];		/* Color values used in menus. */
! unsigned true = -1;			/* hack */
! unsigned int false = 0;			/* ditto */
  MenuLink *menu_link;			/* Temporary menu link pointer. */
  
  char *calloc();
*** uwm.new/uwm.c.old	Tue Dec 15 14:28:44 1987
--- uwm.new/uwm.c	Tue Dec 15 14:57:13 1987
***************
*** 356,363 ****
       
       if (XQueryTree(dpy, DefaultRootWindow(dpy), &junk, &junk, &kiddies, &nkids)
  	 != BadWindow) {
! 	  unsigned int i;
! 	  
  	  for (i = 0; i < nkids; i++) {
  	       XWindowAttributes xwa;
  	       Window transient;
--- 356,364 ----
       
       if (XQueryTree(dpy, DefaultRootWindow(dpy), &junk, &junk, &kiddies, &nkids)
  	 != BadWindow) {
! 	  unsigned int i, nmap = 0;
! 	  Window *tomap = (Window *)malloc(sizeof(Window) * nkids);
! 
  	  for (i = 0; i < nkids; i++) {
  	       XWindowAttributes xwa;
  	       Window transient;
***************
*** 370,381 ****
  		   IsViewable && xwa.override_redirect == False &&
  		   transient == None) {
  		    if (Titles) /* add title to this window */
! 				AddTitle(kiddies[i], True);
  		    XSelectInput(dpy, kiddies[i], (EnterWindowMask |
  			  LeaveWindowMask));
  	       }
  	  }
  	  XFree(kiddies);
       }
       /*
        * Calculate size of the resize pop-up window.
--- 371,385 ----
  		   IsViewable && xwa.override_redirect == False &&
  		   transient == None) {
  		    if (Titles) /* add title to this window */
! 			tomap[nmap++] = AddTitle(kiddies[i], False);
  		    XSelectInput(dpy, kiddies[i], (EnterWindowMask |
  			  LeaveWindowMask));
  	       }
  	  }
  	  XFree(kiddies);
+ 	  for (i = 0; i < nmap; i++)
+ 		XMapWindow(dpy, tomap[i]);
+ 	  free(tomap);
       }
       /*
        * Calculate size of the resize pop-up window.

jg@jumbo.dec.com (Jim Gettys) (12/16/87)

V11 Xlib lacks a batch window creation routine because it doesn't need it.

In V10, each create window cost you a round trip to get the window id,
unless you had a clever routine to batch up the requests and get the pile
of replys all at once.  XCreateWindows was a work around in V10 to get
around the round trip.

In V11, resource ID's are allocated by the client, so no round trip is
required to create a window.  Since the interface no longer would have
provided any advantage, it was removed on simplicity grounds.
					Jim Gettys