1 From c00b6dd12a3daa100673561cdedc5909ed4c3738 Mon Sep 17 00:00:00 2001
2 From: Dominik Csapak <d.csapak@proxmox.com>
3 Date: Thu, 19 Jul 2018 11:31:51 +0200
4 Subject: [PATCH 11/11] add localCursor setting to rfb
6 and use it in app.js (default true)
8 Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
10 app/ui.js | 9 +++++++++
11 core/rfb.js | 10 ++++++++++
12 core/util/cursor.js | 15 ++++++++++++++-
14 4 files changed, 36 insertions(+), 1 deletion(-)
16 diff --git a/app/ui.js b/app/ui.js
17 index c523fcd..ac310ba 100644
20 @@ -161,6 +161,7 @@ const UI = {
21 UI.initSetting('view_clip', false);
22 UI.initSetting('resize', 'off');
23 UI.initSetting('autoresize', true);
24 + UI.initSetting('local_cursor', true);
25 UI.initSetting('shared', true);
26 UI.initSetting('view_only', false);
27 UI.initSetting('path', 'websockify');
28 @@ -350,6 +351,8 @@ const UI = {
29 UI.addSettingChangeHandler('shared');
30 UI.addSettingChangeHandler('view_only');
31 UI.addSettingChangeHandler('view_only', UI.updateViewOnly);
32 + UI.addSettingChangeHandler('local_cursor');
33 + UI.addSettingChangeHandler('local_cursor', UI.updateLocalCursor);
34 UI.addSettingChangeHandler('host');
35 UI.addSettingChangeHandler('port');
36 UI.addSettingChangeHandler('path');
37 @@ -1052,6 +1055,7 @@ const UI = {
38 UI.rfb.addEventListener("desktopname", UI.updateDesktopName);
39 UI.rfb.addEventListener("fbresize", UI.updateSessionSize);
40 UI.rfb.clipViewport = UI.getSetting('view_clip');
41 + UI.rfb.localCursor = UI.getSetting('local_cursor');
42 UI.rfb.scaleViewport = UI.getSetting('resize') === 'scale';
43 UI.rfb.resizeSession = UI.getSetting('resize') === 'remote';
45 @@ -1655,6 +1659,11 @@ const UI = {
49 + updateLocalCursor() {
50 + if (!UI.rfb) return;
51 + UI.rfb.localCursor = UI.getSetting('local_cursor');
56 UI.rfb.viewOnly = UI.getSetting('view_only');
57 diff --git a/core/rfb.js b/core/rfb.js
58 index 3e0f176..8216c53 100644
61 @@ -262,6 +262,7 @@ export default class RFB extends EventTargetMixin {
62 this._clipViewport = false;
63 this._scaleViewport = false;
64 this._resizeSession = false;
65 + this._localCursor = false;
68 // ===== PROPERTIES =====
69 @@ -315,6 +316,15 @@ export default class RFB extends EventTargetMixin {
73 + get localCursor() { return this._localCursor; }
74 + set localCursor(localCursor) {
75 + this._localCursor = localCursor;
78 + this._cursor.setLocalCursor(localCursor);
82 // ===== PUBLIC METHODS =====
85 diff --git a/core/util/cursor.js b/core/util/cursor.js
86 index 18aa7be..2a99bd4 100644
87 --- a/core/util/cursor.js
88 +++ b/core/util/cursor.js
89 @@ -12,6 +12,8 @@ export default class Cursor {
90 constructor(container) {
93 + this._showLocalCursor = false;
95 this._canvas = document.createElement('canvas');
98 @@ -128,7 +130,7 @@ export default class Cursor {
102 - this._target.style.cursor = 'none';
103 + this._target.style.cursor = this._showLocalCursor ? 'default' : 'none';
104 this._canvas.width = 0;
105 this._canvas.height = 0;
106 this._position.x = this._position.x + this._hotSpot.x;
107 @@ -137,6 +139,11 @@ export default class Cursor {
111 + setLocalCursor(cursor) {
112 + this._showLocalCursor = cursor;
113 + this._updateLocalCursor();
116 _handleMouseOver(event) {
117 // This event could be because we're entering the target, or
118 // moving around amongst its sub elements. Let the move handler
119 @@ -225,4 +232,10 @@ export default class Cursor {
120 this._canvas.style.left = this._position.x + "px";
121 this._canvas.style.top = this._position.y + "px";
124 + _updateLocalCursor() {
126 + this._target.style.cursor = this._showLocalCursor ? 'default' : 'none';
130 diff --git a/vnc.html b/vnc.html
131 index 83825eb..438d531 100644
135 <label><input id="noVNC_setting_view_clip" type="checkbox" /> Clip to Window</label>
138 + <label><input id="noVNC_setting_local_cursor" type="checkbox" /> Local Cursor</label>
141 <label><input id="noVNC_setting_autoresize" type="checkbox" /> Autoresize Window</label>