[host] correct cursor visibility information

This commit is contained in:
Geoffrey McRae 2018-10-09 18:28:08 +11:00
parent 0e8678b182
commit f36fd5ac1a
2 changed files with 40 additions and 45 deletions

View File

@ -389,47 +389,6 @@ unsigned int Capture::DXGI::Capture()
return GRAB_STATUS_ERROR;
}
// if we have a mouse update
if (frameInfo.LastMouseUpdateTime.QuadPart)
{
if (
m_lastCursorX != frameInfo.PointerPosition.Position.x ||
m_lastCursorY != frameInfo.PointerPosition.Position.y
) {
ret |= GRAB_STATUS_CURSOR;
cursor.hasPos = true;
cursor.x = m_lastCursorX = frameInfo.PointerPosition.Position.x;
cursor.y = m_lastCursorY = frameInfo.PointerPosition.Position.y;
}
if (m_lastMouseVis != frameInfo.PointerPosition.Visible)
{
ret |= GRAB_STATUS_CURSOR;
m_lastMouseVis = frameInfo.PointerPosition.Visible;
}
cursor.visible = m_lastMouseVis == TRUE;
}
else
{
// always report the mouse position to prevent the guest losing sync (ie: dragging windows)
POINT curPos;
if (GetCursorPos(&curPos))
{
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;
}
}
}
// if the pointer shape has changed
if (frameInfo.PointerShapeBufferSize > 0)
{
@ -488,6 +447,42 @@ unsigned int Capture::DXGI::Capture()
m_hotSpot.y = shapeInfo.HotSpot.y;
}
// if we have a mouse update
if (frameInfo.LastMouseUpdateTime.QuadPart)
{
if (
m_lastCursorX != frameInfo.PointerPosition.Position.x ||
m_lastCursorY != frameInfo.PointerPosition.Position.y
) {
ret |= GRAB_STATUS_CURSOR;
cursor.hasPos = true;
cursor.x = m_lastCursorX = frameInfo.PointerPosition.Position.x;
cursor.y = m_lastCursorY = frameInfo.PointerPosition.Position.y;
}
}
else
{
// always report the mouse position to prevent the guest losing sync (ie: dragging windows)
POINT curPos;
if (GetCursorPos(&curPos))
{
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;
}
}
}
if (m_lastMouseVis != frameInfo.PointerPosition.Visible)
m_lastMouseVis = frameInfo.PointerPosition.Visible;
cursor.visible = m_lastMouseVis == TRUE;
if (ret & GRAB_STATUS_CURSOR)
{
// push the cursor update into the queue

View File

@ -360,9 +360,6 @@ DWORD Service::CursorThread()
flags |= KVMFR_CURSOR_FLAG_POS;
cursor->x = ci.x;
cursor->y = ci.y;
if (ci.visible)
flags |= KVMFR_CURSOR_FLAG_VISIBLE;
}
if (ci.shape)
@ -384,8 +381,11 @@ DWORD Service::CursorThread()
memcpy(m_cursorData, ci.shape->buffer, ci.shape->bufferSize);
}
}
flags |= KVMFR_CURSOR_FLAG_UPDATE;
if (ci.visible)
flags |= KVMFR_CURSOR_FLAG_VISIBLE;
flags |= KVMFR_CURSOR_FLAG_UPDATE;
cursor->flags = flags;
m_capture->FreeCursor(ci);
}