Skip to content

Commit 4a3f5b6

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 doesn't link to ColorSync internally). Instead of relying on this, we should just link to ApplicationServices directly.
1 parent ea1c031 commit 4a3f5b6

File tree

4 files changed

+12
-28
lines changed

4 files changed

+12
-28
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Unreleased
2+
3+
- Fix linking to the `ColorSync` framework on macOS 10.7.
4+
15
# 0.26.0 (2021-12-01)
26

37
- 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).

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,3 @@ fn main() {
119119
```
120120

121121
And run the application with `cargo apk run --example request_redraw_threaded`
122-
123-
#### MacOS
124-
125-
To ensure compatibility with older MacOS systems, winit links to
126-
CGDisplayCreateUUIDFromDisplayID through the CoreGraphics framework.
127-
However, under certain setups this function is only available to be linked
128-
through the newer ColorSync framework. So, winit provides the
129-
`WINIT_LINK_COLORSYNC` environment variable which can be set to `1` or `true`
130-
while compiling to enable linking via ColorSync.
131-

build.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/platform_impl/macos/ffi.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ pub const IO8BitOverlayPixels: &str = "O8";
165165
pub type CGWindowLevel = i32;
166166
pub type CGDisplayModeRef = *mut c_void;
167167

168-
#[cfg_attr(
169-
not(use_colorsync_cgdisplaycreateuuidfromdisplayid),
170-
link(name = "CoreGraphics", kind = "framework")
171-
)]
172-
#[cfg_attr(
173-
use_colorsync_cgdisplaycreateuuidfromdisplayid,
174-
link(name = "ColorSync", kind = "framework")
175-
)]
168+
// `CGDisplayCreateUUIDFromDisplayID` comes from the `ColorSync` framework.
169+
// However, that framework was only introduced "publicly" in macOS 10.13.
170+
//
171+
// Since we want to support older versions, we can't link to `ColorSync`
172+
// directly. Fortunately, it has always been available as a subframework of
173+
// `ApplicationServices`, see:
174+
// https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/OSX_Technology_Overview/SystemFrameworks/SystemFrameworks.html#//apple_ref/doc/uid/TP40001067-CH210-BBCFFIEG
175+
#[link(name = "ApplicationServices", kind = "framework")]
176176
extern "C" {
177177
pub fn CGDisplayCreateUUIDFromDisplayID(display: CGDirectDisplayID) -> CFUUIDRef;
178178
}

0 commit comments

Comments
 (0)