diff --git a/core/rfb.js b/core/rfb.js index 7caa707a..b0caf984 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -46,6 +46,7 @@ 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; @@ -1467,11 +1468,20 @@ export default class RFB extends EventTargetMixin { // 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 - this._sendLeftClickonNextMove = true; + if (this._clickEligible) { + this._sendLeftClickonNextMove = true; + this._clickEligible = false; + } } 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") { @@ -1790,6 +1800,10 @@ 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;