From eef4801ba7f8096921338eb6734f518e6e39c860 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 27 Feb 2009 11:11:06 +0000 Subject: [PATCH] From Roland Smeenk, "Attached is a small bug fix for the redundant messages that are created in OSG applications on windows. GraphicsWindowWin32::setCursor is called every frame from the WM_NCHITTEST message. This will result in a call to ::SetCursor(_currentCursor) every frame, which again causes a WM_MOUSEMOVE to occur. The fix exits GraphicsWindowWin32::setCursor if the requested cursor already is the current cursor. " --- src/osgViewer/GraphicsWindowWin32.cpp | 37 +++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index 9613b2a15..525b69036 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -1935,25 +1935,28 @@ void GraphicsWindowWin32::useCursor( bool cursorOn ) void GraphicsWindowWin32::setCursor( MouseCursor mouseCursor ) { - if (mouseCursor != LeftRightCursor && - mouseCursor != UpDownCursor && - mouseCursor != TopLeftCorner && - mouseCursor != TopRightCorner && - mouseCursor != BottomLeftCorner && - mouseCursor != BottomRightCorner) + if (_mouseCursor != mouseCursor) { - _appMouseCursor = mouseCursor; + if (mouseCursor != LeftRightCursor && + mouseCursor != UpDownCursor && + mouseCursor != TopLeftCorner && + mouseCursor != TopRightCorner && + mouseCursor != BottomLeftCorner && + mouseCursor != BottomRightCorner) + { + _appMouseCursor = mouseCursor; + } + + _mouseCursor = mouseCursor; + HCURSOR newCursor = getOrCreateCursor( mouseCursor); + if (newCursor == _currentCursor) return; + + _currentCursor = newCursor; + _traits->useCursor = (_currentCursor != NULL); + + if (_mouseCursor != InheritCursor) + ::SetCursor(_currentCursor); } - - _mouseCursor = mouseCursor; - HCURSOR newCursor = getOrCreateCursor( mouseCursor); - if (newCursor == _currentCursor) return; - - _currentCursor = newCursor; - _traits->useCursor = (_currentCursor != NULL); - - if (_mouseCursor != InheritCursor) - ::SetCursor(_currentCursor); } HCURSOR GraphicsWindowWin32::getOrCreateCursor(MouseCursor mouseCursor)