mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-20 03:25:03 +00:00
Simplify PASTE option for "set clipboard"
When the client requests to set the clipboard, it may request to press the PASTE key in addition. To be a bit generic, it was stored as a flag in ControlMessage.java. But flags suggest that it represents a bitwise union, which could become confusing when we add a COPY option for getting the clipboard.
This commit is contained in:
parent
149de2f788
commit
51d969b20c
3 changed files with 7 additions and 16 deletions
|
@ -17,8 +17,6 @@ public final class ControlMessage {
|
|||
public static final int TYPE_SET_SCREEN_POWER_MODE = 9;
|
||||
public static final int TYPE_ROTATE_DEVICE = 10;
|
||||
|
||||
public static final int FLAGS_PASTE = 1;
|
||||
|
||||
private int type;
|
||||
private String text;
|
||||
private int metaState; // KeyEvent.META_*
|
||||
|
@ -30,7 +28,7 @@ public final class ControlMessage {
|
|||
private Position position;
|
||||
private int hScroll;
|
||||
private int vScroll;
|
||||
private int flags;
|
||||
private boolean paste;
|
||||
|
||||
private ControlMessage() {
|
||||
}
|
||||
|
@ -75,9 +73,7 @@ public final class ControlMessage {
|
|||
ControlMessage msg = new ControlMessage();
|
||||
msg.type = TYPE_SET_CLIPBOARD;
|
||||
msg.text = text;
|
||||
if (paste) {
|
||||
msg.flags = FLAGS_PASTE;
|
||||
}
|
||||
msg.paste = paste;
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
@ -141,7 +137,7 @@ public final class ControlMessage {
|
|||
return vScroll;
|
||||
}
|
||||
|
||||
public int getFlags() {
|
||||
return flags;
|
||||
public boolean getPaste() {
|
||||
return paste;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,8 +110,7 @@ public class Controller {
|
|||
}
|
||||
break;
|
||||
case ControlMessage.TYPE_SET_CLIPBOARD:
|
||||
boolean paste = (msg.getFlags() & ControlMessage.FLAGS_PASTE) != 0;
|
||||
setClipboard(msg.getText(), paste);
|
||||
setClipboard(msg.getText(), msg.getPaste());
|
||||
break;
|
||||
case ControlMessage.TYPE_SET_SCREEN_POWER_MODE:
|
||||
if (device.supportsInputEvents()) {
|
||||
|
|
|
@ -228,9 +228,7 @@ public class ControlMessageReaderTest {
|
|||
|
||||
Assert.assertEquals(ControlMessage.TYPE_SET_CLIPBOARD, event.getType());
|
||||
Assert.assertEquals("testé", event.getText());
|
||||
|
||||
boolean parse = (event.getFlags() & ControlMessage.FLAGS_PASTE) != 0;
|
||||
Assert.assertTrue(parse);
|
||||
Assert.assertTrue(event.getPaste());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -256,9 +254,7 @@ public class ControlMessageReaderTest {
|
|||
|
||||
Assert.assertEquals(ControlMessage.TYPE_SET_CLIPBOARD, event.getType());
|
||||
Assert.assertEquals(text, event.getText());
|
||||
|
||||
boolean parse = (event.getFlags() & ControlMessage.FLAGS_PASTE) != 0;
|
||||
Assert.assertTrue(parse);
|
||||
Assert.assertTrue(event.getPaste());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Reference in a new issue