diff --git a/src/app/main-api-handler.ts b/src/app/main-api-handler.ts index e8113b8e..a53be1f4 100644 --- a/src/app/main-api-handler.ts +++ b/src/app/main-api-handler.ts @@ -248,6 +248,10 @@ ipcMain.on( if (typeof arg.isInMeeting === 'boolean') { memoryMonitor.setMeetingStatus(arg.isInMeeting); appStateHandler.preventDisplaySleep(arg.isInMeeting); + if (!arg.isInMeeting) { + windowHandler.closeScreenPickerWindow(); + windowHandler.closeScreenSharingIndicator(); + } } break; case apiCmds.memoryInfo: diff --git a/src/app/window-handler.ts b/src/app/window-handler.ts index 7be42e60..c078147d 100644 --- a/src/app/window-handler.ts +++ b/src/app/window-handler.ts @@ -652,7 +652,7 @@ export class WindowHandler { `window-handler: main window closed, destroying all windows!`, ); if (isWindowsOS || isMac) { - this.execCmd(this.screenShareIndicatorFrameUtil, []); + this.closeScreenSharingIndicator(); } this.closeAllWindows(); this.destroyAllWindows(); @@ -921,10 +921,7 @@ export class WindowHandler { } if (isWindowsOS || isMac) { const timeoutValue = 300; - setTimeout( - () => this.execCmd(this.screenShareIndicatorFrameUtil, []), - timeoutValue, - ); + setTimeout(() => this.closeScreenSharingIndicator(), timeoutValue); } else { if ( this.screenSharingFrameWindow && @@ -1449,7 +1446,7 @@ export class WindowHandler { if (source != null) { logger.info(`window-handler: screen-source-select`, source, id); - this.execCmd(this.screenShareIndicatorFrameUtil, []); + this.closeScreenSharingIndicator(); const timeoutValue = 300; setTimeout(() => { this.drawScreenShareIndicatorFrame(source); @@ -1470,7 +1467,7 @@ export class WindowHandler { ipcMain.once('screen-source-selected', (_event, source) => { logger.info(`window-handler: screen-source-selected`, source, id); if (source == null) { - this.execCmd(this.screenShareIndicatorFrameUtil, []); + this.closeScreenSharingIndicator(); if ( this.screenPickerPlaceholderWindow && windowExists(this.screenPickerPlaceholderWindow) @@ -1519,6 +1516,24 @@ export class WindowHandler { }); } + /** + * Closes a screen picker window if it exists + * + */ + public closeScreenPickerWindow() { + if (this.screenPickerWindow && windowExists(this.screenPickerWindow)) { + this.screenPickerWindow.close(); + } + } + + /** + * Closes screen sharing indicator + * + */ + public async closeScreenSharingIndicator() { + this.execCmd(this.screenShareIndicatorFrameUtil, []); + } + /** * Creates a Basic auth window whenever the network * requires authentications @@ -2092,7 +2107,7 @@ export class WindowHandler { default: this.url = this.globalConfig.url + `?x-km-csrf-token=${csrfToken}`; } - await this.execCmd(this.screenShareIndicatorFrameUtil, []); + await this.closeScreenSharingIndicator(); const userAgent = this.getUserAgent(this.mainWebContents); await this.mainWebContents.loadURL(this.url, { userAgent }); } catch (e) { diff --git a/src/app/window-utils.ts b/src/app/window-utils.ts index 9f5bea60..772e3d9b 100644 --- a/src/app/window-utils.ts +++ b/src/app/window-utils.ts @@ -154,7 +154,7 @@ export const preventWindowNavigation = ( } } - windowHandler.execCmd(windowHandler.screenShareIndicatorFrameUtil, []); + windowHandler.closeScreenSharingIndicator(); } if ( @@ -773,7 +773,7 @@ export const reloadWindow = (browserWindow: ICustomBrowserWindow) => { windowHandler.closeAllWindows(); - windowHandler.execCmd(windowHandler.screenShareIndicatorFrameUtil, []); + windowHandler.closeScreenSharingIndicator(); return; }