Re: XForms: I which to registrer a complaint...

Steve Lamont (spl@szechuan.ucsd.edu)
Mon, 6 Oct 97 06:11:16 PDT

To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> I'm currently working on an application using the 0.86 version of the
> forms library. The main application uses a number of transient forms
> containing canvas (or is is canvai?). If a form holding a canvas is
> hidden `fl_hide_form' the canvas window seems to be deleted, and the
> new window needs to be initialised again after `fl_show_form'.
>
> This behaviour also causes `BadDrawable' in the following scenario:
> An application handles a main form and a transient form.
> The trancient form is composed of a canvas and a menu button.
> The canvas has registered to receive `Expose' events.
> One of the menu call backs causes a `fl_hide_form' on the trancient
> form when the `Hide' item is selected. However, when the `Hide' item
> is selected an `Expose' event is generated, but `fl_hide_form' is
> executed before the event is received. The `Expose' handler then
> receives the event, draws in the killed canvas window and causes a
> `BadDrawable' error event.

Yes, this has driven me bats, too. (Well, okay, so it was a short
drive.)

One answer is to either use XUnmapWindow() to sidestep XForms
entirely. This simply hides the Window/form without destroying the
Canvas object. TC once explained to me why the Canvas Window had to
be destroyed when the form was hidden but I've forgotten the
explanation.

> Has anyone else had problems like this, maybe even worked out a usable
> work-around? ...

The other solution is to resort to a hack such as the one below:

void destroy_form( FL_FORM *form )

{

void *dui = form->fdui;
FL_OBJECT *obj = form->first;

/*
* This hack necessary because it appears that the cleanup
* routine is otherwise called after the window is destroyed!
*/

do
if ( ( obj->objclass == FL_CANVAS ) ||
( obj->objclass == FL_GLCANVAS ) )
fl_hide_object( obj );
while ( obj = obj->next );

fl_hide_form( form );
fl_free_form( form );
free( dui );

}

The function traverses the object list and looks for objects of class
FL_CANVAS or FL_GLCANVAS and nukes them first before hiding the form
and, in this case, destroying it. If you wanted to just hide the
form, you could elide the fl_free_form() and free() functions.

> ... I'm extremely reluctent to move my application into
> Motif as I am very happy with the forms library.

Don't do it!

I'd rather gnaw my own legs off and then run a marthon on broken glass
and rock salt rather than go back to Bloatif...

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/