From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Thu, 20 Sep 2018 17:49:24 -0700 Subject: mas-cgdisplayusesforcetogray.patch Removes usage of the CGDisplayUsesForceToGray private API. diff --git a/ui/display/mac/screen_mac.mm b/ui/display/mac/screen_mac.mm index 85545ec7eaa6494fe542ee14e6f3e29ffa7d693e..bf352f9a6f087c28b6ce207bd0e5c09753ffb9cf 100644 --- a/ui/display/mac/screen_mac.mm +++ b/ui/display/mac/screen_mac.mm @@ -108,7 +108,17 @@ Display BuildDisplayForScreen(NSScreen* screen) { display.set_color_depth(NSBitsPerPixelFromDepth([screen depth])); display.set_depth_per_component(NSBitsPerSampleFromDepth([screen depth])); +#ifdef MAS_BUILD + // This is equivalent to the CGDisplayUsesForceToGray() API as at 2018-08-06, + // but avoids usage of the private API. + CFStringRef app = CFSTR("com.apple.CoreGraphics"); + CFStringRef key = CFSTR("DisplayUseForcedGray"); + Boolean key_valid = false; + display.set_is_monochrome( + CFPreferencesGetAppBooleanValue(key, app, &key_valid)); +#else display.set_is_monochrome(CGDisplayUsesForceToGray()); +#endif if (auto display_link = ui::DisplayLinkMac::GetForDisplay(display_id)) display.set_display_frequency(display_link->GetRefreshRate());