[client] update client to handle new cursor move code

This commit is contained in:
Geoffrey McRae 2019-01-11 23:59:46 +11:00
parent 1ef61f6cd3
commit bfc4a1bc16

View File

@ -249,7 +249,8 @@ int cursorThread(void * unused)
while(state.running) while(state.running)
{ {
// poll until we have cursor data // poll until we have cursor data
if(!(state.shm->cursor.flags & KVMFR_CURSOR_FLAG_UPDATE)) if(!(state.shm->cursor.flags & KVMFR_CURSOR_FLAG_UPDATE) &&
!(state.shm->cursor.flags & KVMFR_CURSOR_FLAG_POS))
{ {
if (!state.running) if (!state.running)
return 0; return 0;
@ -258,6 +259,32 @@ int cursorThread(void * unused)
continue; continue;
} }
// if the cursor was moved
bool moved = false;
if (state.shm->cursor.flags & KVMFR_CURSOR_FLAG_POS)
{
state.cursor.x = state.shm->cursor.x;
state.cursor.y = state.shm->cursor.y;
state.haveCursorPos = true;
moved = true;
}
// if this was only a move event
if (!(state.shm->cursor.flags & KVMFR_CURSOR_FLAG_UPDATE))
{
// turn off the pos flag, trigger the event and continue
__sync_and_and_fetch(&state.shm->cursor.flags, ~KVMFR_CURSOR_FLAG_POS);
state.lgr->on_mouse_event
(
state.lgrData,
state.cursorVisible,
state.cursor.x,
state.cursor.y
);
continue;
}
// we must take a copy of the header to prevent the contained arguments // we must take a copy of the header to prevent the contained arguments
// from being abused to overflow buffers. // from being abused to overflow buffers.
memcpy(&header, &state.shm->cursor, sizeof(struct KVMFRCursor)); memcpy(&header, &state.shm->cursor, sizeof(struct KVMFRCursor));
@ -309,14 +336,7 @@ int cursorThread(void * unused)
state.shm->cursor.flags = 0; state.shm->cursor.flags = 0;
bool showCursor = header.flags & KVMFR_CURSOR_FLAG_VISIBLE; bool showCursor = header.flags & KVMFR_CURSOR_FLAG_VISIBLE;
if (header.flags & KVMFR_CURSOR_FLAG_POS) if (showCursor != state.cursorVisible || moved)
{
state.cursor.x = header.x;
state.cursor.y = header.y;
state.haveCursorPos = true;
}
if (showCursor != state.cursorVisible || header.flags & KVMFR_CURSOR_FLAG_POS)
{ {
state.cursorVisible = showCursor; state.cursorVisible = showCursor;
state.lgr->on_mouse_event state.lgr->on_mouse_event