mac/common: fix light sensor deprecations

This commit is contained in:
der richter 2024-10-30 22:08:34 +01:00
parent 23843b4aa5
commit 6f009a91a6
2 changed files with 6 additions and 2 deletions

View File

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

View File

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