[client] spice: separate clipboard state by direction

This commit is contained in:
Geoffrey McRae
2026-07-28 13:10:38 +10:00
parent e4658b4263
commit a5571f0e9e
4 changed files with 20 additions and 10 deletions

View File

@@ -289,9 +289,9 @@ void app_clipboardNotifySize(const LG_ClipboardData type, size_t size)
return; return;
} }
g_state.cbType = spiceType; g_state.cbWriteType = spiceType;
g_state.cbChunked = true; g_state.cbChunked = true;
g_state.cbXfer = size; g_state.cbXfer = size;
} }
void app_clipboardData(const LG_ClipboardData type, uint8_t * data, size_t size) void app_clipboardData(const LG_ClipboardData type, uint8_t * data, size_t size)
@@ -311,7 +311,7 @@ void app_clipboardData(const LG_ClipboardData type, uint8_t * data, size_t size)
if (g_state.cbChunked) if (g_state.cbChunked)
{ {
if (spiceType != g_state.cbType) if (spiceType != g_state.cbWriteType)
{ {
DEBUG_ERROR("SPICE clipboard transfer type changed"); DEBUG_ERROR("SPICE clipboard transfer type changed");
return; return;
@@ -332,8 +332,8 @@ void app_clipboardData(const LG_ClipboardData type, uint8_t * data, size_t size)
g_state.cbXfer -= size; g_state.cbXfer -= size;
if (g_state.cbXfer == 0) if (g_state.cbXfer == 0)
{ {
g_state.cbType = SPICE_DATA_NONE; g_state.cbWriteType = SPICE_DATA_NONE;
g_state.cbChunked = false; g_state.cbChunked = false;
} }
return; return;
} }
@@ -353,7 +353,8 @@ bool app_clipboardRequest(const LG_ClipboardReplyFn replyFn, void * opaque)
if (!g_params.clipboardToLocal || !replyFn || !g_state.cbRequestList) if (!g_params.clipboardToLocal || !replyFn || !g_state.cbRequestList)
return false; return false;
const PSDataType type = g_state.cbType; const PSDataType type = atomic_load_explicit(
&g_state.cbRemoteType, memory_order_acquire);
struct CBRequest * cbr = malloc(sizeof(*cbr)); struct CBRequest * cbr = malloc(sizeof(*cbr));
if (!cbr) if (!cbr)
{ {

View File

@@ -62,7 +62,8 @@ void cb_spiceNotice(const PSDataType type)
if (!g_state.cbAvailable) if (!g_state.cbAvailable)
return; return;
g_state.cbType = type; atomic_store_explicit(
&g_state.cbRemoteType, type, memory_order_release);
g_state.ds->cbNotice(cb_spiceTypeToLGType(type)); g_state.ds->cbNotice(cb_spiceTypeToLGType(type));
} }
@@ -113,6 +114,9 @@ void cb_spiceRelease(void)
if (!g_params.clipboardToLocal) if (!g_params.clipboardToLocal)
return; return;
atomic_store_explicit(
&g_state.cbRemoteType, SPICE_DATA_NONE, memory_order_release);
if (g_state.cbAvailable) if (g_state.cbAvailable)
g_state.ds->cbRelease(); g_state.ds->cbRelease();
} }

View File

@@ -75,7 +75,11 @@ static LGEvent *e_spice = NULL;
static LGThread *t_spice = NULL; static LGThread *t_spice = NULL;
static LGThread *t_render = NULL; static LGThread *t_render = NULL;
struct AppState g_state = { 0 }; struct AppState g_state =
{
.cbRemoteType = SPICE_DATA_NONE,
.cbWriteType = SPICE_DATA_NONE,
};
struct CursorState g_cursor; struct CursorState g_cursor;
// this structure is initialized in config.c // this structure is initialized in config.c

View File

@@ -123,7 +123,8 @@ struct AppState
bool useDMA; bool useDMA;
bool cbAvailable; bool cbAvailable;
PSDataType cbType; _Atomic(PSDataType) cbRemoteType;
PSDataType cbWriteType;
bool cbChunked; bool cbChunked;
size_t cbXfer; size_t cbXfer;
struct ll * cbRequestList; struct ll * cbRequestList;