handle window moved to diffent monitor

This commit is contained in:
mattmcclaskey 2023-10-11 09:27:04 -04:00
parent 3cc2f0caf3
commit 05ddc91382
No known key found for this signature in database
2 changed files with 17 additions and 2 deletions

View File

@ -204,6 +204,7 @@ export default class Display {
this._screens[0].containerWidth = this._target.parentNode.offsetWidth; this._screens[0].containerWidth = this._target.parentNode.offsetWidth;
this._screens[0].width = this._target.parentNode.offsetWidth; this._screens[0].width = this._target.parentNode.offsetWidth;
this._screens[0].height = this._target.parentNode.offsetHeight; this._screens[0].height = this._target.parentNode.offsetHeight;
this._screens[0].pixelRatio = window.devicePixelRatio;
//this._screens[0].width = this._target.width; //this._screens[0].width = this._target.width;
//this._screens[0].height = this._target.height; //this._screens[0].height = this._target.height;

View File

@ -239,6 +239,7 @@ export default class RFB extends EventTargetMixin {
handleWheel: this._handleWheel.bind(this), handleWheel: this._handleWheel.bind(this),
handleGesture: this._handleGesture.bind(this), handleGesture: this._handleGesture.bind(this),
handleFocusChange: this._handleFocusChange.bind(this), handleFocusChange: this._handleFocusChange.bind(this),
handleMouseOut: this._handleMouseOut.bind(this),
}; };
// main setup // main setup
@ -1163,6 +1164,9 @@ export default class RFB extends EventTargetMixin {
window.addEventListener("focus", this._eventHandlers.handleFocusChange); window.addEventListener("focus", this._eventHandlers.handleFocusChange);
window.addEventListener("blur", this._eventHandlers.handleFocusChange); window.addEventListener("blur", this._eventHandlers.handleFocusChange);
//User cursor moves outside of the window
window.addEventListener("mouseover", this._eventHandlers.handleMouseOut);
// In order for the keyboard to not occlude the input being edited // In order for the keyboard to not occlude the input being edited
// we move the hidden input we use for triggering the keyboard to the last click // we move the hidden input we use for triggering the keyboard to the last click
// position which should trigger a page being moved down enough // position which should trigger a page being moved down enough
@ -1757,7 +1761,6 @@ export default class RFB extends EventTargetMixin {
} }
_handleSecondaryDisplayMessage(event) { _handleSecondaryDisplayMessage(event) {
console.log("Message Received: " + event);
if (this._isPrimaryDisplay) { if (this._isPrimaryDisplay) {
} }
@ -1796,6 +1799,18 @@ export default class RFB extends EventTargetMixin {
this.sendKey(keysym, code, down); this.sendKey(keysym, code, down);
} }
_handleMouseOut(ev) {
if (ev.toElement !== null && ev.relatedTarget === null) {
//mouse was outside of the window and just came in, this is our chance to do things
//Ensure the window was not moved to a different screen with a different pixel ratio
if (this._display.screens[0].pixelRatio !== window.devicePixelRatio) {
Log.Debug("Window moved to another screen with different pixel ratio, sending resize request.");
this._requestRemoteResize();
}
}
}
_handleMouse(ev) { _handleMouse(ev) {
/* /*
* We don't check connection status or viewOnly here as the * We don't check connection status or viewOnly here as the
@ -4286,7 +4301,6 @@ RFB.messages = {
}, },
setDesktopSize(sock, size, flags) { setDesktopSize(sock, size, flags) {
console.log(size);
const buff = sock._sQ; const buff = sock._sQ;
const offset = sock._sQlen; const offset = sock._sQlen;