Fix clicking 'quit' in menubar or dock not doing anything on OSX.

Now it actually closes the game
This commit is contained in:
UnknownShadow200 2019-09-07 14:35:16 +10:00
parent 3bc620e6c5
commit bdaae944b5

View file

@ -1678,14 +1678,14 @@ static OSStatus Window_EventHandler(EventHandlerCallRef inCaller, EventRef inEve
return eventNotHandledErr;
}
static pascal OSErr HandleQuitMessage(const AppleEvent* ev, AppleEvent* reply, long handlerRefcon) {
Window_Close();
return 0;
}
typedef EventTargetRef (*GetMenuBarEventTarget_Func)(void);
static void Window_ConnectEvents(void) {
static EventTypeSpec winEventTypes[] = {
{ kEventClassApplication, kEventAppActivated },
{ kEventClassApplication, kEventAppDeactivated },
{ kEventClassApplication, kEventAppQuit },
{ kEventClassKeyboard, kEventRawKeyDown },
{ kEventClassKeyboard, kEventRawKeyRepeat },
{ kEventClassKeyboard, kEventRawKeyUp },
@ -1716,7 +1716,10 @@ static void Window_ConnectEvents(void) {
target = GetApplicationEventTarget();
InstallEventHandler(target, NewEventHandlerUPP(Window_EventHandler),
Array_Elems(appEventTypes), appEventTypes, NULL, NULL);
Array_Elems(appEventTypes), appEventTypes, NULL, NULL);
AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
NewAEEventHandlerUPP(HandleQuitMessage), 0, false);
/* The code below is to get the menubar working. */
/* The documentation for 'RunApplicationEventLoop' states that it installs */