electron/patches/common/chromium/mas-cgdisplayusesforcetogray.patch
Jeremy Apthorp 76c5f5cc8a
build: move libcc patches to electron repo (#14104)
In the GN build, libchromiumcontent is no longer a distinct library, but
merely a container for a set of scripts and patches. Maintaining those
patches in a separate repository is tedious and error-prone, so merge
them into the main repo.

Once this is merged and GN is the default way to build Electron, the
libchromiumcontent repository can be archived.
2018-09-13 22:02:16 -07:00

34 lines
1.3 KiB
Diff

From 82d0ef64e22c69c0435608276149977d2811a3f7 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Mon, 6 Aug 2018 10:58:46 -0700
Subject: fix: [mas] remove usage of CGDisplayUsesForceToGray
---
ui/display/mac/screen_mac.mm | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/ui/display/mac/screen_mac.mm b/ui/display/mac/screen_mac.mm
index 4850c795480e..ec34b25a6fe8 100644
--- a/ui/display/mac/screen_mac.mm
+++ b/ui/display/mac/screen_mac.mm
@@ -106,7 +106,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
// CGDisplayRotation returns a double. Display::SetRotationAsDegree will
// handle the unexpected situations were the angle is not a multiple of 90.
--
2.17.0