macOS: remove obsolete 10.7 and 10.8-specific code.
parent
d293145ec9
commit
67037f064b
|
@ -25,13 +25,6 @@
|
|||
#include "SDL_cocoavideo.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
/* This define was added in the 10.9 SDK. */
|
||||
#ifndef kIOPMAssertPreventUserIdleDisplaySleep
|
||||
#define kIOPMAssertPreventUserIdleDisplaySleep kIOPMAssertionTypePreventUserIdleDisplaySleep
|
||||
#endif
|
||||
#ifndef NSAppKitVersionNumber10_8
|
||||
#define NSAppKitVersionNumber10_8 1187
|
||||
#endif
|
||||
#ifndef MAC_OS_X_VERSION_10_12
|
||||
#define NSEventTypeApplicationDefined NSApplicationDefined
|
||||
#endif
|
||||
|
@ -331,14 +324,10 @@ static NSString *GetApplicationName(void)
|
|||
|
||||
static bool LoadMainMenuNibIfAvailable(void)
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
|
||||
NSDictionary *infoDict;
|
||||
NSString *mainNibFileName;
|
||||
bool success = false;
|
||||
|
||||
if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_8) {
|
||||
return false;
|
||||
}
|
||||
infoDict = [[NSBundle mainBundle] infoDictionary];
|
||||
if (infoDict) {
|
||||
mainNibFileName = [infoDict valueForKey:@"NSMainNibFile"];
|
||||
|
@ -349,9 +338,6 @@ static bool LoadMainMenuNibIfAvailable(void)
|
|||
}
|
||||
|
||||
return success;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void CreateApplicationMenus(void)
|
||||
|
|
|
@ -170,13 +170,11 @@ static SDL_bool GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmode
|
|||
* modes that have duplicate sizes. We don't just rely on SDL's higher level
|
||||
* duplicate filtering because this code can choose what properties are
|
||||
* prefered, and it can add CGDisplayModes to the DisplayModeData's list of
|
||||
* modes to try (see comment below for why that's necessary).
|
||||
* CGDisplayModeGetPixelWidth and friends are only available in 10.8+. */
|
||||
#ifdef MAC_OS_X_VERSION_10_8
|
||||
* modes to try (see comment below for why that's necessary). */
|
||||
pixelW = CGDisplayModeGetPixelWidth(vidmode);
|
||||
pixelH = CGDisplayModeGetPixelHeight(vidmode);
|
||||
|
||||
if (modelist != NULL && floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) {
|
||||
if (modelist != NULL) {
|
||||
CFIndex modescount = CFArrayGetCount(modelist);
|
||||
int i;
|
||||
|
||||
|
@ -246,7 +244,6 @@ static SDL_bool GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmode
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_zerop(mode);
|
||||
data = (SDL_DisplayModeData *)SDL_malloc(sizeof(*data));
|
||||
|
@ -418,7 +415,6 @@ int Cocoa_GetDisplayPhysicalDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, f
|
|||
SDL_DisplayData *data = (SDL_DisplayData *)display->driverdata;
|
||||
|
||||
/* we need the backingScaleFactor for Retina displays, which is only exposed through NSScreen, not CGDisplay, afaik, so find our screen... */
|
||||
CGFloat scaleFactor = 1.0f;
|
||||
NSArray *screens = [NSScreen screens];
|
||||
NSSize displayNativeSize;
|
||||
displayNativeSize.width = (int)CGDisplayPixelsWide(data->display);
|
||||
|
@ -427,9 +423,7 @@ int Cocoa_GetDisplayPhysicalDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, f
|
|||
for (NSScreen *screen in screens) {
|
||||
const CGDirectDisplayID dpyid = (const CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue];
|
||||
if (dpyid == data->display) {
|
||||
#ifdef MAC_OS_X_VERSION_10_8
|
||||
/* Neither CGDisplayScreenSize(description's NSScreenNumber) nor [NSScreen backingScaleFactor] can calculate the correct dpi in macOS. E.g. backingScaleFactor is always 2 in all display modes for rMBP 16" */
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) {
|
||||
CFStringRef dmKeys[1] = { kCGDisplayShowDuplicateLowResolutionModes };
|
||||
CFBooleanRef dmValues[1] = { kCFBooleanTrue };
|
||||
CFDictionaryRef dmOptions = CFDictionaryCreate(kCFAllocatorDefault, (const void **)dmKeys, (const void **)dmValues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
|
@ -458,15 +452,6 @@ int Cocoa_GetDisplayPhysicalDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, f
|
|||
}
|
||||
CFRelease(allDisplayModes);
|
||||
CFRelease(dmOptions);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
// fallback for 10.7
|
||||
scaleFactor = [screen backingScaleFactor];
|
||||
displayNativeSize.width = displayNativeSize.width * scaleFactor;
|
||||
displayNativeSize.height = displayNativeSize.height * scaleFactor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -497,6 +482,8 @@ void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
|
|||
SDL_DisplayMode desktopmode;
|
||||
CFArrayRef modes;
|
||||
CFDictionaryRef dict = NULL;
|
||||
const CFStringRef dictkeys[] = { kCGDisplayShowDuplicateLowResolutionModes };
|
||||
const CFBooleanRef dictvalues[] = { kCFBooleanTrue };
|
||||
|
||||
CVDisplayLinkCreateWithCGDisplay(data->display, &link);
|
||||
|
||||
|
@ -528,18 +515,13 @@ void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
|
|||
* the content of the screen to move up, which this setting avoids:
|
||||
* https://bugzilla.libsdl.org/show_bug.cgi?id=4822
|
||||
*/
|
||||
#ifdef MAC_OS_X_VERSION_10_8
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) {
|
||||
const CFStringRef dictkeys[] = { kCGDisplayShowDuplicateLowResolutionModes };
|
||||
const CFBooleanRef dictvalues[] = { kCFBooleanTrue };
|
||||
|
||||
dict = CFDictionaryCreate(NULL,
|
||||
(const void **)dictkeys,
|
||||
(const void **)dictvalues,
|
||||
1,
|
||||
&kCFCopyStringDictionaryKeyCallBacks,
|
||||
&kCFTypeDictionaryValueCallBacks);
|
||||
}
|
||||
#endif
|
||||
|
||||
modes = CGDisplayCopyAllDisplayModes(data->display, dict);
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
|
||||
#if SDL_VIDEO_DRIVER_COCOA
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
|
||||
#error SDL for macOS must be built with a 10.7 SDK or above.
|
||||
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1070 */
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1090
|
||||
#error SDL for macOS must be built with a 10.9 SDK or above.
|
||||
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1090 */
|
||||
|
||||
#include <float.h> /* For FLT_MAX */
|
||||
|
||||
|
|
Loading…
Reference in New Issue