From 7ea1a97afd3ec6c95d02f1e39b483266a46ac5f3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 7 May 2009 13:30:54 +0000 Subject: [PATCH] From Frederic Bouvier, SetCursor fixes from GraphicsWindowWin32, Original email from Frederic at start of thread: "he patch attached, made from r10068, fix two things, in other of importance : - the selected cursor is never shown ( second change in file ). Only the left arrow is always displayed. - remove the arbitrary ( in my sense ) limitation that the user cannot choose a cursor with the same shape that one used when resizing the window. This limitation doesn't exist for X11, and we have a diverging behaviour there ( first change in file ). Flightgear use the LeftRightCursor in look around mode." Follow up email from Frederic (with changes that finally made it into this check in: "I've just tested Mark's suggestion and it works perfectly, even when the cursor goes to the border then come back inside the window. But his patch doesn't seem to be based on the last revision of the files, or at least not on the trunk, and there are more changes than expected in them, including some loss from the previous patches. The patch attached is based on r10068 of src/osgViewer/GraphicsWindowWin32.cpp and r10067 of include/osgViewer/api/Win32/GraphicsWindowWin32" --- .../osgViewer/api/Win32/GraphicsWindowWin32 | 2 ++ src/osgViewer/GraphicsWindowWin32.cpp | 34 ++++++++----------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/include/osgViewer/api/Win32/GraphicsWindowWin32 b/include/osgViewer/api/Win32/GraphicsWindowWin32 index 6fd9603fc..d54a18903 100644 --- a/include/osgViewer/api/Win32/GraphicsWindowWin32 +++ b/include/osgViewer/api/Win32/GraphicsWindowWin32 @@ -144,6 +144,8 @@ class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow void transformMouseXY(float& x, float& y); + void setCursorImpl(MouseCursor cursor); + HCURSOR getOrCreateCursor(MouseCursor mouseShape); HWND _hwnd; diff --git a/src/osgViewer/GraphicsWindowWin32.cpp b/src/osgViewer/GraphicsWindowWin32.cpp index 26bd1ad98..2c63538b9 100644 --- a/src/osgViewer/GraphicsWindowWin32.cpp +++ b/src/osgViewer/GraphicsWindowWin32.cpp @@ -1939,26 +1939,22 @@ void GraphicsWindowWin32::useCursor( bool cursorOn ) } void GraphicsWindowWin32::setCursor( MouseCursor mouseCursor ) +{ + _appMouseCursor = mouseCursor; + setCursorImpl(mouseCursor); +} + +void GraphicsWindowWin32::setCursorImpl( MouseCursor mouseCursor ) { if (_mouseCursor != 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); } @@ -2354,28 +2350,28 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W { case HTLEFT: case HTRIGHT: - setCursor(LeftRightCursor); + setCursorImpl(LeftRightCursor); break; case HTTOP: case HTBOTTOM: - setCursor(UpDownCursor); + setCursorImpl(UpDownCursor); break; case HTTOPLEFT: - setCursor(TopLeftCorner); + setCursorImpl(TopLeftCorner); break; case HTTOPRIGHT: - setCursor(TopRightCorner); + setCursorImpl(TopRightCorner); break; case HTBOTTOMLEFT: - setCursor(BottomLeftCorner); + setCursorImpl(BottomLeftCorner); break; case HTBOTTOMRIGHT: case HTGROWBOX: - setCursor(BottomRightCorner); + setCursorImpl(BottomRightCorner); break; default: if (_traits->useCursor && _appMouseCursor != InheritCursor) - setCursor(LeftArrowCursor); + setCursorImpl(_appMouseCursor); break; } return result;