Skip to content

Commit 39dd30c

Browse files
authored
Fix CGDisplayCreateUUIDFromDisplayID linking (again) (#2078)
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 c5c99d2 commit 39dd30c

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 Web, implement cursor grabbing through the pointer lock API.
45
- On X11, add mappings for numpad comma, numpad enter, numlock and pause.
56
- On macOS, fix Pinyin IME input by reverting a change that intended to improve IME.

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)