From f165845c2db973dfef40b758775ad51cd7c43e79 Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 16 Sep 2021 19:16:49 +0000 Subject: [PATCH] KASM-1947 binary clipboard WIP --- core/rfb.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/rfb.js b/core/rfb.js index 63b16f26..9a341115 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -2392,6 +2392,8 @@ export default class RFB extends EventTargetMixin { Log.Debug("HandleBinaryClipboard"); let num = this._sock.rQshift8(); // how many different mime types + let blobs = []; + let clipdata = []; for (let i = 0; i < num; i++) { let mimelen = this._sock.rQshift8(); @@ -2399,10 +2401,25 @@ export default class RFB extends EventTargetMixin { let len = this._sock.rQshift32(); - const data = this._sock.rQshiftStr(len); + const data = this._sock.rQshiftBytes(len); // TODO, what do we do with this? 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;