Adjust scaling when session size changes

Session size changes can be initiated from the server, and not just
from the client. Make sure we update the scaling when this happens.
This commit is contained in:
Pierre Ossman 2017-08-16 11:00:04 +02:00
parent b5c982ea42
commit d1a1e0e529
1 changed files with 24 additions and 4 deletions

View File

@ -1242,14 +1242,33 @@ var UI = {
} }
}, 500); }, 500);
} else if (resizeMode === 'scale' || resizeMode === 'downscale') { } else {
var downscaleOnly = resizeMode === 'downscale'; UI.updateScaling();
display.autoscale(screen.w, screen.h, downscaleOnly);
UI.fixScrollbars();
} }
} }
}, },
// Re-calculate local scaling
updateScaling: function() {
if (!UI.rfb) return;
var resizeMode = UI.getSetting('resize');
if (resizeMode !== 'scale' && resizeMode !== 'downscale') {
return;
}
var screen = UI.screenSize();
if (!screen || !UI.connected || !UI.rfb.get_display()) {
return;
}
var display = UI.rfb.get_display();
var downscaleOnly = resizeMode === 'downscale';
display.autoscale(screen.w, screen.h, downscaleOnly);
UI.fixScrollbars();
},
// Gets the the size of the available viewport in the browser window // Gets the the size of the available viewport in the browser window
screenSize: function() { screenSize: function() {
var screen = document.getElementById('noVNC_screen'); var screen = document.getElementById('noVNC_screen');
@ -1674,6 +1693,7 @@ var UI = {
updateSessionSize: function(rfb, width, height) { updateSessionSize: function(rfb, width, height) {
UI.updateViewClip(); UI.updateViewClip();
UI.updateScaling();
UI.fixScrollbars(); UI.fixScrollbars();
}, },