summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorSamuel Mannehed <samuel@cendio.se>2021-12-10 20:11:05 +0100
committerSamuel Mannehed <samuel@cendio.se>2021-12-13 11:20:14 +0100
commit0ff0844a142c086128cce8771a3dad21a499f02b (patch)
treefaa930a62c90f780cccd7eb297c53a45dc9f9463 /core
parent6cd69705d6c9a16337d6f653c14168d2e194684f (diff)
downloadnovnc-0ff0844a142c086128cce8771a3dad21a499f02b.tar.gz
Ignore resize observation caused by server resizesresizeObserverScrollbars
If we increase the remote screen size from the server in such a way that it no longer fits the browser window, the browser will probably want to show scrollbars. The same happens if you enable 'clipping' while the remote is larger than the browser window. These scrollbars do, in turn, decrease the available space in the browser window. This causes our ResizeObserver to trigger. If the resize observation triggers a requestRemoteResize() we will overwrite the size and request a new one just because scrollbars have appeared. We don't want that. We can save the expected client size after resizing, and then compare the current client size with the expected one. If there is no change compared to the expected size, we shouldn't send the request. Fixes issue #1616.
Diffstat (limited to 'core')
-rw-r--r--core/rfb.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/core/rfb.js b/core/rfb.js
index fe9939f..970e03f 100644
--- a/core/rfb.js
+++ b/core/rfb.js
@@ -244,6 +244,8 @@ export default class RFB extends EventTargetMixin {
this._sock.on('message', this._handleMessage.bind(this));
this._sock.on('error', this._socketError.bind(this));
+ this._expectedClientWidth = null;
+ this._expectedClientHeight = null;
this._resizeObserver = new ResizeObserver(this._eventHandlers.handleResize);
// All prepared, kick off the connection
@@ -623,7 +625,26 @@ export default class RFB extends EventTargetMixin {
{ detail: { name: this._fbName } }));
}
+ _saveExpectedClientSize() {
+ this._expectedClientWidth = this._screen.clientWidth;
+ this._expectedClientHeight = this._screen.clientHeight;
+ }
+
+ _currentClientSize() {
+ return [this._screen.clientWidth, this._screen.clientHeight];
+ }
+
+ _clientHasExpectedSize() {
+ const [currentWidth, currentHeight] = this._currentClientSize();
+ return currentWidth == this._expectedClientWidth &&
+ currentHeight == this._expectedClientHeight;
+ }
+
_handleResize() {
+ // Don't change anything if the client size is already as expected
+ if (this._clientHasExpectedSize()) {
+ return;
+ }
// If the window resized then our screen element might have
// as well. Update the viewport dimensions.
window.requestAnimationFrame(() => {
@@ -664,6 +685,12 @@ export default class RFB extends EventTargetMixin {
this._display.viewportChangeSize(size.w, size.h);
this._fixScrollbars();
}
+
+ // When changing clipping we might show or hide scrollbars.
+ // This causes the expected client dimensions to change.
+ if (curClip !== newClip) {
+ this._saveExpectedClientSize();
+ }
}
_updateScale() {
@@ -688,6 +715,7 @@ export default class RFB extends EventTargetMixin {
}
const size = this._screenSize();
+
RFB.messages.setDesktopSize(this._sock,
Math.floor(size.w), Math.floor(size.h),
this._screenID, this._screenFlags);
@@ -2507,6 +2535,9 @@ export default class RFB extends EventTargetMixin {
this._updateScale();
this._updateContinuousUpdates();
+
+ // Keep this size until browser client size changes
+ this._saveExpectedClientSize();
}
_xvpOp(ver, op) {