Re: XForms: three questions

Steve Lamont (spl@szechuan.ucsd.edu)
Fri, 20 Feb 98 09:43:38 PST

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (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
callback.

> 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
gettimeofday():

#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 )
do_the_double_click_stuff();

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, ...

No.

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

Yes.

> Does the order matter?

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

FL_OBJECT *obj;
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.

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://bloch.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/