We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1320

Summary: Apple-Q hotkey should emit SDL_QUIT event on Mac OS X.
Product: SDL Reporter: Ryan C. Gordon <icculus>
Component: eventsAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2 CC: gabomdq
Version: HG 2.0   
Hardware: All   
OS: Mac OS X (All)   

Description Ryan C. Gordon 2011-10-26 15:20:15 UTC
On Mac OS X, we have a "Quit $APPNAME" menu item in the menubar, which, if clicked, will trigger an SDL_QUIT event. We list Apple-Q as the hotkey to trigger this, too.

However, SDL does not map Apple-Q to SDL_QUIT, leaving the app to check for this key combination.

Apple is now, apparently, rejecting Mac App Store submissions that ignore Apple-Q.

I think we should handle this hotkey in SDL, translating it to SDL_QUIT, the same as if the user clicked the menu option. We should, however, add a hint (or for 1.2, perhaps, an environment variable) that allows the key combination to be passed to the app without emitting an SDL_QUIT event.

--ryan.
Comment 1 Ryan C. Gordon 2011-10-26 15:20:43 UTC
Assigning to me.

--ryan.
Comment 2 Gabriel Jacobo 2013-02-12 09:49:05 UTC
*** Bug 1555 has been marked as a duplicate of this bug. ***
Comment 3 Ryan C. Gordon 2013-07-05 13:30:10 UTC
Apparently we hooked up the menu hotkeys at some point, because this already sends SDL_QUIT when you press Apple-Q in SDL2.

Happens here, for future reference. Marking this bug fixed.

Breakpoint 2, SDL_SendQuit () at SDL_quit.c:117
117         return SDL_SendAppEvent(SDL_QUIT);
(gdb) bt
#0  SDL_SendQuit () at SDL_quit.c:117
#1  0x000000010008b8c9 in -[SDLAppDelegate applicationShouldTerminate:] (self=0x100, _cmd=0x7fff905bc9d7, sender=0x102104140) at SDL_cocoaevents.m:51
#2  0x00007fff8ffb4e6f in -[NSApplication _docController:shouldTerminate:] ()
#3  0x00007fff8ffb4d7e in __91-[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]_block_invoke_0 ()
#4  0x00007fff8ffb4c1a in -[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:] ()
#5  0x00007fff8ffb45de in -[NSDocumentController(NSInternal) __closeAllDocumentsWithDelegate:shouldTerminateSelector:] ()
#6  0x00007fff8ffb44af in -[NSApplication _shouldTerminate] ()
#7  0x00007fff8ffb3747 in -[NSApplication terminate:] ()
#8  0x00007fff8fe7d989 in -[NSApplication sendAction:to:from:] ()
#9  0x00007fff8ffb337c in -[NSMenuItem _corePerformAction] ()
#10 0x00007fff8ffb306a in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] ()
#11 0x00007fff8ffb1cf0 in -[NSMenu performKeyEquivalent:] ()
#12 0x00007fff8ffb11b3 in -[NSApplication _handleKeyEquivalent:] ()
#13 0x00007fff8fe6e173 in -[NSApplication sendEvent:] ()
#14 0x000000010008ba38 in Cocoa_PumpEvents (_this=0x102104140) at SDL_cocoaevents.m:230
#15 0x000000010002f003 in SDL_ShouldPollJoystick [inlined] () at /Users/icculus/projects/SDL/src/events/SDL_events.c:404
#16 0x000000010002f003 in SDL_PumpEvents [inlined] () at /Users/icculus/projects/SDL/src/events/SDL_events.c:408
#17 0x000000010002f003 in SDL_WaitEventTimeout (event=0x7fff5fbff8b0, timeout=-1873032745) at SDL_events.c:437
#18 0x0000000100002287 in main (argc=3, argv=0x7fff5fbff988) at testgl2.c:330

--ryan.