From 09992a62b37574362991e6d0389e5ffee2c6c9f3 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Tue, 14 Jul 2026 14:19:38 +0000 Subject: [PATCH 2/5] Cocoa: Guard -convertRectToScreen: for the 10.6 SDK -convertRectToScreen: was added in the 10.7 SDK, so gcc-mp-16 building against the 10.6 SDK resolves the -[NSWindow object] receiver to an untyped id and fails to typecheck NSMouseInRect and the NSRect initializer in _glfwWindowHoveredCocoa and _glfwSetCursorPosCocoa. Fall back to the NSPoint-based -convertBaseToScreen: when compiling against pre-10.7 SDKs, matching the guard style already used for -convertRectToBacking: elsewhere in this file. --- src/cocoa_window.m | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 545ff073..7fe5618f 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1509,8 +1509,16 @@ GLFWbool _glfwWindowHoveredCocoa(_GLFWwindow* window) } [pool release]; - return NSMouseInRect(point, - [window->ns.object convertRectToScreen:[window->ns.view frame]], NO); + + // NOTE: -convertRectToScreen: was added in the 10.7 SDK; Mac OS X 10.6 + // only has the NSPoint-based -convertBaseToScreen: +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + const NSRect frameRect = [window->ns.object convertRectToScreen:[window->ns.view frame]]; +#else + NSRect frameRect = [window->ns.view frame]; + frameRect.origin = [window->ns.object convertBaseToScreen:frameRect.origin]; +#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ + return NSMouseInRect(point, frameRect, NO); } GLFWbool _glfwFramebufferTransparentCocoa(_GLFWwindow* window) @@ -1717,8 +1725,13 @@ void _glfwSetCursorPosCocoa(_GLFWwindow* window, double x, double y) else { const NSRect localRect = NSMakeRect(x, contentRect.size.height - y - 1, 0, 0); - const NSRect globalRect = [window->ns.object convertRectToScreen:localRect]; - const NSPoint globalPoint = globalRect.origin; + // NOTE: -convertRectToScreen: was added in the 10.7 SDK; Mac OS X 10.6 + // only has the NSPoint-based -convertBaseToScreen: +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 + const NSPoint globalPoint = [window->ns.object convertRectToScreen:localRect].origin; +#else + const NSPoint globalPoint = [window->ns.object convertBaseToScreen:localRect.origin]; +#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ CGWarpMouseCursorPosition(CGPointMake(globalPoint.x, _glfwTransformYCocoa(globalPoint.y))); -- 2.43.0