Skip to content

Commit 18d8079

Browse files
committed
Fix CGDisplayCreateUUIDFromDisplayID linking (again)
See also #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.
1 parent 25ff30e commit 18d8079

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22

3+
- Fix linking to the `ColorSync` framework on macOS 10.7, and in newer Rust versions.
34
- On X11, add mappings for numpad comma, numpad enter, numlock and pause.
45
- On macOS, fix Pinyin IME input by reverting a change that intended to improve IME.
56
- On Windows, fix a crash with transparent windows on Windows 11.

src/platform_impl/macos/ffi.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,18 @@ pub const IO8BitOverlayPixels: &str = "O8";
163163
pub type CGWindowLevel = i32;
164164
pub type CGDisplayModeRef = *mut c_void;
165165

166+
// `CGDisplayCreateUUIDFromDisplayID` comes from the `ColorSync` framework.
167+
// However, that framework was only introduced "publicly" in macOS 10.13.
168+
//
169+
// Since we want to support older versions, we can't link to `ColorSync`
170+
// directly. Fortunately, it has always been available as a subframework of
171+
// `ApplicationServices`, see:
172+
// https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/OSX_Technology_Overview/SystemFrameworks/SystemFrameworks.html#//apple_ref/doc/uid/TP40001067-CH210-BBCFFIEG
173+
//
174+
// TODO: Remove the WINIT_LINK_COLORSYNC hack, it is probably not needed.
166175
#[cfg_attr(
167176
not(use_colorsync_cgdisplaycreateuuidfromdisplayid),
168-
link(name = "CoreGraphics", kind = "framework")
177+
link(name = "ApplicationServices", kind = "framework")
169178
)]
170179
#[cfg_attr(
171180
use_colorsync_cgdisplaycreateuuidfromdisplayid,

0 commit comments

Comments
 (0)