| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * Implements a basic UX control for a connected remoting session. | 7 * Implements a basic UX control for a connected remoting session. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 /** @suppress {duplicate} */ | 10 /** @suppress {duplicate} */ |
| 11 var remoting = remoting || {}; | 11 var remoting = remoting || {}; |
| 12 | 12 |
| 13 (function() { | 13 (function() { |
| 14 | 14 |
| 15 'use strict'; | 15 'use strict'; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * True to enable mouse lock. | |
| 19 * This is currently disabled because the current client plugin does not | |
| 20 * properly handle mouse lock and delegated large cursors at the same time. | |
| 21 * This should be re-enabled (by removing this flag) once a version of | |
| 22 * the plugin that supports both has reached Chrome Stable channel. | |
| 23 * (crbug.com/429322). | |
| 24 * | |
| 25 * @type {boolean} | |
| 26 */ | |
| 27 remoting.enableMouseLock = false; | |
| 28 | |
| 29 /** | |
| 30 * @param {remoting.ClientPlugin} plugin | 18 * @param {remoting.ClientPlugin} plugin |
| 31 * @param {HTMLElement} viewportElement | 19 * @param {HTMLElement} viewportElement |
| 32 * @param {HTMLElement} cursorElement | 20 * @param {HTMLElement} cursorElement |
| 33 * | 21 * |
| 34 * @constructor | 22 * @constructor |
| 35 * @implements {base.Disposable} | 23 * @implements {base.Disposable} |
| 36 */ | 24 */ |
| 37 remoting.ConnectedView = function(plugin, viewportElement, cursorElement) { | 25 remoting.ConnectedView = function(plugin, viewportElement, cursorElement) { |
| 38 /** @private */ | 26 /** @private */ |
| 39 this.viewportElement_ = viewportElement; | 27 this.viewportElement_ = viewportElement; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 57 new base.DomEventHook(pluginElement, 'focus', | 45 new base.DomEventHook(pluginElement, 'focus', |
| 58 this.onPluginGotFocus_.bind(this), false), | 46 this.onPluginGotFocus_.bind(this), false), |
| 59 new base.DomEventHook(pluginElement, 'blur', | 47 new base.DomEventHook(pluginElement, 'blur', |
| 60 this.onPluginLostFocus_.bind(this), false), | 48 this.onPluginLostFocus_.bind(this), false), |
| 61 new base.DomEventHook(document, 'visibilitychange', | 49 new base.DomEventHook(document, 'visibilitychange', |
| 62 this.onVisibilityChanged_.bind(this), false) | 50 this.onVisibilityChanged_.bind(this), false) |
| 63 ); | 51 ); |
| 64 | 52 |
| 65 // TODO(wez): Only allow mouse lock if the app has the pointerLock permission. | 53 // TODO(wez): Only allow mouse lock if the app has the pointerLock permission. |
| 66 // Enable automatic mouse-lock. | 54 // Enable automatic mouse-lock. |
| 67 if (remoting.enableMouseLock && | 55 if (this.plugin_.hasFeature(remoting.ClientPlugin.Feature.ALLOW_MOUSE_LOCK)) { |
| 68 this.plugin_.hasFeature(remoting.ClientPlugin.Feature.ALLOW_MOUSE_LOCK)) { | |
| 69 this.plugin_.allowMouseLock(); | 56 this.plugin_.allowMouseLock(); |
| 70 } | 57 } |
| 71 | 58 |
| 72 pluginElement.focus(); | 59 pluginElement.focus(); |
| 73 }; | 60 }; |
| 74 | 61 |
| 75 /** | 62 /** |
| 76 * @return {void} Nothing. | 63 * @return {void} Nothing. |
| 77 */ | 64 */ |
| 78 remoting.ConnectedView.prototype.dispose = function() { | 65 remoting.ConnectedView.prototype.dispose = function() { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 /** | 198 /** |
| 212 * @param {Event} event | 199 * @param {Event} event |
| 213 * @private | 200 * @private |
| 214 */ | 201 */ |
| 215 remoting.ConnectedView.Cursor.prototype.onMouseMoved_ = function(event) { | 202 remoting.ConnectedView.Cursor.prototype.onMouseMoved_ = function(event) { |
| 216 this.cursorElement_.style.top = event.offsetY + 'px'; | 203 this.cursorElement_.style.top = event.offsetY + 'px'; |
| 217 this.cursorElement_.style.left = event.offsetX + 'px'; | 204 this.cursorElement_.style.left = event.offsetX + 'px'; |
| 218 }; | 205 }; |
| 219 | 206 |
| 220 })(); | 207 })(); |
| OLD | NEW |