Skip to content

Commit

Permalink
feat: remove linking to ColorSync (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Mar 15, 2023
1 parent 64046b2 commit a1e96d1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .changes/remove-colorsync-link.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": "patch"
---

On macOS, Remove linking to `ColorSync`
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@ sudo apt install libappindicator3-dev
sudo apt install libayatana-appindicator3-dev
```

#### macOS

To ensure compatibility with older macOS systems, TAO links to
CGDisplayCreateUUIDFromDisplayID through the CoreGraphics framework.
However, under certain setups this function is only available to be linked
through the newer ColorSync framework. So, TAO provides the
`TAO_LINK_COLORSYNC` environment variable which can be set to `1` or `true`
while compiling to enable linking via ColorSync.

### Acknowledgement

This is a fork of [winit](https://crates.io/crates/winit) which replaces Linux's port to Gtk.
Expand Down
8 changes: 0 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
// SPDX-License-Identifier: Apache-2.0

fn main() {
// If building for macos and TAO_LINK_COLORSYNC is set to true
// use CGDisplayCreateUUIDFromDisplayID from ColorSync instead of CoreGraphics
if std::env::var("CARGO_CFG_TARGET_OS").map_or(false, |os| os == "macos")
&& std::env::var("TAO_LINK_COLORSYNC")
.map_or(false, |v| v == "1" || v.eq_ignore_ascii_case("true"))
{
println!("cargo:rustc-cfg=use_colorsync_cgdisplaycreateuuidfromdisplayid");
}
// link carbon hotkey on macOS
{
if std::env::var("CARGO_CFG_TARGET_OS").map_or(false, |os| os == "macos") {
Expand Down
11 changes: 1 addition & 10 deletions src/platform_impl/macos/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,7 @@ pub type CGDisplayModeRef = *mut libc::c_void;
// 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 = "ApplicationServices", kind = "framework")
)]
#[cfg_attr(
use_colorsync_cgdisplaycreateuuidfromdisplayid,
link(name = "ColorSync", kind = "framework")
)]
#[link(name = "ApplicationServices", kind = "framework")]
extern "C" {
pub fn CGDisplayCreateUUIDFromDisplayID(display: CGDirectDisplayID) -> CFUUIDRef;
}
Expand Down

0 comments on commit a1e96d1

Please sign in to comment.