tschak909 / platotermamiga

PLATOTerm for the Commodore-Amiga
GNU General Public License v3.0
8 stars 4 forks source link

Fix help keys menu close. #10

Closed wschaub closed 5 years ago

wschaub commented 5 years ago

In oder to process IDCMP events correctly for the help keys window we have to do some special plumbing in order to share the UserPort and events between both of our windows. This allows us to just have one event loop and process the events immediately.

This is accomplished by the following steps:

Alocation: 1) set up the new window structure with NULL for the events field

2) once we have our Window structure set it's ->UserPort to = the main window's UserPort

3) call ModifyIDCMP(helpwindowptr,IDCMP_CLOSEWINDOW) This will tell intuition to listen for the close window gadget. However it will not attempt to open a new UserPort for that window because UserPort is not null at this point.

4) Profit! we now have events for both windows on the same UserPort.

Tear down: 1) Stop multitasking with Forbid().

2) Swallow up all remaining messages for the window we are about to kill.

3) IMPORTANT assign NULL to the help window's ->UserPort or the next step will close our main UserPort and crash the system on the next event loop.

4) call ModifyIDCMP(helpwindowptr,0L); to tell intuition to stop sending events.

5) Permit() to re-enable multitasking.

6) Finally close the window.

tschak909 commented 5 years ago

Awesomeness.