Re: How to make a new "goodie"?

Steve Lamont (spl@szechuan.ucsd.edu)
Fri, 22 Nov 96 07:12:52 PST

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

> >> Is there a simple solution, or do I have to create a list of the
> >> active forms inside `my_goodie()' (by looking at FL_FORM.deactivated)?

Here's a gross hack that came to me whilst driving to work. Beware:
It is ugly and inefficient but it does seem to work.

[...]

Window this = ob->form->window;
Window root;
Window parent;
Window *children;
int n_children;
int i;

XQueryTree( fl_get_display(), this,
&root, &parent, &children, &n_children );
recurse( root );

[...]

void recurse( Window this )

{

Window root;
Window parent;
Window *children;
int n_children;
int i;

XQueryTree( fl_get_display(), this,
&root, &parent, &children, &n_children );
for ( i = 0; i < n_children; i++ ) {

FL_FORM *form = fl_win_to_form( children[i] );

if ( form )
fprintf( stderr, "Window %08lx is a form\n", children[i] );
recurse( children[i] );

}
XFree( children );

}

You can query the server's Window tree using XQueryTree (other
functions, such as XQueryPointer(), will also work) to find the root
window. Then pass the root Window XID to the recurse() function and
descend the tree, using fl_win_to_form() to get the XForms pointer to
the form. fl_win_to_form() returns NULL if the Window does not belong
to XForms. You can then do whatever you want with the FL_FORM
pointer.

Ugly and relatively slow (it probably generates a round trip to the
server for each XQueryTree -- I'd have to check the protocol document
and I don't have it with me at the moment) but it seems to work.

I'm going to go be sick now.

spl

To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html