Cocoa: Fix code to shutdown display link for inactive monitors

This commit is contained in:
Kovid Goyal 2019-07-11 22:34:28 +05:30
parent 3e0f4d36bc
commit eb30ba7722
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -95,17 +95,13 @@ requestRenderFrame(_GLFWwindow *w, GLFWcocoarenderframefun callback) {
_GLFWDisplayLinkNS *dl = &_glfw.ns.displayLinks.entries[i];
if (dl->displayID == displayID) {
dl->lastRenderFrameRequestedAt = now;
if (!CVDisplayLinkIsRunning(dl->displayLink)) {
CVDisplayLinkStart(dl->displayLink);
} else {
if (dl->lastRenderFrameRequestedAt && now - dl->lastRenderFrameRequestedAt) {
if (dl->displayLink) CVDisplayLinkStop(dl->displayLink);
if (!CVDisplayLinkIsRunning(dl->displayLink)) CVDisplayLinkStart(dl->displayLink);
} else if (dl->displayLink && dl->lastRenderFrameRequestedAt && now - dl->lastRenderFrameRequestedAt >= DISPLAY_LINK_SHUTDOWN_CHECK_INTERVAL) {
CVDisplayLinkStop(dl->displayLink);
dl->lastRenderFrameRequestedAt = 0;
}
}
}
}
}
void
_glfwRestartDisplayLinks(void) {