From 7ca071192e57e73463a40f2b7b43746d7d8aacb2 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 25 Feb 2010 18:05:59 +0000 Subject: [PATCH] From Erik Johnson, "There is an issue on win32 if the application hides the cursor using GraphicsWindowWin32::useCursor(false). The cursor has a habit of re-showing itself. To reproduce, on win32: -Run osgViewer in a windowed mode, with the cursor off, as such: osgViewer::Viewer::Windows windows; viewer.getWindows(windows); for(osgViewer::Viewer::Windows::iterator itr = windows.begin(); itr != windows.end(); ++itr) { (*itr)->useCursor( false ); } -Quickly move the cursor into the window (cursor it should be hidden) -Resize the window by dragging the border (notice the cursor changes to "resize" cursor) -Move the cursor back to the inside of the window (notice the cursor is not hidden anymore) The attached SVN patch will set the cursor to a "NoCursor" during useCursor(false). This correctly stores the no cursor state, so it can be rejuvenated after a future cursor change. This patch also fixes a couple instances where a hidden cursor should show itself, like when it's on the title bar, or the window close button." --- src/osgViewer/GraphicsWindowWin32.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index 347c2071e..e5971661e 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -2057,6 +2057,10 @@ void GraphicsWindowWin32::setWindowName( const std::string & name ) void GraphicsWindowWin32::useCursor( bool cursorOn ) { _traits->useCursor = cursorOn; + if (_traits->useCursor == false) + { + setCursor(NoCursor); + } } void GraphicsWindowWin32::setCursor( MouseCursor mouseCursor ) @@ -2074,7 +2078,7 @@ void GraphicsWindowWin32::setCursorImpl( MouseCursor mouseCursor ) if (newCursor == _currentCursor) return; _currentCursor = newCursor; - _traits->useCursor = (_currentCursor != NULL); + _traits->useCursor = (_currentCursor != NULL) && (_mouseCursor != NoCursor); if (_mouseCursor != InheritCursor) ::SetCursor(_currentCursor); @@ -2490,6 +2494,15 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W case HTGROWBOX: setCursorImpl(BottomRightCorner); break; + case HTSYSMENU: + case HTCAPTION: + case HTMAXBUTTON: + case HTMINBUTTON: + case HTCLOSE: + case HTHELP: + setCursorImpl(LeftArrowCursor); + break; + default: if (_traits->useCursor && _appMouseCursor != InheritCursor) setCursorImpl(_appMouseCursor);