[768] in testers

home help back first fref pref prev next nref lref last post

addendum to xterm scrollbar patch

daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Wed May 16 14:10:48 1990

Date: Wed, 16 May 90 14:10:09 -0400
From: "Jonathan I. Kamens" <jik@pit-manager.MIT.EDU>
To: testers@ATHENA.MIT.EDU
Cc: cfields@ATHENA.MIT.EDU, vanharen@ATHENA.MIT.EDU, swick@ATHENA.MIT.EDU

Well, Ralph explained to me why my patch had problems.  Here is
another patch, to apply *in addition to* the patch I've already
supplied (i.e. apply the other patch, and then apply this):

*** /tmp/,RCSt1001749	Wed May 16 14:08:41 1990
--- scrollbar.c	Wed May 16 13:57:26 1990
***************
*** 64,75 ****
--- 64,141 ----
  	int min_width, min_height;
  {
  	register TScreen *screen = &xw->screen;
+ #ifndef nothack
+ 	XSizeHints sizehints;
+ 	long supp;
+ #endif
  	XtGeometryResult geomreqresult;
  	Dimension oldWidth, oldHeight;
  	Dimension reqWidth, reqHeight, repWidth, repHeight;
  
+ 	/*
+ 	 * I'm going to try to explain, as I understand it, why we
+ 	 * have to do XGetWMNormalHints and XSetWMNormalHints here,
+ 	 * although I can't guarantee that I've got it right.
+ 	 *
+ 	 * In a correctly written toolkit program, the Shell widget
+ 	 * parses the user supplied geometry argument.  However,
+ 	 * because of the way xterm does things, the VT100 widget does
+ 	 * the parsing of the geometry option, not the Shell widget.
+ 	 * The result of this is that the Shell widget doesn't set the
+ 	 * correct window manager hints, and doesn't know that the
+ 	 * user has specified a geometry.
+ 	 *
+ 	 * The XtVaSetValues call below tells the Shell widget to
+ 	 * change its hints.  However, since it's confused about the
+ 	 * hints to begin with, it doesn't get them all right when it
+ 	 * does the SetValues -- it undoes some of what the VT100
+ 	 * widget did when it originally set the hints.
+ 	 *
+ 	 * To fix this, we do the following:
+ 	 *
+ 	 * 1. Get the sizehints directly from the window, going around
+ 	 *    the (confused) shell widget.
+ 	 * 2. Call XtVaSetValues to let the shell widget know which
+ 	 *    hints have changed.  Note that this may not even be
+ 	 *    necessary, since we're going to right ahead after that
+ 	 *    and set the hints ourselves, but it's good to put it
+ 	 *    here anyway, so that when we finally do fix the code so
+ 	 *    that the Shell does the right thing with hints, we
+ 	 *    already have the XtVaSetValues in place.
+ 	 * 3. We set the sizehints directly, this fixing up whatever
+ 	 *    damage was done by the Shell widget during the
+ 	 *    XtVaSetValues.
+ 	 *
+ 	 * Gross, huh?
+ 	 *
+ 	 * The correct fix is to redo VTRealize, VTInitialize and
+ 	 * VTSetValues so that font processing happens early enough to
+ 	 * give back responsibility for the size hints to the Shell.
+ 	 *
+ 	 * Someday, we hope to have time to do this.  Someday, we hope
+ 	 * to have time to completely rewrite xterm.
+ 	 */
+ 
  #ifndef nothack
  	/*
+ 	 * NOTE: If you change the way any of the hints are calculated
+ 	 * below, make sure you change the calculation both in the
+ 	 * sizehints assignments and in the XtVaSetValues.
+ 	 */
+ 
+ 	if (! XGetWMNormalHints(screen->display, XtWindow(XtParent(xw)),
+ 				&sizehints, &supp))
+ 	     sizehints.flags = 0;
+ 	sizehints.base_width = min_width;
+ 	sizehints.base_height = min_height;
+ 	sizehints.width_inc = FontWidth(screen);
+ 	sizehints.height_inc = FontHeight(screen);
+ 	sizehints.min_width = sizehints.base_width + sizehints.width_inc;
+ 	sizehints.min_height = sizehints.base_height + sizehints.height_inc;
+ 	sizehints.flags |= (PBaseSize|PMinSize|PResizeInc);
+ #endif
+ 	
+ 	/*
  	 * Note: width and height are not set here because they are 
  	 * obsolete. 						
  	 */
***************
*** 81,91 ****
  		      XtNminWidth, min_width + FontWidth(screen),
  		      XtNminHeight, min_height + FontHeight(screen),
  		      NULL);
- 	/* Need to sync so that the changes reach the window manager */
- 	/* before we make the resize request.			     */
- 	XSync(screen->display, False);
- #endif
  
  	oldWidth = xw->core.width;
  	oldHeight = xw->core.height;
  	reqWidth = (screen->max_col + 1) * FontWidth(screen) + min_width;
--- 147,157 ----
  		      XtNminWidth, min_width + FontWidth(screen),
  		      XtNminHeight, min_height + FontHeight(screen),
  		      NULL);
  
+ #ifndef nothack
+ 	XSetWMNormalHints(screen->display, XtWindow(XtParent(xw)), &sizehints);
+ #endif
+ 	
  	oldWidth = xw->core.width;
  	oldHeight = xw->core.height;
  	reqWidth = (screen->max_col + 1) * FontWidth(screen) + min_width;

home help back first fref pref prev next nref lref last post