electron/patches/chromium/mas-cgdisplayusesforcetogray.patch

29 lines
1.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
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 b19c27fe7ec208e53bbff9c9901f59ba595f68d8..9a4d2df4b32342c19d03f03a83563f0f178ba54c 100644
--- a/ui/display/mac/screen_mac.mm
+++ b/ui/display/mac/screen_mac.mm
@@ -116,7 +116,17 @@ Display BuildDisplayForScreen(NSScreen* screen) {
display.set_depth_per_component(Display::kHDR10BitsPerComponent);
}
}
+#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());