Index: remoting/webapp/crd/js/client_session.js |
diff --git a/remoting/webapp/crd/js/client_session.js b/remoting/webapp/crd/js/client_session.js |
index 4d68335fde00ad9256711aefc89df57b9ad9ce8a..0d4c32fef49b7cce900e69d00119ad14051b8957 100644 |
--- a/remoting/webapp/crd/js/client_session.js |
+++ b/remoting/webapp/crd/js/client_session.js |
@@ -129,6 +129,8 @@ remoting.ClientSession = function(signalStrategy, container, hostDisplayName, |
/** @private */ |
this.resizeToClient_ = true; |
/** @private */ |
+ this.desktopZoom_ = 1.0; |
+ /** @private */ |
this.remapKeys_ = ''; |
/** @private */ |
this.hasReceivedFrame_ = false; |
@@ -377,6 +379,7 @@ remoting.ClientSession.STATS_KEY_ROUNDTRIP_LATENCY = 'roundtripLatency'; |
remoting.ClientSession.KEY_REMAP_KEYS = 'remapKeys'; |
remoting.ClientSession.KEY_RESIZE_TO_CLIENT = 'resizeToClient'; |
remoting.ClientSession.KEY_SHRINK_TO_FIT = 'shrinkToFit'; |
+remoting.ClientSession.KEY_DESKTOP_ZOOM = 'desktopZoom'; |
/** |
* Set of capabilities for which hasCapability_() can be used to test. |
@@ -502,6 +505,12 @@ remoting.ClientSession.prototype.onHostSettingsLoaded_ = function(options) { |
this.shrinkToFit_ = /** @type {boolean} */ |
options[remoting.ClientSession.KEY_SHRINK_TO_FIT]; |
} |
+ if (remoting.ClientSession.KEY_DESKTOP_ZOOM in options && |
+ typeof(options[remoting.ClientSession.KEY_DESKTOP_ZOOM]) == |
+ 'number') { |
+ this.desktopZoom_ = /** @type {number} */ |
+ options[remoting.ClientSession.KEY_DESKTOP_ZOOM]; |
+ } |
/** @param {boolean} result */ |
this.plugin_.initialize(this.onPluginInitialized_.bind(this)); |
@@ -772,6 +781,25 @@ remoting.ClientSession.prototype.sendPrintScreen = function() { |
} |
/** |
+ * Sets and stores the zoom factor to apply to host sizing requests. |
+ * |
+ * @param {number} desktopZoom Scale factor to apply. |
+ */ |
+remoting.ClientSession.prototype.setDesktopZoom = |
+ function(desktopZoom) { |
+ // Apply the new desktop zoom, if resize to client is enabled. |
Jamie
2014/12/15 18:39:06
Nit: resize-to-client
Wez
2014/12/15 21:49:42
Done.
|
+ this.desktopZoom_ = desktopZoom; |
+ if (this.resizeToClient_) { |
+ this.notifyClientResolution_(); |
+ } |
+ |
+ // Save the new desktop zoom setting. |
+ var options = {}; |
+ options[remoting.ClientSession.KEY_DESKTOP_ZOOM] = this.desktopZoom_; |
+ remoting.HostSettings.save(this.hostId_, options); |
+} |
+ |
+/** |
* Sets and stores the key remapping setting for the current host. |
* |
* @param {string} remappings Comma separated list of key remappings. |
@@ -842,10 +870,7 @@ remoting.ClientSession.prototype.applyRemapKeys_ = function(apply) { |
remoting.ClientSession.prototype.setScreenMode = |
function(shrinkToFit, resizeToClient) { |
if (resizeToClient && !this.resizeToClient_) { |
- var clientArea = this.getClientArea_(); |
- this.plugin_.notifyClientResolution(clientArea.width, |
- clientArea.height, |
- window.devicePixelRatio); |
+ this.notifyClientResolution_(); |
} |
// If enabling shrink, reset bump-scroll offsets. |
@@ -1008,10 +1033,7 @@ remoting.ClientSession.prototype.onConnectionStatusUpdate_ = |
this.setFocusHandlers_(); |
this.onDesktopSizeChanged_(); |
if (this.resizeToClient_) { |
- var clientArea = this.getClientArea_(); |
- this.plugin_.notifyClientResolution(clientArea.width, |
- clientArea.height, |
- window.devicePixelRatio); |
+ this.notifyClientResolution_(); |
} |
// Activate full-screen related UX. |
remoting.fullscreen.addListener(this.callOnFullScreenChanged_); |
@@ -1104,10 +1126,7 @@ remoting.ClientSession.prototype.onSetCapabilities_ = function(capabilities) { |
this.capabilities_ = capabilities; |
if (this.hasCapability_( |
remoting.ClientSession.Capability.SEND_INITIAL_RESOLUTION)) { |
- var clientArea = this.getClientArea_(); |
- this.plugin_.notifyClientResolution(clientArea.width, |
- clientArea.height, |
- window.devicePixelRatio); |
+ this.notifyClientResolution_(); |
} |
if (this.hasCapability_(remoting.ClientSession.Capability.GOOGLE_DRIVE)) { |
this.sendGoogleDriveAccessToken_(); |
@@ -1176,10 +1195,7 @@ remoting.ClientSession.prototype.onResize = function() { |
} |
var clientArea = this.getClientArea_(); |
this.notifyClientResolutionTimer_ = window.setTimeout( |
- this.plugin_.notifyClientResolution.bind(this.plugin_, |
- clientArea.width, |
- clientArea.height, |
- window.devicePixelRatio), |
+ this.notifyClientResolution_.bind(this), |
kResizeRateLimitMs); |
} |
@@ -1633,6 +1649,18 @@ remoting.ClientSession.prototype.getClientArea_ = function() { |
}; |
/** |
+ * Notifies the host of the client's current dimensions and DPI. |
+ * Also takes into account per-host scaling factor, if configured. |
+ * @private |
+ */ |
+remoting.ClientSession.prototype.notifyClientResolution_ = function() { |
+ var clientArea = this.getClientArea_(); |
+ this.plugin_.notifyClientResolution(clientArea.width * this.desktopZoom_, |
+ clientArea.height * this.desktopZoom_, |
+ window.devicePixelRatio); |
Jamie
2014/12/15 18:39:06
Don't you also need to apply the inverse scale to
Wez
2014/12/15 21:49:42
That's a good question.
I've added code in update
|
+} |
+ |
+/** |
* @param {string} url |
* @param {number} hotspotX |
* @param {number} hotspotY |