From 8fcf59f883806398ca1eadda5b0222eaace25255 Mon Sep 17 00:00:00 2001 From: Max Thrun Date: Fri, 28 Oct 2022 23:39:29 -0700 Subject: [PATCH] Cocoa: Ignore monitors which are mirroring another Currently monitors which are mirroring another one are returned by `glfwGetMonitors` but their `ns.screen` is `NULL`. Some functions like `glfwGetMonitorContentScale` and `glfwGetMonitorWorkarea` assert that `ns.screen` is not `NULL`. Since mirrored monitors are logically the same we should only consider the primary monitor and ignore the non-primary ones. --- src/cocoa_monitor.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 6c7315bd..48c20d4b 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -320,6 +320,9 @@ void _glfwPollMonitorsCocoa(void) if (CGDisplayIsAsleep(displays[i])) continue; + if (CGDisplayMirrorsDisplay(displays[i]) != kCGNullDirectDisplay) + continue; + const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]); NSScreen* screen = nil;