Re: [AD] new window hooks patch

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


> well, it's just my opinion, but i find this to be very ugly (sorry) and
> very specific. examples are just that, examples, and their goal is to
> show off a particular feature, so they don't care about being good at
> anything else: the faster to code the better. A real program is (well,
> should be) something more elaborate, and often is. Each program has its
> own behavior, and I think tying escape (or any other key for that matter)
> to this event is a bad thing. I agree that it may be convenient for the
> sake of tradition, but it's a bad thing IMHO.

This was made mainly to save compatibility with the past: I know we could 
make Allegro just to call the hook function and nothing else, but then we'd 
have to modify current programs shipped with the lib distro, as they don't 
set any quit hook, and thus they'll not allow window closing at all.
I'm open to any other solution anyway; let's just discuss them.

> The user would have something like:
>
> void window_close_hook()
> {
>   exit(1); // convenience code of course :)
> }
>
> void init()
> {
>   // other code
>   set_window_close_hook(&window_close_hook);
> }
>
> and then we're good to go, no ?

It is not safe to exit the program inside the hook function: I've tried it 
under BeOS, and I had strange behaviours... So I've written this even in the 
docs (see the patch), to warn user it's safer to set a flag inside the 
function and then check it later.

Of course calling just the hook is cleaner than simulating also a keypress 
(as you say, this can be done inside the hook itself if needed).
Now, what to do? Should we go with the ESC keypress simulation to keep 
compatibility with the past, or go without it for a cleaner, more elegant 
code?
It seems Shawn preferred the first one, but it was a lot of time ago, so 
maybe now it's time to change it.

-- 
Angelo Mottola
a.mottola@xxxxxxxxxx
ICQ UIN #66972680



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