Skip to content

Commit

Permalink
Move acknowledgement handling
Browse files Browse the repository at this point in the history
Handle all actions related to SET_CLIPBOARD from the dedicated method.
  • Loading branch information
rom1v committed Nov 29, 2021
1 parent 2c64e7f commit 27c6cf2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions server/src/main/java/com/genymobile/scrcpy/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,7 @@ private void handleEvent() throws IOException {
}
break;
case ControlMessage.TYPE_SET_CLIPBOARD:
long sequence = msg.getSequence();
setClipboard(msg.getText(), msg.getPaste());
if (sequence != ControlMessage.SEQUENCE_INVALID) {
// Acknowledgement requested
sender.pushAckClipboard(sequence);
}
setClipboard(msg.getText(), msg.getPaste(), msg.getSequence());
break;
case ControlMessage.TYPE_SET_SCREEN_POWER_MODE:
if (device.supportsInputEvents()) {
Expand Down Expand Up @@ -281,7 +276,7 @@ private boolean pressBackOrTurnScreenOn(int action) {
return device.pressReleaseKeycode(KeyEvent.KEYCODE_POWER);
}

private boolean setClipboard(String text, boolean paste) {
private boolean setClipboard(String text, boolean paste, long sequence) {
boolean ok = device.setClipboardText(text);
if (ok) {
Ln.i("Device clipboard set");
Expand All @@ -292,6 +287,11 @@ private boolean setClipboard(String text, boolean paste) {
device.pressReleaseKeycode(KeyEvent.KEYCODE_PASTE);
}

if (sequence != ControlMessage.SEQUENCE_INVALID) {
// Acknowledgement requested
sender.pushAckClipboard(sequence);
}

return ok;
}
}

0 comments on commit 27c6cf2

Please sign in to comment.