mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 13:37:22 +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;
|
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)
|
static void sendPointer(bool newClient)
|
||||||
{
|
{
|
||||||
PLGMPMemory mem;
|
// new clients need the last known shape and current position
|
||||||
if (app.pointerInfo.shapeUpdate || newClient)
|
if (newClient)
|
||||||
{
|
{
|
||||||
if (!newClient)
|
if (!app.pointerShapeValid)
|
||||||
{
|
return;
|
||||||
// swap the latest shape buffer out of rotation
|
|
||||||
PLGMPMemory tmp = app.pointerShape;
|
|
||||||
app.pointerShape = app.pointerMemory[app.pointerIndex];
|
|
||||||
app.pointerMemory[app.pointerIndex] = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// use the last known shape buffer
|
// update the saved details with the current cursor position
|
||||||
mem = app.pointerShape;
|
KVMFRCursor *cursor = lgmpHostMemPtr(app.pointerShape);
|
||||||
}
|
cursor->x = app.pointerInfo.x;
|
||||||
else
|
cursor->y = app.pointerInfo.y;
|
||||||
mem = app.pointerMemory[app.pointerIndex];
|
|
||||||
|
|
||||||
if (++app.pointerIndex == POINTER_SHAPE_BUFFERS)
|
const uint32_t flags = CURSOR_FLAG_POSITION | CURSOR_FLAG_SHAPE |
|
||||||
app.pointerIndex = 0;
|
(app.pointerInfo.visible ? CURSOR_FLAG_VISIBLE : 0);
|
||||||
|
|
||||||
|
postPointer(flags, app.pointerShape);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
|
PLGMPMemory mem = app.pointerMemory[app.pointerIndex];
|
||||||
KVMFRCursor *cursor = lgmpHostMemPtr(mem);
|
KVMFRCursor *cursor = lgmpHostMemPtr(mem);
|
||||||
|
|
||||||
if (app.pointerInfo.positionUpdate || newClient)
|
if (app.pointerInfo.positionUpdate || newClient)
|
||||||
@ -375,23 +390,19 @@ static void sendPointer(bool newClient)
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.pointerShapeValid = true;
|
app.pointerShapeValid = true;
|
||||||
}
|
|
||||||
|
|
||||||
if ((app.pointerInfo.shapeUpdate || newClient) && app.pointerShapeValid)
|
|
||||||
flags |= CURSOR_FLAG_SHAPE;
|
flags |= CURSOR_FLAG_SHAPE;
|
||||||
|
|
||||||
LGMP_STATUS status;
|
// retain this memory for new clients
|
||||||
while ((status = lgmpHostQueuePost(app.pointerQueue, flags, mem)) != LGMP_OK)
|
app.pointerMemory[app.pointerIndex] = app.pointerShape;
|
||||||
{
|
app.pointerShape = mem;
|
||||||
if (status == LGMP_ERR_QUEUE_FULL)
|
|
||||||
{
|
|
||||||
usleep(1);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_ERROR("lgmpHostQueuePost Failed (Pointer): %s", lgmpStatusString(status));
|
// only advance the index if the shape was changed
|
||||||
break;
|
if ((flags & CURSOR_FLAG_SHAPE) != 0)
|
||||||
}
|
if (++app.pointerIndex == POINTER_SHAPE_BUFFERS)
|
||||||
|
app.pointerIndex = 0;
|
||||||
|
|
||||||
|
postPointer(flags, mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void capturePostPointerBuffer(CapturePointer pointer)
|
void capturePostPointerBuffer(CapturePointer pointer)
|
||||||
|
Loading…
Reference in New Issue
Block a user