mirror of https://github.com/Genymobile/scrcpy
Set computer clipboard only if necessary
Do not explicitly set the clipboard text if it already contains the expected content. Even if copy-paste loops are avoided by the previous commit, this avoids to trigger a clipboard change on the computer-side. Refs #1580 <https://github.com/Genymobile/scrcpy/issues/1580>
This commit is contained in:
parent
1223a72eb8
commit
20d3925099
|
@ -25,12 +25,21 @@ receiver_destroy(struct receiver *receiver) {
|
|||
static void
|
||||
process_msg(struct device_msg *msg) {
|
||||
switch (msg->type) {
|
||||
case DEVICE_MSG_TYPE_CLIPBOARD:
|
||||
case DEVICE_MSG_TYPE_CLIPBOARD: {
|
||||
char *current = SDL_GetClipboardText();
|
||||
bool same = current && !strcmp(current, msg->clipboard.text);
|
||||
SDL_free(current);
|
||||
if (same) {
|
||||
LOGD("Computer clipboard unchanged");
|
||||
return;
|
||||
}
|
||||
|
||||
LOGI("Device clipboard copied");
|
||||
SDL_SetClipboardText(msg->clipboard.text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
process_msgs(const unsigned char *buf, size_t len) {
|
||||
|
|
Loading…
Reference in New Issue