From ac07bde81a67e0b69eb677a6295e5f3868a41ca5 Mon Sep 17 00:00:00 2001 From: Oldes Date: Thu, 3 Jan 2019 15:29:43 +0100 Subject: [PATCH] ATRONIX: Support async read from clipboard In case that read doesn't returns the data immediately, it needs to move the data from port/state/data to port/data for later reading. Currently the implementation assumes that the clipboard can be read in one read when it's ready, which means a partial clipboard read is not allowed. (cherry picked from commit 2d7dc6e92fde7286a9304de9df82690c2f85d282) --- src/core/p-clipboard.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/core/p-clipboard.c b/src/core/p-clipboard.c index 7d3fdce74f..db5cf92f36 100644 --- a/src/core/p-clipboard.c +++ b/src/core/p-clipboard.c @@ -50,6 +50,24 @@ req = Use_Port_State(port, RDI_CLIPBOARD, sizeof(REBREQ)); switch (action) { + case A_UPDATE: + // Update the port object after a READ or WRITE operation. + // This is normally called by the WAKE-UP function. + arg = OFV(port, STD_PORT_DATA); + if (req->command == RDC_READ) { + len = req->actual; + if (GET_FLAG(req->flags, RRF_WIDE)) { + len /= sizeof(REBUNI); //correct length + // Copy the string (convert to latin-8 if it fits): + Set_Binary(arg, Copy_Wide_Str(req->data, len)); + } else { + Set_Binary(arg, Copy_OS_Str(req->data, len)); + } + } + else if (req->command == RDC_WRITE) { + SET_NONE(arg); // Write is done. + } + return R_NONE; case A_READ: // This device is opened on the READ: