Skip to content

Commit

Permalink
Mac: Fix the menu bar not always working for non-.app-bundled apps. F…
Browse files Browse the repository at this point in the history
…ixes bug #3051.
  • Loading branch information
slime73 committed Sep 25, 2017
1 parent c44e741 commit fb071a4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/video/cocoa/SDL_cocoaevents.m
Expand Up @@ -216,6 +216,18 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam
{
return (BOOL)SDL_SendDropFile(NULL, [filename UTF8String]) && SDL_SendDropComplete(NULL);
}

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
/* The menu bar of SDL apps which don't have the typical .app bundle
* structure fails to work the first time a window is created (until it's
* de-focused and re-focused), if this call is in Cocoa_RegisterApp instead
* of here. https://bugzilla.libsdl.org/show_bug.cgi?id=3051
*/
if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) {
[NSApp activateIgnoringOtherApps:YES];
}
}
@end

static SDLAppDelegate *appDelegate = nil;
Expand Down Expand Up @@ -361,7 +373,6 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam

if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) {
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
[NSApp activateIgnoringOtherApps:YES];
}

if ([NSApp mainMenu] == nil) {
Expand Down

0 comments on commit fb071a4

Please sign in to comment.