From 106d77c536207239b2b861395b2afa23bd14458e Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Mon, 6 Dec 2021 22:08:39 +0100 Subject: [PATCH] Fix CGDisplayCreateUUIDFromDisplayID linking (again) See also https://github.com/rust-windowing/winit/pull/1626. The `cocoa` crate links to AppKit, which made the symbol `CGDisplayCreateUUIDFromDisplayID` from ApplicationServices/ColorSync (which AppKit uses internally) available to us on macOS 10.8 to 10.13. However, this does not work on macOS 10.7 (where AppKit does not link to ColorSync internally). Instead of relying on this, we should just link to ApplicationServices directly. --- CHANGELOG.md | 4 ++++ src/platform_impl/macos/ffi.rs | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61cf46381a..ec12387b29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Unreleased + +- Fix linking to the `ColorSync` framework on macOS 10.7, and in newer Rust versions. + # 0.26.0 (2021-12-01) - Update `raw-window-handle` to `v0.4`. This is _not_ a breaking change, we still implement `HasRawWindowHandle` from `v0.3`, see [rust-windowing/raw-window-handle#74](https://github.com/rust-windowing/raw-window-handle/pull/74). Note that you might have to run `cargo update -p raw-window-handle` after upgrading. diff --git a/src/platform_impl/macos/ffi.rs b/src/platform_impl/macos/ffi.rs index 991b3f331d..196763e7e2 100644 --- a/src/platform_impl/macos/ffi.rs +++ b/src/platform_impl/macos/ffi.rs @@ -165,9 +165,18 @@ pub const IO8BitOverlayPixels: &str = "O8"; pub type CGWindowLevel = i32; pub type CGDisplayModeRef = *mut c_void; +// `CGDisplayCreateUUIDFromDisplayID` comes from the `ColorSync` framework. +// However, that framework was only introduced "publicly" in macOS 10.13. +// +// Since we want to support older versions, we can't link to `ColorSync` +// directly. Fortunately, it has always been available as a subframework of +// `ApplicationServices`, see: +// https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/OSX_Technology_Overview/SystemFrameworks/SystemFrameworks.html#//apple_ref/doc/uid/TP40001067-CH210-BBCFFIEG +// +// TODO: Remove the WINIT_LINK_COLORSYNC hack, it is probably not needed. #[cfg_attr( not(use_colorsync_cgdisplaycreateuuidfromdisplayid), - link(name = "CoreGraphics", kind = "framework") + link(name = "ApplicationServices", kind = "framework") )] #[cfg_attr( use_colorsync_cgdisplaycreateuuidfromdisplayid,