Merge pull request #81 from kasmtech/bugfix/KASM-5359_multimonitor_errata

Bugfix/kasm 5359 multimonitor errata
This commit is contained in:
Richard Koliser 2023-12-22 13:38:59 -05:00 committed by GitHub
commit eafb24583d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 29 deletions

View File

@ -24,7 +24,7 @@ body {
padding:0; padding:0;
font-family: "Poppins", "Helvetica"; font-family: "Poppins", "Helvetica";
letter-spacing: 0.05em; letter-spacing: 0.05em;
background: white url('../images/icons/kasm_logo.svg') no-repeat fixed center; background: white url('../images/splash.jpg') no-repeat fixed center;
height:100%; height:100%;
touch-action: none; touch-action: none;
} }

View File

@ -1890,7 +1890,7 @@ const UI = {
let new_display_url = `${window.location.protocol}//${window.location.host}${new_display_path}screen.html`; let new_display_url = `${window.location.protocol}//${window.location.host}${new_display_path}screen.html`;
Log.Debug(`Opening a secondary display ${new_display_url}`) Log.Debug(`Opening a secondary display ${new_display_url}`)
window.open(new_display_url); window.open(new_display_url, '_blank', 'toolbar=0,location=0,menubar=0');
}, },
initMonitors(screenPlan) { initMonitors(screenPlan) {

View File

@ -62,7 +62,8 @@ const UI = {
{ {
shared: UI.getSetting('shared', true), shared: UI.getSetting('shared', true),
repeaterID: UI.getSetting('repeaterID', false), repeaterID: UI.getSetting('repeaterID', false),
credentials: { password: null } credentials: { password: null },
hiDpi: UI.getSetting('enable_hidpi', true, false)
}, },
false // Not a primary display false // Not a primary display
); );
@ -96,7 +97,6 @@ const UI = {
UI.rfb.keyboard.enableIME = UI.getSetting('enable_ime', true, false); UI.rfb.keyboard.enableIME = UI.getSetting('enable_ime', true, false);
UI.rfb.clipboardBinary = supportsBinaryClipboard() && UI.rfb.clipboardSeamless; UI.rfb.clipboardBinary = supportsBinaryClipboard() && UI.rfb.clipboardSeamless;
UI.rfb.enableWebRTC = UI.getSetting('enable_webrtc', true, false); UI.rfb.enableWebRTC = UI.getSetting('enable_webrtc', true, false);
UI.rfb.enableHiDpi = UI.getSetting('enable_hidpi', true, false);
UI.rfb.mouseButtonMapper = UI.initMouseButtonMapper(); UI.rfb.mouseButtonMapper = UI.initMouseButtonMapper();
if (UI.rfb.videoQuality === 5) { if (UI.rfb.videoQuality === 5) {
UI.rfb.enableQOI = true; UI.rfb.enableQOI = true;

View File

@ -147,7 +147,7 @@ export default class RFB extends EventTargetMixin {
this._clipboardBinary = true; this._clipboardBinary = true;
this._resendClipboardNextUserDrivenEvent = true; this._resendClipboardNextUserDrivenEvent = true;
this._useUdp = true; this._useUdp = true;
this._hiDpi = false; this._hiDpi = 'hiDpi' in options ? !!options.hiDpi : false;
this._enableQOI = false; this._enableQOI = false;
this.TransitConnectionStates = { this.TransitConnectionStates = {
Tcp: Symbol("tcp"), Tcp: Symbol("tcp"),
@ -1680,10 +1680,11 @@ export default class RFB extends EventTargetMixin {
_handleControlMessage(event) { _handleControlMessage(event) {
if (this._isPrimaryDisplay) { if (this._isPrimaryDisplay) {
// Secondary to Primary screen message // Secondary to Primary screen message
let size;
switch (event.data.eventType) { switch (event.data.eventType) {
case 'register': case 'register':
this._display.addScreen(event.data.screenID, event.data.width, event.data.height, event.data.pixelRatio, event.data.containerHeight, event.data.containerWidth); this._display.addScreen(event.data.screenID, event.data.width, event.data.height, event.data.pixelRatio, event.data.containerHeight, event.data.containerWidth);
const size = this._screenSize(); size = this._screenSize();
RFB.messages.setDesktopSize(this._sock, size, this._screenFlags); RFB.messages.setDesktopSize(this._sock, size, this._screenFlags);
this._sendEncodings(); this._sendEncodings();
this._updateContinuousUpdates(); this._updateContinuousUpdates();
@ -1694,6 +1695,10 @@ export default class RFB extends EventTargetMixin {
console.log('reattach message') console.log('reattach message')
console.log(event.data) console.log(event.data)
this._display.addScreen(event.data.screenID, event.data.width, event.data.height, event.data.pixelRatio, event.data.containerHeight, event.data.containerWidth); this._display.addScreen(event.data.screenID, event.data.width, event.data.height, event.data.pixelRatio, event.data.containerHeight, event.data.containerWidth);
size = this._screenSize();
RFB.messages.setDesktopSize(this._sock, size, this._screenFlags);
this._sendEncodings();
this._updateContinuousUpdates();
this.dispatchEvent(new CustomEvent("screenregistered", {})); this.dispatchEvent(new CustomEvent("screenregistered", {}));
Log.Info(`Secondary monitor (${event.data.screenID}) has been reattached.`); Log.Info(`Secondary monitor (${event.data.screenID}) has been reattached.`);
break; break;
@ -1736,6 +1741,11 @@ export default class RFB extends EventTargetMixin {
this._mouseLastScreenIndex = event.data.mouseLastScreenIndex; this._mouseLastScreenIndex = event.data.mouseLastScreenIndex;
} }
break; break;
case 'receivedClipboard':
if (event.data.mouseLastScreenIndex === this._display.screenIndex) {
this._write_binary_clipboard(...event.data.args);
}
break;
case 'disconnect': case 'disconnect':
this.disconnect(); this.disconnect();
break; break;
@ -1765,8 +1775,8 @@ export default class RFB extends EventTargetMixin {
//let screen = this._screenSize().screens[0]; //let screen = this._screenSize().screens[0];
// //
let size = this._screenSize(); let size = this._screenSize();
this._display.resize(size.screens[0].containerWidth, size.screens[0].containerHeight); this._display.resize(size.screens[0].serverWidth, size.screens[0].serverHeight);
this._display.autoscale(size.screens[0].containerWidth, size.screens[0].containerHeight, size.screens[0].scale); this._display.autoscale(size.screens[0].serverWidth, size.screens[0].serverHeight, size.screens[0].scale);
screen = this._screenSize().screens[0]; screen = this._screenSize().screens[0];
const registertype = (currentScreen) ? 'reattach' : 'register' const registertype = (currentScreen) ? 'reattach' : 'register'
@ -2098,6 +2108,9 @@ export default class RFB extends EventTargetMixin {
ev.stopPropagation(); ev.stopPropagation();
ev.preventDefault(); ev.preventDefault();
// Ensure keys down are synced between client and server
this._keyboard.clearKeysDown(ev);
// On MacOs we need to translate zooming CMD+wheel to CTRL+wheel // On MacOs we need to translate zooming CMD+wheel to CTRL+wheel
if (isMac() && (this._keyboard._keyDownList["MetaLeft"] || this._keyboard._keyDownList["MetaRight"])) { if (isMac() && (this._keyboard._keyDownList["MetaLeft"] || this._keyboard._keyDownList["MetaRight"])) {
this._keyboard._sendKeyEvent(this._keyboard._keyDownList["MetaLeft"], "MetaLeft", false); this._keyboard._sendKeyEvent(this._keyboard._keyDownList["MetaLeft"], "MetaLeft", false);
@ -2868,6 +2881,8 @@ export default class RFB extends EventTargetMixin {
// Disable copyrect when using multiple displays // Disable copyrect when using multiple displays
if (this._display.screens.length === 1) { if (this._display.screens.length === 1) {
encs.push(encodings.encodingCopyRect); encs.push(encodings.encodingCopyRect);
} else {
Log.Debug("Multiple displays detected, disabling copyrect encoding.");
} }
// Only supported with full depth support // Only supported with full depth support
if (this._fbDepth == 24) { if (this._fbDepth == 24) {
@ -3212,6 +3227,18 @@ export default class RFB extends EventTargetMixin {
if (this.clipboardBinary) { if (this.clipboardBinary) {
this._clipHash = 0; this._clipHash = 0;
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( navigator.clipboard.write([new ClipboardItem(clipItemData)]).then(
() => { () => {
if (textdata) { if (textdata) {
@ -3234,10 +3261,6 @@ export default class RFB extends EventTargetMixin {
} }
); );
} }
}
return true;
}
_handle_server_stats_msg() { _handle_server_stats_msg() {
this._sock.rQskipBytes(3); // Padding this._sock.rQskipBytes(3); // Padding