the swift parts can't be nicely encapsulated in the compat file because it lags proper target version compile time checks. Fixes #15292
Unified · Split
| @@ -17,12 +17,17 @@ · 16 unmodified lines | ||
| 17 | 17 | |
| 18 | 18 | #pragma once |
| 19 | 19 | |
| 20 | +#include <AvailabilityMacros.h> | |
| 20 | 21 | #include "config.h" |
| 21 | 22 | |
| 22 | 23 | #ifndef GL_SILENCE_DEPRECATION |
| 23 | 24 | #define GL_SILENCE_DEPRECATION |
| 24 | 25 | #endif |
| 25 | 26 | |
| 26 | −#if !HAVE_MACOS_12_FEATURES | |
| 27 | +#ifndef MAC_OS_VERSION_12_0 | |
| 28 | +#define MAC_OS_VERSION_12_0 120000 | |
| 29 | +#endif | |
| 30 | + | |
| 31 | +#if !HAVE_MACOS_12_FEATURES || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0) | |
| 27 | 32 | #define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster |
| 28 | 33 | #endif |
| @@ -44,10 +44,6 @@ extension NSDraggingInfo { · 43 unmodified lines | ||
| 44 | 44 | } |
| 45 | 45 | #endif |
| 46 | 46 | |
| 47 | −#if !HAVE_MACOS_12_FEATURES | |
| 48 | −let kIOMainPortDefault: mach_port_t = kIOMasterPortDefault | |
| 49 | −#endif | |
| 50 | − | |
| 51 | 47 | #if !HAVE_MACOS_12_FEATURES && HAVE_MACOS_11_FEATURES |
| 52 | 48 | @available(macOS 11.0, *) |
| 53 | 49 | extension CGColorSpace { |
| @@ -281,13 +281,16 @@ class Common: NSObject { · 280 unmodified lines | ||
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | func initLightSensor() { |
| 284 | − let srv = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("AppleLMUController")) | |
| 284 | + let mainPort: mach_port_t | |
| 285 | + if #available(macOS 12.0, *) { mainPort = kIOMainPortDefault } else { mainPort = kIOMasterPortDefault } | |
| 286 | + | |
| 287 | + let srv = IOServiceGetMatchingService(mainPort, IOServiceMatching("AppleLMUController")) | |
| 285 | 288 | if srv == IO_OBJECT_NULL { |
| 286 | 289 | log.verbose("Can't find an ambient light sensor") |
| 287 | 290 | return |
| 288 | 291 | } |
| 289 | 292 | |
| 290 | − lightSensorIOPort = IONotificationPortCreate(kIOMainPortDefault) | |
| 293 | + lightSensorIOPort = IONotificationPortCreate(mainPort) | |
| 291 | 294 | IONotificationPortSetDispatchQueue(lightSensorIOPort, queue) |
| 292 | 295 | var n = io_object_t() |
| 293 | 296 | IOServiceAddInterestNotification(lightSensorIOPort, srv, kIOGeneralInterest, lightSensorCallback, |