Details
-
Bug
-
Resolution: Done
-
P4: Low
-
5.2.0
-
None
-
Found using Microsoft Visual Studio 2012.
-
b87106811e8a087b8c4ee36cd9d7929b57808132 (dev, 23.1.2014, 5.3)
Description
Look at the file ..\src\plugins\platforms\windows\qwindowscontext.cpp, function
QWindowsContext::windowsProc
in the beginning of this function there is a code that re-creates MSG structure.
MSG msg;
msg.hwnd = hwnd; // re-create MSG structure
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);
the code is correct only when message is Mouse Input Notification(WM_LBUTTONDOWN for example, see full list: http://msdn.microsoft.com/en-us/library/windows/desktop/ff468877%28v=vs.85%29.aspx)
In other cases msg.pt contains wrong coordinates because lParam for other messages (for example Keyboard Input Notifications (WM_KEYDOWN), see:http://msdn.microsoft.com/en-us/library/windows/desktop/ff468861%28v=vs.85%29.aspx) does not contain information about cursor coordinates.
So my proposal is either replace
msg.pt.x = GET_X_LPARAM(lParam);
msg.pt.y = GET_Y_LPARAM(lParam);
with
GetCursorPos(&msg.pt)
or call GetCursorPos(&msg.pt) when message is not equal to one of the Mouse Input Notification.