diff --git a/VERSION b/VERSION index 0f635eb1..78c38d26 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-rc3-4-gf0923c4ed7+1 \ No newline at end of file +B1-rc3-5-gb31e8e1cee+1 \ No newline at end of file diff --git a/c-host/platform/Windows/capture/DXGI/src/dxgi.c b/c-host/platform/Windows/capture/DXGI/src/dxgi.c index ffacb90f..56ef3f15 100644 --- a/c-host/platform/Windows/capture/DXGI/src/dxgi.c +++ b/c-host/platform/Windows/capture/DXGI/src/dxgi.c @@ -806,11 +806,8 @@ static CaptureResult dxgi_getPointer(CapturePointer * pointer) assert(this); assert(this->initialized); - if (!os_waitEvent(this->pointerEvent, TIMEOUT_INFINITE)) - { - DEBUG_ERROR("Failed to wait on the pointer event"); - return CAPTURE_RESULT_ERROR; - } + if (!os_waitEvent(this->pointerEvent, 1000)) + return CAPTURE_RESULT_TIMEOUT; if (this->stop) return CAPTURE_RESULT_REINIT; diff --git a/c-host/platform/Windows/capture/NVFBC/src/nvfbc.c b/c-host/platform/Windows/capture/NVFBC/src/nvfbc.c index 5252d62d..dd8a88f3 100644 --- a/c-host/platform/Windows/capture/NVFBC/src/nvfbc.c +++ b/c-host/platform/Windows/capture/NVFBC/src/nvfbc.c @@ -277,11 +277,8 @@ static CaptureResult nvfbc_getPointer(CapturePointer * pointer) { osEventHandle * events[2]; memcpy(&events, &this->cursorEvents, sizeof(osEventHandle *) * 2); - if (!os_waitEvents(events, this->seperateCursor ? 2 : 1, false, TIMEOUT_INFINITE)) - { - DEBUG_ERROR("Failed to wait on the cursor events"); - return CAPTURE_RESULT_ERROR; - } + if (!os_waitEvents(events, this->seperateCursor ? 2 : 1, false, 1000)) + return CAPTURE_RESULT_TIMEOUT; if (this->stop) return CAPTURE_RESULT_REINIT; diff --git a/c-host/src/app.c b/c-host/src/app.c index e147a031..e3e4c9e5 100644 --- a/c-host/src/app.c +++ b/c-host/src/app.c @@ -38,6 +38,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA struct app { + unsigned int clientInstance; + KVMFRHeader * shmHeader; uint8_t * pointerData; unsigned int pointerDataSize; @@ -63,25 +65,50 @@ static int pointerThread(void * opaque) DEBUG_INFO("Pointer thread started"); volatile KVMFRCursor * ci = &(app.shmHeader->cursor); - uint8_t flags; + + uint8_t flags; + bool pointerValid = false; + bool shapeValid = false; + unsigned int clientInstance = 0; + CapturePointer pointer = { 0 }; while(app.running) { - CaptureResult result; - CapturePointer pointer = { 0 }; - - result = app.iface->getPointer(&pointer); - if (result == CAPTURE_RESULT_REINIT) + bool resend = false; + switch(app.iface->getPointer(&pointer)) { - app.reinit = true; - break; + case CAPTURE_RESULT_OK: + { + pointerValid = true; + break; + } + + case CAPTURE_RESULT_REINIT: + { + app.reinit = true; + break; + } + + case CAPTURE_RESULT_ERROR: + { + DEBUG_ERROR("Failed to get the pointer"); + break; + } + + case CAPTURE_RESULT_TIMEOUT: + { + // if the pointer is valid and the client has restarted, send it + if (pointerValid && clientInstance != app.clientInstance) + { + resend = true; + break; + } + + continue; + } } - if (result == CAPTURE_RESULT_ERROR) - { - DEBUG_ERROR("Failed to get the pointer"); - break; - } + clientInstance = app.clientInstance; // wait for the client to finish with the previous update while((ci->flags & ~KVMFR_CURSOR_FLAG_UPDATE) != 0 && app.running) @@ -95,7 +122,7 @@ static int pointerThread(void * opaque) flags |= KVMFR_CURSOR_FLAG_VISIBLE; // if we have shape data - if (pointer.shapeUpdate) + if (pointer.shapeUpdate || (shapeValid && resend)) { switch(pointer.format) { @@ -112,6 +139,7 @@ static int pointerThread(void * opaque) ci->pitch = pointer.pitch; ci->dataPos = app.pointerOffset; ++ci->version; + shapeValid = true; flags |= KVMFR_CURSOR_FLAG_SHAPE; } @@ -367,7 +395,11 @@ int app_main(int argc, char * argv[]) while(app.running) { - INTERLOCKED_AND8(flags, ~(KVMFR_HEADER_FLAG_RESTART)); + if (INTERLOCKED_AND8(flags, ~(KVMFR_HEADER_FLAG_RESTART)) & KVMFR_HEADER_FLAG_RESTART) + { + DEBUG_INFO("Client restarted"); + ++app.clientInstance; + } if (app.reinit && !captureRestart()) { diff --git a/client/renderers/EGL/egl.c b/client/renderers/EGL/egl.c index 435971cb..b86dee55 100644 --- a/client/renderers/EGL/egl.c +++ b/client/renderers/EGL/egl.c @@ -85,6 +85,8 @@ struct Inst float screenScaleX, screenScaleY; bool useNearest; + bool cursorVisible; + int cursorX , cursorY; float mouseWidth , mouseHeight; float mouseScaleX, mouseScaleY; @@ -249,6 +251,13 @@ void egl_on_resize(void * opaque, const int width, const int height, const LG_Re this->splashRatio = (float)width / (float)height; this->screenScaleX = 1.0f / width; this->screenScaleY = 1.0f / height; + + egl_cursor_set_state( + this->cursor, + this->cursorVisible, + (((float)this->cursorX * this->mouseScaleX) - 1.0f) * this->scaleX, + (((float)this->cursorY * this->mouseScaleY) - 1.0f) * this->scaleY + ); } bool egl_on_mouse_shape(void * opaque, const LG_RendererCursor cursor, const int width, const int height, const int pitch, const uint8_t * data) @@ -270,15 +279,18 @@ bool egl_on_mouse_shape(void * opaque, const LG_RendererCursor cursor, const int return true; } -bool egl_on_mouse_event(void * opaque, const bool visible , const int x, const int y) +bool egl_on_mouse_event(void * opaque, const bool visible, const int x, const int y) { struct Inst * this = (struct Inst *)opaque; + this->cursorVisible = visible; + this->cursorX = x; + this->cursorY = y; egl_cursor_set_state( this->cursor, - visible, - (((float)x * this->mouseScaleX) - 1.0f) * this->scaleX, - (((float)y * this->mouseScaleY) - 1.0f) * this->scaleY + this->cursorVisible, + (((float)this->cursorX * this->mouseScaleX) - 1.0f) * this->scaleX, + (((float)this->cursorY * this->mouseScaleY) - 1.0f) * this->scaleY ); return true; diff --git a/common/include/common/locking.h b/common/include/common/locking.h index 24e3949c..969e91a1 100644 --- a/common/include/common/locking.h +++ b/common/include/common/locking.h @@ -19,8 +19,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA #pragma once #if defined(__GCC__) || defined(__GNUC__) -#define INTERLOCKED_AND8 __sync_and_and_fetch -#define INTERLOCKED_OR8 __sync_or_and_fetch +#define INTERLOCKED_AND8 __sync_fetch_and_and +#define INTERLOCKED_OR8 __sync_fetch_and_or #else #define INTERLOCKED_OR8 InterlockedOr8 #define INTERLOCKED_AND8 InterlockedAnd8