From 19b3de10e1a7dc072cb2e06b73ffb049425616c7 Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 21 Dec 2023 13:58:27 +0000 Subject: [PATCH 1/6] artifacting fix, open new displays in new window --- app/ui.js | 6 +++--- core/rfb.js | 4 ++++ vnc.html | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/ui.js b/app/ui.js index 247fc581..cf48d90e 100644 --- a/app/ui.js +++ b/app/ui.js @@ -25,8 +25,8 @@ window.updateSetting = (name, value) => { } } -import "core-js/stable"; -import "regenerator-runtime/runtime"; +//import "core-js/stable"; +//import "regenerator-runtime/runtime"; import * as Log from '../core/util/logging.js'; import _, { l10n } from './localization.js'; import { isTouchDevice, isSafari, hasScrollbarGutter, dragThreshold, supportsBinaryClipboard, isFirefox, isWindows, isIOS, supportsPointerLock } @@ -1890,7 +1890,7 @@ const UI = { let new_display_url = `${window.location.protocol}//${window.location.host}${new_display_path}screen.html`; 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) { diff --git a/core/rfb.js b/core/rfb.js index f1e63c4f..636e1b68 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -1694,6 +1694,8 @@ export default class RFB extends EventTargetMixin { console.log('reattach message') 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._sendEncodings(); + this._updateContinuousUpdates(); this.dispatchEvent(new CustomEvent("screenregistered", {})); Log.Info(`Secondary monitor (${event.data.screenID}) has been reattached.`); break; @@ -2868,6 +2870,8 @@ export default class RFB extends EventTargetMixin { // Disable copyrect when using multiple displays if (this._display.screens.length === 1) { encs.push(encodings.encodingCopyRect); + } else { + Log.Debug("Multiple displays detected, disabling copyrect encoding."); } // Only supported with full depth support if (this._fbDepth == 24) { diff --git a/vnc.html b/vnc.html index 0cf590b0..c6fa0a33 100644 --- a/vnc.html +++ b/vnc.html @@ -50,7 +50,7 @@ - + From d51c5e37b75f4f9a633523e995971ce37c50cd1a Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 21 Dec 2023 14:08:05 +0000 Subject: [PATCH 2/6] change default background splash --- app/styles/base.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/styles/base.css b/app/styles/base.css index 9a3abcd5..b6e49f9c 100644 --- a/app/styles/base.css +++ b/app/styles/base.css @@ -24,7 +24,7 @@ body { padding:0; font-family: "Poppins", "Helvetica"; 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%; touch-action: none; } From 82e0100a978883a2c2be68ceee801f7bd0d43142 Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 21 Dec 2023 15:46:11 +0000 Subject: [PATCH 3/6] fix clipboard write to client from secondary screen --- core/rfb.js | 55 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/core/rfb.js b/core/rfb.js index 636e1b68..40f2db16 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -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(); From 88ecc905ef6e2e45fcc198905e5db89def8755b6 Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 21 Dec 2023 15:53:46 +0000 Subject: [PATCH 4/6] sync down control keys on scroll --- core/rfb.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/rfb.js b/core/rfb.js index 40f2db16..054c48bd 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -2105,6 +2105,9 @@ export default class RFB extends EventTargetMixin { ev.stopPropagation(); 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 if (isMac() && (this._keyboard._keyDownList["MetaLeft"] || this._keyboard._keyDownList["MetaRight"])) { this._keyboard._sendKeyEvent(this._keyboard._keyDownList["MetaLeft"], "MetaLeft", false); From ed83f31384feb804093d9567623cdcfd71f9a817 Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 21 Dec 2023 18:14:03 +0000 Subject: [PATCH 5/6] fixed bug with secondary screen on high dpi screen --- app/ui_screen.js | 4 ++-- core/rfb.js | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/ui_screen.js b/app/ui_screen.js index d2b0044f..66bb0e1d 100644 --- a/app/ui_screen.js +++ b/app/ui_screen.js @@ -62,7 +62,8 @@ const UI = { { shared: UI.getSetting('shared', true), repeaterID: UI.getSetting('repeaterID', false), - credentials: { password: null } + credentials: { password: null }, + hiDpi: UI.getSetting('enable_hidpi', true, false) }, false // Not a primary display ); @@ -96,7 +97,6 @@ const UI = { UI.rfb.keyboard.enableIME = UI.getSetting('enable_ime', true, false); UI.rfb.clipboardBinary = supportsBinaryClipboard() && UI.rfb.clipboardSeamless; UI.rfb.enableWebRTC = UI.getSetting('enable_webrtc', true, false); - UI.rfb.enableHiDpi = UI.getSetting('enable_hidpi', true, false); UI.rfb.mouseButtonMapper = UI.initMouseButtonMapper(); if (UI.rfb.videoQuality === 5) { UI.rfb.enableQOI = true; diff --git a/core/rfb.js b/core/rfb.js index 054c48bd..a8af15ce 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -147,7 +147,7 @@ export default class RFB extends EventTargetMixin { this._clipboardBinary = true; this._resendClipboardNextUserDrivenEvent = true; this._useUdp = true; - this._hiDpi = false; + this._hiDpi = 'hiDpi' in options ? !!options.hiDpi : false; this._enableQOI = false; this.TransitConnectionStates = { Tcp: Symbol("tcp"), @@ -1680,10 +1680,11 @@ export default class RFB extends EventTargetMixin { _handleControlMessage(event) { if (this._isPrimaryDisplay) { // Secondary to Primary screen message + let size; switch (event.data.eventType) { case 'register': 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); this._sendEncodings(); this._updateContinuousUpdates(); @@ -1694,6 +1695,8 @@ export default class RFB extends EventTargetMixin { console.log('reattach message') 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); + size = this._screenSize(); + RFB.messages.setDesktopSize(this._sock, size, this._screenFlags); this._sendEncodings(); this._updateContinuousUpdates(); this.dispatchEvent(new CustomEvent("screenregistered", {})); @@ -1772,8 +1775,8 @@ export default class RFB extends EventTargetMixin { //let screen = this._screenSize().screens[0]; // let size = this._screenSize(); - this._display.resize(size.screens[0].containerWidth, size.screens[0].containerHeight); - this._display.autoscale(size.screens[0].containerWidth, size.screens[0].containerHeight, size.screens[0].scale); + this._display.resize(size.screens[0].serverWidth, size.screens[0].serverHeight); + this._display.autoscale(size.screens[0].serverWidth, size.screens[0].serverHeight, size.screens[0].scale); screen = this._screenSize().screens[0]; const registertype = (currentScreen) ? 'reattach' : 'register' From 2d407bd732abdc47836132af2e89d52b9e5d104a Mon Sep 17 00:00:00 2001 From: matt Date: Thu, 21 Dec 2023 18:15:13 +0000 Subject: [PATCH 6/6] remove dev mode --- app/ui.js | 4 ++-- vnc.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/ui.js b/app/ui.js index cf48d90e..10f5a8f3 100644 --- a/app/ui.js +++ b/app/ui.js @@ -25,8 +25,8 @@ window.updateSetting = (name, value) => { } } -//import "core-js/stable"; -//import "regenerator-runtime/runtime"; +import "core-js/stable"; +import "regenerator-runtime/runtime"; import * as Log from '../core/util/logging.js'; import _, { l10n } from './localization.js'; import { isTouchDevice, isSafari, hasScrollbarGutter, dragThreshold, supportsBinaryClipboard, isFirefox, isWindows, isIOS, supportsPointerLock } diff --git a/vnc.html b/vnc.html index c6fa0a33..0cf590b0 100644 --- a/vnc.html +++ b/vnc.html @@ -50,7 +50,7 @@ - +