KASM-1947 binary clipboard WIP

This commit is contained in:
matt 2021-09-16 19:16:49 +00:00
parent effc0eee02
commit f165845c2d
1 changed files with 18 additions and 1 deletions

View File

@ -2392,6 +2392,8 @@ export default class RFB extends EventTargetMixin {
Log.Debug("HandleBinaryClipboard"); Log.Debug("HandleBinaryClipboard");
let num = this._sock.rQshift8(); // how many different mime types let num = this._sock.rQshift8(); // how many different mime types
let blobs = [];
let clipdata = [];
for (let i = 0; i < num; i++) { for (let i = 0; i < num; i++) {
let mimelen = this._sock.rQshift8(); let mimelen = this._sock.rQshift8();
@ -2399,10 +2401,25 @@ export default class RFB extends EventTargetMixin {
let len = this._sock.rQshift32(); let len = this._sock.rQshift32();
const data = this._sock.rQshiftStr(len); const data = this._sock.rQshiftBytes(len);
// TODO, what do we do with this? // TODO, what do we do with this?
console.log("Mime " + mime + ", len ", len); console.log("Mime " + mime + ", len ", len);
switch(mime) {
case "image/png":
let blob = new Blob([data], { type: mime });
clipdata.push(new ClipboardItem({ [mime]: blob }));
break;
}
}
if (clipdata.length > 0) {
navigator.clipboard.write(clipdata).then(
function() {},
function(err) {
console.log("Error writing to client clipboard: " + err);
});
} }
return true; return true;