diff --git a/app/ui.js b/app/ui.js index f17aca15..231947d0 100644 --- a/app/ui.js +++ b/app/ui.js @@ -1391,6 +1391,8 @@ const UI = { UI.hideStatus(); + window.name = 'primaryDisplay' + if (!host) { Log.Error("Can't connect when host is: " + host); UI.showStatus(_("Must set host"), 'error'); diff --git a/app/ui_screen.js b/app/ui_screen.js index bb08dedc..98fe19d2 100644 --- a/app/ui_screen.js +++ b/app/ui_screen.js @@ -206,7 +206,7 @@ const UI = { UI.screenID = screen.screenID UI.screen = screen document.querySelector('title').textContent = 'Display ' + UI.screenID - + window.name = UI.screenID if (supportsBinaryClipboard()) { // explicitly request permission to the clipboard diff --git a/core/rfb.js b/core/rfb.js index 724cb57e..ed2719ee 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -43,11 +43,6 @@ import { toSignedRelative16bit } from './util/int.js'; const DISCONNECT_TIMEOUT = 3; const DEFAULT_BACKGROUND = 'rgb(40, 40, 40)'; -var _videoQuality = 2; -var _enableWebP = false; -var _enableQOI = false; -var _clickEligible = false; - // Minimum wait (ms) between two mouse moves const MOUSE_MOVE_DELAY = 17; @@ -149,6 +144,8 @@ export default class RFB extends EventTargetMixin { this._useUdp = true; this._hiDpi = 'hiDpi' in options ? !!options.hiDpi : false; this._enableQOI = false; + this._videoQuality = 2; + this._enableWebP = false; this.TransitConnectionStates = { Tcp: Symbol("tcp"), Udp: Symbol("udp"), @@ -1451,6 +1448,7 @@ export default class RFB extends EventTargetMixin { this._display.dispose(); clearTimeout(this._resizeTimeout); clearTimeout(this._mouseMoveTimer); + window.localStorage.removeItem('lastWindow') Log.Debug("<< RFB.disconnect"); } @@ -1462,28 +1460,22 @@ export default class RFB extends EventTargetMixin { _handleFocusChange(event) { this._resendClipboardNextUserDrivenEvent = true; - if (event.type == 'focus' && event.currentTarget instanceof Window) { if (this._lastVisibilityState === 'visible') { + const lastWindow = window.localStorage.getItem('lastWindow') Log.Debug("Window focused while user switched between windows."); // added for multi-montiors // as user moves from window to window, focus change loses a click, this marks the next mouse // move to simulate a left click. We wait for the next mouse move because we need accurate x,y coords - if (this._clickEligible) { + if (lastWindow != event.currentTarget.name) { this._sendLeftClickonNextMove = true; - this._clickEligible = false; + window.localStorage.setItem('lastWindow', event.currentTarget.name) } } else { Log.Debug("Window focused while user switched between tabs."); } - } else if (event.type == 'blur') { - // Tell all windows we lost focus - let message = { - eventType: 'lostFocus' - } - this._controlChannel.postMessage(message); } if (document.visibilityState === "visible" && this._lastVisibilityState === "hidden") { @@ -1802,10 +1794,6 @@ export default class RFB extends EventTargetMixin { } _handleControlMessage(event) { - if (event.data.eventType == 'lostFocus') { - this._clickEligible = true; - return; - } if (this._isPrimaryDisplay) { // Secondary to Primary screen message let size;