Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ const UI = {
UI.initSetting('repeaterID', '');
UI.initSetting('reconnect', false);
UI.initSetting('reconnect_delay', 5000);
UI.initSetting('incfbureq_delay', 0);
},
// Adds a link to the label elements on the corresponding input elements
setupSettingLabels() {
Expand Down Expand Up @@ -379,6 +380,8 @@ const UI = {
UI.addSettingChangeHandler('logging', UI.updateLogging);
UI.addSettingChangeHandler('reconnect');
UI.addSettingChangeHandler('reconnect_delay');
UI.addSettingChangeHandler('incfbureq_delay');
UI.addSettingChangeHandler('incfbureq_delay', UI.updateIncrementalFBUpdateReqDelay);
},

addFullscreenHandlers() {
Expand Down Expand Up @@ -892,6 +895,7 @@ const UI = {
UI.updateSetting('logging');
UI.updateSetting('reconnect');
UI.updateSetting('reconnect_delay');
UI.updateSetting('incfbureq_delay');

document.getElementById('noVNC_settings')
.classList.add("noVNC_open");
Expand Down Expand Up @@ -1100,6 +1104,7 @@ const UI = {
UI.rfb.resizeSession = UI.getSetting('resize') === 'remote';
UI.rfb.qualityLevel = parseInt(UI.getSetting('quality'));
UI.rfb.compressionLevel = parseInt(UI.getSetting('compression'));
UI.rfb.incfbureqDelay = parseInt(UI.getSetting('incfbureq_delay'));
UI.rfb.showDotCursor = UI.getSetting('show_dot');

UI.updateViewOnly(); // requires UI.rfb
Expand Down Expand Up @@ -1763,6 +1768,10 @@ const UI = {
WebUtil.initLogging(UI.getSetting('logging'));
},

updateIncrementalFBUpdateReqDelay() {
UI.connected && (UI.rfb.incfbureqDelay = parseInt(UI.getSetting('incfbureq_delay')));
},

updateDesktopName(e) {
UI.desktopName = e.detail.name;
// Display the desktop name in the document title
Expand Down
42 changes: 40 additions & 2 deletions core/rfb.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ export default class RFB extends EventTargetMixin {
this._resizeTimeout = null; // resize rate limiting
this._mouseMoveTimer = null;

this._incfbureqDelay = 0; // delay incremental FBU requests,
this._incfbureqTimer = false; // disabled until first FBU
this._incfbureq = null;

// Decoder states
this._decoders = {};

Expand Down Expand Up @@ -413,6 +417,18 @@ export default class RFB extends EventTargetMixin {
}
}

get incfbureqDelay() {
return this._incfbureqDelay;
}
set incfbureqDelay(delay) {
if (delay < this._incfbureqDelay && this._incfbureq ) {
clearTimeout(this._incfbureqTimer);
typeof this._incfbureq === 'function' && (this._incfbureq());
}
this._incfbureq = null;
this._incfbureqDelay = delay;
}

// ===== PUBLIC METHODS =====

disconnect() {
Expand Down Expand Up @@ -2570,7 +2586,8 @@ export default class RFB extends EventTargetMixin {
ret = this._framebufferUpdate();
if (ret && !this._enabledContinuousUpdates) {
RFB.messages.fbUpdateRequest(this._sock, true, 0, 0,
this._fbWidth, this._fbHeight);
this._fbWidth, this._fbHeight,
{ rfb: this, delay: this._incfbureqDelay });
}
return ret;

Expand Down Expand Up @@ -2980,6 +2997,9 @@ export default class RFB extends EventTargetMixin {
this._FBU.encoding + ")");
return false;
}
if (this._incfbureqTimer === false) {
this._incfbureqTimer = null;
}

try {
return decoder.decodeRect(this._FBU.x, this._FBU.y,
Expand Down Expand Up @@ -3362,7 +3382,25 @@ RFB.messages = {
sock.flush();
},

fbUpdateRequest(sock, incremental, x, y, w, h) {
fbUpdateRequest(sock, incremental, x, y, w, h, { rfb, delay } = {}) {
if (incremental && delay !== 0 && rfb?._incfbureqTimer !== false ) {
if (delay !== undefined) {
if (rfb._incfbureqTimer === null) {
// save bound function for calling in incfbureqDelay setter
// if value is changed while request is delayed
rfb._incfbureq = RFB.messages.fbUpdateRequest.bind(
null,
sock, incremental, x, y, w, h,
{ rfb, delay: undefined }
);
rfb._incfbureqTimer = setTimeout(rfb._incfbureq, delay);
}
return;
} else {
rfb._incfbureq = null;
rfb._incfbureqTimer = null;
}
}
if (typeof(x) === "undefined") { x = 0; }
if (typeof(y) === "undefined") { y = 0; }

Expand Down
4 changes: 4 additions & 0 deletions vnc.html
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ <h1 class="noVNC_logo" translate="no"><span>no</span><br>VNC</h1>
<label for="noVNC_setting_reconnect_delay">Reconnect delay (ms):</label>
<input id="noVNC_setting_reconnect_delay" type="number">
</li>
<li>
<label for="noVNC_setting_incfbureq_delay">Update request delay (ms):</label>
<input id="noVNC_setting_incfbureq_delay" type="number">
</li>
<li><hr></li>
<li>
<label>
Expand Down
1 change: 1 addition & 0 deletions vnc_lite.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
// Set parameters that can be changed on an active connection
rfb.viewOnly = readQueryVariable('view_only', false);
rfb.scaleViewport = readQueryVariable('scale', false);
rfb.incfbureqDelay = readQueryVariable('incfbureq_delay', 0);
</script>
</head>

Expand Down