mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-31 05:56:24 +08:00
macOS: remove obsolete 10.7 and 10.8-specific code.
This commit is contained in:
committed by
Sam Lantinga
parent
d293145ec9
commit
67037f064b
@@ -25,13 +25,6 @@
|
|||||||
#include "SDL_cocoavideo.h"
|
#include "SDL_cocoavideo.h"
|
||||||
#include "../../events/SDL_events_c.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
|
#ifndef MAC_OS_X_VERSION_10_12
|
||||||
#define NSEventTypeApplicationDefined NSApplicationDefined
|
#define NSEventTypeApplicationDefined NSApplicationDefined
|
||||||
#endif
|
#endif
|
||||||
@@ -331,14 +324,10 @@ static NSString *GetApplicationName(void)
|
|||||||
|
|
||||||
static bool LoadMainMenuNibIfAvailable(void)
|
static bool LoadMainMenuNibIfAvailable(void)
|
||||||
{
|
{
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
|
|
||||||
NSDictionary *infoDict;
|
NSDictionary *infoDict;
|
||||||
NSString *mainNibFileName;
|
NSString *mainNibFileName;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_8) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
infoDict = [[NSBundle mainBundle] infoDictionary];
|
infoDict = [[NSBundle mainBundle] infoDictionary];
|
||||||
if (infoDict) {
|
if (infoDict) {
|
||||||
mainNibFileName = [infoDict valueForKey:@"NSMainNibFile"];
|
mainNibFileName = [infoDict valueForKey:@"NSMainNibFile"];
|
||||||
@@ -349,9 +338,6 @@ static bool LoadMainMenuNibIfAvailable(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreateApplicationMenus(void)
|
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
|
* 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
|
* duplicate filtering because this code can choose what properties are
|
||||||
* prefered, and it can add CGDisplayModes to the DisplayModeData's list of
|
* prefered, and it can add CGDisplayModes to the DisplayModeData's list of
|
||||||
* modes to try (see comment below for why that's necessary).
|
* 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
|
|
||||||
pixelW = CGDisplayModeGetPixelWidth(vidmode);
|
pixelW = CGDisplayModeGetPixelWidth(vidmode);
|
||||||
pixelH = CGDisplayModeGetPixelHeight(vidmode);
|
pixelH = CGDisplayModeGetPixelHeight(vidmode);
|
||||||
|
|
||||||
if (modelist != NULL && floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) {
|
if (modelist != NULL) {
|
||||||
CFIndex modescount = CFArrayGetCount(modelist);
|
CFIndex modescount = CFArrayGetCount(modelist);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -246,7 +244,6 @@ static SDL_bool GetDisplayMode(_THIS, CGDisplayModeRef vidmode, SDL_bool vidmode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
SDL_zerop(mode);
|
SDL_zerop(mode);
|
||||||
data = (SDL_DisplayModeData *)SDL_malloc(sizeof(*data));
|
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;
|
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... */
|
/* 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];
|
NSArray *screens = [NSScreen screens];
|
||||||
NSSize displayNativeSize;
|
NSSize displayNativeSize;
|
||||||
displayNativeSize.width = (int)CGDisplayPixelsWide(data->display);
|
displayNativeSize.width = (int)CGDisplayPixelsWide(data->display);
|
||||||
@@ -427,46 +423,35 @@ int Cocoa_GetDisplayPhysicalDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, f
|
|||||||
for (NSScreen *screen in screens) {
|
for (NSScreen *screen in screens) {
|
||||||
const CGDirectDisplayID dpyid = (const CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue];
|
const CGDirectDisplayID dpyid = (const CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue];
|
||||||
if (dpyid == data->display) {
|
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" */
|
/* 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 };
|
||||||
CFStringRef dmKeys[1] = { kCGDisplayShowDuplicateLowResolutionModes };
|
CFBooleanRef dmValues[1] = { kCFBooleanTrue };
|
||||||
CFBooleanRef dmValues[1] = { kCFBooleanTrue };
|
CFDictionaryRef dmOptions = CFDictionaryCreate(kCFAllocatorDefault, (const void **)dmKeys, (const void **)dmValues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||||
CFDictionaryRef dmOptions = CFDictionaryCreate(kCFAllocatorDefault, (const void **)dmKeys, (const void **)dmValues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
CFArrayRef allDisplayModes = CGDisplayCopyAllDisplayModes(dpyid, dmOptions);
|
||||||
CFArrayRef allDisplayModes = CGDisplayCopyAllDisplayModes(dpyid, dmOptions);
|
CFIndex n = CFArrayGetCount(allDisplayModes);
|
||||||
CFIndex n = CFArrayGetCount(allDisplayModes);
|
for (CFIndex i = 0; i < n; ++i) {
|
||||||
for (CFIndex i = 0; i < n; ++i) {
|
CGDisplayModeRef m = (CGDisplayModeRef)CFArrayGetValueAtIndex(allDisplayModes, i);
|
||||||
CGDisplayModeRef m = (CGDisplayModeRef)CFArrayGetValueAtIndex(allDisplayModes, i);
|
CGFloat width = CGDisplayModeGetPixelWidth(m);
|
||||||
CGFloat width = CGDisplayModeGetPixelWidth(m);
|
CGFloat height = CGDisplayModeGetPixelHeight(m);
|
||||||
CGFloat height = CGDisplayModeGetPixelHeight(m);
|
CGFloat HiDPIWidth = CGDisplayModeGetWidth(m);
|
||||||
CGFloat HiDPIWidth = CGDisplayModeGetWidth(m);
|
|
||||||
|
|
||||||
// Only check 1x mode
|
// Only check 1x mode
|
||||||
if (width == HiDPIWidth) {
|
if (width == HiDPIWidth) {
|
||||||
if (CGDisplayModeGetIOFlags(m) & kDisplayModeNativeFlag) {
|
if (CGDisplayModeGetIOFlags(m) & kDisplayModeNativeFlag) {
|
||||||
displayNativeSize.width = width;
|
displayNativeSize.width = width;
|
||||||
displayNativeSize.height = height;
|
displayNativeSize.height = height;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the largest size even if kDisplayModeNativeFlag is not present e.g. iMac 27-Inch with 5K Retina
|
// Get the largest size even if kDisplayModeNativeFlag is not present e.g. iMac 27-Inch with 5K Retina
|
||||||
if (width > displayNativeSize.width) {
|
if (width > displayNativeSize.width) {
|
||||||
displayNativeSize.width = width;
|
displayNativeSize.width = width;
|
||||||
displayNativeSize.height = height;
|
displayNativeSize.height = height;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CFRelease(allDisplayModes);
|
|
||||||
CFRelease(dmOptions);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
// fallback for 10.7
|
|
||||||
scaleFactor = [screen backingScaleFactor];
|
|
||||||
displayNativeSize.width = displayNativeSize.width * scaleFactor;
|
|
||||||
displayNativeSize.height = displayNativeSize.height * scaleFactor;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
CFRelease(allDisplayModes);
|
||||||
|
CFRelease(dmOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,6 +482,8 @@ void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
|
|||||||
SDL_DisplayMode desktopmode;
|
SDL_DisplayMode desktopmode;
|
||||||
CFArrayRef modes;
|
CFArrayRef modes;
|
||||||
CFDictionaryRef dict = NULL;
|
CFDictionaryRef dict = NULL;
|
||||||
|
const CFStringRef dictkeys[] = { kCGDisplayShowDuplicateLowResolutionModes };
|
||||||
|
const CFBooleanRef dictvalues[] = { kCFBooleanTrue };
|
||||||
|
|
||||||
CVDisplayLinkCreateWithCGDisplay(data->display, &link);
|
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:
|
* the content of the screen to move up, which this setting avoids:
|
||||||
* https://bugzilla.libsdl.org/show_bug.cgi?id=4822
|
* https://bugzilla.libsdl.org/show_bug.cgi?id=4822
|
||||||
*/
|
*/
|
||||||
#ifdef MAC_OS_X_VERSION_10_8
|
|
||||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) {
|
dict = CFDictionaryCreate(NULL,
|
||||||
const CFStringRef dictkeys[] = { kCGDisplayShowDuplicateLowResolutionModes };
|
(const void **)dictkeys,
|
||||||
const CFBooleanRef dictvalues[] = { kCFBooleanTrue };
|
(const void **)dictvalues,
|
||||||
dict = CFDictionaryCreate(NULL,
|
1,
|
||||||
(const void **)dictkeys,
|
&kCFCopyStringDictionaryKeyCallBacks,
|
||||||
(const void **)dictvalues,
|
&kCFTypeDictionaryValueCallBacks);
|
||||||
1,
|
|
||||||
&kCFCopyStringDictionaryKeyCallBacks,
|
|
||||||
&kCFTypeDictionaryValueCallBacks);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
modes = CGDisplayCopyAllDisplayModes(data->display, dict);
|
modes = CGDisplayCopyAllDisplayModes(data->display, dict);
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,9 @@
|
|||||||
|
|
||||||
#if SDL_VIDEO_DRIVER_COCOA
|
#if SDL_VIDEO_DRIVER_COCOA
|
||||||
|
|
||||||
#if 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.7 SDK or above.
|
#error SDL for macOS must be built with a 10.9 SDK or above.
|
||||||
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1070 */
|
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1090 */
|
||||||
|
|
||||||
#include <float.h> /* For FLT_MAX */
|
#include <float.h> /* For FLT_MAX */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user