[469] in Athena Bugs

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

Athena Widgets Viewport, forcebars & resizing

daemon@ATHENA.MIT.EDU (Mark W. Eichin)
Mon Jul 4 00:37:12 1988

Date: Mon, 4 Jul 88 00:36:23 EDT
From: Mark W. Eichin <eichin@ATHENA.MIT.EDU>
To: xbugs@ATHENA.MIT.EDU
Cc: Chris D. Peterson <kit@ATHENA.MIT.EDU>, bugs@ATHENA.MIT.EDU
The Viewport widget has two serious bugs (serious in that my
application wont work without fixing them both :-):
	1) The forcebars option doesn't work at all. It tries to
CreateScrollbar the two bars before the parent exists, and
CreateScrollbar tries to use the constraints of the parent. Result is
a coredump on the Vax (dereference of NULL pointer.)
	{1a) Even if it did work, the code tries to create a horizontal
scrollbar when allowvert is on...}
	2) When a child of the Viewport asks to be resized, the
Viewport tells it "Yes" and resizes it to something else (apparently the
size of the clipping window...) The child should *ALWAYS* get to
resize itself to anything it wants, and the viewport should permit it.
The viewport can (and should) refuse to permit location changes, but
it should allow anything to happen to the size (and update the
scrollbars to match.)

The following patch file is relative to the src/lib/Xaw/Viewport.c
file identified as:
static char rcsid[] = "$Header: Viewport.c,v 1.19 88/02/26 10:15:15 swick Exp $";

The patch puts #ifdef notdef around three sections of code (the first
turns off the original scrollbar creation, the other two are to fix
the resize problem.) Code is added to do CreateScrollbars under more
circumstances. A call to RedrawThumbs is added to the GeometryManager.

WARNING: This code has only been tested with forcebars and allowvert
on; this is what my application needed. It should probably work
without them...  that is up to you to test.

			     Mark Eichin
		       <eichin@athena.mit.edu>
	      Project Athena ``Watchmaker'', ZephyrTeam

*** /mit/x11dev/src/lib/Xaw/Viewport.c	Thu Mar  3 14:44:34 1988
--- Viewport.c	Mon Jul  4 00:07:16 1988
***************
*** 210,222 ****
  
      w->form.default_spacing = 0;
  
      if (w->viewport.forcebars) {
  	if (w->viewport.allowhoriz)
  	    clip_args[1].value = (XtArgVal)CreateScrollbar(w, True);
  
  	if (w->viewport.allowvert)
! 	    clip_args[0].value = (XtArgVal)CreateScrollbar(w, True);
      }
  
      clip_args[2].value = (XtArgVal)Max(w->core.width,1);
      clip_args[3].value = (XtArgVal)Max(w->core.height,1);
--- 210,224 ----
  
      w->form.default_spacing = 0;
  
+ #ifdef notdef
      if (w->viewport.forcebars) {
  	if (w->viewport.allowhoriz)
  	    clip_args[1].value = (XtArgVal)CreateScrollbar(w, True);
  
  	if (w->viewport.allowvert)
! 	    clip_args[0].value = (XtArgVal)CreateScrollbar(w, False);
      }
+ #endif
  
      clip_args[2].value = (XtArgVal)Max(w->core.width,1);
      clip_args[3].value = (XtArgVal)Max(w->core.height,1);
***************
*** 432,443 ****
      clip_width = w->core.width;
      clip_height = w->core.height;
      if (w->viewport.forcebars) {
! 	if (needsvert = w->viewport.allowvert)
  	    clip_width -= w->viewport.vert_bar->core.width +
! 			  w->viewport.vert_bar->core.border_width;
! 	if (needshoriz = w->viewport.allowhoriz)
  	    clip_height -= w->viewport.horiz_bar->core.height +
! 			   w->viewport.horiz_bar->core.border_width;
  	AssignMax( clip_width, 1 );
  	AssignMax( clip_height, 1 );
      }
--- 434,449 ----
      clip_width = w->core.width;
      clip_height = w->core.height;
      if (w->viewport.forcebars) {
!         if (needsvert = w->viewport.allowvert) {
! 	    if(!w->viewport.vert_bar) CreateScrollbar(w, False);
  	    clip_width -= w->viewport.vert_bar->core.width +
! 	                  w->viewport.vert_bar->core.border_width;
! 	}
! 	if (needshoriz = w->viewport.allowhoriz) {
! 	    if(!w->viewport.horiz_bar) CreateScrollbar(w, True);
  	    clip_height -= w->viewport.horiz_bar->core.height +
! 	                   w->viewport.horiz_bar->core.border_width;
! 	}
  	AssignMax( clip_width, 1 );
  	AssignMax( clip_height, 1 );
      }
***************
*** 459,467 ****
  	    }
  	    if (! XtIsRealized(widget))
  		needsvert = needshoriz = FALSE;
! 	    if (needshoriz && !w->viewport.horiz_bar)
  		CreateScrollbar(w, True);
! 	    if (needsvert && !w->viewport.vert_bar)
  		CreateScrollbar(w, False);
  	    clip_width = w->core.width -
  		(needsvert ? w->viewport.vert_bar->core.width
--- 465,475 ----
  	    }
  	    if (! XtIsRealized(widget))
  		needsvert = needshoriz = FALSE;
! 	    if ((w->viewport.forcebars || needshoriz)
! 		&& !w->viewport.horiz_bar)
  		CreateScrollbar(w, True);
! 	    if ((w->viewport.forcebars || needsvert)
! 		&& !w->viewport.vert_bar)
  		CreateScrollbar(w, False);
  	    clip_width = w->core.width -
  		(needsvert ? w->viewport.vert_bar->core.width
***************
*** 529,536 ****
      }
  
      if (child) {
! 	XtResizeWidget( child, (Dimension)child_width,
  		        (Dimension)child_height, 0 );
  	MoveChild(w, child->core.x, child->core.y);
      }
  }
--- 537,546 ----
      }
  
      if (child) {
! #ifdef notdef
!       XtResizeWidget( child, (Dimension)child_width,
  		        (Dimension)child_height, 0 );
+ #endif
  	MoveChild(w, child->core.x, child->core.y);
      }
  }
***************
*** 605,610 ****
--- 615,621 ----
  			     (rWidth ? request->width : w->core.width),
  			     (rHeight ? request->height : w->core.height) );
  
+ #ifdef notdef
      if (rWidth && w->core.width != request->width) {
  	if (!w->viewport.allowhoriz
  	    || request->width < w->core.width)
***************
*** 622,627 ****
--- 633,641 ----
  	}
      }
      *reply = allowed;
+ #endif
+     *reply = *request;
+     
      if (result == XtGeometryYes) {
  	Boolean needs_horiz = False, needs_vert = False;
  	if (rWidth)  child->core.width = request->width;
***************
*** 654,659 ****
--- 668,674 ----
      }
  
      if (reconfigured) (*w->core.widget_class->core_class.resize)( (Widget)w );
+     RedrawThumbs(w);
      return result;
  }
  

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