-/* $Id: mac.c,v 1.33 2003/01/18 20:09:21 ben Exp $ */
+/* $Id: mac.c,v 1.36 2003/01/24 00:25:33 ben Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
*/
#include <MacTypes.h>
+#include <AEDataModel.h>
+#include <AppleEvents.h>
#include <Quickdraw.h>
#include <Fonts.h>
#include <MacWindows.h>
Session *sesslist;
static int cold = 1;
+static int borednow = FALSE;
struct mac_gestalts mac_gestalts;
static void mac_startup(void);
static void mac_adjustmenus(void);
static void mac_closewindow(WindowPtr);
static void mac_zoomwindow(WindowPtr, short);
-static void mac_shutdown(void);
#pragma noreturn (cleanup_exit)
struct mac_windows {
mac_gestalts.uncvattr = (*ti)->tecUnicodeConverterFeatures;
DisposeHandle((Handle)ti);
}
- /* OpenTransport? */
- if (Gestalt(gestaltOpenTpt, &mac_gestalts.otptattr) != noErr ||
- (mac_gestalts.otptattr & gestaltOpenTptTCPPresentMask) == 0 ||
- ot_init() != noErr)
- mac_gestalts.otptattr = 0;
- if (mac_gestalts.otptattr == 0) {
- /* MacTCP? */
- if (Gestalt(FOUR_CHAR_CODE('mtcp'), &mac_gestalts.mtcpvers) != noErr)
- mac_gestalts.mtcpvers = 0;
- if (mac_gestalts.mtcpvers > 0) {
- if (mactcp_init() != noErr)
- mac_gestalts.mtcpvers = 0;
- }
- } else
- mac_gestalts.mtcpvers = 0;
+
+ sk_init();
/* We've been tested with the Appearance Manager */
if (mac_gestalts.apprvers != 0)
LMSetCurDirStore(dirid);
}
}
+
+ /* Install Apple Event handlers. */
+ AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
+ NewAEEventHandlerUPP(&mac_aevt_oapp), 0, FALSE);
+ AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
+ NewAEEventHandlerUPP(&mac_aevt_odoc), 0, FALSE);
+ AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
+ NewAEEventHandlerUPP(&mac_aevt_pdoc), 0, FALSE);
+ AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
+ NewAEEventHandlerUPP(&mac_aevt_quit), 0, FALSE);
}
static void mac_eventloop(void) {
mac_adjustcursor(cursrgn);
if (gotevent)
mac_event(&event);
- if (mac_gestalts.mtcpvers != 0)
- mactcp_poll();
- if (mac_gestalts.otptattr != 0)
- ot_poll();
+ if (borednow)
+ cleanup_exit(0);
+ sk_poll();
mac_pollterm();
}
DisposeRgn(cursrgn);
DIBadMount(pt, event->message);
}
break;
+ case kHighLevelEvent:
+ AEProcessAppleEvent(event); /* errors? */
+ break;
}
}
}
}
+pascal OSErr mac_aevt_quit(const AppleEvent *req, AppleEvent *reply,
+ long refcon)
+{
+ DescType type;
+ Size size;
+
+ if (AEGetAttributePtr(req, keyMissedKeywordAttr, typeWildCard,
+ &type, NULL, 0, &size) == noErr)
+ return errAEParamMissed;
+
+ borednow = 1;
+ return noErr;
+}
+
void cleanup_exit(int status)
{