| Index: remoting/webapp/client_session.js
|
| diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js
|
| index 92ded18175d512d6998eccecc0e4535e1d021bff..c8f11cf6bbd7f91728a45fedc800b511f9189f8d 100644
|
| --- a/remoting/webapp/client_session.js
|
| +++ b/remoting/webapp/client_session.js
|
| @@ -178,28 +178,29 @@ remoting.ClientSession.prototype.updateScrollbarVisibility = function() {
|
| if (!this.shrinkToFit_) {
|
| // Determine whether or not horizontal or vertical scrollbars are
|
| // required, taking into account their width.
|
| - needsVerticalScroll = window.innerHeight < this.plugin_.desktopHeight;
|
| - needsHorizontalScroll = window.innerWidth < this.plugin_.desktopWidth;
|
| + var clientArea = this.getClientArea_();
|
| + needsVerticalScroll = clientArea.height < this.plugin_.desktopHeight;
|
| + needsHorizontalScroll = clientArea.width < this.plugin_.desktopWidth;
|
| var kScrollBarWidth = 16;
|
| if (needsHorizontalScroll && !needsVerticalScroll) {
|
| needsVerticalScroll =
|
| - window.innerHeight - kScrollBarWidth < this.plugin_.desktopHeight;
|
| + clientArea.height - kScrollBarWidth < this.plugin_.desktopHeight;
|
| } else if (!needsHorizontalScroll && needsVerticalScroll) {
|
| needsHorizontalScroll =
|
| - window.innerWidth - kScrollBarWidth < this.plugin_.desktopWidth;
|
| + clientArea.width - kScrollBarWidth < this.plugin_.desktopWidth;
|
| }
|
| }
|
|
|
| - var htmlNode = /** @type {HTMLElement} */ (document.documentElement);
|
| + var scroller = document.getElementById('scroller');
|
| if (needsHorizontalScroll) {
|
| - htmlNode.classList.remove('no-horizontal-scroll');
|
| + scroller.classList.remove('no-horizontal-scroll');
|
| } else {
|
| - htmlNode.classList.add('no-horizontal-scroll');
|
| + scroller.classList.add('no-horizontal-scroll');
|
| }
|
| if (needsVerticalScroll) {
|
| - htmlNode.classList.remove('no-vertical-scroll');
|
| + scroller.classList.remove('no-vertical-scroll');
|
| } else {
|
| - htmlNode.classList.add('no-vertical-scroll');
|
| + scroller.classList.add('no-vertical-scroll');
|
| }
|
| };
|
|
|
| @@ -553,6 +554,9 @@ remoting.ClientSession.prototype.removePlugin = function() {
|
| function() {
|
| remoting.fullscreen.removeListener(listener);
|
| });
|
| + if (remoting.titleBar) {
|
| + remoting.titleBar.setClientSession(null);
|
| + }
|
|
|
| // Remove mediasource-rendering class from video-contained - this will also
|
| // hide the <video> element.
|
| @@ -738,9 +742,10 @@ remoting.ClientSession.prototype.onSetScreenMode_ = function(event) {
|
| remoting.ClientSession.prototype.setScreenMode_ =
|
| function(shrinkToFit, resizeToClient) {
|
| if (resizeToClient && !this.resizeToClient_) {
|
| - this.plugin_.notifyClientResolution(window.innerWidth,
|
| - window.innerHeight,
|
| - window.devicePixelRatio);
|
| + var clientArea = this.getClientArea_();
|
| + this.plugin_.notifyClientResolution(clientArea.width,
|
| + clientArea.height,
|
| + window.devicePixelRatio);
|
| }
|
|
|
| // If enabling shrink, reset bump-scroll offsets.
|
| @@ -925,13 +930,18 @@ remoting.ClientSession.prototype.onConnectionStatusUpdate_ =
|
| this.setFocusHandlers_();
|
| this.onDesktopSizeChanged_();
|
| if (this.resizeToClient_) {
|
| - this.plugin_.notifyClientResolution(window.innerWidth,
|
| - window.innerHeight,
|
| - window.devicePixelRatio);
|
| + var clientArea = this.getClientArea_();
|
| + this.plugin_.notifyClientResolution(clientArea.width,
|
| + clientArea.height,
|
| + window.devicePixelRatio);
|
| }
|
| - // Start listening for full-screen related events.
|
| + // Activate full-screen related UX.
|
| remoting.fullscreen.addListener(this.callOnFullScreenChanged_);
|
| remoting.fullscreen.syncWithMaximize(true);
|
| + if (remoting.titleBar) {
|
| + remoting.titleBar.setClientSession(this);
|
| + }
|
| +
|
| } else if (status == remoting.ClientSession.State.FAILED) {
|
| switch (error) {
|
| case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE:
|
| @@ -988,9 +998,10 @@ remoting.ClientSession.prototype.onSetCapabilities_ = function(capabilities) {
|
| this.capabilities_ = capabilities;
|
| if (this.hasCapability_(
|
| remoting.ClientSession.Capability.SEND_INITIAL_RESOLUTION)) {
|
| - this.plugin_.notifyClientResolution(window.innerWidth,
|
| - window.innerHeight,
|
| - window.devicePixelRatio);
|
| + var clientArea = this.getClientArea_();
|
| + this.plugin_.notifyClientResolution(clientArea.width,
|
| + clientArea.height,
|
| + window.devicePixelRatio);
|
| }
|
| };
|
|
|
| @@ -1048,10 +1059,11 @@ remoting.ClientSession.prototype.onResize = function() {
|
| remoting.ClientSession.Capability.RATE_LIMIT_RESIZE_REQUESTS)) {
|
| kResizeRateLimitMs = 250;
|
| }
|
| + var clientArea = this.getClientArea_();
|
| this.notifyClientResolutionTimer_ = window.setTimeout(
|
| this.plugin_.notifyClientResolution.bind(this.plugin_,
|
| - window.innerWidth,
|
| - window.innerHeight,
|
| + clientArea.width,
|
| + clientArea.height,
|
| window.devicePixelRatio),
|
| kResizeRateLimitMs);
|
| }
|
| @@ -1116,8 +1128,7 @@ remoting.ClientSession.prototype.updateDimensions = function() {
|
| return;
|
| }
|
|
|
| - var windowWidth = window.innerWidth;
|
| - var windowHeight = window.innerHeight;
|
| + var clientArea = this.getClientArea_();
|
| var desktopWidth = this.plugin_.desktopWidth;
|
| var desktopHeight = this.plugin_.desktopHeight;
|
|
|
| @@ -1142,8 +1153,9 @@ remoting.ClientSession.prototype.updateDimensions = function() {
|
|
|
| if (this.shrinkToFit_) {
|
| // Reduce the scale, if necessary, to fit the whole desktop in the window.
|
| - var scaleFitWidth = Math.min(scale, 1.0 * windowWidth / desktopWidth);
|
| - var scaleFitHeight = Math.min(scale, 1.0 * windowHeight / desktopHeight);
|
| + var scaleFitWidth = Math.min(scale, 1.0 * clientArea.width / desktopWidth);
|
| + var scaleFitHeight =
|
| + Math.min(scale, 1.0 * clientArea.height / desktopHeight);
|
| scale = Math.min(scaleFitHeight, scaleFitWidth);
|
|
|
| // If we're running full-screen then try to handle common side-by-side
|
| @@ -1302,12 +1314,13 @@ remoting.ClientSession.prototype.scroll_ = function(dx, dy) {
|
| };
|
|
|
| var stopX = { stop: false };
|
| + var clientArea = this.getClientArea_();
|
| style.marginLeft = adjustMargin(style.marginLeft, dx,
|
| - window.innerWidth, plugin.clientWidth, stopX);
|
| + clientArea.width, plugin.clientWidth, stopX);
|
|
|
| var stopY = { stop: false };
|
| - style.marginTop = adjustMargin(style.marginTop, dy,
|
| - window.innerHeight, plugin.clientHeight, stopY);
|
| + style.marginTop = adjustMargin(
|
| + style.marginTop, dy, clientArea.height, plugin.clientHeight, stopY);
|
| return stopX.stop && stopY.stop;
|
| };
|
|
|
| @@ -1364,8 +1377,9 @@ remoting.ClientSession.prototype.onMouseMove_ = function(event) {
|
| return 0;
|
| };
|
|
|
| - var dx = computeDelta(event.x, window.innerWidth);
|
| - var dy = computeDelta(event.y, window.innerHeight);
|
| + var clientArea = this.getClientArea_();
|
| + var dx = computeDelta(event.x, clientArea.width);
|
| + var dy = computeDelta(event.y, clientArea.height);
|
|
|
| if (dx != 0 || dy != 0) {
|
| /** @type {remoting.ClientSession} */
|
| @@ -1443,3 +1457,15 @@ remoting.ClientSession.prototype.createGnubbyAuthHandler_ = function() {
|
| this.sendGnubbyAuthMessage({'type': 'control', 'option': 'auth-v1'});
|
| }
|
| };
|
| +
|
| +/**
|
| + * @return {{width: number, height: number}} The height of the window's client
|
| + * area. This differs between apps v1 and apps v2 due to the custom window
|
| + * borders used by the latter.
|
| + * @private
|
| + */
|
| +remoting.ClientSession.prototype.getClientArea_ = function() {
|
| + return remoting.titleBar ?
|
| + remoting.titleBar.getClientArea() :
|
| + { 'width': window.innerWidth, 'height': window.innerHeight };
|
| +}
|
|
|