From 7b938c6b08b2a0365af1e248f52053a9de0031dd Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 27 Sep 2010 02:32:41 +0200 Subject: [PATCH] Added Win32 implementation of two-dimensional scrolling. --- src/win32/platform.h | 3 +++ src/win32/win32_window.c | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) mode change 100644 => 100755 src/win32/win32_window.c diff --git a/src/win32/platform.h b/src/win32/platform.h index 112afb11..8a2a2ffa 100755 --- a/src/win32/platform.h +++ b/src/win32/platform.h @@ -120,6 +120,9 @@ typedef struct tagKBDLLHOOKSTRUCT { #ifndef WHEEL_DELTA #define WHEEL_DELTA 120 #endif +#ifndef WM_MOUSEHWHEEL +#define WM_MOUSEHWHEEL 0x020E +#endif #ifndef WM_XBUTTONDOWN #define WM_XBUTTONDOWN 0x020B diff --git a/src/win32/win32_window.c b/src/win32/win32_window.c old mode 100644 new mode 100755 index 8ac59203..231dd562 --- a/src/win32/win32_window.c +++ b/src/win32/win32_window.c @@ -622,8 +622,6 @@ static void translateChar(_GLFWwindow* window, DWORD wParam, DWORD lParam) static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - int wheelDelta; - _GLFWwindow* window = (_GLFWwindow*) GetWindowLongPtr(hWnd, 0); switch (uMsg) @@ -880,12 +878,15 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_MOUSEWHEEL: { - wheelDelta = (((int)wParam) >> 16) / WHEEL_DELTA; - window->wheelPos += wheelDelta; + _glfwInputScroll(window, 0, (((int) wParam) >> 16) / WHEEL_DELTA); + return 0; + } - if (window->mouseWheelCallback) - window->mouseWheelCallback(window, window->wheelPos); + case WM_MOUSEHWHEEL: + { + // This message is only sent on Windows Vista and later + _glfwInputScroll(window, (((int) wParam) >> 16) / WHEEL_DELTA, 0); return 0; } @@ -1635,6 +1636,12 @@ void _glfwPlatformPollEvents(void) MSG msg; _GLFWwindow* window; + for (window = _glfwLibrary.windowListHead; window; window = window->next) + { + window->scrollX = 0; + window->scrollY = 0; + } + window = _glfwLibrary.cursorLockWindow; if (window) {