Fix send clipboard seamless client to server (#34)
Co-authored-by: mmcclaskey <matt@kasmweb.com>
This commit is contained in:
parent
842d7ad938
commit
acb64b01b3
38
app/ui.js
38
app/ui.js
|
@ -30,8 +30,8 @@ window.updateSetting = (name, value) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//import "core-js/stable";
|
import "core-js/stable";
|
||||||
//import "regenerator-runtime/runtime";
|
import "regenerator-runtime/runtime";
|
||||||
import * as Log from '../core/util/logging.js';
|
import * as Log from '../core/util/logging.js';
|
||||||
import _, { l10n } from './localization.js';
|
import _, { l10n } from './localization.js';
|
||||||
import { isTouchDevice, isSafari, hasScrollbarGutter, dragThreshold, supportsBinaryClipboard, isFirefox, isWindows, isIOS, supportsPointerLock }
|
import { isTouchDevice, isSafari, hasScrollbarGutter, dragThreshold, supportsBinaryClipboard, isFirefox, isWindows, isIOS, supportsPointerLock }
|
||||||
|
@ -66,8 +66,6 @@ const UI = {
|
||||||
controlbarMouseDownClientY: 0,
|
controlbarMouseDownClientY: 0,
|
||||||
controlbarMouseDownOffsetY: 0,
|
controlbarMouseDownOffsetY: 0,
|
||||||
|
|
||||||
needToCheckClipboardChange: false,
|
|
||||||
|
|
||||||
inhibitReconnect: true,
|
inhibitReconnect: true,
|
||||||
reconnectCallback: null,
|
reconnectCallback: null,
|
||||||
reconnectPassword: null,
|
reconnectPassword: null,
|
||||||
|
@ -462,8 +460,6 @@ const UI = {
|
||||||
.addEventListener('change', UI.clipboardSend);
|
.addEventListener('change', UI.clipboardSend);
|
||||||
document.getElementById("noVNC_clipboard_clear_button")
|
document.getElementById("noVNC_clipboard_clear_button")
|
||||||
.addEventListener('click', UI.clipboardClear);
|
.addEventListener('click', UI.clipboardClear);
|
||||||
|
|
||||||
window.addEventListener("focus", UI.copyFromLocalClipboard);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Add a call to save settings when the element changes,
|
// Add a call to save settings when the element changes,
|
||||||
|
@ -1248,16 +1244,6 @@ const UI = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
readClipboard: function readClipboard(callback) {
|
|
||||||
if (navigator.clipboard && navigator.clipboard.readText) {
|
|
||||||
navigator.clipboard.readText().then(function (text) {
|
|
||||||
return callback(text);
|
|
||||||
}).catch(function () {
|
|
||||||
return Log.Debug("Failed to read system clipboard");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
clipboardReceive(e) {
|
clipboardReceive(e) {
|
||||||
if (UI.rfb.clipboardDown) {
|
if (UI.rfb.clipboardDown) {
|
||||||
var curvalue = document.getElementById('noVNC_clipboard_text').value;
|
var curvalue = document.getElementById('noVNC_clipboard_text').value;
|
||||||
|
@ -1291,26 +1277,6 @@ const UI = {
|
||||||
setTimeout(UI.showOverlay.bind(this, msg, secs), 200);
|
setTimeout(UI.showOverlay.bind(this, msg, secs), 200);
|
||||||
},
|
},
|
||||||
|
|
||||||
copyFromLocalClipboard: function copyFromLocalClipboard() {
|
|
||||||
if (!document.hasFocus()) {
|
|
||||||
Log.Debug("window does not have focus");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (UI.rfb && UI.rfb.clipboardUp && UI.rfb.clipboardSeamless) {
|
|
||||||
|
|
||||||
if (UI.rfb.clipboardBinary) {
|
|
||||||
navigator.clipboard.read().then((data) => {
|
|
||||||
if (UI.rfb) {
|
|
||||||
UI.rfb.clipboardPasteDataFrom(data);
|
|
||||||
}
|
|
||||||
UI.needToCheckClipboardChange = false;
|
|
||||||
}, (err) => {
|
|
||||||
Log.Debug("No data in clipboard");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
clipboardClear() {
|
clipboardClear() {
|
||||||
document.getElementById('noVNC_clipboard_text').value = "";
|
document.getElementById('noVNC_clipboard_text').value = "";
|
||||||
UI.rfb.clipboardPasteFrom("");
|
UI.rfb.clipboardPasteFrom("");
|
||||||
|
|
35
core/rfb.js
35
core/rfb.js
|
@ -824,6 +824,27 @@ export default class RFB extends EventTargetMixin {
|
||||||
this._keyboard.blur();
|
this._keyboard.blur();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkLocalClipboard() {
|
||||||
|
if (this.clipboardUp && this.clipboardSeamless) {
|
||||||
|
|
||||||
|
if (this.clipboardBinary) {
|
||||||
|
navigator.clipboard.read().then((data) => {
|
||||||
|
this.clipboardPasteDataFrom(data);
|
||||||
|
}, (err) => {
|
||||||
|
Log.Debug("No data in clipboard: " + err);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (navigator.clipboard && navigator.clipboard.readText) {
|
||||||
|
navigator.clipboard.readText().then(function (text) {
|
||||||
|
this.clipboardPasteFrom(text);
|
||||||
|
}.bind(this)).catch(function () {
|
||||||
|
return Log.Debug("Failed to read system clipboard");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clipboardPasteFrom(text) {
|
clipboardPasteFrom(text) {
|
||||||
if (this._rfbConnectionState !== 'connected' || this._viewOnly) { return; }
|
if (this._rfbConnectionState !== 'connected' || this._viewOnly) { return; }
|
||||||
if (!(typeof text === 'string' && text.length > 0)) { return; }
|
if (!(typeof text === 'string' && text.length > 0)) { return; }
|
||||||
|
@ -1551,6 +1572,7 @@ export default class RFB extends EventTargetMixin {
|
||||||
this._keyboard._sendKeyEvent(this._keyboard._keyDownList["MetaRight"], "MetaRight", false);
|
this._keyboard._sendKeyEvent(this._keyboard._keyDownList["MetaRight"], "MetaRight", false);
|
||||||
this._keyboard._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true);
|
this._keyboard._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true);
|
||||||
}
|
}
|
||||||
|
this.checkLocalClipboard();
|
||||||
|
|
||||||
this._handleMouseButton(pos.x, pos.y,
|
this._handleMouseButton(pos.x, pos.y,
|
||||||
true, 1 << ev.button);
|
true, 1 << ev.button);
|
||||||
|
@ -2599,7 +2621,10 @@ export default class RFB extends EventTargetMixin {
|
||||||
|
|
||||||
this.dispatchEvent(new CustomEvent(
|
this.dispatchEvent(new CustomEvent(
|
||||||
"clipboard",
|
"clipboard",
|
||||||
{ detail: { text: text } }));
|
{ detail: { text: text } })
|
||||||
|
);
|
||||||
|
|
||||||
|
this._clipHash = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//Extended msg.
|
//Extended msg.
|
||||||
|
@ -3080,15 +3105,15 @@ export default class RFB extends EventTargetMixin {
|
||||||
|
|
||||||
_sendUdpDowngrade() {
|
_sendUdpDowngrade() {
|
||||||
this._changeTransitConnectionState(this.TransitConnectionStates.Downgrading);
|
this._changeTransitConnectionState(this.TransitConnectionStates.Downgrading);
|
||||||
const buff = sock._sQ;
|
const buff = this._sock._sQ;
|
||||||
const offset = sock._sQlen;
|
const offset = this._sock._sQlen;
|
||||||
|
|
||||||
buff[offset] = 181; // msg-type
|
buff[offset] = 181; // msg-type
|
||||||
buff[offset + 1] = 0; // u16 len
|
buff[offset + 1] = 0; // u16 len
|
||||||
buff[offset + 2] = 0;
|
buff[offset + 2] = 0;
|
||||||
|
|
||||||
sock._sQlen += 3;
|
this._sock._sQlen += 3;
|
||||||
sock.flush();
|
this._sock.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleUdpUpgrade() {
|
_handleUdpUpgrade() {
|
||||||
|
|
Loading…
Reference in New Issue