[comp.windows.open-look] problem using xview with twm's interactive window positioning

janet@bilby.cs.uwa.oz.au (Janet Jackson) (01/07/91)

The attached simple xview program brings up a base frame containing a panel.
The panel has one button which toggles a subframe.  That is, when the user
presses the button once, the subframe is displayed; then if the user presses
the button again, the subframe is removed; and so on.

If the user clicks the button twice in rapid succession, one would expect
the subframe to quickly appear and disappear.  This works fine under olwm
or OpenWindows, which, in the absence of geometry specifications, place the
windows where they feel like it.  It also works under twm if I either specify
the window's geometry, or turn off interactive positioning via the
RandomPlacement variable.

However, with twm making the user position the window, one of two things
happen:

1. the display does not alter, but twm appears to hang.  The panel
   arrow cursor remains displayed, and I can move it about, but I can't
   do anything else.  I have to kill twm from another terminal to get out
   of it.

2. twm displays the outline of the subframe and lets me position it.  The
   subframe is then displayed.  At this point I expect the subframe to
   disappear immediately, but only the decorations disappear.  The "inside"
   of the window is still there.  (In a version where the subframe contained
   buttons, the buttons still worked.)

   My program now thinks the subframe is down (and XV_SHOW is indeed FALSE),
   so if I click the button again, XV_SHOW will be set TRUE.  The decorations
   do not come back.  If I click the button once more, setting XV_SHOW FALSE,
   the subframe disappears and the program is "back to normal".

These two behaviours seem to occur about equally often, and I can't find
any way to predict which will occur.

The problem only happens if the second click comes before twm has time to
display the window outline.  If the second click comes after the subframe is
up, the subframe disappears just fine.

I have tried altering most of the likely-looking variables of twm without
success.

This problem is occurring in a real application I am writing.  I would very
much like this application to be reliable under twm.

Has anyone encountered this kind of thing?  Is it a bug/misfeature in twm,
in which case is there a workaround? or is something wrong with the way
my program interacts with the window manager?

I have been trying to solve this for some time now.  If anyone can help, I
will be eternally grateful!

My environment:  Sun SPARCstation 1 running SunOS 4.0.3 and X11 Release 4.

Thanks in advance,

Janet Jackson
(janet@cs.uwa.oz.AU)
Department of Computer Science
The University of Western Australia

---cut here---
/* this is just one of the standard example programs with a few changes */
#include <xview/xview.h>
#include <xview/panel.h>

Frame frame;     /* top level application base-frame */
Frame subframe;  /* subframe is a child of frame */
int   up = 0;    /* set when subframe is displayed*/

main(argc, argv)
int argc;
char *argv[];
{
    Panel panel;
    int show_cmd_frame();

    xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);

    /* Create base frame */
    frame = (Frame)xv_create(NULL, FRAME,
        FRAME_LABEL, argv[0],
        NULL);

    /* Install a panel and a panel button */
    panel = (Panel)xv_create(frame, PANEL, NULL);
    (void) xv_create(panel, PANEL_BUTTON,
        PANEL_LABEL_STRING, "Show It",
        PANEL_NOTIFY_PROC,  show_cmd_frame,
        NULL);

    /* Create the command frame -- not displayed until XV_SHOW is set */
    subframe = (Frame)xv_create(frame, FRAME,
        FRAME_LABEL,         "Popup",
        NULL);

    xv_main_loop(frame);
}

/* Called when base frame's button is pushed -- toggle subframe up or down*/
show_cmd_frame(item, event)
Frame item;
Event *event;
{
    xv_set(subframe, XV_SHOW, (up ? FALSE : TRUE), NULL);
    up = !up;
}