Re: [AD] event hooks

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2006-12-13, Elias Pschernig <elias@xxxxxxxxxx> wrote:
> On Thu, 2006-12-14 at 01:13 +1100, Peter Wang wrote:
> > 
> > A problem is that a single event may be delivered to multiple event
> > queues, a callback might be called multiple times for the same event.
> 
> I see. Probably could add a flag which gets cleared.

That will preclude an implementation of events where AL_EVENTs are
delivered to event queues by copying their contents, rather than passing
a pointer.  The current implementation uses the latter, but I think it's
a mistake.

Ok, with copying, we could still share a flag, but that's too
complicated.

> > > Or alternatively, have a function:
> > > 
> > > void al_event_acknowledge(AL_EVENT *event);
> > 
> > This is basically what I had in mind, but I was thinking of a
> > resize-event specific function, rather than a general acknowledgement
> > function.  I think this is easier to work with than a callback.
> 
> So something like:
> 
> al_display_acknowledge_resize(AL_DISPLAY *display);
> 
> And it would "fix" all the internal stuff for a possibly changed window
> size. (Should come up with a better name than of course, something
> following the al_verb_noun scheme.)

I see you've called it al_acknowledge_resize() in SVN, which I quite
like.  Or al_ack_resize(AL_DISPLAY *display); ?

> Actually, I just had another thought, this function could again be
> called automatically, but not from the events handling, but from
> al_flip() this time.

I'm not sure.  Part of the acknowledgement is not only that Allegro gets
a chance to fix stuff up, but the user gets an opportunity as well.
Do you consider this problematic?

    al_wait_for_event(&ev);
    switch (ev.type) {

	case AL_EVENT_DISPLAY_EXPOSE:
	    ...
	    al_flip();	    // may cause a resize acknowledgement
	    break;

	case AL_EVENT_DISPLAY_RESIZE:
	    ...
	    al_flip();
	    break;
	...
    }

Peter





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/