]>
Commit | Line | Data |
---|---|---|
2b8dde16 | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
d709d68c DC |
2 | From: Dominik Csapak <d.csapak@proxmox.com> |
3 | Date: Thu, 19 Jul 2018 11:31:51 +0200 | |
bf74ff33 | 4 | Subject: [PATCH] add localCursor setting to rfb |
d709d68c DC |
5 | |
6 | and use it in app.js (default true) | |
7 | ||
8 | Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> | |
bf74ff33 | 9 | Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> |
d709d68c | 10 | --- |
bf74ff33 | 11 | app/ui.js | 10 ++++++++++ |
d709d68c DC |
12 | core/rfb.js | 10 ++++++++++ |
13 | core/util/cursor.js | 15 ++++++++++++++- | |
14 | vnc.html | 3 +++ | |
bf74ff33 | 15 | 4 files changed, 37 insertions(+), 1 deletion(-) |
d709d68c DC |
16 | |
17 | diff --git a/app/ui.js b/app/ui.js | |
e5e59874 | 18 | index f7b7dc4..37a0279 100644 |
d709d68c DC |
19 | --- a/app/ui.js |
20 | +++ b/app/ui.js | |
e5e59874 | 21 | @@ -172,6 +172,7 @@ const UI = { |
bf74ff33 TL |
22 | UI.initSetting('quality', 6); |
23 | UI.initSetting('compression', 2); | |
d709d68c DC |
24 | UI.initSetting('autoresize', true); |
25 | + UI.initSetting('local_cursor', true); | |
26 | UI.initSetting('shared', true); | |
27 | UI.initSetting('view_only', false); | |
2b8dde16 | 28 | UI.initSetting('show_dot', false); |
e5e59874 | 29 | @@ -362,6 +363,8 @@ const UI = { |
d709d68c | 30 | UI.addSettingChangeHandler('view_only', UI.updateViewOnly); |
2b8dde16 DC |
31 | UI.addSettingChangeHandler('show_dot'); |
32 | UI.addSettingChangeHandler('show_dot', UI.updateShowDotCursor); | |
d709d68c DC |
33 | + UI.addSettingChangeHandler('local_cursor'); |
34 | + UI.addSettingChangeHandler('local_cursor', UI.updateLocalCursor); | |
35 | UI.addSettingChangeHandler('host'); | |
36 | UI.addSettingChangeHandler('port'); | |
37 | UI.addSettingChangeHandler('path'); | |
e5e59874 | 38 | @@ -1057,6 +1060,7 @@ const UI = { |
d709d68c DC |
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'; | |
bf74ff33 | 45 | UI.rfb.qualityLevel = parseInt(UI.getSetting('quality')); |
e5e59874 | 46 | @@ -1693,6 +1697,12 @@ const UI = { |
bf74ff33 TL |
47 | * ============== |
48 | * MISC | |
49 | * ------v------*/ | |
50 | + | |
d709d68c DC |
51 | + updateLocalCursor() { |
52 | + if (!UI.rfb) return; | |
53 | + UI.rfb.localCursor = UI.getSetting('local_cursor'); | |
54 | + }, | |
55 | + | |
56 | updateViewOnly() { | |
57 | if (!UI.rfb) return; | |
58 | UI.rfb.viewOnly = UI.getSetting('view_only'); | |
59 | diff --git a/core/rfb.js b/core/rfb.js | |
e5e59874 | 60 | index 90ca28b..ec75610 100644 |
d709d68c DC |
61 | --- a/core/rfb.js |
62 | +++ b/core/rfb.js | |
e5e59874 | 63 | @@ -256,6 +256,7 @@ export default class RFB extends EventTargetMixin { |
d709d68c DC |
64 | this._clipViewport = false; |
65 | this._scaleViewport = false; | |
66 | this._resizeSession = false; | |
67 | + this._localCursor = false; | |
d709d68c | 68 | |
bf74ff33 TL |
69 | this._showDotCursor = false; |
70 | if (options.showDotCursor !== undefined) { | |
e5e59874 | 71 | @@ -316,6 +317,15 @@ export default class RFB extends EventTargetMixin { |
bf74ff33 TL |
72 | } |
73 | } | |
d709d68c DC |
74 | |
75 | + get localCursor() { return this._localCursor; } | |
76 | + set localCursor(localCursor) { | |
77 | + this._localCursor = localCursor; | |
78 | + | |
79 | + if (this._cursor) { | |
80 | + this._cursor.setLocalCursor(localCursor); | |
81 | + } | |
82 | + } | |
83 | + | |
bf74ff33 TL |
84 | get showDotCursor() { return this._showDotCursor; } |
85 | set showDotCursor(show) { | |
86 | this._showDotCursor = show; | |
d709d68c | 87 | diff --git a/core/util/cursor.js b/core/util/cursor.js |
e5e59874 | 88 | index 12bcced..ce7340e 100644 |
d709d68c DC |
89 | --- a/core/util/cursor.js |
90 | +++ b/core/util/cursor.js | |
91 | @@ -12,6 +12,8 @@ export default class Cursor { | |
2b8dde16 | 92 | constructor() { |
d709d68c DC |
93 | this._target = null; |
94 | ||
95 | + this._showLocalCursor = false; | |
96 | + | |
97 | this._canvas = document.createElement('canvas'); | |
98 | ||
99 | if (useFallback) { | |
e5e59874 | 100 | @@ -100,7 +102,7 @@ export default class Cursor { |
d709d68c DC |
101 | } |
102 | ||
103 | clear() { | |
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; | |
e5e59874 | 109 | @@ -130,6 +132,11 @@ export default class Cursor { |
bf74ff33 | 110 | this._updateVisibility(target); |
d709d68c DC |
111 | } |
112 | ||
113 | + setLocalCursor(cursor) { | |
114 | + this._showLocalCursor = cursor; | |
115 | + this._updateLocalCursor(); | |
116 | + } | |
117 | + | |
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 | |
e5e59874 | 121 | @@ -182,6 +189,11 @@ export default class Cursor { |
bf74ff33 | 122 | } |
d709d68c | 123 | } |
bf74ff33 | 124 | |
d709d68c DC |
125 | + _updateLocalCursor() { |
126 | + if (this._target) | |
127 | + this._target.style.cursor = this._showLocalCursor ? 'default' : 'none'; | |
128 | + } | |
bf74ff33 TL |
129 | + |
130 | _showCursor() { | |
131 | if (this._canvas.style.visibility === 'hidden') { | |
132 | this._canvas.style.visibility = ''; | |
e5e59874 | 133 | @@ -240,4 +252,5 @@ export default class Cursor { |
bf74ff33 TL |
134 | return document.captureElement && |
135 | document.documentElement.contains(document.captureElement); | |
136 | } | |
d709d68c DC |
137 | + |
138 | } | |
139 | diff --git a/vnc.html b/vnc.html | |
e5e59874 | 140 | index 21b3844..3e63087 100644 |
d709d68c DC |
141 | --- a/vnc.html |
142 | +++ b/vnc.html | |
e5e59874 | 143 | @@ -154,6 +154,9 @@ |
d709d68c | 144 | <li> |
2b8dde16 DC |
145 | <label><input id="noVNC_setting_view_clip" type="checkbox"> Clip to Window</label> |
146 | </li> | |
147 | + <li> | |
d709d68c DC |
148 | + <label><input id="noVNC_setting_local_cursor" type="checkbox" /> Local Cursor</label> |
149 | + </li> | |
2b8dde16 | 150 | <li> |
d709d68c DC |
151 | <label><input id="noVNC_setting_autoresize" type="checkbox" /> Autoresize Window</label> |
152 | </li> |