]> git.proxmox.com Git - novnc-pve.git/blob - debian/patches/0011-add-localCursor-setting-to-rfb.patch
add a setting for local cursor
[novnc-pve.git] / debian / patches / 0011-add-localCursor-setting-to-rfb.patch
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
5
6 and use it in app.js (default true)
7
8 Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
9 ---
10 app/ui.js | 9 +++++++++
11 core/rfb.js | 10 ++++++++++
12 core/util/cursor.js | 15 ++++++++++++++-
13 vnc.html | 3 +++
14 4 files changed, 36 insertions(+), 1 deletion(-)
15
16 diff --git a/app/ui.js b/app/ui.js
17 index c523fcd..ac310ba 100644
18 --- a/app/ui.js
19 +++ b/app/ui.js
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';
44
45 @@ -1655,6 +1659,11 @@ const UI = {
46 }
47 },
48
49 + updateLocalCursor() {
50 + if (!UI.rfb) return;
51 + UI.rfb.localCursor = UI.getSetting('local_cursor');
52 + },
53 +
54 updateViewOnly() {
55 if (!UI.rfb) return;
56 UI.rfb.viewOnly = UI.getSetting('view_only');
57 diff --git a/core/rfb.js b/core/rfb.js
58 index 3e0f176..8216c53 100644
59 --- a/core/rfb.js
60 +++ b/core/rfb.js
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;
66 }
67
68 // ===== PROPERTIES =====
69 @@ -315,6 +316,15 @@ export default class RFB extends EventTargetMixin {
70 }
71 }
72
73 + get localCursor() { return this._localCursor; }
74 + set localCursor(localCursor) {
75 + this._localCursor = localCursor;
76 +
77 + if (this._cursor) {
78 + this._cursor.setLocalCursor(localCursor);
79 + }
80 + }
81 +
82 // ===== PUBLIC METHODS =====
83
84 disconnect() {
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) {
91 this._target = null;
92
93 + this._showLocalCursor = false;
94 +
95 this._canvas = document.createElement('canvas');
96
97 if (useFallback) {
98 @@ -128,7 +130,7 @@ export default class Cursor {
99 }
100
101 clear() {
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 {
108 this._hotSpot.y = 0;
109 }
110
111 + setLocalCursor(cursor) {
112 + this._showLocalCursor = cursor;
113 + this._updateLocalCursor();
114 + }
115 +
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";
122 }
123 +
124 + _updateLocalCursor() {
125 + if (this._target)
126 + this._target.style.cursor = this._showLocalCursor ? 'default' : 'none';
127 + }
128 +
129 }
130 diff --git a/vnc.html b/vnc.html
131 index 83825eb..438d531 100644
132 --- a/vnc.html
133 +++ b/vnc.html
134 @@ -177,6 +177,9 @@
135 <label><input id="noVNC_setting_view_clip" type="checkbox" /> Clip to Window</label>
136 </li>
137 <li>
138 + <label><input id="noVNC_setting_local_cursor" type="checkbox" /> Local Cursor</label>
139 + </li>
140 + <li>
141 <label><input id="noVNC_setting_autoresize" type="checkbox" /> Autoresize Window</label>
142 </li>
143 <li>
144 --
145 2.11.0
146