From 9190cf8796599940d7e3e17e774ddf9359275426 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 16 Nov 2016 04:01:36 +0100 Subject: [PATCH] Cocoa: Disable deprecated function on macOS 10.12+ CGDisplayModeCopyPixelEncoding is deprecated starting with macOS 10.12. --- README.md | 2 ++ src/cocoa_monitor.m | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f7e75d96..932cdfb8 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,8 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: Window creation failed to set first responder (#876,#883) - [Cocoa] Bugfix: Removed use of deprecated `CGDisplayIOServicePort` function (#165,#192,#508,#511) +- [Cocoa] Bugfix: Disabled use of deprecated `CGDisplayModeCopyPixelEncoding` + function on macOS 10.12+ - [EGL] Added support for `EGL_KHR_get_all_proc_addresses` (#871) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 2545edf0..0a09bd2d 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -128,6 +128,7 @@ static GLFWbool modeIsGood(CGDisplayModeRef mode) if (flags & kDisplayModeStretchedFlag) return GLFW_FALSE; +#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101200 CFStringRef format = CGDisplayModeCopyPixelEncoding(mode); if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) && CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0)) @@ -137,6 +138,7 @@ static GLFWbool modeIsGood(CGDisplayModeRef mode) } CFRelease(format); +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ return GLFW_TRUE; } @@ -157,8 +159,8 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode, result.refreshRate = (int) (time.timeScale / (double) time.timeValue); } +#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101200 CFStringRef format = CGDisplayModeCopyPixelEncoding(mode); - if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0) { result.redBits = 5; @@ -166,13 +168,16 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode, result.blueBits = 5; } else +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ { result.redBits = 8; result.greenBits = 8; result.blueBits = 8; } +#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101200 CFRelease(format); +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ return result; }