mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Fix clicking 'quit' in menubar or dock not doing anything on OSX.
Now it actually closes the game
This commit is contained in:
parent
3bc620e6c5
commit
bdaae944b5
11
src/Window.c
11
src/Window.c
@ -1678,14 +1678,14 @@ static OSStatus Window_EventHandler(EventHandlerCallRef inCaller, EventRef inEve
|
|||||||
return eventNotHandledErr;
|
return eventNotHandledErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pascal OSErr HandleQuitMessage(const AppleEvent* ev, AppleEvent* reply, long handlerRefcon) {
|
||||||
|
Window_Close();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
typedef EventTargetRef (*GetMenuBarEventTarget_Func)(void);
|
typedef EventTargetRef (*GetMenuBarEventTarget_Func)(void);
|
||||||
|
|
||||||
static void Window_ConnectEvents(void) {
|
static void Window_ConnectEvents(void) {
|
||||||
static EventTypeSpec winEventTypes[] = {
|
static EventTypeSpec winEventTypes[] = {
|
||||||
{ kEventClassApplication, kEventAppActivated },
|
|
||||||
{ kEventClassApplication, kEventAppDeactivated },
|
|
||||||
{ kEventClassApplication, kEventAppQuit },
|
|
||||||
|
|
||||||
{ kEventClassKeyboard, kEventRawKeyDown },
|
{ kEventClassKeyboard, kEventRawKeyDown },
|
||||||
{ kEventClassKeyboard, kEventRawKeyRepeat },
|
{ kEventClassKeyboard, kEventRawKeyRepeat },
|
||||||
{ kEventClassKeyboard, kEventRawKeyUp },
|
{ kEventClassKeyboard, kEventRawKeyUp },
|
||||||
@ -1718,6 +1718,9 @@ static void Window_ConnectEvents(void) {
|
|||||||
InstallEventHandler(target, NewEventHandlerUPP(Window_EventHandler),
|
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 code below is to get the menubar working. */
|
||||||
/* The documentation for 'RunApplicationEventLoop' states that it installs */
|
/* The documentation for 'RunApplicationEventLoop' states that it installs */
|
||||||
/* the standard application event handler which lets the menubar work. */
|
/* the standard application event handler which lets the menubar work. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user