1 From 0000000000000000000000000000000000000000 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] add localCursor setting to rfb
6 and use it in app.js (default true)
8 Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
9 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
11 app/ui.js | 10 ++++++++++
12 core/rfb.js | 10 ++++++++++
13 core/util/cursor.js | 15 ++++++++++++++-
15 4 files changed, 37 insertions(+), 1 deletion(-)
17 diff --git a/app/ui.js b/app/ui.js
18 index d604067..d8126bc 100644
21 @@ -166,6 +166,7 @@ const UI = {
22 UI.initSetting('quality', 6);
23 UI.initSetting('compression', 2);
24 UI.initSetting('autoresize', true);
25 + UI.initSetting('local_cursor', true);
26 UI.initSetting('shared', true);
27 UI.initSetting('view_only', false);
28 UI.initSetting('show_dot', false);
29 @@ -356,6 +357,8 @@ const UI = {
30 UI.addSettingChangeHandler('view_only', UI.updateViewOnly);
31 UI.addSettingChangeHandler('show_dot');
32 UI.addSettingChangeHandler('show_dot', UI.updateShowDotCursor);
33 + UI.addSettingChangeHandler('local_cursor');
34 + UI.addSettingChangeHandler('local_cursor', UI.updateLocalCursor);
35 UI.addSettingChangeHandler('host');
36 UI.addSettingChangeHandler('port');
37 UI.addSettingChangeHandler('path');
38 @@ -1056,6 +1059,7 @@ const UI = {
39 UI.rfb.addEventListener("desktopname", UI.updateDesktopName);
40 UI.rfb.addEventListener("fbresize", UI.updateSessionSize);
41 UI.rfb.clipViewport = UI.getSetting('view_clip');
42 + UI.rfb.localCursor = UI.getSetting('local_cursor');
43 UI.rfb.scaleViewport = UI.getSetting('resize') === 'scale';
44 UI.rfb.resizeSession = UI.getSetting('resize') === 'remote';
45 UI.rfb.qualityLevel = parseInt(UI.getSetting('quality'));
46 @@ -1692,6 +1696,12 @@ const UI = {
51 + updateLocalCursor() {
52 + if (!UI.rfb) return;
53 + UI.rfb.localCursor = UI.getSetting('local_cursor');
58 UI.rfb.viewOnly = UI.getSetting('view_only');
59 diff --git a/core/rfb.js b/core/rfb.js
60 index 7ea2004..85c7836 100644
63 @@ -296,6 +296,7 @@ export default class RFB extends EventTargetMixin {
64 this._clipViewport = false;
65 this._scaleViewport = false;
66 this._resizeSession = false;
67 + this._localCursor = false;
69 this._showDotCursor = false;
70 if (options.showDotCursor !== undefined) {
71 @@ -356,6 +357,15 @@ export default class RFB extends EventTargetMixin {
75 + get localCursor() { return this._localCursor; }
76 + set localCursor(localCursor) {
77 + this._localCursor = localCursor;
80 + this._cursor.setLocalCursor(localCursor);
84 get showDotCursor() { return this._showDotCursor; }
85 set showDotCursor(show) {
86 this._showDotCursor = show;
87 diff --git a/core/util/cursor.js b/core/util/cursor.js
88 index 4db1dab..e5b1768 100644
89 --- a/core/util/cursor.js
90 +++ b/core/util/cursor.js
91 @@ -12,6 +12,8 @@ export default class Cursor {
95 + this._showLocalCursor = false;
97 this._canvas = document.createElement('canvas');
100 @@ -110,7 +112,7 @@ export default class Cursor {
104 - this._target.style.cursor = 'none';
105 + this._target.style.cursor = this._showLocalCursor ? 'default' : 'none';
106 this._canvas.width = 0;
107 this._canvas.height = 0;
108 this._position.x = this._position.x + this._hotSpot.x;
109 @@ -140,6 +142,11 @@ export default class Cursor {
110 this._updateVisibility(target);
113 + setLocalCursor(cursor) {
114 + this._showLocalCursor = cursor;
115 + this._updateLocalCursor();
118 _handleMouseOver(event) {
119 // This event could be because we're entering the target, or
120 // moving around amongst its sub elements. Let the move handler
121 @@ -192,6 +199,11 @@ export default class Cursor {
125 + _updateLocalCursor() {
127 + this._target.style.cursor = this._showLocalCursor ? 'default' : 'none';
131 if (this._canvas.style.visibility === 'hidden') {
132 this._canvas.style.visibility = '';
133 @@ -250,4 +262,5 @@ export default class Cursor {
134 return document.captureElement &&
135 document.documentElement.contains(document.captureElement);
139 diff --git a/vnc.html b/vnc.html
140 index 9f594e2..bf1fde5 100644
145 <label><input id="noVNC_setting_view_clip" type="checkbox"> Clip to Window</label>
148 + <label><input id="noVNC_setting_local_cursor" type="checkbox" /> Local Cursor</label>
151 <label><input id="noVNC_setting_autoresize" type="checkbox" /> Autoresize Window</label>