From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Thu, 20 Sep 2018 17:49:24 -0700 Subject: mas: avoid usage of CGDisplayUsesForceToGray Removes usage of the CGDisplayUsesForceToGray private API. diff --git a/ui/display/mac/screen_mac.mm b/ui/display/mac/screen_mac.mm index a771c1c03fd1afe3a5e563b4421721a5ddc2eb93..a6cbdfcbeff30508d921d4637aac543dce9e8ad3 100644 --- a/ui/display/mac/screen_mac.mm +++ b/ui/display/mac/screen_mac.mm @@ -171,7 +171,17 @@ DisplayMac BuildDisplayForScreen(NSScreen* screen) { display.set_color_depth(Display::kDefaultBitsPerPixel); display.set_depth_per_component(Display::kDefaultBitsPerComponent); } +#if IS_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 // Query the display's refresh rate. {