fix clipboard write to client from secondary screen

This commit is contained in:
matt 2023-12-21 15:46:11 +00:00
parent d51c5e37b7
commit 82e0100a97
1 changed files with 34 additions and 21 deletions

View File

@ -1738,6 +1738,11 @@ export default class RFB extends EventTargetMixin {
this._mouseLastScreenIndex = event.data.mouseLastScreenIndex;
}
break;
case 'receivedClipboard':
if (event.data.mouseLastScreenIndex === this._display.screenIndex) {
this._write_binary_clipboard(...event.data.args);
}
break;
case 'disconnect':
this.disconnect();
break;
@ -3216,33 +3221,41 @@ export default class RFB extends EventTargetMixin {
if (this.clipboardBinary) {
this._clipHash = 0;
navigator.clipboard.write([new ClipboardItem(clipItemData)]).then(
() => {
if (textdata) {
this._clipHash = hashUInt8Array(textdata);
}
},
(err) => {
Log.Error("Error writing to client clipboard: " + err);
// Lets try writeText
if (textdata.length > 0) {
navigator.clipboard.writeText(textdata).then(
() => {
this._clipHash = hashUInt8Array(textdata);
},
(err) => {
Log.Error("Error writing text to client clipboard: " + err);
}
);
}
}
);
if (this._mouseLastScreenIndex === 0) {
this._write_binary_clipboard(clipItemData, textdata)
} else {
this._proxyRFBMessage('receivedClipboard', [ clipItemData, textdata ]);
}
}
}
return true;
}
_write_binary_clipboard(clipItemData, textdata) {
navigator.clipboard.write([new ClipboardItem(clipItemData)]).then(
() => {
if (textdata) {
this._clipHash = hashUInt8Array(textdata);
}
},
(err) => {
Log.Error("Error writing to client clipboard: " + err);
// Lets try writeText
if (textdata.length > 0) {
navigator.clipboard.writeText(textdata).then(
() => {
this._clipHash = hashUInt8Array(textdata);
},
(err) => {
Log.Error("Error writing text to client clipboard: " + err);
}
);
}
}
);
}
_handle_server_stats_msg() {
this._sock.rQskipBytes(3); // Padding
const length = this._sock.rQshift32();