From bdaae944b51ae30d1eb88af751b579b7720a6f59 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 7 Sep 2019 14:35:16 +1000 Subject: [PATCH] Fix clicking 'quit' in menubar or dock not doing anything on OSX. Now it actually closes the game --- src/Window.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Window.c b/src/Window.c index 91d791ae8..da263d282 100644 --- a/src/Window.c +++ b/src/Window.c @@ -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 */