diff --git a/app/ui.js b/app/ui.js index bc1ed064..f866bd3c 100644 --- a/app/ui.js +++ b/app/ui.js @@ -1421,7 +1421,7 @@ const UI = { UI.rfb.mouseButtonMapper = UI.initMouseButtonMapper(); if (UI.rfb.videoQuality === 5) { UI.rfb.enableQOI = true; - } + } //Only explicitly request permission to clipboard on browsers that support binary clipboard access if (supportsBinaryClipboard()) { diff --git a/app/ui_screen.js b/app/ui_screen.js index b772e39f..4ec64a02 100644 --- a/app/ui_screen.js +++ b/app/ui_screen.js @@ -3,6 +3,7 @@ import * as WebUtil from "./webutil.js"; import { isTouchDevice, isSafari, hasScrollbarGutter, dragThreshold, supportsBinaryClipboard, isFirefox, isWindows, isIOS, supportsPointerLock } from '../core/util/browser.js'; import { MouseButtonMapper, XVNC_BUTTONS } from "../core/mousebuttonmapper.js"; +import * as Log from '../core/util/logging.js'; const UI = { connected: false, @@ -29,9 +30,11 @@ const UI = { document.getElementById('noVNC_connect_button').addEventListener('click', UI.connect);; }, - getSetting(name, isBool) { - const ctrl = document.getElementById('noVNC_setting_' + name); + getSetting(name, isBool, default_value) { let val = WebUtil.readSetting(name); + if ((val === 'undefined' || val === null) && default_value !== 'undefined' && default_value !== null) { + val = default_value; + } if (typeof val !== 'undefined' && val !== null && isBool) { if (val.toString().toLowerCase() in {'0': 1, 'no': 1, 'false': 1}) { val = false; @@ -72,22 +75,27 @@ const UI = { UI.rfb.maxVideoResolutionY = parseInt(UI.getSetting('max_video_resolution_y')); UI.rfb.frameRate = parseInt(UI.getSetting('framerate')); UI.rfb.compressionLevel = parseInt(UI.getSetting('compression')); - UI.rfb.showDotCursor = UI.getSetting('show_dot'); + UI.rfb.showDotCursor = UI.getSetting('show_dot', true); UI.rfb.idleDisconnect = UI.getSetting('idle_disconnect'); UI.rfb.pointerRelative = UI.getSetting('pointer_relative'); UI.rfb.videoQuality = parseInt(UI.getSetting('video_quality')); UI.rfb.antiAliasing = UI.getSetting('anti_aliasing'); - UI.rfb.clipboardUp = UI.getSetting('clipboard_up'); - UI.rfb.clipboardDown = UI.getSetting('clipboard_down'); - UI.rfb.clipboardSeamless = UI.getSetting('clipboard_seamless'); - UI.rfb.keyboard.enableIME = UI.getSetting('enable_ime'); + UI.rfb.clipboardUp = UI.getSetting('clipboard_up', true, true); + UI.rfb.clipboardDown = UI.getSetting('clipboard_down', true, true); + UI.rfb.clipboardSeamless = UI.getSetting('clipboard_seamless', true, true); + UI.rfb.keyboard.enableIME = UI.getSetting('enable_ime', true, false); UI.rfb.clipboardBinary = supportsBinaryClipboard() && UI.rfb.clipboardSeamless; - UI.rfb.enableWebRTC = UI.getSetting('enable_webrtc'); - UI.rfb.enableHiDpi = UI.getSetting('enable_hidpi'); + UI.rfb.enableWebRTC = UI.getSetting('enable_webrtc', true, false); + UI.rfb.enableHiDpi = UI.getSetting('enable_hidpi', true, false); UI.rfb.mouseButtonMapper = UI.initMouseButtonMapper(); if (UI.rfb.videoQuality === 5) { UI.rfb.enableQOI = true; } + + if (supportsBinaryClipboard()) { + // explicitly request permission to the clipboard + navigator.permissions.query({ name: "clipboard-read" }).then((result) => { Log.Debug('binary clipboard enabled') }); + } }, updateVisualState(state) { diff --git a/core/display.js b/core/display.js index 1b648504..ad21264c 100644 --- a/core/display.js +++ b/core/display.js @@ -121,6 +121,7 @@ export default class Display { // ===== PROPERTIES ===== get screens() { return this._screens; } + get screenId() { return this._screenID; } get antiAliasing() { return this._antiAliasing; } set antiAliasing(value) { @@ -161,6 +162,66 @@ export default class Display { // ===== PUBLIC METHODS ===== + /* + Returns coordinates that are client relative when multiple monitors are in use + Returns an array with the following + 0 - screen index + 1 - screenId + 2 - x + 3 - y + */ + getClientRelativeCoordinates(x, y) { + if (this._screens.length == 1) { + return [ 0, this._screenID, x, y ]; + } + //TODO: The following logic will only support two monitors placed horizontally + let screenOrientation = this._screens[1].relativePosition; + let screenIdx = 0; + let screenId = this._screens[0].screenID; + if (screenOrientation == 0) { + if (x >= this._screens[1].x) { + x -= this._screens[1].x; + screenIdx = 1; + screenId = this._screens[1].screenID; + } + } else if (screenOrientation == 2) { + if (x >= this._screens[0].x) { + x -= this._screens[0].x; + } + } + return [ screenIdx, screenId, x, y ]; + } + + /* + Returns coordinates that are server relative when multiple monitors are in use + */ + getServerRelativeCoordinates(screenId, x, y) { + // If this is the primary screen and only one screen, lets keep it simple + if (this._isPrimaryDisplay && this._screens.length == 1) { + return [x, y]; + } + + // Find the screen index by ID + let screenIdx = -1; + for (let i=0; i