mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 07:01:30 +00:00
[common] clipboard: enlarge transfer buffers
This commit is contained in:
@@ -1040,7 +1040,7 @@ struct ClipboardWrite
|
|||||||
bool pollRegistered;
|
bool pollRegistered;
|
||||||
bool streamActive;
|
bool streamActive;
|
||||||
bool requesting;
|
bool requesting;
|
||||||
uint8_t buffer[KVMFR_CLIPBOARD_DATA_BYTES];
|
uint8_t buffer[KVMFR_CLIPBOARD_REPRESENTATION_BYTES];
|
||||||
};
|
};
|
||||||
|
|
||||||
static void clipboardWriteDestroy(struct ClipboardWrite * data)
|
static void clipboardWriteDestroy(struct ClipboardWrite * data)
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ struct ClipboardRead
|
|||||||
bool calling;
|
bool calling;
|
||||||
bool readyPending;
|
bool readyPending;
|
||||||
bool eof;
|
bool eof;
|
||||||
uint8_t buffer[KVMFR_CLIPBOARD_DATA_BYTES];
|
uint8_t buffer[KVMFR_CLIPBOARD_REPRESENTATION_BYTES];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WCBState
|
struct WCBState
|
||||||
|
|||||||
@@ -206,8 +206,9 @@ bool x11CBEventThread(const XEvent * xe)
|
|||||||
const size_t remaining = write->fileSize - (size_t)write->offset;
|
const size_t remaining = write->fileSize - (size_t)write->offset;
|
||||||
if (remaining)
|
if (remaining)
|
||||||
{
|
{
|
||||||
const size_t chunk = remaining > KVMFR_CLIPBOARD_DATA_BYTES ?
|
const size_t chunk =
|
||||||
KVMFR_CLIPBOARD_DATA_BYTES : remaining;
|
remaining > KVMFR_CLIPBOARD_REPRESENTATION_BYTES ?
|
||||||
|
KVMFR_CLIPBOARD_REPRESENTATION_BYTES : remaining;
|
||||||
XChangeProperty(x11.display,
|
XChangeProperty(x11.display,
|
||||||
write->event.xselection.requestor,
|
write->event.xselection.requestor,
|
||||||
write->event.xselection.property,
|
write->event.xselection.property,
|
||||||
@@ -357,7 +358,8 @@ static LG_ClipboardResult x11CBWriteChunk(void * opaque,
|
|||||||
LG_UNLOCK(x11cb.lock);
|
LG_UNLOCK(x11cb.lock);
|
||||||
return LG_CLIPBOARD_RESULT_BLOCKED;
|
return LG_CLIPBOARD_RESULT_BLOCKED;
|
||||||
}
|
}
|
||||||
if (offset != write->offset || size > KVMFR_CLIPBOARD_DATA_BYTES)
|
if (offset != write->offset ||
|
||||||
|
size > KVMFR_CLIPBOARD_REPRESENTATION_BYTES)
|
||||||
{
|
{
|
||||||
LG_UNLOCK(x11cb.lock);
|
LG_UNLOCK(x11cb.lock);
|
||||||
return LG_CLIPBOARD_RESULT_FAILED;
|
return LG_CLIPBOARD_RESULT_FAILED;
|
||||||
@@ -978,7 +980,7 @@ static void x11CBFileImportIncr(const XPropertyEvent e)
|
|||||||
readProperty:
|
readProperty:
|
||||||
if (XGetWindowProperty(e.display, e.window, e.atom,
|
if (XGetWindowProperty(e.display, e.window, e.atom,
|
||||||
x11cb.fileImport.propertyOffset,
|
x11cb.fileImport.propertyOffset,
|
||||||
(KVMFR_CLIPBOARD_DATA_BYTES + 3U) / 4U,
|
(KVMFR_CLIPBOARD_REPRESENTATION_BYTES + 3U) / 4U,
|
||||||
True, AnyPropertyType, &type, &format, &itemCount, &after,
|
True, AnyPropertyType, &type, &format, &itemCount, &after,
|
||||||
&data) != Success || (itemCount && !data) || (!itemCount && after) ||
|
&data) != Success || (itemCount && !data) || (!itemCount && after) ||
|
||||||
type != x11cb.fileImport.target || format != 8 ||
|
type != x11cb.fileImport.target || format != 8 ||
|
||||||
@@ -1136,7 +1138,7 @@ readProperty:
|
|||||||
e.window,
|
e.window,
|
||||||
e.atom,
|
e.atom,
|
||||||
x11cb.read.propertyOffset,
|
x11cb.read.propertyOffset,
|
||||||
(KVMFR_CLIPBOARD_DATA_BYTES + 3U) / 4U,
|
(KVMFR_CLIPBOARD_REPRESENTATION_BYTES + 3U) / 4U,
|
||||||
True, // delete the property
|
True, // delete the property
|
||||||
AnyPropertyType,
|
AnyPropertyType,
|
||||||
&type,
|
&type,
|
||||||
@@ -1198,7 +1200,7 @@ readProperty:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemCount > KVMFR_CLIPBOARD_DATA_BYTES)
|
if (itemCount > KVMFR_CLIPBOARD_REPRESENTATION_BYTES)
|
||||||
{
|
{
|
||||||
const struct X11ClipboardRead read = clearReadNL();
|
const struct X11ClipboardRead read = clearReadNL();
|
||||||
LG_UNLOCK(x11cb.lock);
|
LG_UNLOCK(x11cb.lock);
|
||||||
|
|||||||
@@ -35,12 +35,18 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define TEST_SHM_SIZE (8U * 1024U * 1024U)
|
|
||||||
#define TEST_WAIT_MS 2500U
|
#define TEST_WAIT_MS 2500U
|
||||||
#define TEST_QUIET_MS 50U
|
#define TEST_QUIET_MS 50U
|
||||||
#define TEST_MEMORY_MAX 128U
|
#define TEST_MEMORY_MAX 128U
|
||||||
#define SLOT_BYTES \
|
#define SLOT_BYTES \
|
||||||
(sizeof(KVMFRClipboardSlotHeader) + KVMFR_CLIPBOARD_DATA_BYTES)
|
(sizeof(KVMFRClipboardSlotHeader) + KVMFR_CLIPBOARD_DATA_BYTES)
|
||||||
|
#define TEST_TRANSIENT_SLOTS 4U
|
||||||
|
#define TEST_SHM_OVERHEAD (1024U * 1024U)
|
||||||
|
/* Match the production inbound and outbound slot pools, retain several
|
||||||
|
* synthetic host DATA records at once, and leave room for LGMP metadata. */
|
||||||
|
#define TEST_SHM_SIZE \
|
||||||
|
((2U * KVMFR_CLIPBOARD_SLOT_COUNT + TEST_TRANSIENT_SLOTS) * SLOT_BYTES + \
|
||||||
|
TEST_SHM_OVERHEAD)
|
||||||
|
|
||||||
#define CHECK(x) \
|
#define CHECK(x) \
|
||||||
do \
|
do \
|
||||||
@@ -1219,6 +1225,10 @@ static bool testMalformedFileData(TestState * state)
|
|||||||
|
|
||||||
static bool testFileStream(TestState * state)
|
static bool testFileStream(TestState * state)
|
||||||
{
|
{
|
||||||
|
static uint8_t bytes[KVMFR_CLIPBOARD_FILE_READ_BYTES];
|
||||||
|
for (size_t i = 0; i < sizeof(bytes); ++i)
|
||||||
|
bytes[i] = (uint8_t)(i * 131U + 17U);
|
||||||
|
|
||||||
KVMFRClipboardMessage claimRecord;
|
KVMFRClipboardMessage claimRecord;
|
||||||
CHECK(claim(state, 78, false, &claimRecord));
|
CHECK(claim(state, 78, false, &claimRecord));
|
||||||
CHECK(own(state, 78, claimRecord.generation));
|
CHECK(own(state, 78, claimRecord.generation));
|
||||||
@@ -1251,7 +1261,7 @@ static bool testFileStream(TestState * state)
|
|||||||
request.offset = 123;
|
request.offset = 123;
|
||||||
request.size = 42;
|
request.size = 42;
|
||||||
request.format = KVMFR_CLIPBOARD_FORMAT_FILES;
|
request.format = KVMFR_CLIPBOARD_FORMAT_FILES;
|
||||||
request.flags = 3;
|
request.flags = sizeof(bytes);
|
||||||
request.token = KVMFR_CLIPBOARD_FILE_OP_READ;
|
request.token = KVMFR_CLIPBOARD_FILE_OP_READ;
|
||||||
CHECK(postRecord(state, &request,
|
CHECK(postRecord(state, &request,
|
||||||
KVMFR_CLIPBOARD_QUEUE_MESSAGE, NULL));
|
KVMFR_CLIPBOARD_QUEUE_MESSAGE, NULL));
|
||||||
@@ -1262,14 +1272,13 @@ static bool testFileStream(TestState * state)
|
|||||||
CHECK(descriptor.request == request.transfer);
|
CHECK(descriptor.request == request.transfer);
|
||||||
CHECK(descriptor.node == 42);
|
CHECK(descriptor.node == 42);
|
||||||
CHECK(descriptor.offset == 123);
|
CHECK(descriptor.offset == 123);
|
||||||
CHECK(descriptor.length == 3);
|
CHECK(descriptor.length == sizeof(bytes));
|
||||||
CHECK(descriptor.operation == LG_CLIPBOARD_FILE_READ);
|
CHECK(descriptor.operation == LG_CLIPBOARD_FILE_READ);
|
||||||
CHECK(state->ops->fileDataBegin(state->clipboard,
|
CHECK(state->ops->fileDataBegin(state->clipboard,
|
||||||
&descriptor, 3) == LG_CLIPBOARD_RESULT_ACCEPTED);
|
&descriptor, sizeof(bytes)) == LG_CLIPBOARD_RESULT_ACCEPTED);
|
||||||
|
|
||||||
CHECK(postGrant(state, claimRecord.generation, 1));
|
CHECK(postGrant(state, claimRecord.generation, 1));
|
||||||
CHECK(waitMemory(state, state->grantMemory[0]));
|
CHECK(waitMemory(state, state->grantMemory[0]));
|
||||||
static const uint8_t bytes[] = { 9, 8, 7 };
|
|
||||||
CHECK(state->ops->fileDataChunk(state->clipboard,
|
CHECK(state->ops->fileDataChunk(state->clipboard,
|
||||||
&descriptor, 0, bytes, sizeof(bytes)) ==
|
&descriptor, 0, bytes, sizeof(bytes)) ==
|
||||||
LG_CLIPBOARD_RESULT_ACCEPTED);
|
LG_CLIPBOARD_RESULT_ACCEPTED);
|
||||||
@@ -1278,16 +1287,19 @@ static bool testFileStream(TestState * state)
|
|||||||
const void * data;
|
const void * data;
|
||||||
CHECK(checkFileCommit(state, 1, &commit, &slot, &data));
|
CHECK(checkFileCommit(state, 1, &commit, &slot, &data));
|
||||||
CHECK(slot.flags == KVMFR_CLIPBOARD_FLAG_BEGIN);
|
CHECK(slot.flags == KVMFR_CLIPBOARD_FLAG_BEGIN);
|
||||||
CHECK(slot.offset == 0 && slot.sequence == 0 && slot.size == 3);
|
CHECK(slot.offset == 0 && slot.sequence == 0 &&
|
||||||
|
slot.size == sizeof(bytes));
|
||||||
|
CHECK(slot.length == sizeof(bytes));
|
||||||
CHECK(memcmp(data, bytes, sizeof(bytes)) == 0);
|
CHECK(memcmp(data, bytes, sizeof(bytes)) == 0);
|
||||||
|
|
||||||
CHECK(postGrant(state, claimRecord.generation, 1));
|
CHECK(postGrant(state, claimRecord.generation, 1));
|
||||||
CHECK(waitMemory(state, state->grantMemory[0]));
|
CHECK(waitMemory(state, state->grantMemory[0]));
|
||||||
CHECK(state->ops->fileDataEnd(state->clipboard,
|
CHECK(state->ops->fileDataEnd(state->clipboard,
|
||||||
&descriptor, 3) == LG_CLIPBOARD_RESULT_ACCEPTED);
|
&descriptor, sizeof(bytes)) == LG_CLIPBOARD_RESULT_ACCEPTED);
|
||||||
CHECK(checkFileCommit(state, 1, &commit, &slot, &data));
|
CHECK(checkFileCommit(state, 1, &commit, &slot, &data));
|
||||||
CHECK(slot.flags == KVMFR_CLIPBOARD_FLAG_END);
|
CHECK(slot.flags == KVMFR_CLIPBOARD_FLAG_END);
|
||||||
CHECK(slot.offset == 3 && slot.sequence == 1 && slot.size == 3);
|
CHECK(slot.offset == sizeof(bytes) && slot.sequence == 1 &&
|
||||||
|
slot.size == sizeof(bytes));
|
||||||
CHECK(slot.length == 0);
|
CHECK(slot.length == 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#include "KVMFRInput.h"
|
#include "KVMFRInput.h"
|
||||||
|
|
||||||
#define KVMFR_MAGIC "KVMFR---"
|
#define KVMFR_MAGIC "KVMFR---"
|
||||||
#define KVMFR_VERSION 31
|
#define KVMFR_VERSION 32
|
||||||
|
|
||||||
// Fallback used by producers that cannot report the source display's SDR
|
// Fallback used by producers that cannot report the source display's SDR
|
||||||
// white level. IDD frames override this with IDDCX_METADATA2::SdrWhiteLevel.
|
// white level. IDD frames override this with IDDCX_METADATA2::SdrWhiteLevel.
|
||||||
|
|||||||
@@ -26,9 +26,12 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define KVMFR_CLIPBOARD_VERSION 2U
|
#define KVMFR_CLIPBOARD_VERSION 3U
|
||||||
#define KVMFR_CLIPBOARD_SLOT_COUNT 8U
|
#define KVMFR_CLIPBOARD_SLOT_COUNT 1U
|
||||||
#define KVMFR_CLIPBOARD_DATA_BYTES (64U * 1024U)
|
#define KVMFR_CLIPBOARD_DATA_BYTES (1024U * 1024U)
|
||||||
|
/* Keep text and image chunks within the core X11 request limit. File data can
|
||||||
|
* use the full slot without passing through XChangeProperty. */
|
||||||
|
#define KVMFR_CLIPBOARD_REPRESENTATION_BYTES (64U * 1024U)
|
||||||
#define KVMFR_CLIPBOARD_SIZE_UNKNOWN UINT64_MAX
|
#define KVMFR_CLIPBOARD_SIZE_UNKNOWN UINT64_MAX
|
||||||
#define KVMFR_CLIPBOARD_FILE_READ_BYTES (1024U * 1024U)
|
#define KVMFR_CLIPBOARD_FILE_READ_BYTES (1024U * 1024U)
|
||||||
#define KVMFR_CLIPBOARD_FILE_ROOT_NODE UINT64_C(0)
|
#define KVMFR_CLIPBOARD_FILE_ROOT_NODE UINT64_C(0)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
static constexpr uint32_t LG_CLIPBOARD_MAPPING_MAGIC = 0x4c474342U;
|
static constexpr uint32_t LG_CLIPBOARD_MAPPING_MAGIC = 0x4c474342U;
|
||||||
static constexpr uint32_t LG_CLIPBOARD_MAPPING_VERSION = 2U;
|
static constexpr uint32_t LG_CLIPBOARD_MAPPING_VERSION = 3U;
|
||||||
|
|
||||||
struct ClipboardRingSlot
|
struct ClipboardRingSlot
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class CLGMPHost;
|
|||||||
class CLGMPClipboardTransport final : public IClipboardSource
|
class CLGMPClipboardTransport final : public IClipboardSource
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static constexpr unsigned MEMORY_COUNT = 8;
|
static constexpr unsigned MEMORY_COUNT = KVMFR_CLIPBOARD_SLOT_COUNT;
|
||||||
static constexpr unsigned INTERNAL_TARGET_COUNT =
|
static constexpr unsigned INTERNAL_TARGET_COUNT =
|
||||||
CLGMPClipboardFiles::MAX_ACQUISITIONS +
|
CLGMPClipboardFiles::MAX_ACQUISITIONS +
|
||||||
CLGMPClipboardFiles::MAX_REQUESTS + 3;
|
CLGMPClipboardFiles::MAX_REQUESTS + 3;
|
||||||
|
|||||||
@@ -457,7 +457,7 @@ namespace
|
|||||||
std::vector<uint8_t> buffer;
|
std::vector<uint8_t> buffer;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
buffer.resize(KVMFR_CLIPBOARD_DATA_BYTES);
|
buffer.resize(KVMFR_CLIPBOARD_REPRESENTATION_BYTES);
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc&)
|
catch (const std::bad_alloc&)
|
||||||
{
|
{
|
||||||
@@ -1653,7 +1653,8 @@ void CClipboardManager::ProcessSendData(Work&& work)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const size_t length = static_cast<size_t>((std::min<uint64_t>)(
|
const size_t length = static_cast<size_t>((std::min<uint64_t>)(
|
||||||
KVMFR_CLIPBOARD_DATA_BYTES, total - work.record.offset));
|
KVMFR_CLIPBOARD_REPRESENTATION_BYTES,
|
||||||
|
total - work.record.offset));
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
if (length)
|
if (length)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user