mirror of
https://github.com/Genymobile/scrcpy
synced 2024-12-11 09:46:53 +00:00
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,11 +25,20 @@ 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;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
|
Loading…
Reference in New Issue
Block a user