Commit e7abceee authored by wez@chromium.org's avatar wez@chromium.org

Send new client dimensions to host whenever they change.

This will be manually testable by checking for NotifyClientDimensions messages logged by hosts, once the host end logging is enabled.

DO NOT COMMIT THIS UNTIL CL 10262035 HAS LANDED.

BUG=110212

Review URL: http://codereview.chromium.org/10265033

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134846 0039d316-1c4b-4281-b951-d872f2087c98
parent 0b3ec609
...@@ -49,6 +49,7 @@ remoting.ClientPlugin.prototype.isSupportedVersion = function() {}; ...@@ -49,6 +49,7 @@ remoting.ClientPlugin.prototype.isSupportedVersion = function() {};
remoting.ClientPlugin.Feature = { remoting.ClientPlugin.Feature = {
HIGH_QUALITY_SCALING: 'highQualityScaling', HIGH_QUALITY_SCALING: 'highQualityScaling',
INJECT_KEY_EVENT: 'injectKeyEvent', INJECT_KEY_EVENT: 'injectKeyEvent',
NOTIFY_CLIENT_DIMENSIONS: 'notifyClientDimensions',
REMAP_KEY: 'remapKey', REMAP_KEY: 'remapKey',
SEND_CLIPBOARD_ITEM: 'sendClipboardItem' SEND_CLIPBOARD_ITEM: 'sendClipboardItem'
}; };
...@@ -134,3 +135,12 @@ remoting.ClientPlugin.prototype.getPerfStats = function() {}; ...@@ -134,3 +135,12 @@ remoting.ClientPlugin.prototype.getPerfStats = function() {};
* @param {string} item The clipboard item. * @param {string} item The clipboard item.
*/ */
remoting.ClientPlugin.prototype.sendClipboardItem = function(mimeType, item) {}; remoting.ClientPlugin.prototype.sendClipboardItem = function(mimeType, item) {};
/**
* Notifies the host that the client has the specified dimensions.
*
* @param {number} width The available client width.
* @param {number} height The available client height.
*/
remoting.ClientPlugin.prototype.notifyClientDimensions =
function(width, height) {};
...@@ -364,6 +364,21 @@ remoting.ClientPluginAsync.prototype.sendClipboardItem = ...@@ -364,6 +364,21 @@ remoting.ClientPluginAsync.prototype.sendClipboardItem =
data: { mimeType: mimeType, item: item }})); data: { mimeType: mimeType, item: item }}));
}; };
/**
* Notifies the host that the client has the specified dimensions.
*
* @param {number} width The available client width.
* @param {number} height The available client height.
*/
remoting.ClientPluginAsync.prototype.notifyClientDimensions =
function(width, height) {
if (!this.hasFeature(remoting.ClientPlugin.Feature.NOTIFY_CLIENT_DIMENSIONS))
return;
this.plugin.postMessage(JSON.stringify(
{ method: 'notifyClientDimensions',
data: { width: width, height: height }}));
};
/** /**
* If we haven't yet received a "hello" message from the plugin, change its * If we haven't yet received a "hello" message from the plugin, change its
* size so that the user can confirm it if click-to-play is enabled, or can * size so that the user can confirm it if click-to-play is enabled, or can
......
...@@ -230,20 +230,20 @@ remoting.ClientPluginV1.prototype.getPerfStats = function() { ...@@ -230,20 +230,20 @@ remoting.ClientPluginV1.prototype.getPerfStats = function() {
}; };
/** /**
* This dummy method exists only so that this class implements ClientPlugin. * These dummy methods exist only so that this class implements ClientPlugin.
* */
* @param {string} mimeType The MIME type of the clipboard item.
* @param {string} item The clipboard item. /**
* @param {string} mimeType
* @param {string} item
*/ */
remoting.ClientPluginV1.prototype.sendClipboardItem = function(mimeType, item) { remoting.ClientPluginV1.prototype.sendClipboardItem = function(mimeType, item) {
return; return;
}; };
/** /**
* This dummy method exists only so that this class implements ClientPlugin. * @param {number} usbKeycode
* * @param {boolean} pressed
* @param {number} usbKeycode The USB-style code of the key to inject.
* @param {boolean} pressed True to inject a key press, False for a release.
*/ */
remoting.ClientPluginV1.prototype.injectKeyEvent = remoting.ClientPluginV1.prototype.injectKeyEvent =
function(usbKeycode, pressed) { function(usbKeycode, pressed) {
...@@ -251,12 +251,19 @@ remoting.ClientPluginV1.prototype.injectKeyEvent = ...@@ -251,12 +251,19 @@ remoting.ClientPluginV1.prototype.injectKeyEvent =
}; };
/** /**
* Remap one USB keycode to another in all subsequent key events. * @param {number} fromKeycode
* * @param {number} toKeycode
* @param {number} fromKeycode The USB-style code of the key to remap.
* @param {number} toKeycode The USB-style code to remap the key to.
*/ */
remoting.ClientPluginV1.prototype.remapKey = remoting.ClientPluginV1.prototype.remapKey =
function(fromKeycode, toKeycode) { function(fromKeycode, toKeycode) {
return; return;
}; };
/**
* @param {number} width
* @param {number} height
*/
remoting.ClientPluginV1.prototype.notifyClientDimensions =
function(width, height) {
return;
};
...@@ -58,6 +58,10 @@ remoting.ClientSession = function(hostJid, hostPublicKey, sharedSecret, ...@@ -58,6 +58,10 @@ remoting.ClientSession = function(hostJid, hostPublicKey, sharedSecret,
this.scaleToFit = false; this.scaleToFit = false;
this.logToServer = new remoting.LogToServer(); this.logToServer = new remoting.LogToServer();
this.onStateChange = onStateChange; this.onStateChange = onStateChange;
/** @type {number?} */
this.notifyClientDimensionsTimer_ = null;
/** @type {remoting.ClientSession} */ /** @type {remoting.ClientSession} */
var that = this; var that = this;
/** @type {function():void} @private */ /** @type {function():void} @private */
...@@ -71,20 +75,22 @@ remoting.ClientSession = function(hostJid, hostPublicKey, sharedSecret, ...@@ -71,20 +75,22 @@ remoting.ClientSession = function(hostJid, hostPublicKey, sharedSecret,
/** @type {function():void} @private */ /** @type {function():void} @private */
this.callToggleFullScreen_ = function() { that.toggleFullScreen_(); }; this.callToggleFullScreen_ = function() { that.toggleFullScreen_(); };
/** @type {remoting.MenuButton} @private */ /** @type {remoting.MenuButton} @private */
this.sendKeysMenu_ = new remoting.MenuButton(
document.getElementById('send-keys-menu')
);
/** @type {remoting.MenuButton} @private */
this.screenOptionsMenu_ = new remoting.MenuButton( this.screenOptionsMenu_ = new remoting.MenuButton(
document.getElementById('screen-options-menu'), document.getElementById('screen-options-menu'),
function() { that.onShowOptionsMenu_(); } function() { that.onShowOptionsMenu_(); }
); );
/** @type {remoting.MenuButton} @private */
this.sendKeysMenu_ = new remoting.MenuButton(
document.getElementById('send-keys-menu')
);
/** @type {HTMLElement} @private */ /** @type {HTMLElement} @private */
this.shrinkToFit_ = document.getElementById('enable-shrink-to-fit'); this.shrinkToFit_ = document.getElementById('enable-shrink-to-fit');
/** @type {HTMLElement} @private */ /** @type {HTMLElement} @private */
this.originalSize_ = document.getElementById('disable-shrink-to-fit'); this.originalSize_ = document.getElementById('disable-shrink-to-fit');
/** @type {HTMLElement} @private */ /** @type {HTMLElement} @private */
this.fullScreen_ = document.getElementById('toggle-full-screen'); this.fullScreen_ = document.getElementById('toggle-full-screen');
this.shrinkToFit_.addEventListener('click', this.callEnableShrink_, false); this.shrinkToFit_.addEventListener('click', this.callEnableShrink_, false);
this.originalSize_.addEventListener('click', this.callDisableShrink_, false); this.originalSize_.addEventListener('click', this.callDisableShrink_, false);
this.fullScreen_.addEventListener('click', this.callToggleFullScreen_, false); this.fullScreen_.addEventListener('click', this.callToggleFullScreen_, false);
...@@ -504,6 +510,21 @@ remoting.ClientSession.prototype.setState_ = function(newState) { ...@@ -504,6 +510,21 @@ remoting.ClientSession.prototype.setState_ = function(newState) {
*/ */
remoting.ClientSession.prototype.onResize = function() { remoting.ClientSession.prototype.onResize = function() {
this.updateDimensions(); this.updateDimensions();
if (this.notifyClientDimensionsTimer_) {
window.clearTimeout(this.notifyClientDimensionsTimer_);
this.notifyClientDimensionsTimer_ = null;
}
// Defer notifying the host of the change until the window stops resizing, to
// avoid overloading the control channel with notifications.
/** @type {remoting.ClientSession} */
var that = this;
var notifyClientDimensions = function() {
that.plugin.notifyClientDimensions(window.innerWidth, window.innerHeight);
}
this.notifyClientDimensionsTimer_ =
window.setTimeout(notifyClientDimensions, 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