From Mike Connell, "This is a tiny fix for win32.

The current code takes the mouse cursor position and adds it to the
window (left,top) position, and sends the mouse cursor there. But this
doesn't take into account the window decoration.

The new code converts the given (x,y) coordinates from the client area
coordinate system to the screen instead using ClientToScreen. I think
this is the natural windows way to do it.

Tested on XP with osgviewer
"

Note from Robet Osfield, made a few changes to layout to make it more consistent 
with the rest of the OSG and used #if 0 instead if (0) blocks.
This commit is contained in:
Robert Osfield
2007-06-30 16:19:56 +00:00
parent efda16ac56
commit c7a316e445

View File

@@ -1724,6 +1724,7 @@ void GraphicsWindowWin32::requestWarpPointer( float x, float y )
RECT windowRect;
#if 0
if (!::GetWindowRect(_hwnd, &windowRect))
{
reportErrorForScreen("GraphicsWindowWin32::requestWarpPointer() - Unable to get window rectangle", _traits->screenNum, ::GetLastError());
@@ -1734,8 +1735,24 @@ void GraphicsWindowWin32::requestWarpPointer( float x, float y )
{
reportErrorForScreen("GraphicsWindowWin32::requestWarpPointer() - Unable to set cursor position", _traits->screenNum, ::GetLastError());
return;
}
#else
// MIKEC: NEW CODE
POINT pt;
pt.x=x;
pt.y=y;
// convert point in client area coordinates to screen coordinates
if (!::ClientToScreen(_hwnd,&pt))
{
reportErrorForScreen("GraphicsWindowWin32::requestWarpPointer() - Unable to convert cursor position to screen coordinates", _traits->screenNum, ::GetLastError());
}
if (!::SetCursorPos(pt.x,pt.y))
{
reportErrorForScreen("GraphicsWindowWin32::requestWarpPointer() - Unable to set cursor position", _traits->screenNum, ::GetLastError());
return;
}
#endif
getEventQueue()->mouseWarped(x,y);
}