unregister a display if window closes

This commit is contained in:
mattmcclaskey 2023-09-20 09:06:27 -04:00
parent c35b8c68f3
commit 23076cdc7c
No known key found for this signature in database
3 changed files with 20 additions and 3 deletions

View File

@ -220,7 +220,9 @@ const UI = {
}, },
disconnect() { disconnect() {
if (UI.rfb) {
UI.rfb.disconnect();
}
}, },
connectFinished(e) { connectFinished(e) {

View File

@ -418,9 +418,10 @@ export default class Display {
} }
removeScreen(screenID) { removeScreen(screenID) {
if (this.isPrimaryDisplay) { if (this._isPrimaryDisplay) {
for (let i=1; i<this._screens.length; i++) { for (let i=1; i<this._screens.length; i++) {
if (this._screens[i].screenID == screenID) { if (this._screens[i].screenID == screenID) {
this._screens[i].channel.close();
this._screens.splice(i, 1); this._screens.splice(i, 1);
return true; return true;
} }

View File

@ -770,11 +770,14 @@ export default class RFB extends EventTargetMixin {
} }
disconnect() { disconnect() {
if (this._rfbConnectionState !== 'proxied') { if (this._isPrimaryDisplay) {
this._updateConnectionState('disconnecting'); this._updateConnectionState('disconnecting');
this._sock.off('error'); this._sock.off('error');
this._sock.off('message'); this._sock.off('message');
this._sock.off('open'); this._sock.off('open');
} else {
this._updateConnectionState('disconnecting');
this._unregisterSecondaryDisplay();
} }
} }
@ -1676,6 +1679,17 @@ export default class RFB extends EventTargetMixin {
} }
_unregisterSecondaryDisplay() {
if (!this._isPrimaryDisplay){
let message = {
eventType: 'unregister',
screenID: this._display.screenId
}
this._controlChannel.postMessage(message);
}
}
_registerSecondaryDisplay() { _registerSecondaryDisplay() {
if (!this._isPrimaryDisplay) { if (!this._isPrimaryDisplay) {
//let screen = this._screenSize().screens[0]; //let screen = this._screenSize().screens[0];