From 871aee2aae74bda844a93de37078970e1a2f2da4 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 28 May 2018 10:34:24 +1000 Subject: [PATCH] [host] fixed missed cursor shape updates --- host/Capture/DXGI.cpp | 11 +++++------ host/ICapture.h | 2 ++ host/Service.cpp | 27 ++++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/host/Capture/DXGI.cpp b/host/Capture/DXGI.cpp index be8386e7..15a09832 100644 --- a/host/Capture/DXGI.cpp +++ b/host/Capture/DXGI.cpp @@ -608,7 +608,6 @@ GrabStatus Capture::DXGI::GrabFrameTexture(struct FrameInfo & frame, struct Curs IDXGIResourcePtr res; HRESULT status; - bool cursorUpdate = false; for (int i = 0; i < 2; ++i) { while (true) @@ -652,8 +651,8 @@ GrabStatus Capture::DXGI::GrabFrameTexture(struct FrameInfo & frame, struct Curs m_lastMousePos.x != frameInfo.PointerPosition.Position.x || m_lastMousePos.y != frameInfo.PointerPosition.Position.y ) { - cursorUpdate = true; - cursor.hasPos = true; + cursor.updated = true; + cursor.hasPos = true; cursor.x = frameInfo.PointerPosition.Position.x; cursor.y = frameInfo.PointerPosition.Position.y; m_lastMousePos.x = frameInfo.PointerPosition.Position.x; @@ -662,7 +661,7 @@ GrabStatus Capture::DXGI::GrabFrameTexture(struct FrameInfo & frame, struct Curs if (m_lastMouseVis != frameInfo.PointerPosition.Visible) { - cursorUpdate = true; + cursor.updated = true; m_lastMouseVis = frameInfo.PointerPosition.Visible; } @@ -672,7 +671,7 @@ GrabStatus Capture::DXGI::GrabFrameTexture(struct FrameInfo & frame, struct Curs // if the pointer shape has changed if (frameInfo.PointerShapeBufferSize > 0) { - cursorUpdate = true; + cursor.updated = true; if (m_pointerBufSize < frameInfo.PointerShapeBufferSize) { if (m_pointer) @@ -713,7 +712,7 @@ GrabStatus Capture::DXGI::GrabFrameTexture(struct FrameInfo & frame, struct Curs SafeRelease(&res); - if (cursorUpdate) + if (cursor.updated) return GRAB_STATUS_CURSOR; } diff --git a/host/ICapture.h b/host/ICapture.h index 9ca22dd6..465577e6 100644 --- a/host/ICapture.h +++ b/host/ICapture.h @@ -25,6 +25,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA struct CursorInfo { + bool updated; + bool visible; bool hasShape; bool hasPos; diff --git a/host/Service.cpp b/host/Service.cpp index 1b3bef6d..8b4edd22 100644 --- a/host/Service.cpp +++ b/host/Service.cpp @@ -275,10 +275,28 @@ bool Service::Process() return false; } - if (cursor.hasPos || cursor.hasShape) + if (cursor.updated) { EnterCriticalSection(&m_cursorCS); - memcpy(&m_cursorInfo, &cursor, sizeof(struct CursorInfo)); + if (cursor.hasPos) + { + m_cursorInfo.hasPos = true; + m_cursorInfo.x = cursor.x; + m_cursorInfo.y = cursor.y; + } + + if (cursor.hasShape) + { + m_cursorInfo.hasShape = true; + m_cursorInfo.dataSize = cursor.dataSize; + m_cursorInfo.type = cursor.type; + m_cursorInfo.w = cursor.w; + m_cursorInfo.h = cursor.h; + m_cursorInfo.pitch = cursor.pitch; + m_cursorInfo.shape = cursor.shape; + } + + m_cursorInfo.visible = cursor.visible; LeaveCriticalSection(&m_cursorCS); SetEvent(m_cursorEvent); } @@ -326,6 +344,8 @@ DWORD Service::CursorThread() EnterCriticalSection(&m_cursorCS); if (m_cursorInfo.hasPos) { + m_cursorInfo.hasPos = false; + // tell the client where the cursor is cursor->flags |= KVMFR_CURSOR_FLAG_POS; cursor->x = m_cursorInfo.x; @@ -339,6 +359,7 @@ DWORD Service::CursorThread() if (m_cursorInfo.hasShape) { + m_cursorInfo.hasShape = false; if (m_cursorInfo.dataSize > m_cursorDataSize) DEBUG_ERROR("Cursor size exceeds allocated space"); else @@ -356,8 +377,8 @@ DWORD Service::CursorThread() memcpy(m_cursorData, m_cursorInfo.shape, m_cursorInfo.dataSize); } } - LeaveCriticalSection(&m_cursorCS); + LeaveCriticalSection(&m_cursorCS); cursor->flags |= KVMFR_CURSOR_FLAG_UPDATE; }