NewCreature / Allegro-Legacy

Make Your Allegro 4 Programs Run On Modern Systems Using Allegro 5
19 stars 3 forks source link

doesn't handle close button callback #22

Closed connorjclark closed 2 years ago

connorjclark commented 2 years ago

a5_sys_set_close_button_callback sets the provided callback, but this value is never used. I think a new event handling queue is needed in the a5/ directory (to listen for ALLEGRO_EVENT_DISPLAY_CLOSE and call the system close button callback, but I don't know where to put it.

also:

https://github.com/NewCreature/Allegro-Legacy/blob/7e7350485876a08e201fc4b5c3f908f4f65a3505/src/a5/a5_system.c#L78 this condition should be removed, because an a4 program may set the close callback before the display has been created

NewCreature commented 2 years ago

I addressed both of these issues in 0bf7bad5f174a529d020396ce59f53c5aaf0ac7a. Since the close button callback can only ever be triggered if there is a window, we can just hook the display up to the display thread's event queue.

If the user has disabled threaded display handling, the callback will not be called. It might be good to put a note in the README about that. Presumably, if the user has disabled threaded display handling, they are already going to be handling the events. The important thing here is if a user builds their unmodified Allegro 4 program with Allegro Legacy, it will behave as expected.

connorjclark commented 2 years ago

confirmed that patch works for me. thanks for the quick fix!