mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 08:38:20 +00:00
[host] app: fix issue with wrong cursor shape being sent for new clients
When a new cursor shape is provided by the capture interface we need to retain a copy of it incase a new client connects which will not yet have the cursor shape. The logic here was flawed causing the wrong shape to be sent to a new client in some instances.
This commit is contained in:
parent
d82f2e510d
commit
e9b009db9f
@ -321,29 +321,44 @@ bool captureGetPointerBuffer(void ** data, uint32_t * size)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void postPointer(uint32_t flags, PLGMPMemory mem)
|
||||
{
|
||||
LGMP_STATUS status;
|
||||
while ((status = lgmpHostQueuePost(app.pointerQueue, flags, mem)) != LGMP_OK)
|
||||
{
|
||||
if (status == LGMP_ERR_QUEUE_FULL)
|
||||
{
|
||||
usleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUG_ERROR("lgmpHostQueuePost Failed (Pointer): %s", lgmpStatusString(status));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void sendPointer(bool newClient)
|
||||
{
|
||||
PLGMPMemory mem;
|
||||
if (app.pointerInfo.shapeUpdate || newClient)
|
||||
// new clients need the last known shape and current position
|
||||
if (newClient)
|
||||
{
|
||||
if (!newClient)
|
||||
{
|
||||
// swap the latest shape buffer out of rotation
|
||||
PLGMPMemory tmp = app.pointerShape;
|
||||
app.pointerShape = app.pointerMemory[app.pointerIndex];
|
||||
app.pointerMemory[app.pointerIndex] = tmp;
|
||||
}
|
||||
if (!app.pointerShapeValid)
|
||||
return;
|
||||
|
||||
// use the last known shape buffer
|
||||
mem = app.pointerShape;
|
||||
}
|
||||
else
|
||||
mem = app.pointerMemory[app.pointerIndex];
|
||||
// update the saved details with the current cursor position
|
||||
KVMFRCursor *cursor = lgmpHostMemPtr(app.pointerShape);
|
||||
cursor->x = app.pointerInfo.x;
|
||||
cursor->y = app.pointerInfo.y;
|
||||
|
||||
if (++app.pointerIndex == POINTER_SHAPE_BUFFERS)
|
||||
app.pointerIndex = 0;
|
||||
const uint32_t flags = CURSOR_FLAG_POSITION | CURSOR_FLAG_SHAPE |
|
||||
(app.pointerInfo.visible ? CURSOR_FLAG_VISIBLE : 0);
|
||||
|
||||
postPointer(flags, app.pointerShape);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t flags = 0;
|
||||
PLGMPMemory mem = app.pointerMemory[app.pointerIndex];
|
||||
KVMFRCursor *cursor = lgmpHostMemPtr(mem);
|
||||
|
||||
if (app.pointerInfo.positionUpdate || newClient)
|
||||
@ -375,23 +390,19 @@ static void sendPointer(bool newClient)
|
||||
}
|
||||
|
||||
app.pointerShapeValid = true;
|
||||
}
|
||||
|
||||
if ((app.pointerInfo.shapeUpdate || newClient) && app.pointerShapeValid)
|
||||
flags |= CURSOR_FLAG_SHAPE;
|
||||
|
||||
LGMP_STATUS status;
|
||||
while ((status = lgmpHostQueuePost(app.pointerQueue, flags, mem)) != LGMP_OK)
|
||||
{
|
||||
if (status == LGMP_ERR_QUEUE_FULL)
|
||||
{
|
||||
usleep(1);
|
||||
continue;
|
||||
// retain this memory for new clients
|
||||
app.pointerMemory[app.pointerIndex] = app.pointerShape;
|
||||
app.pointerShape = mem;
|
||||
}
|
||||
|
||||
DEBUG_ERROR("lgmpHostQueuePost Failed (Pointer): %s", lgmpStatusString(status));
|
||||
break;
|
||||
}
|
||||
// only advance the index if the shape was changed
|
||||
if ((flags & CURSOR_FLAG_SHAPE) != 0)
|
||||
if (++app.pointerIndex == POINTER_SHAPE_BUFFERS)
|
||||
app.pointerIndex = 0;
|
||||
|
||||
postPointer(flags, mem);
|
||||
}
|
||||
|
||||
void capturePostPointerBuffer(CapturePointer pointer)
|
||||
|
Loading…
Reference in New Issue
Block a user