From 68fd4e8bb35eed4ef23f1ac334c10bbdf8ac831b Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Sat, 8 Sep 2018 18:49:19 +0200 Subject: [PATCH] Cocoa: Fix work area retrieval on missing screen Closes #1322. --- src/cocoa_monitor.m | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index e4eb12d1..9e74e15c 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -413,21 +413,18 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos NSScreen *resultScreen; for (NSScreen *screen in [NSScreen screens]) { if ([[[screen deviceDescription] valueForKey:@"NSScreenNumber"] intValue] == monitor->ns.displayID) { - resultScreen = screen; + NSRect frameRect = [screen visibleFrame]; + if (xpos) + *xpos = NSMinX(frameRect); + if (ypos) + *ypos = NSMinY(frameRect); + if (width) + *width = NSWidth(frameRect); + if (height) + *height = NSHeight(frameRect); break; } } - - NSRect frameRect = [[NSScreen resultScreen] visibleFrame]; - - if (xpos) - *xpos = NSMinX(frameRect); - if (ypos) - *ypos = NSMinY(frameRect); - if (width) - *width = NSWidth(frameRect); - if (height) - *height = NSHeight(frameRect); } GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)