diff --git a/client/src/app.c b/client/src/app.c index 1c6acd99..1464e8db 100644 --- a/client/src/app.c +++ b/client/src/app.c @@ -1087,12 +1087,14 @@ bool app_useSpiceDisplay(bool enable) if (enable) { purespice_connectChannel(PS_CHANNEL_DISPLAY); + purespice_connectChannel(PS_CHANNEL_CURSOR); renderQueue_spiceShow(true); } else { renderQueue_spiceShow(false); purespice_disconnectChannel(PS_CHANNEL_DISPLAY); + purespice_disconnectChannel(PS_CHANNEL_CURSOR); } overlayStatus_set(LG_USER_STATUS_SPICE, enable); diff --git a/client/src/main.c b/client/src/main.c index b8b30160..58575866 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -923,6 +923,35 @@ static void spice_drawBitmap(unsigned int surfaceId, PSBitmapFormat format, renderQueue_spiceDrawBitmap(x, y, width, height, stride, data, topDown); } +static void spice_setCursorRGBAImage(int width, int height, int hx, int hy, + const void * data) +{ + g_state.spiceHotX = hx; + g_state.spiceHotY = hy; + + void * copied = malloc(width * height * 4); + memcpy(copied, data, width * height * 4); + renderQueue_cursorImage(false, width, height, width * 4, copied); +} + +static void spice_setCursorMonoImage(int width, int height, int hx, int hy, + const void * xorMask, const void * andMask) +{ + g_state.spiceHotX = hx; + g_state.spiceHotY = hy; + + int stride = (width + 7) / 8; + uint8_t * buffer = malloc(stride * height * 2); + memcpy(buffer, xorMask, stride * height); + memcpy(buffer + stride * height, andMask, stride * height); + renderQueue_cursorImage(true, width, height * 2, stride, buffer); +} + +static void spice_setCursorState(bool visible, int x, int y) +{ + renderQueue_cursorState(visible, x, y, g_state.spiceHotX, g_state.spiceHotY); +} + int spiceThread(void * arg) { if (g_params.useSpiceAudio) @@ -956,6 +985,14 @@ int spiceThread(void * arg) .drawFill = spice_drawFill, .drawBitmap = spice_drawBitmap }, + .cursor = + { + .enable = true, + .autoConnect = false, + .setRGBAImage = spice_setCursorRGBAImage, + .setMonoImage = spice_setCursorMonoImage, + .setState = spice_setCursorState, + }, #if ENABLE_AUDIO .playback = { diff --git a/client/src/main.h b/client/src/main.h index 9769cc45..3f9b6a2f 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -150,6 +150,8 @@ struct AppState bool autoIdleInhibitState; enum MicDefaultState micDefaultState; + + int spiceHotX, spiceHotY; }; struct AppParams