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
1 changed files with 10 additions and 1 deletions
|
@ -25,10 +25,19 @@ receiver_destroy(struct receiver *receiver) {
|
||||||
static void
|
static void
|
||||||
process_msg(struct device_msg *msg) {
|
process_msg(struct device_msg *msg) {
|
||||||
switch (msg->type) {
|
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");
|
LOGI("Device clipboard copied");
|
||||||
SDL_SetClipboardText(msg->clipboard.text);
|
SDL_SetClipboardText(msg->clipboard.text);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue