KASM-5598 Get mouse down working cross browser (#98)

* KASM-5598 Get mouse down working cross browser

* moved variables declared outside the class

---------

Co-authored-by: Chris Hunt <chris.hunt@kasmweb.com>
Co-authored-by: mattmcclaskey <matt@kasmweb.com>
This commit is contained in:
KodeStar 2024-02-09 12:54:05 +00:00 committed by GitHub
parent 5a3b4f0d69
commit 602dff9258
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 19 deletions

View File

@ -1391,6 +1391,8 @@ const UI = {
UI.hideStatus(); UI.hideStatus();
window.name = 'primaryDisplay'
if (!host) { if (!host) {
Log.Error("Can't connect when host is: " + host); Log.Error("Can't connect when host is: " + host);
UI.showStatus(_("Must set host"), 'error'); UI.showStatus(_("Must set host"), 'error');

View File

@ -206,7 +206,7 @@ const UI = {
UI.screenID = screen.screenID UI.screenID = screen.screenID
UI.screen = screen UI.screen = screen
document.querySelector('title').textContent = 'Display ' + UI.screenID document.querySelector('title').textContent = 'Display ' + UI.screenID
window.name = UI.screenID
if (supportsBinaryClipboard()) { if (supportsBinaryClipboard()) {
// explicitly request permission to the clipboard // explicitly request permission to the clipboard

View File

@ -43,11 +43,6 @@ import { toSignedRelative16bit } from './util/int.js';
const DISCONNECT_TIMEOUT = 3; const DISCONNECT_TIMEOUT = 3;
const DEFAULT_BACKGROUND = 'rgb(40, 40, 40)'; 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 // Minimum wait (ms) between two mouse moves
const MOUSE_MOVE_DELAY = 17; const MOUSE_MOVE_DELAY = 17;
@ -149,6 +144,8 @@ export default class RFB extends EventTargetMixin {
this._useUdp = true; this._useUdp = true;
this._hiDpi = 'hiDpi' in options ? !!options.hiDpi : false; this._hiDpi = 'hiDpi' in options ? !!options.hiDpi : false;
this._enableQOI = false; this._enableQOI = false;
this._videoQuality = 2;
this._enableWebP = false;
this.TransitConnectionStates = { this.TransitConnectionStates = {
Tcp: Symbol("tcp"), Tcp: Symbol("tcp"),
Udp: Symbol("udp"), Udp: Symbol("udp"),
@ -1451,6 +1448,7 @@ export default class RFB extends EventTargetMixin {
this._display.dispose(); this._display.dispose();
clearTimeout(this._resizeTimeout); clearTimeout(this._resizeTimeout);
clearTimeout(this._mouseMoveTimer); clearTimeout(this._mouseMoveTimer);
window.localStorage.removeItem('lastWindow')
Log.Debug("<< RFB.disconnect"); Log.Debug("<< RFB.disconnect");
} }
@ -1462,28 +1460,22 @@ export default class RFB extends EventTargetMixin {
_handleFocusChange(event) { _handleFocusChange(event) {
this._resendClipboardNextUserDrivenEvent = true; this._resendClipboardNextUserDrivenEvent = true;
if (event.type == 'focus' && event.currentTarget instanceof Window) { if (event.type == 'focus' && event.currentTarget instanceof Window) {
if (this._lastVisibilityState === 'visible') { if (this._lastVisibilityState === 'visible') {
const lastWindow = window.localStorage.getItem('lastWindow')
Log.Debug("Window focused while user switched between windows."); Log.Debug("Window focused while user switched between windows.");
// added for multi-montiors // added for multi-montiors
// as user moves from window to window, focus change loses a click, this marks the next mouse // 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 // 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._sendLeftClickonNextMove = true;
this._clickEligible = false; window.localStorage.setItem('lastWindow', event.currentTarget.name)
} }
} else { } else {
Log.Debug("Window focused while user switched between tabs."); 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") { if (document.visibilityState === "visible" && this._lastVisibilityState === "hidden") {
@ -1802,10 +1794,6 @@ export default class RFB extends EventTargetMixin {
} }
_handleControlMessage(event) { _handleControlMessage(event) {
if (event.data.eventType == 'lostFocus') {
this._clickEligible = true;
return;
}
if (this._isPrimaryDisplay) { if (this._isPrimaryDisplay) {
// Secondary to Primary screen message // Secondary to Primary screen message
let size; let size;