Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait SET_CLIPBOARD ack before Ctrl+v via HID #2814

Merged
merged 9 commits into from
Nov 24, 2021
Merged

Wait SET_CLIPBOARD ack before Ctrl+v via HID #2814

merged 9 commits into from
Nov 24, 2021

Conversation

rom1v
Copy link
Collaborator

@rom1v rom1v commented Nov 21, 2021

To allow seamless copy-paste (see v1.15 highlights), on Ctrl+v, a SET_CLIPBOARD request is performed before injecting Ctrl+v.

But when HID keyboard is enabled, the Ctrl+v injection is not sent on the same channel as the clipboard request, so they are not serialized, and may occur in any order. If Ctrl+v is injected before the new clipboard content is set, then the old content is pasted instead, which is incorrect.

To minimize the probability of occurrence of the wrong order, a delay of 2 milliseconds was added before injecting Ctrl+v: e416332. Then 5ms: 45b0f81. But even with 5ms, the wrong behavior sometimes happens.

To handle it properly, add an acknowledgement mechanism, so that Ctrl+v is injected over AOA only after the SET_CLIPBOARD request has been performed and acknowledged by the server.

Set the device clipboard to empty string if necessary. Otherwise, the
current device clipboard will be pasted on Ctrl+v.

PR #2814 <#2814>
This prevents to paste the current Android clipboard, which would be
unexpected.

PR #2814 <#2814>
Pass the information that device clipboard has been set to the key
processor. This avoids the keyprocessor to "guess", and paves the way to
implement a proper acknowledgement mechanism.

PR #2814 <#2814>
This will allow to send requests with sequence numbers to the server
and wait for acknowledgements.

PR #2814 <#2814>
This will allow the client to request an acknowledgement.

PR #2814 <#2814>
Add a device message type so that the device could send acknowledgements
for SET_CLIPBOARD requests.

PR #2814 <#2814>
If the client provided a sequence number on SET_CLIPBOARD request, make
the device send back an acknowledgement once the clipboard is set.

PR #2814 <#2814>
So that we can use it from several files.

PR #2814 <#2814>
To allow seamless copy-paste, on Ctrl+v, a SET_CLIPBOARD request is
performed before injecting Ctrl+v.

But when HID keyboard is enabled, the Ctrl+v injection is not sent on
the same channel as the clipboard request, so they are not serialized,
and may occur in any order. If Ctrl+v happens to be injected before the
new clipboard content is set, then the old content is pasted instead,
which is incorrect.

To minimize the probability of occurrence of the wrong order, a delay of
2 milliseconds was added before injecting Ctrl+v. Then 5ms. But even
with 5ms, the wrong behavior sometimes happens.

To handle it properly, add an acknowledgement mechanism, so that Ctrl+v
is injected over AOA only after the SET_CLIPBOARD request has been
performed and acknowledged by the server.

Refs e416332
Refs 45b0f81

PR #2814 <#2814>
@rom1v rom1v merged commit 5d17bcf into dev Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant