Cocoa: Fix duplicate monitor connection events

(cherry picked from commit 5aff72aa00)
This commit is contained in:
Camilla Löwy 2021-01-18 01:26:00 +01:00
parent eda12dd949
commit 14921d1e24

View File

@ -338,7 +338,8 @@ void _glfwPollMonitorsNS(void)
// display replacement on machines with automatic graphics // display replacement on machines with automatic graphics
// switching // switching
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]); 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) 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]); const CGSize size = CGDisplayScreenSize(displays[i]);
char* name = getDisplayName(displays[i]); char* name = getDisplayName(displays[i]);
if (!name) if (!name)