diff --git a/guacamole/src/main/webapp/scripts/client-ui.js b/guacamole/src/main/webapp/scripts/client-ui.js index ab9bc48a0..4a39adb0e 100644 --- a/guacamole/src/main/webapp/scripts/client-ui.js +++ b/guacamole/src/main/webapp/scripts/client-ui.js @@ -769,6 +769,28 @@ GuacUI.Client.updateThumbnail = function() { }; +/** + * Sets the current display scale to the given value, where 1 is 100% (1:1 + * pixel ratio). Out-of-range values will be clamped in-range. + * + * @param {Number} new_scale The new scale to apply + */ +GuacUI.Client.setScale = function(new_scale) { + + new_scale = Math.max(new_scale, GuacUI.Client.min_zoom); + new_scale = Math.min(new_scale, GuacUI.Client.max_zoom); + + if (GuacUI.Client.attachedClient) + GuacUI.Client.attachedClient.scale(new_scale); + + GuacUI.Client.zoom_state.textContent = Math.round(new_scale * 100) + "%"; + + // Auto-fit is implicitly enabled at minimum zoom level + if (new_scale === GuacUI.Client.min_zoom) + GuacUI.Client.auto_fit.checked = true; + +}; + /** * Updates the scale of the attached Guacamole.Client based on current window * size and "auto-fit" setting. @@ -786,25 +808,12 @@ GuacUI.Client.updateDisplayScale = function() { // Clamp scale to minimum zoom level, keep at minimum zoom if at minimum zoom before if (guac.getScale() < min_zoom || guac.getScale() === GuacUI.Client.min_zoom) { - guac.scale(min_zoom); - GuacUI.Client.zoom_state.textContent = Math.round(min_zoom * 100) + "%"; + GuacUI.Client.min_zoom = min_zoom; + GuacUI.Client.setScale(min_zoom); } + else + GuacUI.Client.min_zoom = min_zoom; - GuacUI.Client.min_zoom = min_zoom; - -}; - -/** - * Sets the current display scale to the given value, where 1 is 100% (1:1 - * pixel ratio). Out-of-range values will be clamped in-range. - * - * @param {Number} new_scale The new scale to apply - */ -GuacUI.Client.setScale = function(new_scale) { - new_scale = Math.max(new_scale, GuacUI.Client.min_zoom); - new_scale = Math.min(new_scale, GuacUI.Client.max_zoom); - guac.scale(new_scale); - GuacUI.Client.zoom_state.textContent = Math.round(new_scale * 100) + "%"; }; /**