|
* TinkerDifferent *
Retro Computing Community |
| Home | Forums | What's New | Search | Settings |
| 68kWhy call FlushEvents between InitFonts and InitWindows? |
Forums > Vintage Apple > Software & Operating Systems > Software | Development
|
ryandesign New Tinkerer -------- Joined: May 11, 2024 Posts: 14 Likes: 9 |
Jul 3, 2025 - #1
Is anyone aware of any Apple documentation that explains the reasoning behind the specific place that they suggested calling
FlushEvents during application initialization?The Road Map chapter of Inside Macintosh I suggested the Toolbox be initialized this way:
This order is repeated in many third-party books and sample programs of the 80s and early 90s. The order of some of these is critical. For example, Inside Macintosh I says:
I understand the purpose of calling FlushEvents. It clears the event queue to prevent "stray" events. For example, if the user inadvertently triple-clicked an application instead of double-clicking it, you don't want that third click to be interpreted by the new application, especially if the new application opens a window with an active control right where the application icon had been in the Finder.What I don't understand is why Apple suggested calling FlushEvents between InitFonts and InitWindows. What's the significance or importance of that? Why not call FlushEvents after all the Init functions? If the purpose is to clear unintended user input that occurred before the app finished launching, it makes sense that FlushEvents should be called as late as possible in the application's initialization process, after all the managers have been initialized and after the application has loaded in its menubar and done its other initialization. In other places, like Inside Macintosh II, it just says FlushEvents should be called "at the beginning of your application" without mentioning sandwiching it between two seemingly arbitrary Init functions.Inside Macintosh I even says:
And yet their sample code shows calling FlushEvents--part of the Event Manager--before having initialized the Window Manager by calling InitWindows.In the rebooted documentation series of the early 90s, in Inside Macintosh: Overview, in Listing 4-2, Apple has changed the order to one that makes more sense to me:
|
|
David Cook Tinkerer -------- Joined: Jul 20, 2023 Posts: 130 Likes: 172 |
Jul 3, 2025 - #2
I agree that the new order makes a lot more sense, particularly since events can be added during interrupts. So, an event can be posted as the other managers are initialized.
In the 1983 (pre-launch) technical notes, they say: "Before using the Event Manager, you should call the Window Manager procedure InitWindows: parts of the Event Manager rely on the Window Manager's data structures and will not work properly unless those structures have been properly initialized." That is not the order recommended by Inside Macintosh. In Technical Note #135 they recommend a different mask at initialization. If a disk is inserted as an application is started up, that event would originally be flushed if you use the 'everyEvent' mask by itself. FlushEvents (everyEvent - diskMask,0); They fixed the disk-inserted-event problem in their code (but probably only in Mac Plus ROMs and forward?) by ANDing the mask supplied by the caller. MOVE.W D0,D4 ; mask of events to remove AND.W FlEvtMask,D4 ; only flush masked events <03Mar85> One other interesting bug fix: ; put a -1 into LastSPExtra (long) for the FontMGR (fixes a bug when under Switcher). MOVEQ #-1,D1 ; <28-Oct-85> MOVE.L D1,LastSPExtra ; <28-Oct-85> |
|
ryandesign New Tinkerer -------- Joined: May 11, 2024 Posts: 14 Likes: 9 |
Jul 3, 2025 - #3
Thanks, the concern about inadvertently clearing disk-inserted events had occurred to me but I don't think I had found that example buried in Tech Note #135 before.
Looking at the ROM disassembly in Gryphel FDisasm, I agree: In the 128K ROM, FlushEvents ANDs with FlEventMask (which is set during reset to $FF7F) and puts -1 in LastSPExtra but none of those happen in the 64K ROM. |
| Page 1 of 1 |
| Home | Forums | What's New | Search | Bookmarks | RSS | Original | Settings |
| XenForo Retro Proxy by TinkerDifferent.com |