From 63bba49e3101ec28f11f564825fe2b9e01495cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 5 Dec 2023 20:59:42 +0100 Subject: [PATCH] Cocoa: Fix compilation error on OS X 10.8 The occlusion state parts of NSWindow are OS X 10.9+ only but we still (technically) support building for only 10.8. Fixes #2161 (cherry picked from commit 5e4496cb420df4d93b4a31805b9fef443433f73b) --- README.md | 2 ++ src/cocoa_window.m | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 462c7d63..fd897ec7 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,8 @@ information on what to include when reporting a bug. - [Win32] Fix pkg-config for dynamic library on Windows (#2386, #2420) - [Win32] Bugfix: `glfwWaitEventsTimeout` did not return for some sent messages (#2408) - [Win32] Bugfix: XInput could reportedly provide invalid DPad bit masks (#2291) + - [Cocoa] Bugfix: Compilation failed on OS X 10.8 due to unconditional use of 10.9+ + symbols (#2161) - [Wayland] Added improved fallback window decorations via libdecor (#1639,#1693) - [Wayland] Bugfix: Connecting a mouse after `glfwInit` would segfault (#1450) - [Wayland] Disabled alpha channel for opaque windows on systems lacking diff --git a/src/cocoa_window.m b/src/cocoa_window.m index bbab6c4f..449025c1 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -309,10 +309,15 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidChangeOcclusionState:(NSNotification* )notification { - if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible) - window->ns.occluded = GLFW_FALSE; - else - window->ns.occluded = GLFW_TRUE; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 + if ([window->ns.object respondsToSelector:@selector(occlusionState)]) + { + if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible) + window->ns.occluded = GLFW_FALSE; + else + window->ns.occluded = GLFW_TRUE; + } +#endif } @end