forked from Green-Sky/tomato
Merge commit '852f2a6343518919e5ca8d3c1bbcab9f493e3cd8'
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -133,6 +133,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
ofObject:(id)object
|
||||
change:(NSDictionary *)change
|
||||
context:(void *)context;
|
||||
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app;
|
||||
@end
|
||||
|
||||
@implementation SDLAppDelegate : NSObject
|
||||
@@ -141,18 +142,21 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
self = [super init];
|
||||
if (self) {
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
SDL_bool registerActivationHandlers = SDL_GetHintBoolean("SDL_MAC_REGISTER_ACTIVATION_HANDLERS", SDL_TRUE);
|
||||
|
||||
seenFirstActivate = NO;
|
||||
|
||||
[center addObserver:self
|
||||
selector:@selector(windowWillClose:)
|
||||
name:NSWindowWillCloseNotification
|
||||
object:nil];
|
||||
if (registerActivationHandlers) {
|
||||
[center addObserver:self
|
||||
selector:@selector(windowWillClose:)
|
||||
name:NSWindowWillCloseNotification
|
||||
object:nil];
|
||||
|
||||
[center addObserver:self
|
||||
selector:@selector(focusSomeWindow:)
|
||||
name:NSApplicationDidBecomeActiveNotification
|
||||
object:nil];
|
||||
[center addObserver:self
|
||||
selector:@selector(focusSomeWindow:)
|
||||
name:NSApplicationDidBecomeActiveNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
[center addObserver:self
|
||||
selector:@selector(localeDidChange:)
|
||||
@@ -287,11 +291,14 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
return (BOOL)SDL_SendDropFile(NULL, [filename UTF8String]) && SDL_SendDropComplete(NULL);
|
||||
return (BOOL)SDL_SendDropFile(NULL, NULL, [filename UTF8String]) && SDL_SendDropComplete(NULL);
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
if (!SDL_GetHintBoolean("SDL_MAC_REGISTER_ACTIVATION_HANDLERS", SDL_TRUE))
|
||||
return;
|
||||
|
||||
/* 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
|
||||
@@ -315,10 +322,26 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
- (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
|
||||
{
|
||||
NSString *path = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
|
||||
SDL_SendDropFile(NULL, [path UTF8String]);
|
||||
SDL_SendDropFile(NULL, NULL, [path UTF8String]);
|
||||
SDL_SendDropComplete(NULL);
|
||||
}
|
||||
|
||||
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app
|
||||
{
|
||||
// This just tells Cocoa that we didn't do any custom save state magic for the app,
|
||||
// so the system is safe to use NSSecureCoding internally, instead of using unencrypted
|
||||
// save states for backwards compatibility. If we don't return YES here, we'll get a
|
||||
// warning on the console at startup:
|
||||
//
|
||||
// ```
|
||||
// WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
|
||||
// ```
|
||||
//
|
||||
// More-detailed explanation:
|
||||
// https://stackoverflow.com/questions/77283578/sonoma-and-nsapplicationdelegate-applicationsupportssecurerestorablestate/77320845#77320845
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
static SDLAppDelegate *appDelegate = nil;
|
||||
|
Reference in New Issue
Block a user