| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 * | 171 * |
| 172 * TODO(jamiewalch): crbug.com/252796: Remove this once crbug.com/240772 is | 172 * TODO(jamiewalch): crbug.com/252796: Remove this once crbug.com/240772 is |
| 173 * fixed. | 173 * fixed. |
| 174 */ | 174 */ |
| 175 remoting.ClientSession.prototype.updateScrollbarVisibility = function() { | 175 remoting.ClientSession.prototype.updateScrollbarVisibility = function() { |
| 176 var needsVerticalScroll = false; | 176 var needsVerticalScroll = false; |
| 177 var needsHorizontalScroll = false; | 177 var needsHorizontalScroll = false; |
| 178 if (!this.shrinkToFit_) { | 178 if (!this.shrinkToFit_) { |
| 179 // Determine whether or not horizontal or vertical scrollbars are | 179 // Determine whether or not horizontal or vertical scrollbars are |
| 180 // required, taking into account their width. | 180 // required, taking into account their width. |
| 181 needsVerticalScroll = window.innerHeight < this.plugin_.desktopHeight; | 181 var clientArea = this.getClientArea_(); |
| 182 needsHorizontalScroll = window.innerWidth < this.plugin_.desktopWidth; | 182 needsVerticalScroll = clientArea.height < this.plugin_.desktopHeight; |
| 183 needsHorizontalScroll = clientArea.width < this.plugin_.desktopWidth; |
| 183 var kScrollBarWidth = 16; | 184 var kScrollBarWidth = 16; |
| 184 if (needsHorizontalScroll && !needsVerticalScroll) { | 185 if (needsHorizontalScroll && !needsVerticalScroll) { |
| 185 needsVerticalScroll = | 186 needsVerticalScroll = |
| 186 window.innerHeight - kScrollBarWidth < this.plugin_.desktopHeight; | 187 clientArea.height - kScrollBarWidth < this.plugin_.desktopHeight; |
| 187 } else if (!needsHorizontalScroll && needsVerticalScroll) { | 188 } else if (!needsHorizontalScroll && needsVerticalScroll) { |
| 188 needsHorizontalScroll = | 189 needsHorizontalScroll = |
| 189 window.innerWidth - kScrollBarWidth < this.plugin_.desktopWidth; | 190 clientArea.width - kScrollBarWidth < this.plugin_.desktopWidth; |
| 190 } | 191 } |
| 191 } | 192 } |
| 192 | 193 |
| 193 var htmlNode = /** @type {HTMLElement} */ (document.documentElement); | 194 var scroller = document.getElementById('scroller'); |
| 194 if (needsHorizontalScroll) { | 195 if (needsHorizontalScroll) { |
| 195 htmlNode.classList.remove('no-horizontal-scroll'); | 196 scroller.classList.remove('no-horizontal-scroll'); |
| 196 } else { | 197 } else { |
| 197 htmlNode.classList.add('no-horizontal-scroll'); | 198 scroller.classList.add('no-horizontal-scroll'); |
| 198 } | 199 } |
| 199 if (needsVerticalScroll) { | 200 if (needsVerticalScroll) { |
| 200 htmlNode.classList.remove('no-vertical-scroll'); | 201 scroller.classList.remove('no-vertical-scroll'); |
| 201 } else { | 202 } else { |
| 202 htmlNode.classList.add('no-vertical-scroll'); | 203 scroller.classList.add('no-vertical-scroll'); |
| 203 } | 204 } |
| 204 }; | 205 }; |
| 205 | 206 |
| 206 // Note that the positive values in both of these enums are copied directly | 207 // Note that the positive values in both of these enums are copied directly |
| 207 // from chromoting_scriptable_object.h and must be kept in sync. The negative | 208 // from chromoting_scriptable_object.h and must be kept in sync. The negative |
| 208 // values represent state transitions that occur within the web-app that have | 209 // values represent state transitions that occur within the web-app that have |
| 209 // no corresponding plugin state transition. | 210 // no corresponding plugin state transition. |
| 210 /** @enum {number} */ | 211 /** @enum {number} */ |
| 211 remoting.ClientSession.State = { | 212 remoting.ClientSession.State = { |
| 212 CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting. | 213 CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting. |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 'click', this.callToggleFullScreen_, false); | 547 'click', this.callToggleFullScreen_, false); |
| 547 | 548 |
| 548 // Leave full-screen mode, and stop listening for related events. | 549 // Leave full-screen mode, and stop listening for related events. |
| 549 var listener = this.callOnFullScreenChanged_; | 550 var listener = this.callOnFullScreenChanged_; |
| 550 remoting.fullscreen.syncWithMaximize(false); | 551 remoting.fullscreen.syncWithMaximize(false); |
| 551 remoting.fullscreen.activate( | 552 remoting.fullscreen.activate( |
| 552 false, | 553 false, |
| 553 function() { | 554 function() { |
| 554 remoting.fullscreen.removeListener(listener); | 555 remoting.fullscreen.removeListener(listener); |
| 555 }); | 556 }); |
| 557 if (remoting.titleBar) { |
| 558 remoting.titleBar.setClientSession(null); |
| 559 } |
| 556 | 560 |
| 557 // Remove mediasource-rendering class from video-contained - this will also | 561 // Remove mediasource-rendering class from video-contained - this will also |
| 558 // hide the <video> element. | 562 // hide the <video> element. |
| 559 /** @type {HTMLElement} */(document.getElementById('video-container')) | 563 /** @type {HTMLElement} */(document.getElementById('video-container')) |
| 560 .classList.remove('mediasource-rendering'); | 564 .classList.remove('mediasource-rendering'); |
| 561 }; | 565 }; |
| 562 | 566 |
| 563 /** | 567 /** |
| 564 * Deletes the <embed> element from the container and disconnects. | 568 * Deletes the <embed> element from the container and disconnects. |
| 565 * | 569 * |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 * @param {boolean} resizeToClient True if window resizes should cause the | 735 * @param {boolean} resizeToClient True if window resizes should cause the |
| 732 * host to attempt to resize its desktop to match the client window size; | 736 * host to attempt to resize its desktop to match the client window size; |
| 733 * false to disable this behaviour for subsequent window resizes--the | 737 * false to disable this behaviour for subsequent window resizes--the |
| 734 * current host desktop size is not restored in this case. | 738 * current host desktop size is not restored in this case. |
| 735 * @return {void} Nothing. | 739 * @return {void} Nothing. |
| 736 * @private | 740 * @private |
| 737 */ | 741 */ |
| 738 remoting.ClientSession.prototype.setScreenMode_ = | 742 remoting.ClientSession.prototype.setScreenMode_ = |
| 739 function(shrinkToFit, resizeToClient) { | 743 function(shrinkToFit, resizeToClient) { |
| 740 if (resizeToClient && !this.resizeToClient_) { | 744 if (resizeToClient && !this.resizeToClient_) { |
| 741 this.plugin_.notifyClientResolution(window.innerWidth, | 745 var clientArea = this.getClientArea_(); |
| 742 window.innerHeight, | 746 this.plugin_.notifyClientResolution(clientArea.width, |
| 743 window.devicePixelRatio); | 747 clientArea.height, |
| 748 window.devicePixelRatio); |
| 744 } | 749 } |
| 745 | 750 |
| 746 // If enabling shrink, reset bump-scroll offsets. | 751 // If enabling shrink, reset bump-scroll offsets. |
| 747 var needsScrollReset = shrinkToFit && !this.shrinkToFit_; | 752 var needsScrollReset = shrinkToFit && !this.shrinkToFit_; |
| 748 | 753 |
| 749 this.shrinkToFit_ = shrinkToFit; | 754 this.shrinkToFit_ = shrinkToFit; |
| 750 this.resizeToClient_ = resizeToClient; | 755 this.resizeToClient_ = resizeToClient; |
| 751 this.updateScrollbarVisibility(); | 756 this.updateScrollbarVisibility(); |
| 752 | 757 |
| 753 if (this.hostId_ != '') { | 758 if (this.hostId_ != '') { |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 * @private | 923 * @private |
| 919 * @param {number} status The plugin's status. | 924 * @param {number} status The plugin's status. |
| 920 * @param {number} error The plugin's error state, if any. | 925 * @param {number} error The plugin's error state, if any. |
| 921 */ | 926 */ |
| 922 remoting.ClientSession.prototype.onConnectionStatusUpdate_ = | 927 remoting.ClientSession.prototype.onConnectionStatusUpdate_ = |
| 923 function(status, error) { | 928 function(status, error) { |
| 924 if (status == remoting.ClientSession.State.CONNECTED) { | 929 if (status == remoting.ClientSession.State.CONNECTED) { |
| 925 this.setFocusHandlers_(); | 930 this.setFocusHandlers_(); |
| 926 this.onDesktopSizeChanged_(); | 931 this.onDesktopSizeChanged_(); |
| 927 if (this.resizeToClient_) { | 932 if (this.resizeToClient_) { |
| 928 this.plugin_.notifyClientResolution(window.innerWidth, | 933 var clientArea = this.getClientArea_(); |
| 929 window.innerHeight, | 934 this.plugin_.notifyClientResolution(clientArea.width, |
| 930 window.devicePixelRatio); | 935 clientArea.height, |
| 936 window.devicePixelRatio); |
| 931 } | 937 } |
| 932 // Start listening for full-screen related events. | 938 // Activate full-screen related UX. |
| 933 remoting.fullscreen.addListener(this.callOnFullScreenChanged_); | 939 remoting.fullscreen.addListener(this.callOnFullScreenChanged_); |
| 934 remoting.fullscreen.syncWithMaximize(true); | 940 remoting.fullscreen.syncWithMaximize(true); |
| 941 if (remoting.titleBar) { |
| 942 remoting.titleBar.setClientSession(this); |
| 943 } |
| 944 |
| 935 } else if (status == remoting.ClientSession.State.FAILED) { | 945 } else if (status == remoting.ClientSession.State.FAILED) { |
| 936 switch (error) { | 946 switch (error) { |
| 937 case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE: | 947 case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE: |
| 938 this.error_ = remoting.Error.HOST_IS_OFFLINE; | 948 this.error_ = remoting.Error.HOST_IS_OFFLINE; |
| 939 break; | 949 break; |
| 940 case remoting.ClientSession.ConnectionError.SESSION_REJECTED: | 950 case remoting.ClientSession.ConnectionError.SESSION_REJECTED: |
| 941 this.error_ = remoting.Error.INVALID_ACCESS_CODE; | 951 this.error_ = remoting.Error.INVALID_ACCESS_CODE; |
| 942 break; | 952 break; |
| 943 case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL: | 953 case remoting.ClientSession.ConnectionError.INCOMPATIBLE_PROTOCOL: |
| 944 this.error_ = remoting.Error.INCOMPATIBLE_PROTOCOL; | 954 this.error_ = remoting.Error.INCOMPATIBLE_PROTOCOL; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 */ | 991 */ |
| 982 remoting.ClientSession.prototype.onSetCapabilities_ = function(capabilities) { | 992 remoting.ClientSession.prototype.onSetCapabilities_ = function(capabilities) { |
| 983 if (this.capabilities_ != null) { | 993 if (this.capabilities_ != null) { |
| 984 console.error('onSetCapabilities_() is called more than once'); | 994 console.error('onSetCapabilities_() is called more than once'); |
| 985 return; | 995 return; |
| 986 } | 996 } |
| 987 | 997 |
| 988 this.capabilities_ = capabilities; | 998 this.capabilities_ = capabilities; |
| 989 if (this.hasCapability_( | 999 if (this.hasCapability_( |
| 990 remoting.ClientSession.Capability.SEND_INITIAL_RESOLUTION)) { | 1000 remoting.ClientSession.Capability.SEND_INITIAL_RESOLUTION)) { |
| 991 this.plugin_.notifyClientResolution(window.innerWidth, | 1001 var clientArea = this.getClientArea_(); |
| 992 window.innerHeight, | 1002 this.plugin_.notifyClientResolution(clientArea.width, |
| 993 window.devicePixelRatio); | 1003 clientArea.height, |
| 1004 window.devicePixelRatio); |
| 994 } | 1005 } |
| 995 }; | 1006 }; |
| 996 | 1007 |
| 997 /** | 1008 /** |
| 998 * @private | 1009 * @private |
| 999 * @param {remoting.ClientSession.State} newState The new state for the session. | 1010 * @param {remoting.ClientSession.State} newState The new state for the session. |
| 1000 * @return {void} Nothing. | 1011 * @return {void} Nothing. |
| 1001 */ | 1012 */ |
| 1002 remoting.ClientSession.prototype.setState_ = function(newState) { | 1013 remoting.ClientSession.prototype.setState_ = function(newState) { |
| 1003 var oldState = this.state_; | 1014 var oldState = this.state_; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 } | 1052 } |
| 1042 | 1053 |
| 1043 // Defer notifying the host of the change until the window stops resizing, to | 1054 // Defer notifying the host of the change until the window stops resizing, to |
| 1044 // avoid overloading the control channel with notifications. | 1055 // avoid overloading the control channel with notifications. |
| 1045 if (this.resizeToClient_) { | 1056 if (this.resizeToClient_) { |
| 1046 var kResizeRateLimitMs = 1000; | 1057 var kResizeRateLimitMs = 1000; |
| 1047 if (this.hasCapability_( | 1058 if (this.hasCapability_( |
| 1048 remoting.ClientSession.Capability.RATE_LIMIT_RESIZE_REQUESTS)) { | 1059 remoting.ClientSession.Capability.RATE_LIMIT_RESIZE_REQUESTS)) { |
| 1049 kResizeRateLimitMs = 250; | 1060 kResizeRateLimitMs = 250; |
| 1050 } | 1061 } |
| 1062 var clientArea = this.getClientArea_(); |
| 1051 this.notifyClientResolutionTimer_ = window.setTimeout( | 1063 this.notifyClientResolutionTimer_ = window.setTimeout( |
| 1052 this.plugin_.notifyClientResolution.bind(this.plugin_, | 1064 this.plugin_.notifyClientResolution.bind(this.plugin_, |
| 1053 window.innerWidth, | 1065 clientArea.width, |
| 1054 window.innerHeight, | 1066 clientArea.height, |
| 1055 window.devicePixelRatio), | 1067 window.devicePixelRatio), |
| 1056 kResizeRateLimitMs); | 1068 kResizeRateLimitMs); |
| 1057 } | 1069 } |
| 1058 | 1070 |
| 1059 // If bump-scrolling is enabled, adjust the plugin margins to fully utilize | 1071 // If bump-scrolling is enabled, adjust the plugin margins to fully utilize |
| 1060 // the new window area. | 1072 // the new window area. |
| 1061 this.resetScroll_(); | 1073 this.resetScroll_(); |
| 1062 | 1074 |
| 1063 this.updateScrollbarVisibility(); | 1075 this.updateScrollbarVisibility(); |
| 1064 }; | 1076 }; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 * remote desktop and client window, and the current scale-to-fit setting. | 1121 * remote desktop and client window, and the current scale-to-fit setting. |
| 1110 * | 1122 * |
| 1111 * @return {void} Nothing. | 1123 * @return {void} Nothing. |
| 1112 */ | 1124 */ |
| 1113 remoting.ClientSession.prototype.updateDimensions = function() { | 1125 remoting.ClientSession.prototype.updateDimensions = function() { |
| 1114 if (this.plugin_.desktopWidth == 0 || | 1126 if (this.plugin_.desktopWidth == 0 || |
| 1115 this.plugin_.desktopHeight == 0) { | 1127 this.plugin_.desktopHeight == 0) { |
| 1116 return; | 1128 return; |
| 1117 } | 1129 } |
| 1118 | 1130 |
| 1119 var windowWidth = window.innerWidth; | 1131 var clientArea = this.getClientArea_(); |
| 1120 var windowHeight = window.innerHeight; | |
| 1121 var desktopWidth = this.plugin_.desktopWidth; | 1132 var desktopWidth = this.plugin_.desktopWidth; |
| 1122 var desktopHeight = this.plugin_.desktopHeight; | 1133 var desktopHeight = this.plugin_.desktopHeight; |
| 1123 | 1134 |
| 1124 // When configured to display a host at its original size, we aim to display | 1135 // When configured to display a host at its original size, we aim to display |
| 1125 // it as close to its physical size as possible, without losing data: | 1136 // it as close to its physical size as possible, without losing data: |
| 1126 // - If client and host have matching DPI, render the host pixel-for-pixel. | 1137 // - If client and host have matching DPI, render the host pixel-for-pixel. |
| 1127 // - If the host has higher DPI then still render pixel-for-pixel. | 1138 // - If the host has higher DPI then still render pixel-for-pixel. |
| 1128 // - If the host has lower DPI then let Chrome up-scale it to natural size. | 1139 // - If the host has lower DPI then let Chrome up-scale it to natural size. |
| 1129 | 1140 |
| 1130 // We specify the plugin dimensions in Density-Independent Pixels, so to | 1141 // We specify the plugin dimensions in Density-Independent Pixels, so to |
| 1131 // render pixel-for-pixel we need to down-scale the host dimensions by the | 1142 // render pixel-for-pixel we need to down-scale the host dimensions by the |
| 1132 // devicePixelRatio of the client. To match the host pixel density, we choose | 1143 // devicePixelRatio of the client. To match the host pixel density, we choose |
| 1133 // an initial scale factor based on the client devicePixelRatio and host DPI. | 1144 // an initial scale factor based on the client devicePixelRatio and host DPI. |
| 1134 | 1145 |
| 1135 // Determine the effective device pixel ratio of the host, based on DPI. | 1146 // Determine the effective device pixel ratio of the host, based on DPI. |
| 1136 var hostPixelRatioX = Math.ceil(this.plugin_.desktopXDpi / 96); | 1147 var hostPixelRatioX = Math.ceil(this.plugin_.desktopXDpi / 96); |
| 1137 var hostPixelRatioY = Math.ceil(this.plugin_.desktopYDpi / 96); | 1148 var hostPixelRatioY = Math.ceil(this.plugin_.desktopYDpi / 96); |
| 1138 var hostPixelRatio = Math.min(hostPixelRatioX, hostPixelRatioY); | 1149 var hostPixelRatio = Math.min(hostPixelRatioX, hostPixelRatioY); |
| 1139 | 1150 |
| 1140 // Down-scale by the smaller of the client and host ratios. | 1151 // Down-scale by the smaller of the client and host ratios. |
| 1141 var scale = 1.0 / Math.min(window.devicePixelRatio, hostPixelRatio); | 1152 var scale = 1.0 / Math.min(window.devicePixelRatio, hostPixelRatio); |
| 1142 | 1153 |
| 1143 if (this.shrinkToFit_) { | 1154 if (this.shrinkToFit_) { |
| 1144 // Reduce the scale, if necessary, to fit the whole desktop in the window. | 1155 // Reduce the scale, if necessary, to fit the whole desktop in the window. |
| 1145 var scaleFitWidth = Math.min(scale, 1.0 * windowWidth / desktopWidth); | 1156 var scaleFitWidth = Math.min(scale, 1.0 * clientArea.width / desktopWidth); |
| 1146 var scaleFitHeight = Math.min(scale, 1.0 * windowHeight / desktopHeight); | 1157 var scaleFitHeight = |
| 1158 Math.min(scale, 1.0 * clientArea.height / desktopHeight); |
| 1147 scale = Math.min(scaleFitHeight, scaleFitWidth); | 1159 scale = Math.min(scaleFitHeight, scaleFitWidth); |
| 1148 | 1160 |
| 1149 // If we're running full-screen then try to handle common side-by-side | 1161 // If we're running full-screen then try to handle common side-by-side |
| 1150 // multi-monitor combinations more intelligently. | 1162 // multi-monitor combinations more intelligently. |
| 1151 if (remoting.fullscreen.isActive()) { | 1163 if (remoting.fullscreen.isActive()) { |
| 1152 // If the host has two monitors each the same size as the client then | 1164 // If the host has two monitors each the same size as the client then |
| 1153 // scale-to-fit will have the desktop occupy only 50% of the client area, | 1165 // scale-to-fit will have the desktop occupy only 50% of the client area, |
| 1154 // in which case it would be preferable to down-scale less and let the | 1166 // in which case it would be preferable to down-scale less and let the |
| 1155 // user bump-scroll around ("scale-and-pan"). | 1167 // user bump-scroll around ("scale-and-pan"). |
| 1156 // Triggering scale-and-pan if less than 65% of the client area would be | 1168 // 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... |
| 1295 */ | 1307 */ |
| 1296 var adjustMargin = function(curr, delta, windowBound, pluginBound, stop) { | 1308 var adjustMargin = function(curr, delta, windowBound, pluginBound, stop) { |
| 1297 var minMargin = Math.min(0, windowBound - pluginBound); | 1309 var minMargin = Math.min(0, windowBound - pluginBound); |
| 1298 var result = (curr ? parseFloat(curr) : 0) - delta; | 1310 var result = (curr ? parseFloat(curr) : 0) - delta; |
| 1299 result = Math.min(0, Math.max(minMargin, result)); | 1311 result = Math.min(0, Math.max(minMargin, result)); |
| 1300 stop.stop = (result == 0 || result == minMargin); | 1312 stop.stop = (result == 0 || result == minMargin); |
| 1301 return result + 'px'; | 1313 return result + 'px'; |
| 1302 }; | 1314 }; |
| 1303 | 1315 |
| 1304 var stopX = { stop: false }; | 1316 var stopX = { stop: false }; |
| 1317 var clientArea = this.getClientArea_(); |
| 1305 style.marginLeft = adjustMargin(style.marginLeft, dx, | 1318 style.marginLeft = adjustMargin(style.marginLeft, dx, |
| 1306 window.innerWidth, plugin.clientWidth, stopX); | 1319 clientArea.width, plugin.clientWidth, stopX); |
| 1307 | 1320 |
| 1308 var stopY = { stop: false }; | 1321 var stopY = { stop: false }; |
| 1309 style.marginTop = adjustMargin(style.marginTop, dy, | 1322 style.marginTop = adjustMargin( |
| 1310 window.innerHeight, plugin.clientHeight, stopY); | 1323 style.marginTop, dy, clientArea.height, plugin.clientHeight, stopY); |
| 1311 return stopX.stop && stopY.stop; | 1324 return stopX.stop && stopY.stop; |
| 1312 }; | 1325 }; |
| 1313 | 1326 |
| 1314 remoting.ClientSession.prototype.resetScroll_ = function() { | 1327 remoting.ClientSession.prototype.resetScroll_ = function() { |
| 1315 if (this.plugin_) { | 1328 if (this.plugin_) { |
| 1316 var plugin = this.plugin_.element(); | 1329 var plugin = this.plugin_.element(); |
| 1317 plugin.style.marginTop = '0px'; | 1330 plugin.style.marginTop = '0px'; |
| 1318 plugin.style.marginLeft = '0px'; | 1331 plugin.style.marginLeft = '0px'; |
| 1319 } | 1332 } |
| 1320 }; | 1333 }; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 var computeDelta = function(mousePos, size) { | 1370 var computeDelta = function(mousePos, size) { |
| 1358 var threshold = 10; | 1371 var threshold = 10; |
| 1359 if (mousePos >= size - threshold) { | 1372 if (mousePos >= size - threshold) { |
| 1360 return 1 + 5 * (mousePos - (size - threshold)) / threshold; | 1373 return 1 + 5 * (mousePos - (size - threshold)) / threshold; |
| 1361 } else if (mousePos <= threshold) { | 1374 } else if (mousePos <= threshold) { |
| 1362 return -1 - 5 * (threshold - mousePos) / threshold; | 1375 return -1 - 5 * (threshold - mousePos) / threshold; |
| 1363 } | 1376 } |
| 1364 return 0; | 1377 return 0; |
| 1365 }; | 1378 }; |
| 1366 | 1379 |
| 1367 var dx = computeDelta(event.x, window.innerWidth); | 1380 var clientArea = this.getClientArea_(); |
| 1368 var dy = computeDelta(event.y, window.innerHeight); | 1381 var dx = computeDelta(event.x, clientArea.width); |
| 1382 var dy = computeDelta(event.y, clientArea.height); |
| 1369 | 1383 |
| 1370 if (dx != 0 || dy != 0) { | 1384 if (dx != 0 || dy != 0) { |
| 1371 /** @type {remoting.ClientSession} */ | 1385 /** @type {remoting.ClientSession} */ |
| 1372 var that = this; | 1386 var that = this; |
| 1373 /** | 1387 /** |
| 1374 * Scroll the view, and schedule a timer to do so again unless we've hit | 1388 * Scroll the view, and schedule a timer to do so again unless we've hit |
| 1375 * the edges of the screen. This timer is cancelled when the mouse moves. | 1389 * the edges of the screen. This timer is cancelled when the mouse moves. |
| 1376 * @param {number} expected The time at which we expect to be called. | 1390 * @param {number} expected The time at which we expect to be called. |
| 1377 */ | 1391 */ |
| 1378 var repeatScroll = function(expected) { | 1392 var repeatScroll = function(expected) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 * supported. | 1450 * supported. |
| 1437 * @private | 1451 * @private |
| 1438 */ | 1452 */ |
| 1439 remoting.ClientSession.prototype.createGnubbyAuthHandler_ = function() { | 1453 remoting.ClientSession.prototype.createGnubbyAuthHandler_ = function() { |
| 1440 if (this.mode_ == remoting.ClientSession.Mode.ME2ME) { | 1454 if (this.mode_ == remoting.ClientSession.Mode.ME2ME) { |
| 1441 this.gnubbyAuthHandler_ = new remoting.GnubbyAuthHandler(this); | 1455 this.gnubbyAuthHandler_ = new remoting.GnubbyAuthHandler(this); |
| 1442 // TODO(psj): Move to more generic capabilities mechanism. | 1456 // TODO(psj): Move to more generic capabilities mechanism. |
| 1443 this.sendGnubbyAuthMessage({'type': 'control', 'option': 'auth-v1'}); | 1457 this.sendGnubbyAuthMessage({'type': 'control', 'option': 'auth-v1'}); |
| 1444 } | 1458 } |
| 1445 }; | 1459 }; |
| 1460 |
| 1461 /** |
| 1462 * @return {{width: number, height: number}} The height of the window's client |
| 1463 * area. This differs between apps v1 and apps v2 due to the custom window |
| 1464 * borders used by the latter. |
| 1465 * @private |
| 1466 */ |
| 1467 remoting.ClientSession.prototype.getClientArea_ = function() { |
| 1468 return remoting.titleBar ? |
| 1469 remoting.titleBar.getClientArea() : |
| 1470 { 'width': window.innerWidth, 'height': window.innerHeight }; |
| 1471 } |
| OLD | NEW |