Re: XForms: three questions

Steve Lamont (
Fri, 20 Feb 98 09:43:38 PST

# To subscribers of the xforms list from (Steve Lamont) :

> (1) Browser double clicks
> How is one expected to use the browser double click callback? My
> program should do different things depending on whether a browser
> is single clicked or double clicked, so I install both a regular
> callback and a double click callback. But when I double click, the
> single click callback is called, then the double click callback, and
> then the single click callback again. When the first single click
> callback is called, I don't know whether it's a real single click or
> not.

I don't think the single and double click callbacks were really meant
to be used together. I suppose one could kluge something to avoid
acting on the second single click callback by setting a flag in the
double click callback to tell the single click callback to ignore the

> The (not terribly satisfactory) workaround that I'm using doesn't
> use the double click callback at all. I start an itimer when the
> program gets a single click. If the timer expires before another click
> comes in, then the timer's signal handler performs the single click
> action. The trouble with this is that it precludes other uses of
> SIGALRM. If xforms looked for double clicks in the main event loop, it
> wouldn't have to use an itimer.

The problem is, of course, disambiguating the single from the double
click. You'll note that in most applications, a single click doesn't
do much other than, for example, change the color or mode of an
object. The double click does the actual work.

You don't really need to us SIGALRM to do your workaround. Simply use

#define SECS(tv) ( (tv).tv_sec + ( 1.0e-6 * (tv).tv_usec ) )
#define DOUBLE_CLICK_TIME 0.25 /* I like about a 1/4 of a second */

void callback( FL_OBJECT *ob, long data )


static double last_time = 0.0;
struct timeval tv;

gettimeofday( &tv, NULL );

if ( SECS( tv ) - last_time <= DOUBLE_CLICK_TIME )

last_time - SECS( tv );


> (2) Deleting and freeing grouped objects
> What is the correct way to delete and free grouped objects? Does
> deleting or freeing a group also delete and free the objects in the
> group, ...


> ... or does each object have to be deleted and freed separately?


> Does the order matter?

Sort of. Here's what I'd do.

int objclass;

obj = kill_gp; /* Initialize with your group head */

do {

FL_OBJECT *next = obj->next;

objclass = obj->objclass;

fl_hide_object( obj );
fl_delete_object( obj );
fl_free_object( obj );

obj = next;

} while ( objclass != FL_END_GROUP );

I've tested it in a limited sort of way and it seems to work.

> (3) Spurious callbacks
> Mike Blackwell posted about a mysterious crashing bug in the SGI 0.88
> version, having to do with input objects. TC responded that that
> problem may be fixed in 0.88.1. ...

I've seen a similar problem but have never been able to reliably
reproduce it. :-(

I dunno if TC has fixed it or not.

To unsubscribe, send the message "unsubscribe" to or see
XForms Home Page:
List Archive: