[comp.windows.x] Bug in Viewport widget?

jkh@meepmeep.UUCP (Jordan K. Hubbard) (03/02/89)

Symptom:

   When a viewport is resized to be *larger* than the client's minimum
   desired size, it does not enlarge the child.

Repeat-By:

   Compile the following program. Run it with some numeric argument
   (the size of the asciiStringWidget's buffer) and let the window
   have its default minimum size (if you're running uwm or awm, place
   it with the left button). You should see a "text" cursor in all portions
   of the window. Make the window larger. You will still see the text
   cursor in the *original* window boundries, but the "gobbler" cursor
   in the extended areas. This is the cursor of the viewport window. The
   child has not been resized.

   If the window is made smaller, the correct behaviour is observed (scroll
   bars are added vertically and horizontally as needed). In no case will
   the text window be made larger than its original size.

   Is this a feature?

Fix:

   Look at the viewport code for 15 minutes. Run around in circles until
   you throw up. Sorry, I don't have a fix.


---- code follows ----

#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/AsciiText.h>
#include <X11/Viewport.h>
#include <X11/Shell.h>
#include <X11/cursorfont.h>
#include <stdio.h>

Arg args[10];
Cardinal i;

Widget Toplevel, Output;

int Buflen;
char *Buffer;

main(ac, av)
Cardinal ac;
String *av;
{
     Widget tmp;
     static Arg arglist[] = {
	  {XtNstring, (XtArgVal) NULL},
	  {XtNlength, (XtArgVal) NULL},
	  {XtNheight, (XtArgVal) 200 },
	  {XtNtextOptions, scrollVertical},
	  {XtNtextOptions, scrollHorizontal},
	  {XtNtextOptions, scrollOnOverflow},
     };

     setbuf(stderr, NULL);

     if (ac < 2) {
	  fprintf(stderr, "length expected\n");
	  exit(1);
     }
     Toplevel = XtInitialize("test", "Test", NULL, NULL, &ac, av);
     i = 0;
     XtSetArg(args[i], XtNallowShellResize, (XtArgVal)TRUE); i++;
     XtSetValues(Toplevel, args, i);

     i = 0;
     XtSetArg(args[i], XtNallowVert, (XtArgVal)TRUE); i++;
     XtSetArg(args[i], XtNallowHoriz, (XtArgVal)TRUE); i++;
     tmp = XtCreateManagedWidget(NULL, viewportWidgetClass, Toplevel, args, i);

     Buflen = atoi(av[1]);
     Buffer = (char *)XtMalloc(Buflen);
     bzero(Buffer, Buflen);
     arglist[0].value = (XtArgVal)Buffer;
     arglist[1].value = (XtArgVal)Buflen;
     Output = XtCreateManagedWidget("output", asciiStringWidgetClass,
				    tmp, arglist, XtNumber(arglist));
     XtTextEnableRedisplay(Output);
     XtRealizeWidget(Toplevel);
     XDefineCursor(XtDisplay(Toplevel), XtWindow(Toplevel),
	XCreateFontCursor(XtDisplay(Toplevel), XC_boat));
     XDefineCursor(XtDisplay(Toplevel), XtWindow(tmp),
	XCreateFontCursor(XtDisplay(Toplevel), XC_gobbler));
     XtMainLoop();
}

vojta@skippy.berkeley.edu (Paul Vojta) (03/05/89)

In article <8903011608.AA04842@meepmeep.UUCP> jkh@meepmeep.UUCP (Jordan K. Hubbard) writes:
>Symptom:
>
>   When a viewport is resized to be *larger* than the client's minimum
>   desired size, it does not enlarge the child.

I have noticed a bug in the R3 toolkit which does not appear in the R2
toolkit.  It may or may not be related to the above bug.

Specifically, I have an application (a version of xdvi) which changes
the size of the child widget by using XtSetValues.  If the child widget
shrinks to a size small enough to fit within the viewport, the scroll
bars do not go away.  (However, if the child grows, then scroll bars
appear as necessary.)

--Paul Vojta, vojta@math.berkeley.edu