From b87106811e8a087b8c4ee36cd9d7929b57808132 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 22 Jan 2014 16:55:10 +0100 Subject: [PATCH] Windows: Reconstruct MSG-structure properly. The MSG structure is supposed to contain screen coordinates of the mouse position. Use GET_X/Y_LPARAM for mouse events and transform for client coordinates. Use GetCursorPos() for other events. Task-number: QTBUG-36337 Change-Id: I3ad4de20e1a460ee58f22645a4339a2444d129ed Reviewed-by: Joerg Bornemann --- .../platforms/windows/qwindowscontext.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index c0db4805df..8380aba13b 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -734,8 +734,20 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, msg.message = message; // time and pt fields ignored msg.wParam = wParam; msg.lParam = lParam; - msg.pt.x = GET_X_LPARAM(lParam); - msg.pt.y = GET_Y_LPARAM(lParam); + msg.pt.x = msg.pt.y = 0; + if (et != QtWindows::CursorEvent && (et & (QtWindows::MouseEventFlag | QtWindows::NonClientEventFlag))) { + msg.pt.x = GET_X_LPARAM(lParam); + msg.pt.y = GET_Y_LPARAM(lParam); + // For non-client-area messages, these are screen coordinates (as expected + // in the MSG structure), otherwise they are client coordinates. + if (!(et & QtWindows::NonClientEventFlag)) { + ClientToScreen(msg.hwnd, &msg.pt); + } + } else { +#ifndef Q_OS_WINCE + GetCursorPos(&msg.pt); +#endif + } // Run the native event filters. long filterResult = 0;