diff --git a/include/osgViewer/api/Win32/GraphicsWindowWin32 b/include/osgViewer/api/Win32/GraphicsWindowWin32 index 71846ef2a..f7b7f4f7c 100644 --- a/include/osgViewer/api/Win32/GraphicsWindowWin32 +++ b/include/osgViewer/api/Win32/GraphicsWindowWin32 @@ -183,6 +183,8 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow, p std::map, bool> _keyMap; + std::set _capturedMouseButtons; + bool _applyWorkaroundForMultimonitorMultithreadNVidiaWin32Issues; }; diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index 6aacaa0d4..de8cf4c42 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -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; ///////////////////