mac/compat: fix compatibility for deployment targets lower than SDK ver

the swift parts can't be nicely encapsulated in the compat file because
it lags proper target version compile time checks.

Fixes #15292
This commit is contained in:
der richter 2024-11-17 16:02:43 +01:00
parent 46574d479d
commit 45c1c58680
3 changed files with 11 additions and 7 deletions

View File

@ -17,12 +17,17 @@
#pragma once
#include <AvailabilityMacros.h>
#include "config.h"
#ifndef GL_SILENCE_DEPRECATION
#define GL_SILENCE_DEPRECATION
#endif
#if !HAVE_MACOS_12_FEATURES
#ifndef MAC_OS_VERSION_12_0
#define MAC_OS_VERSION_12_0 120000
#endif
#if !HAVE_MACOS_12_FEATURES || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
#define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
#endif

View File

@ -44,10 +44,6 @@ extension NSDraggingInfo {
}
#endif
#if !HAVE_MACOS_12_FEATURES
let kIOMainPortDefault: mach_port_t = kIOMasterPortDefault
#endif
#if !HAVE_MACOS_12_FEATURES && HAVE_MACOS_11_FEATURES
@available(macOS 11.0, *)
extension CGColorSpace {

View File

@ -281,13 +281,16 @@ class Common: NSObject {
}
func initLightSensor() {
let srv = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("AppleLMUController"))
let mainPort: mach_port_t
if #available(macOS 12.0, *) { mainPort = kIOMainPortDefault } else { mainPort = kIOMasterPortDefault }
let srv = IOServiceGetMatchingService(mainPort, IOServiceMatching("AppleLMUController"))
if srv == IO_OBJECT_NULL {
log.verbose("Can't find an ambient light sensor")
return
}
lightSensorIOPort = IONotificationPortCreate(kIOMainPortDefault)
lightSensorIOPort = IONotificationPortCreate(mainPort)
IONotificationPortSetDispatchQueue(lightSensorIOPort, queue)
var n = io_object_t()
IOServiceAddInterestNotification(lightSensorIOPort, srv, kIOGeneralInterest, lightSensorCallback,