[comp.windows.x] question about widget visibility

sundar@WHEATIES.AI.MIT.EDU (Sundar Narasimhan) (07/04/88)

I have an application that creates a few widgets and draws on them.
I am using the athena widget set -- forms, command butttons etc..
Input to the application comes from stdin. When I wrote the code to
read and write to the widgets, I noticed that the first few display
commands never appeared on the screen. All the display commands were
those commands written to the widget between the time the toplevel
window is rubberbanded and the user uses his mouse to position the
window on the screen. I used XFlush()'s just after every display
command to no avail.

So I say to myself, my application needs to wait until it is sure that
the display window is actually visible before it can draw on it; 
I tried setting
    XtSetMappedWhenManaged(top, TRUE);
first and then
    XtSetMappedWhenManaged(top, FALSE);
and made explicit calls to XtMapWidget. I added XFlush()'s after this
and still the widgets (windows) do NOT become visible on the screen.

I then notice this thing called the VisibilityNotify event. 
So I try adding an event handler like the one shown below assuming
that the default corepart would have visible_interest set to TRUE;
    XtAddEventHandler(top, VisibilityNotify, 0, visibility, 0);

I guess wrong again. Since my handler is never being invoked obviously
the default is for visible_interest to be set to FALSE. I can't seem to be
able to set this variable. (#including CoreP.h in my program
gives all sorts of name clashes, but that is entirely another matter).

So, folks, what is the recommended way of finding out when your widget
is visible?

-Sundar

RWS@ZERMATT.LCS.MIT.EDU (Robert Scheifler) (07/05/88)

    Date: Mon, 4 Jul 88 10:47:21 EDT
    From: sundar@wheaties.ai.mit.edu (Sundar Narasimhan)

	XtAddEventHandler(top, VisibilityNotify, 0, visibility, 0);

This should work, if you use the correct argument of VisibilityChangeMask
instead of VisibilityNotify.

    Since my handler is never being invoked obviously
    the default is for visible_interest to be set to FALSE.

The default is FALSE, but this is independent of whether your handler
is called.  visible_interest simply controls dynamic updating of the
"visible" Core component.

    I can't seem to be
    able to set this variable.

visible_interest is a class component, not an instance component.
To change it, you need to create a new (sub)class.

    So, folks, what is the recommended way of finding out when your widget
    is visible?

Well, generally the right thing is to register an expose proc, and
repaint only when your expose proc gets called (or in response to
direct user input, of course).