From 8ca8db65ed10efb4c2fb6b23e9ecb5ac17b3b842 Mon Sep 17 00:00:00 2001 From: VICTOR RAPHAEL BRAGA DE SALES MASCARENHAS Date: Wed, 19 Dec 2018 02:13:58 -0200 Subject: [PATCH] ELECTRON-955 fixing toast notification does not show on top of the Electron after it is minimized and maximized again (#534) --- js/windowMgr.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/js/windowMgr.js b/js/windowMgr.js index 667d209f..23bc2af0 100644 --- a/js/windowMgr.js +++ b/js/windowMgr.js @@ -121,6 +121,25 @@ function createMainWindow(initialUrl) { }); } +/** + * ELECTRON-955: Always on Top - Toast notification does not show on top (front) of the Electron app after it is minimized and maximized again + * Bring to front all notification windows + */ +function bringToFrontNotification() { + if (mainWindow && !mainWindow.isDestroyed()) { + let allBrowserWindows = BrowserWindow.getAllWindows(); + const notificationWindow = allBrowserWindows.filter((item) => item.winName === 'notification-window'); + if (mainWindow.isAlwaysOnTop()) { + notificationWindow.forEach((item) => { + if (item && !item.isDestroyed()) { + item.setAlwaysOnTop(true); + } + }); + } + } +} + + /** * Creates the main window with bounds * @param initialUrl @@ -758,6 +777,7 @@ function saveMainWinBounds() { if (mainWindow && !mainWindow.isDestroyed()) { newBounds.isMaximized = mainWindow.isMaximized(); newBounds.isFullScreen = mainWindow.isFullScreen(); + bringToFrontNotification(); } if (newBounds) {