Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
macOS: Fix an OS-generated warning printed to stdout on launch in bun…
…dled apps.
  • Loading branch information
slime73 committed Nov 10, 2017
1 parent fcb77f9 commit 5501bcc
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/video/cocoa/SDL_cocoaevents.m
Expand Up @@ -38,6 +38,8 @@ @interface SDLApplication : NSApplication
- (void)terminate:(id)sender;
- (void)sendEvent:(NSEvent *)theEvent;

+ (void)registerUserDefaults;

@end

@implementation SDLApplication
Expand Down Expand Up @@ -90,6 +92,17 @@ - (void)sendEvent:(NSEvent *)theEvent
[super sendEvent:theEvent];
}

+ (void)registerUserDefaults
{
NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithBool:NO], @"AppleMomentumScrollSupported",
[NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled",
[NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState",
nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
[appDefaults release];
}

@end // SDLApplication

/* setAppleMenu disappeared from the headers in 10.4 */
Expand Down Expand Up @@ -227,6 +240,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) {
[NSApp activateIgnoringOtherApps:YES];
}

/* If we call this before NSApp activation, macOS might print a complaint
* about ApplePersistenceIgnoreState. */
[SDLApplication registerUserDefaults];
}
@end

Expand Down Expand Up @@ -379,13 +396,12 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
CreateApplicationMenus();
}
[NSApp finishLaunching];
NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithBool:NO], @"AppleMomentumScrollSupported",
[NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled",
[NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState",
nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
[appDefaults release];
if ([NSApp delegate]) {
/* The SDL app delegate calls this in didFinishLaunching if it's
* attached to the NSApp, otherwise we need to call it manually.
*/
[SDLApplication registerUserDefaults];
}
}
if (NSApp && !appDelegate) {
appDelegate = [[SDLAppDelegate alloc] init];
Expand Down

0 comments on commit 5501bcc

Please sign in to comment.