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() {
if (UI.rfb) {
UI.rfb.disconnect();
}
},
connectFinished(e) {

View File

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

View File

@ -770,11 +770,14 @@ export default class RFB extends EventTargetMixin {
}
disconnect() {
if (this._rfbConnectionState !== 'proxied') {
if (this._isPrimaryDisplay) {
this._updateConnectionState('disconnecting');
this._sock.off('error');
this._sock.off('message');
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() {
if (!this._isPrimaryDisplay) {
//let screen = this._screenSize().screens[0];