OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Class handling creation and teardown of a remoting client session. | 7 * Class handling creation and teardown of a remoting client session. |
8 * | 8 * |
9 * The ClientSession class controls lifetime of the client plugin | 9 * The ClientSession class controls lifetime of the client plugin |
10 * object and provides the plugin with the functionality it needs to | 10 * object and provides the plugin with the functionality it needs to |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 * | 169 * |
170 * TODO(jamiewalch): crbug.com/252796: Remove this once crbug.com/240772 is | 170 * TODO(jamiewalch): crbug.com/252796: Remove this once crbug.com/240772 is |
171 * fixed. | 171 * fixed. |
172 */ | 172 */ |
173 remoting.ClientSession.prototype.updateScrollbarVisibility = function() { | 173 remoting.ClientSession.prototype.updateScrollbarVisibility = function() { |
174 var needsVerticalScroll = false; | 174 var needsVerticalScroll = false; |
175 var needsHorizontalScroll = false; | 175 var needsHorizontalScroll = false; |
176 if (!this.shrinkToFit_) { | 176 if (!this.shrinkToFit_) { |
177 // Determine whether or not horizontal or vertical scrollbars are | 177 // Determine whether or not horizontal or vertical scrollbars are |
178 // required, taking into account their width. | 178 // required, taking into account their width. |
179 needsVerticalScroll = window.innerHeight < this.plugin_.desktopHeight; | 179 var clientArea = this.getClientArea_(); |
180 needsHorizontalScroll = window.innerWidth < this.plugin_.desktopWidth; | 180 needsVerticalScroll = clientArea.height < this.plugin_.desktopHeight; |
| 181 needsHorizontalScroll = clientArea.width < this.plugin_.desktopWidth; |
181 var kScrollBarWidth = 16; | 182 var kScrollBarWidth = 16; |
182 if (needsHorizontalScroll && !needsVerticalScroll) { | 183 if (needsHorizontalScroll && !needsVerticalScroll) { |
183 needsVerticalScroll = | 184 needsVerticalScroll = |
184 window.innerHeight - kScrollBarWidth < this.plugin_.desktopHeight; | 185 clientArea.height - kScrollBarWidth < this.plugin_.desktopHeight; |
185 } else if (!needsHorizontalScroll && needsVerticalScroll) { | 186 } else if (!needsHorizontalScroll && needsVerticalScroll) { |
186 needsHorizontalScroll = | 187 needsHorizontalScroll = |
187 window.innerWidth - kScrollBarWidth < this.plugin_.desktopWidth; | 188 clientArea.width - kScrollBarWidth < this.plugin_.desktopWidth; |
188 } | 189 } |
189 } | 190 } |
190 | 191 |
191 var htmlNode = /** @type {HTMLElement} */ (document.documentElement); | 192 var scroller = document.getElementById('scroller'); |
192 if (needsHorizontalScroll) { | 193 if (needsHorizontalScroll) { |
193 htmlNode.classList.remove('no-horizontal-scroll'); | 194 scroller.classList.remove('no-horizontal-scroll'); |
194 } else { | 195 } else { |
195 htmlNode.classList.add('no-horizontal-scroll'); | 196 scroller.classList.add('no-horizontal-scroll'); |
196 } | 197 } |
197 if (needsVerticalScroll) { | 198 if (needsVerticalScroll) { |
198 htmlNode.classList.remove('no-vertical-scroll'); | 199 scroller.classList.remove('no-vertical-scroll'); |
199 } else { | 200 } else { |
200 htmlNode.classList.add('no-vertical-scroll'); | 201 scroller.classList.add('no-vertical-scroll'); |
201 } | 202 } |
202 }; | 203 }; |
203 | 204 |
204 // Note that the positive values in both of these enums are copied directly | 205 // Note that the positive values in both of these enums are copied directly |
205 // from chromoting_scriptable_object.h and must be kept in sync. The negative | 206 // from chromoting_scriptable_object.h and must be kept in sync. The negative |
206 // values represent state transitions that occur within the web-app that have | 207 // values represent state transitions that occur within the web-app that have |
207 // no corresponding plugin state transition. | 208 // no corresponding plugin state transition. |
208 /** @enum {number} */ | 209 /** @enum {number} */ |
209 remoting.ClientSession.State = { | 210 remoting.ClientSession.State = { |
210 CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting. | 211 CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting. |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 'click', this.callToggleFullScreen_, false); | 562 'click', this.callToggleFullScreen_, false); |
562 | 563 |
563 // Leave full-screen mode, and stop listening for related events. | 564 // Leave full-screen mode, and stop listening for related events. |
564 var listener = this.callOnFullScreenChanged_; | 565 var listener = this.callOnFullScreenChanged_; |
565 remoting.fullscreen.syncWithMaximize(false); | 566 remoting.fullscreen.syncWithMaximize(false); |
566 remoting.fullscreen.activate( | 567 remoting.fullscreen.activate( |
567 false, | 568 false, |
568 function() { | 569 function() { |
569 remoting.fullscreen.removeListener(listener); | 570 remoting.fullscreen.removeListener(listener); |
570 }); | 571 }); |
| 572 if (remoting.windowFrame) { |
| 573 remoting.windowFrame.setConnected(false); |
| 574 } |
571 | 575 |
572 // Remove mediasource-rendering class from video-contained - this will also | 576 // Remove mediasource-rendering class from video-contained - this will also |
573 // hide the <video> element. | 577 // hide the <video> element. |
574 /** @type {HTMLElement} */(document.getElementById('video-container')) | 578 /** @type {HTMLElement} */(document.getElementById('video-container')) |
575 .classList.remove('mediasource-rendering'); | 579 .classList.remove('mediasource-rendering'); |
576 }; | 580 }; |
577 | 581 |
578 /** | 582 /** |
579 * Disconnect the current session with a particular |error|. The session will | 583 * Disconnect the current session with a particular |error|. The session will |
580 * raise a |stateChanged| event in response to it. The caller should then call | 584 * raise a |stateChanged| event in response to it. The caller should then call |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 * @param {boolean} resizeToClient True if window resizes should cause the | 763 * @param {boolean} resizeToClient True if window resizes should cause the |
760 * host to attempt to resize its desktop to match the client window size; | 764 * host to attempt to resize its desktop to match the client window size; |
761 * false to disable this behaviour for subsequent window resizes--the | 765 * false to disable this behaviour for subsequent window resizes--the |
762 * current host desktop size is not restored in this case. | 766 * current host desktop size is not restored in this case. |
763 * @return {void} Nothing. | 767 * @return {void} Nothing. |
764 * @private | 768 * @private |
765 */ | 769 */ |
766 remoting.ClientSession.prototype.setScreenMode_ = | 770 remoting.ClientSession.prototype.setScreenMode_ = |
767 function(shrinkToFit, resizeToClient) { | 771 function(shrinkToFit, resizeToClient) { |
768 if (resizeToClient && !this.resizeToClient_) { | 772 if (resizeToClient && !this.resizeToClient_) { |
769 this.plugin_.notifyClientResolution(window.innerWidth, | 773 var clientArea = this.getClientArea_(); |
770 window.innerHeight, | 774 this.plugin_.notifyClientResolution(clientArea.width, |
771 window.devicePixelRatio); | 775 clientArea.height, |
| 776 window.devicePixelRatio); |
772 } | 777 } |
773 | 778 |
774 // If enabling shrink, reset bump-scroll offsets. | 779 // If enabling shrink, reset bump-scroll offsets. |
775 var needsScrollReset = shrinkToFit && !this.shrinkToFit_; | 780 var needsScrollReset = shrinkToFit && !this.shrinkToFit_; |
776 | 781 |
777 this.shrinkToFit_ = shrinkToFit; | 782 this.shrinkToFit_ = shrinkToFit; |
778 this.resizeToClient_ = resizeToClient; | 783 this.resizeToClient_ = resizeToClient; |
779 this.updateScrollbarVisibility(); | 784 this.updateScrollbarVisibility(); |
780 | 785 |
781 if (this.hostId_ != '') { | 786 if (this.hostId_ != '') { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 * @private | 951 * @private |
947 * @param {number} status The plugin's status. | 952 * @param {number} status The plugin's status. |
948 * @param {number} error The plugin's error state, if any. | 953 * @param {number} error The plugin's error state, if any. |
949 */ | 954 */ |
950 remoting.ClientSession.prototype.onConnectionStatusUpdate_ = | 955 remoting.ClientSession.prototype.onConnectionStatusUpdate_ = |
951 function(status, error) { | 956 function(status, error) { |
952 if (status == remoting.ClientSession.State.CONNECTED) { | 957 if (status == remoting.ClientSession.State.CONNECTED) { |
953 this.setFocusHandlers_(); | 958 this.setFocusHandlers_(); |
954 this.onDesktopSizeChanged_(); | 959 this.onDesktopSizeChanged_(); |
955 if (this.resizeToClient_) { | 960 if (this.resizeToClient_) { |
956 this.plugin_.notifyClientResolution(window.innerWidth, | 961 var clientArea = this.getClientArea_(); |
957 window.innerHeight, | 962 this.plugin_.notifyClientResolution(clientArea.width, |
958 window.devicePixelRatio); | 963 clientArea.height, |
| 964 window.devicePixelRatio); |
959 } | 965 } |
960 // Start listening for full-screen related events. | 966 // Activate full-screen related UX. |
961 remoting.fullscreen.addListener(this.callOnFullScreenChanged_); | 967 remoting.fullscreen.addListener(this.callOnFullScreenChanged_); |
962 remoting.fullscreen.syncWithMaximize(true); | 968 remoting.fullscreen.syncWithMaximize(true); |
| 969 if (remoting.windowFrame) { |
| 970 remoting.windowFrame.setConnected(true); |
| 971 } |
| 972 |
963 } else if (status == remoting.ClientSession.State.FAILED) { | 973 } else if (status == remoting.ClientSession.State.FAILED) { |
964 switch (error) { | 974 switch (error) { |
965 case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE: | 975 case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE: |
966 this.error_ = remoting.Error.HOST_IS_OFFLINE; | 976 this.error_ = remoting.Error.HOST_IS_OFFLINE; |
967 break; | 977 break; |
968 case remoting.ClientSession.ConnectionError.SESSION_REJECTED: | 978 case remoting.ClientSession.ConnectionError.SESSION_REJECTED: |
969 this.error_ = remoting.Error.INVALID_ACCESS_CODE; | 979 this.error_ = remoting.Error.INVALID_ACCESS_CODE; |
970 break; | 980 break; |
971 case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL: | 981 case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL: |
972 this.error_ = remoting.Error.INCOMPATIBLE_PROTOCOL; | 982 this.error_ = remoting.Error.INCOMPATIBLE_PROTOCOL; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 */ | 1022 */ |
1013 remoting.ClientSession.prototype.onSetCapabilities_ = function(capabilities) { | 1023 remoting.ClientSession.prototype.onSetCapabilities_ = function(capabilities) { |
1014 if (this.capabilities_ != null) { | 1024 if (this.capabilities_ != null) { |
1015 console.error('onSetCapabilities_() is called more than once'); | 1025 console.error('onSetCapabilities_() is called more than once'); |
1016 return; | 1026 return; |
1017 } | 1027 } |
1018 | 1028 |
1019 this.capabilities_ = capabilities; | 1029 this.capabilities_ = capabilities; |
1020 if (this.hasCapability_( | 1030 if (this.hasCapability_( |
1021 remoting.ClientSession.Capability.SEND_INITIAL_RESOLUTION)) { | 1031 remoting.ClientSession.Capability.SEND_INITIAL_RESOLUTION)) { |
1022 this.plugin_.notifyClientResolution(window.innerWidth, | 1032 var clientArea = this.getClientArea_(); |
1023 window.innerHeight, | 1033 this.plugin_.notifyClientResolution(clientArea.width, |
1024 window.devicePixelRatio); | 1034 clientArea.height, |
| 1035 window.devicePixelRatio); |
1025 } | 1036 } |
1026 }; | 1037 }; |
1027 | 1038 |
1028 /** | 1039 /** |
1029 * @private | 1040 * @private |
1030 * @param {remoting.ClientSession.State} newState The new state for the session. | 1041 * @param {remoting.ClientSession.State} newState The new state for the session. |
1031 * @return {void} Nothing. | 1042 * @return {void} Nothing. |
1032 */ | 1043 */ |
1033 remoting.ClientSession.prototype.setState_ = function(newState) { | 1044 remoting.ClientSession.prototype.setState_ = function(newState) { |
1034 var oldState = this.state_; | 1045 var oldState = this.state_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 } | 1084 } |
1074 | 1085 |
1075 // Defer notifying the host of the change until the window stops resizing, to | 1086 // Defer notifying the host of the change until the window stops resizing, to |
1076 // avoid overloading the control channel with notifications. | 1087 // avoid overloading the control channel with notifications. |
1077 if (this.resizeToClient_) { | 1088 if (this.resizeToClient_) { |
1078 var kResizeRateLimitMs = 1000; | 1089 var kResizeRateLimitMs = 1000; |
1079 if (this.hasCapability_( | 1090 if (this.hasCapability_( |
1080 remoting.ClientSession.Capability.RATE_LIMIT_RESIZE_REQUESTS)) { | 1091 remoting.ClientSession.Capability.RATE_LIMIT_RESIZE_REQUESTS)) { |
1081 kResizeRateLimitMs = 250; | 1092 kResizeRateLimitMs = 250; |
1082 } | 1093 } |
| 1094 var clientArea = this.getClientArea_(); |
1083 this.notifyClientResolutionTimer_ = window.setTimeout( | 1095 this.notifyClientResolutionTimer_ = window.setTimeout( |
1084 this.plugin_.notifyClientResolution.bind(this.plugin_, | 1096 this.plugin_.notifyClientResolution.bind(this.plugin_, |
1085 window.innerWidth, | 1097 clientArea.width, |
1086 window.innerHeight, | 1098 clientArea.height, |
1087 window.devicePixelRatio), | 1099 window.devicePixelRatio), |
1088 kResizeRateLimitMs); | 1100 kResizeRateLimitMs); |
1089 } | 1101 } |
1090 | 1102 |
1091 // If bump-scrolling is enabled, adjust the plugin margins to fully utilize | 1103 // If bump-scrolling is enabled, adjust the plugin margins to fully utilize |
1092 // the new window area. | 1104 // the new window area. |
1093 this.resetScroll_(); | 1105 this.resetScroll_(); |
1094 | 1106 |
1095 this.updateScrollbarVisibility(); | 1107 this.updateScrollbarVisibility(); |
1096 }; | 1108 }; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 * remote desktop and client window, and the current scale-to-fit setting. | 1153 * remote desktop and client window, and the current scale-to-fit setting. |
1142 * | 1154 * |
1143 * @return {void} Nothing. | 1155 * @return {void} Nothing. |
1144 */ | 1156 */ |
1145 remoting.ClientSession.prototype.updateDimensions = function() { | 1157 remoting.ClientSession.prototype.updateDimensions = function() { |
1146 if (this.plugin_.desktopWidth == 0 || | 1158 if (this.plugin_.desktopWidth == 0 || |
1147 this.plugin_.desktopHeight == 0) { | 1159 this.plugin_.desktopHeight == 0) { |
1148 return; | 1160 return; |
1149 } | 1161 } |
1150 | 1162 |
1151 var windowWidth = window.innerWidth; | 1163 var clientArea = this.getClientArea_(); |
1152 var windowHeight = window.innerHeight; | |
1153 var desktopWidth = this.plugin_.desktopWidth; | 1164 var desktopWidth = this.plugin_.desktopWidth; |
1154 var desktopHeight = this.plugin_.desktopHeight; | 1165 var desktopHeight = this.plugin_.desktopHeight; |
1155 | 1166 |
1156 // When configured to display a host at its original size, we aim to display | 1167 // When configured to display a host at its original size, we aim to display |
1157 // it as close to its physical size as possible, without losing data: | 1168 // it as close to its physical size as possible, without losing data: |
1158 // - If client and host have matching DPI, render the host pixel-for-pixel. | 1169 // - If client and host have matching DPI, render the host pixel-for-pixel. |
1159 // - If the host has higher DPI then still render pixel-for-pixel. | 1170 // - If the host has higher DPI then still render pixel-for-pixel. |
1160 // - If the host has lower DPI then let Chrome up-scale it to natural size. | 1171 // - If the host has lower DPI then let Chrome up-scale it to natural size. |
1161 | 1172 |
1162 // We specify the plugin dimensions in Density-Independent Pixels, so to | 1173 // We specify the plugin dimensions in Density-Independent Pixels, so to |
1163 // render pixel-for-pixel we need to down-scale the host dimensions by the | 1174 // render pixel-for-pixel we need to down-scale the host dimensions by the |
1164 // devicePixelRatio of the client. To match the host pixel density, we choose | 1175 // devicePixelRatio of the client. To match the host pixel density, we choose |
1165 // an initial scale factor based on the client devicePixelRatio and host DPI. | 1176 // an initial scale factor based on the client devicePixelRatio and host DPI. |
1166 | 1177 |
1167 // Determine the effective device pixel ratio of the host, based on DPI. | 1178 // Determine the effective device pixel ratio of the host, based on DPI. |
1168 var hostPixelRatioX = Math.ceil(this.plugin_.desktopXDpi / 96); | 1179 var hostPixelRatioX = Math.ceil(this.plugin_.desktopXDpi / 96); |
1169 var hostPixelRatioY = Math.ceil(this.plugin_.desktopYDpi / 96); | 1180 var hostPixelRatioY = Math.ceil(this.plugin_.desktopYDpi / 96); |
1170 var hostPixelRatio = Math.min(hostPixelRatioX, hostPixelRatioY); | 1181 var hostPixelRatio = Math.min(hostPixelRatioX, hostPixelRatioY); |
1171 | 1182 |
1172 // Down-scale by the smaller of the client and host ratios. | 1183 // Down-scale by the smaller of the client and host ratios. |
1173 var scale = 1.0 / Math.min(window.devicePixelRatio, hostPixelRatio); | 1184 var scale = 1.0 / Math.min(window.devicePixelRatio, hostPixelRatio); |
1174 | 1185 |
1175 if (this.shrinkToFit_) { | 1186 if (this.shrinkToFit_) { |
1176 // Reduce the scale, if necessary, to fit the whole desktop in the window. | 1187 // Reduce the scale, if necessary, to fit the whole desktop in the window. |
1177 var scaleFitWidth = Math.min(scale, 1.0 * windowWidth / desktopWidth); | 1188 var scaleFitWidth = Math.min(scale, 1.0 * clientArea.width / desktopWidth); |
1178 var scaleFitHeight = Math.min(scale, 1.0 * windowHeight / desktopHeight); | 1189 var scaleFitHeight = |
| 1190 Math.min(scale, 1.0 * clientArea.height / desktopHeight); |
1179 scale = Math.min(scaleFitHeight, scaleFitWidth); | 1191 scale = Math.min(scaleFitHeight, scaleFitWidth); |
1180 | 1192 |
1181 // If we're running full-screen then try to handle common side-by-side | 1193 // If we're running full-screen then try to handle common side-by-side |
1182 // multi-monitor combinations more intelligently. | 1194 // multi-monitor combinations more intelligently. |
1183 if (remoting.fullscreen.isActive()) { | 1195 if (remoting.fullscreen.isActive()) { |
1184 // If the host has two monitors each the same size as the client then | 1196 // If the host has two monitors each the same size as the client then |
1185 // scale-to-fit will have the desktop occupy only 50% of the client area, | 1197 // scale-to-fit will have the desktop occupy only 50% of the client area, |
1186 // in which case it would be preferable to down-scale less and let the | 1198 // in which case it would be preferable to down-scale less and let the |
1187 // user bump-scroll around ("scale-and-pan"). | 1199 // user bump-scroll around ("scale-and-pan"). |
1188 // Triggering scale-and-pan if less than 65% of the client area would be | 1200 // Triggering scale-and-pan if less than 65% of the client area would be |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 */ | 1339 */ |
1328 var adjustMargin = function(curr, delta, windowBound, pluginBound, stop) { | 1340 var adjustMargin = function(curr, delta, windowBound, pluginBound, stop) { |
1329 var minMargin = Math.min(0, windowBound - pluginBound); | 1341 var minMargin = Math.min(0, windowBound - pluginBound); |
1330 var result = (curr ? parseFloat(curr) : 0) - delta; | 1342 var result = (curr ? parseFloat(curr) : 0) - delta; |
1331 result = Math.min(0, Math.max(minMargin, result)); | 1343 result = Math.min(0, Math.max(minMargin, result)); |
1332 stop.stop = (result == 0 || result == minMargin); | 1344 stop.stop = (result == 0 || result == minMargin); |
1333 return result + 'px'; | 1345 return result + 'px'; |
1334 }; | 1346 }; |
1335 | 1347 |
1336 var stopX = { stop: false }; | 1348 var stopX = { stop: false }; |
| 1349 var clientArea = this.getClientArea_(); |
1337 style.marginLeft = adjustMargin(style.marginLeft, dx, | 1350 style.marginLeft = adjustMargin(style.marginLeft, dx, |
1338 window.innerWidth, plugin.clientWidth, stopX); | 1351 clientArea.width, plugin.clientWidth, stopX); |
1339 | 1352 |
1340 var stopY = { stop: false }; | 1353 var stopY = { stop: false }; |
1341 style.marginTop = adjustMargin(style.marginTop, dy, | 1354 style.marginTop = adjustMargin( |
1342 window.innerHeight, plugin.clientHeight, stopY); | 1355 style.marginTop, dy, clientArea.height, plugin.clientHeight, stopY); |
1343 return stopX.stop && stopY.stop; | 1356 return stopX.stop && stopY.stop; |
1344 }; | 1357 }; |
1345 | 1358 |
1346 remoting.ClientSession.prototype.resetScroll_ = function() { | 1359 remoting.ClientSession.prototype.resetScroll_ = function() { |
1347 if (this.plugin_) { | 1360 if (this.plugin_) { |
1348 var plugin = this.plugin_.element(); | 1361 var plugin = this.plugin_.element(); |
1349 plugin.style.marginTop = '0px'; | 1362 plugin.style.marginTop = '0px'; |
1350 plugin.style.marginLeft = '0px'; | 1363 plugin.style.marginLeft = '0px'; |
1351 } | 1364 } |
1352 }; | 1365 }; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 var computeDelta = function(mousePos, size) { | 1402 var computeDelta = function(mousePos, size) { |
1390 var threshold = 10; | 1403 var threshold = 10; |
1391 if (mousePos >= size - threshold) { | 1404 if (mousePos >= size - threshold) { |
1392 return 1 + 5 * (mousePos - (size - threshold)) / threshold; | 1405 return 1 + 5 * (mousePos - (size - threshold)) / threshold; |
1393 } else if (mousePos <= threshold) { | 1406 } else if (mousePos <= threshold) { |
1394 return -1 - 5 * (threshold - mousePos) / threshold; | 1407 return -1 - 5 * (threshold - mousePos) / threshold; |
1395 } | 1408 } |
1396 return 0; | 1409 return 0; |
1397 }; | 1410 }; |
1398 | 1411 |
1399 var dx = computeDelta(event.x, window.innerWidth); | 1412 var clientArea = this.getClientArea_(); |
1400 var dy = computeDelta(event.y, window.innerHeight); | 1413 var dx = computeDelta(event.x, clientArea.width); |
| 1414 var dy = computeDelta(event.y, clientArea.height); |
1401 | 1415 |
1402 if (dx != 0 || dy != 0) { | 1416 if (dx != 0 || dy != 0) { |
1403 /** @type {remoting.ClientSession} */ | 1417 /** @type {remoting.ClientSession} */ |
1404 var that = this; | 1418 var that = this; |
1405 /** | 1419 /** |
1406 * Scroll the view, and schedule a timer to do so again unless we've hit | 1420 * Scroll the view, and schedule a timer to do so again unless we've hit |
1407 * the edges of the screen. This timer is cancelled when the mouse moves. | 1421 * the edges of the screen. This timer is cancelled when the mouse moves. |
1408 * @param {number} expected The time at which we expect to be called. | 1422 * @param {number} expected The time at which we expect to be called. |
1409 */ | 1423 */ |
1410 var repeatScroll = function(expected) { | 1424 var repeatScroll = function(expected) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 * supported. | 1482 * supported. |
1469 * @private | 1483 * @private |
1470 */ | 1484 */ |
1471 remoting.ClientSession.prototype.createGnubbyAuthHandler_ = function() { | 1485 remoting.ClientSession.prototype.createGnubbyAuthHandler_ = function() { |
1472 if (this.mode_ == remoting.ClientSession.Mode.ME2ME) { | 1486 if (this.mode_ == remoting.ClientSession.Mode.ME2ME) { |
1473 this.gnubbyAuthHandler_ = new remoting.GnubbyAuthHandler(this); | 1487 this.gnubbyAuthHandler_ = new remoting.GnubbyAuthHandler(this); |
1474 // TODO(psj): Move to more generic capabilities mechanism. | 1488 // TODO(psj): Move to more generic capabilities mechanism. |
1475 this.sendGnubbyAuthMessage({'type': 'control', 'option': 'auth-v1'}); | 1489 this.sendGnubbyAuthMessage({'type': 'control', 'option': 'auth-v1'}); |
1476 } | 1490 } |
1477 }; | 1491 }; |
| 1492 |
| 1493 /** |
| 1494 * @return {{width: number, height: number}} The height of the window's client |
| 1495 * area. This differs between apps v1 and apps v2 due to the custom window |
| 1496 * borders used by the latter. |
| 1497 * @private |
| 1498 */ |
| 1499 remoting.ClientSession.prototype.getClientArea_ = function() { |
| 1500 return remoting.windowFrame ? |
| 1501 remoting.windowFrame.getClientArea() : |
| 1502 { 'width': window.innerWidth, 'height': window.innerHeight }; |
| 1503 } |
OLD | NEW |