From 5aff72aa0016105477b9ce16f2da590939cec981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Jan 2021 01:26:00 +0100 Subject: [PATCH] Cocoa: Fix duplicate monitor connection events --- src/cocoa_monitor.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index d0112d26..8891f8a6 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -338,7 +338,8 @@ void _glfwPollMonitorsNS(void) // display replacement on machines with automatic graphics // switching const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]); - for (uint32_t j = 0; j < disconnectedCount; j++) + uint32_t j; + for (j = 0; j < disconnectedCount; j++) { if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber) { @@ -347,6 +348,9 @@ void _glfwPollMonitorsNS(void) } } + if (j < disconnectedCount) + continue; + const CGSize size = CGDisplayScreenSize(displays[i]); char* name = getDisplayName(displays[i]); if (!name)