SDA-1268 - Workaround to exit fullscreen when notification is clicked (#939)

This commit is contained in:
Kiran Niranjan
2020-03-25 13:00:52 +05:30
committed by GitHub
parent 154b93a1d2
commit 74c703cea9
2 changed files with 25 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
import { app, ipcMain } from 'electron';
import { app, BrowserWindow, ipcMain } from 'electron';
import { config } from '../app/config-handler';
import { createComponentWindow, windowExists } from '../app/window-utils';
@@ -242,6 +242,7 @@ class Notification extends NotificationHandler {
callback(NotificationActions.notificationClicked, data);
}
this.hideNotification(clientId);
this.exitFullScreen();
}
}
@@ -329,6 +330,23 @@ class Notification extends NotificationHandler {
});
}
/**
* SDA-1268 - Workaround to exit window
* fullscreen state when notification is clicked
*/
public exitFullScreen(): void {
const browserWindows: ICustomBrowserWindow[] = BrowserWindow.getAllWindows() as ICustomBrowserWindow[];
for (const win in browserWindows) {
if (Object.prototype.hasOwnProperty.call(browserWindows, win)) {
const browserWin = browserWindows[ win ];
if (browserWin && windowExists(browserWin) && browserWin.winName === apiName.mainWindowName && browserWin.isFullScreen()) {
browserWin.webContents.send('exit-html-fullscreen');
return;
}
}
}
}
/**
* Waits for window to load and resolves
*

View File

@@ -140,3 +140,9 @@ ipcRenderer.on('show-banner', (_event, { show, bannerType, url }) => {
ipcRenderer.on('initialize-memory-refresh', () => {
monitorMemory(getRandomTime(minMemoryFetchInterval, maxMemoryFetchInterval));
});
ipcRenderer.on('exit-html-fullscreen', async () => {
if (document && typeof document.exitFullscreen === 'function') {
await document.exitFullscreen();
}
});