[client] main: add support for spice cursor channel

This commit is contained in:
Quantum 2022-09-18 20:30:18 -04:00 committed by Geoffrey McRae
parent 1fd00ba26c
commit 0c63a901be
3 changed files with 41 additions and 0 deletions

View File

@ -1087,12 +1087,14 @@ bool app_useSpiceDisplay(bool enable)
if (enable) if (enable)
{ {
purespice_connectChannel(PS_CHANNEL_DISPLAY); purespice_connectChannel(PS_CHANNEL_DISPLAY);
purespice_connectChannel(PS_CHANNEL_CURSOR);
renderQueue_spiceShow(true); renderQueue_spiceShow(true);
} }
else else
{ {
renderQueue_spiceShow(false); renderQueue_spiceShow(false);
purespice_disconnectChannel(PS_CHANNEL_DISPLAY); purespice_disconnectChannel(PS_CHANNEL_DISPLAY);
purespice_disconnectChannel(PS_CHANNEL_CURSOR);
} }
overlayStatus_set(LG_USER_STATUS_SPICE, enable); overlayStatus_set(LG_USER_STATUS_SPICE, enable);

View File

@ -923,6 +923,35 @@ static void spice_drawBitmap(unsigned int surfaceId, PSBitmapFormat format,
renderQueue_spiceDrawBitmap(x, y, width, height, stride, data, topDown); 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) int spiceThread(void * arg)
{ {
if (g_params.useSpiceAudio) if (g_params.useSpiceAudio)
@ -956,6 +985,14 @@ int spiceThread(void * arg)
.drawFill = spice_drawFill, .drawFill = spice_drawFill,
.drawBitmap = spice_drawBitmap .drawBitmap = spice_drawBitmap
}, },
.cursor =
{
.enable = true,
.autoConnect = false,
.setRGBAImage = spice_setCursorRGBAImage,
.setMonoImage = spice_setCursorMonoImage,
.setState = spice_setCursorState,
},
#if ENABLE_AUDIO #if ENABLE_AUDIO
.playback = .playback =
{ {

View File

@ -150,6 +150,8 @@ struct AppState
bool autoIdleInhibitState; bool autoIdleInhibitState;
enum MicDefaultState micDefaultState; enum MicDefaultState micDefaultState;
int spiceHotX, spiceHotY;
}; };
struct AppParams struct AppParams