From c2521b1b159d1fd0c13391acccab460697b4d821 Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Wed, 5 Nov 2014 23:59:12 -0800 Subject: [PATCH] GUAC-807 Moved usage of safeApply to a more sane place. --- .../app/client/directives/guacClient.js | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/guacamole/src/main/webapp/app/client/directives/guacClient.js b/guacamole/src/main/webapp/app/client/directives/guacClient.js index 2d674ee9a..b488b46c4 100644 --- a/guacamole/src/main/webapp/app/client/directives/guacClient.js +++ b/guacamole/src/main/webapp/app/client/directives/guacClient.js @@ -136,27 +136,27 @@ angular.module('client').directive('guacClient', [function guacClient() { * size and "auto-fit" setting. */ $scope.updateDisplayScale = function() { - $scope.safeApply(function() { - var guac = $scope.attachedClient; - if (!guac) - return; - // Calculate scale to fit screen - $scope.clientProperties.minScale = Math.min( - $scope.main.offsetWidth / Math.max(guac.getDisplay().getWidth(), 1), - $scope.main.offsetHeight / Math.max(guac.getDisplay().getHeight(), 1) - ); + var guac = $scope.attachedClient; + if (!guac) + return; - // Calculate appropriate maximum zoom level - $scope.clientProperties.maxScale = Math.max($scope.clientProperties.minScale, 3); + // Calculate scale to fit screen + $scope.clientProperties.minScale = Math.min( + $scope.main.offsetWidth / Math.max(guac.getDisplay().getWidth(), 1), + $scope.main.offsetHeight / Math.max(guac.getDisplay().getHeight(), 1) + ); - // Clamp zoom level, maintain auto-fit - if (guac.getDisplay().getScale() < $scope.clientProperties.minScale || $scope.clientProperties.autoFit) - $scope.clientProperties.scale = $scope.clientProperties.minScale; + // Calculate appropriate maximum zoom level + $scope.clientProperties.maxScale = Math.max($scope.clientProperties.minScale, 3); + + // Clamp zoom level, maintain auto-fit + if (guac.getDisplay().getScale() < $scope.clientProperties.minScale || $scope.clientProperties.autoFit) + $scope.clientProperties.scale = $scope.clientProperties.minScale; + + else if (guac.getDisplay().getScale() > $scope.clientProperties.maxScale) + $scope.clientProperties.scale = $scope.clientProperties.maxScale; - else if (guac.getDisplay().getScale() > $scope.clientProperties.maxScale) - $scope.clientProperties.scale = $scope.clientProperties.maxScale; - }); }; /** @@ -599,7 +599,7 @@ angular.module('client').directive('guacClient', [function guacClient() { // If the window is resized, attempt to resize client $window.addEventListener('resize', function onResizeWindow() { - $scope.updateDisplayScale(); + $scope.safeApply($scope.updateDisplayScale()); }); var show_keyboard_gesture_possible = true;