[host] fixed missed cursor shape updates

This commit is contained in:
Geoffrey McRae 2018-05-28 10:34:24 +10:00
parent 62e67c345c
commit 871aee2aae
3 changed files with 31 additions and 9 deletions

View File

@ -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;
}

View File

@ -25,6 +25,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
struct CursorInfo
{
bool updated;
bool visible;
bool hasShape;
bool hasPos;

View File

@ -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;
}