mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Cocoa: Fix call to NSWindow from non-main threads
glfwSwapBuffers may be called by any thread but NSWindow may not. Bug introduced byc3ca88055f
and reported by @crujose. (cherry picked from commit949275bbed
)
This commit is contained in:
parent
404c28df3d
commit
6e01359e36
@ -121,6 +121,7 @@ typedef struct _GLFWwindowNS
|
|||||||
id layer;
|
id layer;
|
||||||
|
|
||||||
GLFWbool maximized;
|
GLFWbool maximized;
|
||||||
|
GLFWbool occluded;
|
||||||
GLFWbool retina;
|
GLFWbool retina;
|
||||||
|
|
||||||
// Cached window properties to filter out duplicate events
|
// Cached window properties to filter out duplicate events
|
||||||
|
@ -322,6 +322,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
_glfwInputWindowFocus(window, GLFW_FALSE);
|
_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
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ static void swapBuffersNSGL(_GLFWwindow* window)
|
|||||||
|
|
||||||
// HACK: Simulate vsync with usleep as NSGL swap interval does not apply to
|
// HACK: Simulate vsync with usleep as NSGL swap interval does not apply to
|
||||||
// windows with a non-visible occlusion state
|
// windows with a non-visible occlusion state
|
||||||
if (!([window->ns.object occlusionState] & NSWindowOcclusionStateVisible))
|
if (window->ns.occluded)
|
||||||
{
|
{
|
||||||
int interval = 0;
|
int interval = 0;
|
||||||
[window->context.nsgl.object getValues:&interval
|
[window->context.nsgl.object getValues:&interval
|
||||||
|
Loading…
Reference in New Issue
Block a user