From Alexander Sinditskiy, "I found issue with capturing mouse buttons.

This issue can be reproduced:
1. Create osgViewer window,
2. Push right&left mouse buttons on the osgViewer window,
3. Move mouse out of window, and release right&left mouse buttons.

osgViewer window handle only first mouse release, as result window thinks that we did not released second mouse button.

I attached fix for this issue."
This commit is contained in:
Robert Osfield 2012-11-08 17:19:51 +00:00
parent 1b871a822d
commit 36f6ef7242
2 changed files with 14 additions and 2 deletions

View File

@ -183,6 +183,8 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow, p
std::map<std::pair<int, int>, bool> _keyMap;
std::set<int> _capturedMouseButtons;
bool _applyWorkaroundForMultimonitorMultithreadNVidiaWin32Issues;
};

View File

@ -2508,6 +2508,8 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
else if (uMsg==WM_MBUTTONDOWN) button = 2;
else button = 3;
_capturedMouseButtons.insert(button);
float mx = GET_X_LPARAM(lParam);
float my = GET_Y_LPARAM(lParam);
transformMouseXY(mx, my);
@ -2522,14 +2524,17 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
/////////////////////
{
::ReleaseCapture();
int button;
if (uMsg==WM_LBUTTONUP) button = 1;
else if (uMsg==WM_MBUTTONUP) button = 2;
else button = 3;
_capturedMouseButtons.erase(button);
if(_capturedMouseButtons.empty())
::ReleaseCapture();
float mx = GET_X_LPARAM(lParam);
float my = GET_Y_LPARAM(lParam);
transformMouseXY(mx, my);
@ -2552,6 +2557,8 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
else if (uMsg==WM_MBUTTONDBLCLK) button = 2;
else button = 3;
_capturedMouseButtons.insert(button);
float mx = GET_X_LPARAM(lParam);
float my = GET_Y_LPARAM(lParam);
transformMouseXY(mx, my);
@ -2703,6 +2710,9 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
key->second = false;
}
}
_capturedMouseButtons.clear();
break;
///////////////////