From f36fd5ac1ad4aa2e7cbf17a1f2bd9956c74e948d Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 9 Oct 2018 18:28:08 +1100 Subject: [PATCH] [host] correct cursor visibility information --- host/Capture/DXGI.cpp | 77 ++++++++++++++++++++----------------------- host/Service.cpp | 8 ++--- 2 files changed, 40 insertions(+), 45 deletions(-) diff --git a/host/Capture/DXGI.cpp b/host/Capture/DXGI.cpp index c7b7b869..cd4cfe04 100644 --- a/host/Capture/DXGI.cpp +++ b/host/Capture/DXGI.cpp @@ -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 diff --git a/host/Service.cpp b/host/Service.cpp index 5c71dee0..fa74b495 100644 --- a/host/Service.cpp +++ b/host/Service.cpp @@ -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); }