diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 15c21696..e979396c 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -121,6 +121,7 @@ typedef struct _GLFWwindowNS id layer; GLFWbool maximized; + GLFWbool occluded; GLFWbool retina; // Cached window properties to filter out duplicate events diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 129e975e..17f34733 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -322,6 +322,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwInputWindowFocus(window, GLFW_FALSE); } +- (void)windowDidChangeOcclusionState:(NSNotification* )notification +{ + if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible) + window->ns.occluded = GLFW_FALSE; + else + window->ns.occluded = GLFW_TRUE; +} + @end diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 3bcfafcc..10286849 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -51,7 +51,7 @@ static void swapBuffersNSGL(_GLFWwindow* window) // HACK: Simulate vsync with usleep as NSGL swap interval does not apply to // windows with a non-visible occlusion state - if (!([window->ns.object occlusionState] & NSWindowOcclusionStateVisible)) + if (window->ns.occluded) { int interval = 0; [window->context.nsgl.object getValues:&interval