Commit 84ad3eaa authored by wez@chromium.org's avatar wez@chromium.org

Update web-app client to use plugin notifyDeviceResolution API.

BUG=172404


Review URL: https://chromiumcodereview.appspot.com/12207099

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181987 0039d316-1c4b-4281-b951-d872f2087c98
parent 7a6934ea
...@@ -55,6 +55,7 @@ remoting.ClientPlugin.prototype.isSupportedVersion = function() {}; ...@@ -55,6 +55,7 @@ remoting.ClientPlugin.prototype.isSupportedVersion = function() {};
remoting.ClientPlugin.Feature = { remoting.ClientPlugin.Feature = {
INJECT_KEY_EVENT: 'injectKeyEvent', INJECT_KEY_EVENT: 'injectKeyEvent',
NOTIFY_CLIENT_DIMENSIONS: 'notifyClientDimensions', NOTIFY_CLIENT_DIMENSIONS: 'notifyClientDimensions',
NOTIFY_CLIENT_RESOLUTION: 'notifyClientResolution',
PAUSE_VIDEO: 'pauseVideo', PAUSE_VIDEO: 'pauseVideo',
PAUSE_AUDIO: 'pauseAudio', PAUSE_AUDIO: 'pauseAudio',
REMAP_KEY: 'remapKey', REMAP_KEY: 'remapKey',
...@@ -147,13 +148,14 @@ remoting.ClientPlugin.prototype.getPerfStats = function() {}; ...@@ -147,13 +148,14 @@ remoting.ClientPlugin.prototype.getPerfStats = function() {};
remoting.ClientPlugin.prototype.sendClipboardItem = function(mimeType, item) {}; remoting.ClientPlugin.prototype.sendClipboardItem = function(mimeType, item) {};
/** /**
* Notifies the host that the client has the specified dimensions. * Notifies the host that the client has the specified size and pixel density.
* *
* @param {number} width The available client width. * @param {number} width The available client width in DIPs.
* @param {number} height The available client height. * @param {number} height The available client height in DIPs.
* @param {number} device_scale The number of device pixels per DIP.
*/ */
remoting.ClientPlugin.prototype.notifyClientDimensions = remoting.ClientPlugin.prototype.notifyClientResolution =
function(width, height) {}; function(width, height, device_scale) {};
/** /**
* Requests that the host pause or resume sending video updates. * Requests that the host pause or resume sending video updates.
......
...@@ -385,18 +385,27 @@ remoting.ClientPluginAsync.prototype.sendClipboardItem = ...@@ -385,18 +385,27 @@ remoting.ClientPluginAsync.prototype.sendClipboardItem =
}; };
/** /**
* Notifies the host that the client has the specified dimensions. * Notifies the host that the client has the specified size and pixel density.
* *
* @param {number} width The available client width. * @param {number} width The available client width in DIPs.
* @param {number} height The available client height. * @param {number} height The available client height in DIPs.
* @param {number} device_scale The number of device pixels per DIP.
*/ */
remoting.ClientPluginAsync.prototype.notifyClientDimensions = remoting.ClientPluginAsync.prototype.notifyClientResolution =
function(width, height) { function(width, height, device_scale) {
if (!this.hasFeature(remoting.ClientPlugin.Feature.NOTIFY_CLIENT_DIMENSIONS)) if (this.hasFeature(remoting.ClientPlugin.Feature.NOTIFY_CLIENT_RESOLUTION)) {
return; var dpi = device_scale * 96;
this.plugin.postMessage(JSON.stringify( this.plugin.postMessage(JSON.stringify(
{ method: 'notifyClientDimensions', { method: 'notifyClientResolution',
data: { width: width, height: height }})); data: { width: width * device_scale,
height: height * device_scale,
x_dpi: dpi, y_dpi: dpi }}));
} else if (this.hasFeature(
remoting.ClientPlugin.Feature.NOTIFY_CLIENT_DIMENSIONS)) {
this.plugin.postMessage(JSON.stringify(
{ method: 'notifyClientDimensions',
data: { width: width, height: height }}));
}
}; };
/** /**
......
...@@ -64,7 +64,7 @@ remoting.ClientSession = function(hostJid, clientJid, ...@@ -64,7 +64,7 @@ remoting.ClientSession = function(hostJid, clientJid,
this.onStateChange_ = null; this.onStateChange_ = null;
/** @type {number?} @private */ /** @type {number?} @private */
this.notifyClientDimensionsTimer_ = null; this.notifyClientResolutionTimer_ = null;
/** @type {number?} @private */ /** @type {number?} @private */
this.bumpScrollTimer_ = null; this.bumpScrollTimer_ = null;
...@@ -504,7 +504,9 @@ remoting.ClientSession.prototype.setScreenMode_ = ...@@ -504,7 +504,9 @@ remoting.ClientSession.prototype.setScreenMode_ =
function(shrinkToFit, resizeToClient) { function(shrinkToFit, resizeToClient) {
if (resizeToClient && !this.resizeToClient_) { if (resizeToClient && !this.resizeToClient_) {
this.plugin.notifyClientDimensions(window.innerWidth, window.innerHeight); this.plugin.notifyClientResolution(window.innerWidth,
window.innerHeight,
window.devicePixelRatio);
} }
// If enabling shrink, reset bump-scroll offsets. // If enabling shrink, reset bump-scroll offsets.
...@@ -627,7 +629,9 @@ remoting.ClientSession.prototype.onConnectionStatusUpdate_ = ...@@ -627,7 +629,9 @@ remoting.ClientSession.prototype.onConnectionStatusUpdate_ =
if (status == remoting.ClientSession.State.CONNECTED) { if (status == remoting.ClientSession.State.CONNECTED) {
this.onDesktopSizeChanged_(); this.onDesktopSizeChanged_();
if (this.resizeToClient_) { if (this.resizeToClient_) {
this.plugin.notifyClientDimensions(window.innerWidth, window.innerHeight); this.plugin.notifyClientResolution(window.innerWidth,
window.innerHeight,
window.devicePixelRatio);
} }
} else if (status == remoting.ClientSession.State.FAILED) { } else if (status == remoting.ClientSession.State.FAILED) {
this.error_ = /** @type {remoting.ClientSession.ConnectionError} */ (error); this.error_ = /** @type {remoting.ClientSession.ConnectionError} */ (error);
...@@ -688,18 +692,19 @@ remoting.ClientSession.prototype.setState_ = function(newState) { ...@@ -688,18 +692,19 @@ remoting.ClientSession.prototype.setState_ = function(newState) {
remoting.ClientSession.prototype.onResize = function() { remoting.ClientSession.prototype.onResize = function() {
this.updateDimensions(); this.updateDimensions();
if (this.notifyClientDimensionsTimer_) { if (this.notifyClientResolutionTimer_) {
window.clearTimeout(this.notifyClientDimensionsTimer_); window.clearTimeout(this.notifyClientResolutionTimer_);
this.notifyClientDimensionsTimer_ = null; this.notifyClientResolutionTimer_ = null;
} }
// Defer notifying the host of the change until the window stops resizing, to // Defer notifying the host of the change until the window stops resizing, to
// avoid overloading the control channel with notifications. // avoid overloading the control channel with notifications.
if (this.resizeToClient_) { if (this.resizeToClient_) {
this.notifyClientDimensionsTimer_ = window.setTimeout( this.notifyClientResolutionTimer_ = window.setTimeout(
this.plugin.notifyClientDimensions.bind(this.plugin, this.plugin.notifyClientResolution.bind(this.plugin,
window.innerWidth, window.innerWidth,
window.innerHeight), window.innerHeight,
window.devicePixelRatio),
1000); 1000);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment