Skip to content

Commit

Permalink
ATRONIX: Support async read from clipboard
Browse files Browse the repository at this point in the history
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 2d7dc6e)
  • Loading branch information
Oldes committed Jan 25, 2019
1 parent 4148634 commit ac07bde
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/core/p-clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ac07bde

Please sign in to comment.