From 472d45c07b9a8d6f5ee47c78452315b8bf6fc08b Mon Sep 17 00:00:00 2001 From: Josh Codd Date: Tue, 26 Oct 2021 00:14:30 +0100 Subject: [PATCH] Cocoa: Fix deprecation of kIOMasterPortDefault This adds a workaround for kIOMasterPortDefault having been deprecated in favor of kIOMainPortDefault in macOS 12.0. Closes #1980 (cherry picked from commit f75c251deccde745d3d3f313aa81955095369d6f) --- src/cocoa_monitor.m | 4 ++-- src/cocoa_platform.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 6271828e..f64d78d7 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -58,7 +58,7 @@ static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen) io_service_t service; CFDictionaryRef info; - if (IOServiceGetMatchingServices(kIOMasterPortDefault, + if (IOServiceGetMatchingServices(kIOMainPortDefault, IOServiceMatching("IODisplayConnect"), &it) != 0) { @@ -231,7 +231,7 @@ static double getFallbackRefreshRate(CGDirectDisplayID displayID) io_iterator_t it; io_service_t service; - if (IOServiceGetMatchingServices(kIOMasterPortDefault, + if (IOServiceGetMatchingServices(kIOMainPortDefault, IOServiceMatching("IOFramebuffer"), &it) != 0) { diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 1d7c03c6..114883de 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -41,6 +41,13 @@ typedef void* id; #endif +// NOTE: Many Cocoa enum values have been renamed and we need to build across +// SDK versions where one is unavailable or the other deprecated +// We use the newer names in code and these macros to handle compatibility +#if MAC_OS_X_VERSION_MAX_ALLOWED < 120000 + #define kIOMainPortDefault kIOMasterPortDefault +#endif + // NOTE: Many Cocoa enum values have been renamed and we need to build across // SDK versions where one is unavailable or the other deprecated // We use the newer names in code and these macros to handle compatibility