[host] correct mouse position with hotspot offset

This commit is contained in:
Geoffrey McRae 2018-10-09 18:10:59 +11:00
parent ce4f1be2a6
commit 0e8678b182
2 changed files with 15 additions and 6 deletions

View File

@ -414,13 +414,19 @@ unsigned int Capture::DXGI::Capture()
{
// always report the mouse position to prevent the guest losing sync (ie: dragging windows)
POINT curPos;
if (GetCursorPos(&curPos) && (curPos.x != m_lastCursorX || curPos.y != m_lastCursorY))
if (GetCursorPos(&curPos))
{
ret |= GRAB_STATUS_CURSOR;
cursor.hasPos = true;
cursor.x = m_lastCursorX = curPos.x;
cursor.y = m_lastCursorY = curPos.y;
cursor.visible = m_lastMouseVis;
curPos.x -= m_hotSpot.x;
curPos.y -= m_hotSpot.y;
if (curPos.x != m_lastCursorX || curPos.y != m_lastCursorY)
{
ret |= GRAB_STATUS_CURSOR;
cursor.hasPos = true;
cursor.x = m_lastCursorX = curPos.x;
cursor.y = m_lastCursorY = curPos.y;
cursor.visible = m_lastMouseVis;
}
}
}
@ -478,6 +484,8 @@ unsigned int Capture::DXGI::Capture()
cursor.w = shapeInfo.Width;
cursor.h = shapeInfo.Height;
cursor.pitch = shapeInfo.Pitch;
m_hotSpot.x = shapeInfo.HotSpot.x;
m_hotSpot.y = shapeInfo.HotSpot.y;
}
if (ret & GRAB_STATUS_CURSOR)

View File

@ -104,5 +104,6 @@ namespace Capture
int m_lastCursorX, m_lastCursorY;
BOOL m_lastMouseVis;
POINT m_hotSpot;
};
};