Add option to select default cursor

This commit is contained in:
DomenGaber 2020-02-05 12:01:56 +01:00
parent 0d74223888
commit 65bd696326
4 changed files with 36 additions and 5 deletions

View File

@ -167,6 +167,7 @@ const UI = {
UI.initSetting('view_only', false);
UI.initSetting('img_bgrx_mode', false);
UI.initSetting('show_dot', false);
UI.initSetting('show_pointer', false);
UI.initSetting('path', 'websockify');
UI.initSetting('repeaterID', '');
UI.initSetting('reconnect', false);
@ -359,6 +360,8 @@ const UI = {
UI.addSettingChangeHandler('img_bgrx_mode', UI.applyBGRXMode);
UI.addSettingChangeHandler('show_dot');
UI.addSettingChangeHandler('show_dot', UI.updateShowDotCursor);
UI.addSettingChangeHandler('show_pointer');
UI.addSettingChangeHandler('show_pointer', UI.updateShowPointerCursor);
UI.addSettingChangeHandler('host');
UI.addSettingChangeHandler('port');
UI.addSettingChangeHandler('path');
@ -1101,6 +1104,7 @@ const UI = {
UI.rfb.scaleViewport = UI.getSetting('resize') === 'scale';
UI.rfb.resizeSession = UI.getSetting('resize') === 'remote';
UI.rfb.showDotCursor = UI.getSetting('show_dot');
UI.rfb.showPointerCursor = UI.getSetting('show_pointer');
UI.trackMouse();
UI.trackClicks();
@ -1722,6 +1726,11 @@ const UI = {
UI.rfb.showDotCursor = UI.getSetting('show_dot');
},
updateShowPointerCursor() {
if (!UI.rfb) return;
UI.rfb.showPointerCursor = UI.getSetting('show_pointer');
},
updateLogging() {
WebUtil.init_logging(UI.getSetting('logging'));
},

View File

@ -251,6 +251,10 @@ export default class RFB extends EventTargetMixin {
Log.Warn("Specifying showDotCursor as a RFB constructor argument is deprecated");
this._showDotCursor = options.showDotCursor;
}
this._showPointerCursor = false;
if (options.showPointerCursor !== undefined) {
this._showPointerCursor = options.showPointerCursor;
}
}
// ===== PROPERTIES =====
@ -315,6 +319,12 @@ export default class RFB extends EventTargetMixin {
this._refreshCursor();
}
get showPointerCursor() { return this._showPointerCursor; }
set showPointerCursor(show) {
this._showPointerCursor = show;
this._refreshCursor();
}
get background() { return this._screen.style.background; }
set background(cssValue) { this._screen.style.background = cssValue; }
@ -1884,11 +1894,16 @@ export default class RFB extends EventTargetMixin {
this._rfb_connection_state !== "connected") {
return;
}
const image = this._shouldShowDotCursor() ? RFB.cursors.dot : this._cursorImage;
this._cursor.change(image.rgbaPixels,
image.hotx, image.hoty,
image.w, image.h
);
if (this._showPointerCursor) {
this._cursor.changeToDefaultCursor();
} else {
const image = this._shouldShowDotCursor() ? RFB.cursors.dot : this._cursorImage;
this._cursor.change(image.rgbaPixels,
image.hotx, image.hoty,
image.w, image.h
);
}
}
static genDES(password, challenge) {

View File

@ -121,6 +121,10 @@ export default class Cursor {
}
}
changeToDefaultCursor() {
this._target.style.cursor = 'default';
}
clear() {
this._target.style.cursor = 'none';
this._canvas.width = 0;

View File

@ -243,6 +243,9 @@
<input id="noVNC_setting_reconnect_delay" type="number">
</li>
<li><hr></li>
<li>
<label><input id="noVNC_setting_show_pointer" type="checkbox"> Show Default when No Cursor</label>
</li>
<li>
<label><input id="noVNC_setting_show_dot" type="checkbox"> Show Dot when No Cursor</label>
</li>