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,14 +95,10 @@ requestRenderFrame(_GLFWwindow *w, GLFWcocoarenderframefun callback) {
_GLFWDisplayLinkNS *dl = &_glfw.ns.displayLinks.entries[i]; _GLFWDisplayLinkNS *dl = &_glfw.ns.displayLinks.entries[i];
if (dl->displayID == displayID) { if (dl->displayID == displayID) {
dl->lastRenderFrameRequestedAt = now; dl->lastRenderFrameRequestedAt = now;
if (!CVDisplayLinkIsRunning(dl->displayLink)) { if (!CVDisplayLinkIsRunning(dl->displayLink)) CVDisplayLinkStart(dl->displayLink);
CVDisplayLinkStart(dl->displayLink); } else if (dl->displayLink && dl->lastRenderFrameRequestedAt && now - dl->lastRenderFrameRequestedAt >= DISPLAY_LINK_SHUTDOWN_CHECK_INTERVAL) {
} else { CVDisplayLinkStop(dl->displayLink);
if (dl->lastRenderFrameRequestedAt && now - dl->lastRenderFrameRequestedAt) { dl->lastRenderFrameRequestedAt = 0;
if (dl->displayLink) CVDisplayLinkStop(dl->displayLink);
dl->lastRenderFrameRequestedAt = 0;
}
}
} }
} }
} }