From bfc4a1bc16b7375780835d79c9c2b5a0f90b6989 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 11 Jan 2019 23:59:46 +1100 Subject: [PATCH] [client] update client to handle new cursor move code --- client/main.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/client/main.c b/client/main.c index 028bd6c1..91a4706c 100644 --- a/client/main.c +++ b/client/main.c @@ -249,7 +249,8 @@ int cursorThread(void * unused) while(state.running) { // 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) return 0; @@ -258,6 +259,32 @@ int cursorThread(void * unused) 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 // from being abused to overflow buffers. memcpy(&header, &state.shm->cursor, sizeof(struct KVMFRCursor)); @@ -309,14 +336,7 @@ int cursorThread(void * unused) state.shm->cursor.flags = 0; bool showCursor = header.flags & KVMFR_CURSOR_FLAG_VISIBLE; - if (header.flags & KVMFR_CURSOR_FLAG_POS) - { - state.cursor.x = header.x; - state.cursor.y = header.y; - state.haveCursorPos = true; - } - - if (showCursor != state.cursorVisible || header.flags & KVMFR_CURSOR_FLAG_POS) + if (showCursor != state.cursorVisible || moved) { state.cursorVisible = showCursor; state.lgr->on_mouse_event