diff options
| author | Teddy Wing | 2021-03-04 20:44:59 +0100 |
|---|---|---|
| committer | Teddy Wing | 2021-03-04 20:46:58 +0100 |
| commit | aea4d2b64d3a0017c4a68b03acb5bbd063a08ab9 (patch) | |
| tree | 0b081285ac00a8885b2caf482d21a9c5039ee36d | |
| parent | 5e2ba76654f28189dfd3c7f0d2e45bb1e94b21bb (diff) | |
| download | Re-Good-Catalina-Invert-Colours-aea4d2b64d3a0017c4a68b03acb5bbd063a08ab9.tar.bz2 | |
Invert all displays
Previously, I was only inverting the main display. Get a list of active
displays and invert all of them.
Decided to set the maximum display count to eight because that seemed
like a sufficiently high number for most people.
| -rw-r--r-- | main.m | 31 |
1 files changed, 23 insertions, 8 deletions
@@ -1,18 +1,33 @@ #import <CoreGraphics/CoreGraphics.h> +#define MAX_DISPLAYS 8 + int main(int argc, const char * argv[]) { const CGGammaValue inverted_gamma[2] = {1, 0}; - CGError error = CGSetDisplayTransferByTable( - CGMainDisplayID(), - 2, - inverted_gamma, - inverted_gamma, - inverted_gamma - ); + CGDirectDisplayID active_displays[MAX_DISPLAYS]; + uint32_t display_count; + CGError error = CGGetActiveDisplayList( + MAX_DISPLAYS, + &active_displays[0], + &display_count + ); if (error != kCGErrorSuccess) { - // TODO: error handling + return 69; + } + + for (int i = 0; i < display_count; i++) { + error = CGSetDisplayTransferByTable( + active_displays[i], + 2, + inverted_gamma, + inverted_gamma, + inverted_gamma + ); + if (error != kCGErrorSuccess) { + // TODO: error handling + } } for (;;) {} |
