From 35b8ee6a7136cd3b1c8eb298aaba1e35c60eae5f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 28 Sep 2010 02:30:05 +0200 Subject: [PATCH] Updated Cocoa port to new internal API. --- src/cocoa/cocoa_window.m | 18 +++++++++--------- src/cocoa/platform.h | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/cocoa/cocoa_window.m b/src/cocoa/cocoa_window.m index 6bb55712..4014bf8c 100644 --- a/src/cocoa/cocoa_window.m +++ b/src/cocoa/cocoa_window.m @@ -109,15 +109,12 @@ - (void)windowDidBecomeKey:(NSNotification *)notification { - _glfwLibrary.activeWindow = window; + _glfwInputWindowFocus(window, GL_TRUE); } - (void)windowDidResignKey:(NSNotification *)notification { - if (window == _glfwLibrary.activeWindow) - _glfwLibrary.activeWindow = NULL; - - _glfwInputDeactivation(window); + _glfwInputWindowFocus(window, GL_FALSE); } @end @@ -449,11 +446,14 @@ static int convertMacKeyCode(unsigned int macKeyCode) - (void)scrollWheel:(NSEvent *)event { - window->NS.wheelPosFloating += [event deltaY]; - window->wheelPos = lrint(window->NS.wheelPosFloating); + double deltaX = window->NS.fracScrollX + [event deltaX]; + double deltaY = window->NS.fracScrollY + [event deltaY]; - if (window->mouseWheelCallback) - window->mouseWheelCallback(window, window->wheelPos); + if ((int) deltaX || (int) deltaY) + _glfwInputScroll(window, (int) deltaX, (int) deltaY); + + window->NS.fracScrollX = (int) (deltaX - floor(deltaX)); + window->NS.fracScrollY = (int) (deltaY - floor(deltaY)); } @end diff --git a/src/cocoa/platform.h b/src/cocoa/platform.h index e1cb9464..708f8aeb 100644 --- a/src/cocoa/platform.h +++ b/src/cocoa/platform.h @@ -85,7 +85,8 @@ typedef struct _GLFWwindowNS id window; id delegate; unsigned int modifierFlags; - double wheelPosFloating; + double fracScrollX; + double fracScrollY; } _GLFWwindowNS;