From 7a98a886b66fa03782a5cc40ddb6f46ab9b2e4f7 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 9 Jan 2020 20:27:55 +1100 Subject: [PATCH] [c-host] use the correct buffer for the cursor shape --- .../platform/Windows/capture/DXGI/src/dxgi.c | 2 +- c-host/src/app.c | 25 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/c-host/platform/Windows/capture/DXGI/src/dxgi.c b/c-host/platform/Windows/capture/DXGI/src/dxgi.c index 3c517798..b42686ff 100644 --- a/c-host/platform/Windows/capture/DXGI/src/dxgi.c +++ b/c-host/platform/Windows/capture/DXGI/src/dxgi.c @@ -699,7 +699,7 @@ static CaptureResult dxgi_capture() // if the pointer has moved or changed state bool postPointer = false; CapturePointer pointer = { 0 }; - void * pointerShape = NULL; + void * pointerShape = NULL; UINT pointerShapeSize = 0; if (frameInfo.LastMouseUpdateTime.QuadPart) diff --git a/c-host/src/app.c b/c-host/src/app.c index 61c2b24a..5b885e6b 100644 --- a/c-host/src/app.c +++ b/c-host/src/app.c @@ -261,6 +261,7 @@ bool captureGetPointerBuffer(void ** data, uint32_t * size) // spin until there is room while(lgmpHostQueuePending(app.pointerQueue) == LGMP_Q_POINTER_LEN) { + DEBUG_INFO("pending"); if (!app.running) return false; } @@ -273,19 +274,12 @@ bool captureGetPointerBuffer(void ** data, uint32_t * size) void capturePostPointerBuffer(CapturePointer pointer) { - // spin until there is room - while(lgmpHostQueuePending(app.pointerQueue) == LGMP_Q_POINTER_LEN) - { - if (!app.running) - return; - } - PLGMPMemory mem; const bool newClient = lgmpHostNewSubCount(app.pointerQueue) > 0; if (pointer.shapeUpdate || newClient) { - if (!newClient) + if (pointer.shapeUpdate) { // swap the latest shape buffer out of rotation PLGMPMemory tmp = app.pointerShape; @@ -297,7 +291,11 @@ void capturePostPointerBuffer(CapturePointer pointer) mem = app.pointerShape; } else + { mem = app.pointerMemory[app.pointerIndex]; + if (++app.pointerIndex == LGMP_Q_POINTER_LEN) + app.pointerIndex = 0; + } KVMFRCursor *cursor = lgmpHostMemPtr(mem); cursor->x = pointer.x; @@ -324,17 +322,18 @@ void capturePostPointerBuffer(CapturePointer pointer) app.pointerShapeValid = true; } - const bool sendShape = (pointer.shapeUpdate || newClient) && app.pointerShapeValid; + const uint32_t sendShape = + ((pointer.shapeUpdate || newClient) && app.pointerShapeValid) ? 1 : 0; LGMP_STATUS status; - if ((status = lgmpHostPost(app.pointerQueue, sendShape ? 1 : 0, mem)) != LGMP_OK) + while ((status = lgmpHostPost(app.pointerQueue, sendShape, mem)) != LGMP_OK) { + if (status == LGMP_ERR_QUEUE_FULL) + continue; + DEBUG_ERROR("lgmpHostPost Failed (Pointer): %s", lgmpStatusString(status)); return; } - - if (++app.pointerIndex == LGMP_Q_POINTER_LEN) - app.pointerIndex = 0; } // this is called from the platform specific startup routine