From f03d9990b6d935a0731404754127c5b0ade1dd64 Mon Sep 17 00:00:00 2001 From: Kyle McDonald Date: Sat, 15 Jun 2013 15:27:13 -0400 Subject: [PATCH 1/2] added support for OS X 10.6 windows --- src/cocoa_window.m | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index eea86335..fc573e0d 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -32,7 +32,6 @@ // Needed for _NSGetProgname #include - // Enter fullscreen mode // static void enterFullscreenMode(_GLFWwindow* window) @@ -112,7 +111,11 @@ static void centerCursor(_GLFWwindow *window) [window->nsgl.context update]; const NSRect contentRect = [window->ns.view frame]; - const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 + const NSRect fbRect = contentRect; +#else + const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; +#endif _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); _glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height); @@ -525,7 +528,11 @@ static int translateKey(unsigned int key) - (void)viewDidChangeBackingProperties { const NSRect contentRect = [window->ns.view frame]; - const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 + const NSRect fbRect = contentRect; +#else + const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; +#endif _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); } @@ -814,8 +821,10 @@ static GLboolean createWindow(_GLFWwindow* window, } window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; - +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 +#else [window->ns.view setWantsBestResolutionOpenGLSurface:YES]; +#endif [window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]]; [window->ns.object setContentView:window->ns.view]; @@ -823,9 +832,12 @@ static GLboolean createWindow(_GLFWwindow* window, [window->ns.object setAcceptsMouseMovedEvents:YES]; [window->ns.object disableCursorRects]; [window->ns.object center]; - + +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 +#else if ([window->ns.object respondsToSelector:@selector(setRestorable:)]) [window->ns.object setRestorable:NO]; +#endif return GL_TRUE; } From 073aeb6828ebddcd0ee2d620263363df2607d1d3 Mon Sep 17 00:00:00 2001 From: Kyle McDonald Date: Sat, 15 Jun 2013 15:52:56 -0400 Subject: [PATCH 2/2] checking capabilities at run time instead, based on suggestions from @nilium --- src/cocoa_window.m | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index fc573e0d..e696a2e4 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -111,11 +111,9 @@ static void centerCursor(_GLFWwindow *window) [window->nsgl.context update]; const NSRect contentRect = [window->ns.view frame]; -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 - const NSRect fbRect = contentRect; -#else - const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; -#endif + const NSRect fbRect = [window->ns.view respondsToSelector:@selector(convertRectToBacking:)] + ? [window->ns.view convertRectToBacking:contentRect] + : contentRect; _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); _glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height); @@ -527,12 +525,10 @@ static int translateKey(unsigned int key) - (void)viewDidChangeBackingProperties { - const NSRect contentRect = [window->ns.view frame]; -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 - const NSRect fbRect = contentRect; -#else - const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect]; -#endif + const NSRect contentRect = [window->ns.view frame]; + const NSRect fbRect = [window->ns.view respondsToSelector:@selector(convertRectToBacking:)] + ? [window->ns.view convertRectToBacking:contentRect] + : contentRect; _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height); } @@ -821,10 +817,9 @@ static GLboolean createWindow(_GLFWwindow* window, } window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 -#else - [window->ns.view setWantsBestResolutionOpenGLSurface:YES]; -#endif + + 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]; @@ -833,11 +828,8 @@ static GLboolean createWindow(_GLFWwindow* window, [window->ns.object disableCursorRects]; [window->ns.object center]; -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 -#else if ([window->ns.object respondsToSelector:@selector(setRestorable:)]) [window->ns.object setRestorable:NO]; -#endif return GL_TRUE; }