-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[Clipboard] copy/paste outside scrcpy got truncated #1580
Comments
This is very weird. So you copy-paste from a desktop application to another desktop application, which do not involve the device?
Only in one direction: if the device clipboard is updated, it is copied to the computer clipboard. This allows to copy some text from the device, then just press Ctrl+v on the computer. But if your computer clipboard is updated, it is not automatically sent to the device (this would cause a security issue, because copying a password on the computer would send it to the device, and all apps could listen). Instead, it is only sent on Ctrl(+shift)+v. Could you screen-capture the behavior you describe, please? How do you copy-paste between your applications? Ctrl+c/Ctrl+v? Does it also happen when you right-click, then click on "paste" (in an app having such a menu)?
scrcpy should not receive these keys at all if it doesn't have focus.
Already done on |
Please retest with these changes (adding more logs): diffdiff --git a/app/src/input_manager.c b/app/src/input_manager.c
index e8ba9f79..accffb8b 100644
--- a/app/src/input_manager.c
+++ b/app/src/input_manager.c
@@ -106,6 +106,8 @@ request_device_clipboard(struct controller *controller) {
struct control_msg msg;
msg.type = CONTROL_MSG_TYPE_GET_CLIPBOARD;
+ LOGI("request_device_clipboard");
+
if (!controller_push_msg(controller, &msg)) {
LOGW("Could not request device clipboard");
}
@@ -124,6 +126,9 @@ set_device_clipboard(struct controller *controller, bool paste) {
return;
}
+ LOGI("set_device_clipboard (%s): %d", paste ? "paste" : "-",
+ (int) strlen(text));
+
struct control_msg msg;
msg.type = CONTROL_MSG_TYPE_SET_CLIPBOARD;
msg.set_clipboard.text = text;
diff --git a/app/src/receiver.c b/app/src/receiver.c
index 0474ff55..c30678c0 100644
--- a/app/src/receiver.c
+++ b/app/src/receiver.c
@@ -26,7 +26,8 @@ static void
process_msg(struct device_msg *msg) {
switch (msg->type) {
case DEVICE_MSG_TYPE_CLIPBOARD:
- LOGI("Device clipboard copied");
+ LOGI("Device clipboard copied %d",
+ (int) strlen(msg->clipboard.text));
SDL_SetClipboardText(msg->clipboard.text);
break;
}
diff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java
index 960c6a6e..e4ebc32a 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Controller.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java
@@ -105,12 +105,14 @@ public class Controller {
break;
case ControlMessage.TYPE_GET_CLIPBOARD:
String clipboardText = device.getClipboardText();
+ Ln.i("GET_CLIPBOARD: " + (clipboardText != null ? clipboardText.length() : "null"));
if (clipboardText != null) {
sender.pushClipboardText(clipboardText);
}
break;
case ControlMessage.TYPE_SET_CLIPBOARD:
boolean paste = (msg.getFlags() & ControlMessage.FLAGS_PASTE) != 0;
+ Ln.i("SET_CLIPBOARD (" + paste + "): " + msg.getText().length());
setClipboard(msg.getText(), paste);
break;
case ControlMessage.TYPE_SET_SCREEN_POWER_MODE:
@@ -195,6 +197,7 @@ public class Controller {
}
}
+ Ln.i("point = " + point);
MotionEvent event = MotionEvent
.obtain(lastTouchDown, now, action, pointerCount, pointerProperties, pointerCoords, 0, buttons, 1f, 1f, DEVICE_ID_VIRTUAL, 0,
InputDevice.SOURCE_TOUCHSCREEN, 0);
diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java
index 44b3afd4..a14f671b 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Server.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Server.java
@@ -66,6 +66,7 @@ public final class Server {
device.setClipboardListener(new Device.ClipboardListener() {
@Override
public void onClipboardTextChanged(String text) {
+ Ln.i("onClipboardTextChanged(" + text.length() + ")");
controller.getSender().pushClipboardText(text);
}
}); (I also added a log for #1581)
(replace these files in your v1.14 release) Please post the console output (as text) + a video, it should help :) Thank you |
Below is the gif and the Console Output Console Dump
|
OK, thank you for the results. So the events outside the screen are correctly forwarded. Your device software just don't consider them for gestures. So I'm closing, there is no problem on scrcpy side. |
Sorry, wrong gif and Console Details
|
OK, so it seems that when you copy, the content is synchronized to your device clipboard (even without scrcpy). As a consequence, when scrcpy is open, the device clipboard change is synchronized back to the computer (but truncated). If you close scrcpy, copy some text in your VScode, can you paste it directly on your device in some text area (long-click, paste)? |
So I copy the text in vscode before open scrcpy. Then run scrcpy. I am able to paste my long content into some android text editor |
If you don't use scrcpy at all, copy some text (not necessarily long, just few characters) in VScode while your device is plugged, is the content automatically copied to the device clipboard? If you paste on the device, does it paste the content you just copied in VScode? |
Now that you mention it, yeah, it does sync my clipboard to the phone. I setup Microsot Your Phone but it is closed during the test and the clipboard still sync |
I think because I am beta build, they have that clipboard auto sync. I disable feature and it is good now. |
👍 Btw, that's a worrying feature: anytime you copy something on your computer (even without pasting to the device), the content is sent to the device (and to all the apps who can listen to the clipboard). I'm already worried that scrcpy will probably do that when you explicitly paste to the device: #1465 (comment) |
Environment
Describe the bug
A clear and concise description of what the bug is.
So this bug is when I copy/paste between programs outside of scrcpy but scrcpy is running in background
So I copy big text between vscode sessions, not copy to/from scrcpy but my text would be truncated at 4093 characters.
I suspect scrcpy keep reading clipboard and replace clipboard with what it see.
Below are my console log, the 2>&1 is for redirect all error to output pipe so you could ignore it
In below case, I only did one copy/paste operation but scrcpy keep coping forever
On errors, please provide the output of the console (and
adb logcat
if relevant).Please do not post screenshots of your terminal, just post the content as text instead.
The text was updated successfully, but these errors were encountered: