From d5cd6ec8ebeb3469233ba36cb61f69629985aabc Mon Sep 17 00:00:00 2001 From: Kyle McDonald Date: Sun, 16 Jun 2013 18:40:10 +0200 Subject: [PATCH] Restored support for Mac OS X 10.6. Modified during merge. --- README.md | 3 +++ src/cocoa_window.m | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 68ef4bbd..1098717e 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,8 @@ See the [GLFW 3.0 documentation](http://www.glfw.org/docs/3.0/). library - [Cocoa] Bugfix: `glfwGetFramebufferSize` return the size in screen coordinates + - [Cocoa] Bugfix: Messages not supported on Mac OS X 10.6 were used without + tests for precence - [Win32] Bugfix: Context creation was attempted even if no valid pixel formats had been found - [X11] Bugfix: Duplicate window position and window and framebuffer size @@ -168,6 +170,7 @@ skills. - Martins Mozeiko - Tristam MacDonald - Hans Mackowiak + - Kyle McDonald - David Medlock - Jonathan Mercier - Marcel Metz diff --git a/src/cocoa_window.m b/src/cocoa_window.m index d338e17b..cb153860 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -69,6 +69,16 @@ static float transformY(float y) return height - y; } +// Returns the backing rect of the specified window +// +static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect) +{ + if ([window->ns.view respondsToSelector:@selector(convertRectToBacking:)]) + return [window->ns.view convertRectToBacking:contentRect]; + else + return contentRect; +} + //------------------------------------------------------------------------ // Delegate for window related notifications @@ -112,7 +122,7 @@ static void centerCursor(_GLFWwindow *window) [window->nsgl.context update]; const NSRect contentRect = [window->ns.view frame]; - const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; + const NSRect fbRect = convertRectToBacking(window, contentRect); _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); _glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height); @@ -525,7 +535,7 @@ static int translateKey(unsigned int key) - (void)viewDidChangeBackingProperties { const NSRect contentRect = [window->ns.view frame]; - const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; + const NSRect fbRect = convertRectToBacking(window, contentRect); _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); } @@ -815,7 +825,8 @@ static GLboolean createWindow(_GLFWwindow* window, window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; - [window->ns.view setWantsBestResolutionOpenGLSurface:YES]; + if ([window->ns.view respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) + [window->ns.view setWantsBestResolutionOpenGLSurface:YES]; [window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]]; [window->ns.object setContentView:window->ns.view]; @@ -943,7 +954,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height) { const NSRect contentRect = [window->ns.view frame]; - const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; + const NSRect fbRect = convertRectToBacking(window, contentRect); if (width) *width = (int) fbRect.size.width;