mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-29 02:11:28 -06:00
ELECTRON-1401 - Fix issues with pop-out window restore (#738)
This commit is contained in:
parent
e5d86dc6d7
commit
f47b606f9f
@ -8,7 +8,12 @@ import { logger } from '../common/logger';
|
|||||||
import { getGuid } from '../common/utils';
|
import { getGuid } from '../common/utils';
|
||||||
import { whitelistHandler } from '../common/whitelist-handler';
|
import { whitelistHandler } from '../common/whitelist-handler';
|
||||||
import { config } from './config-handler';
|
import { config } from './config-handler';
|
||||||
import { handlePermissionRequests, monitorWindowActions, removeWindowEventListener } from './window-actions';
|
import {
|
||||||
|
handlePermissionRequests,
|
||||||
|
monitorWindowActions,
|
||||||
|
removeWindowEventListener,
|
||||||
|
sendInitialBoundChanges,
|
||||||
|
} from './window-actions';
|
||||||
import { ICustomBrowserWindow, windowHandler } from './window-handler';
|
import { ICustomBrowserWindow, windowHandler } from './window-handler';
|
||||||
import {
|
import {
|
||||||
getBounds,
|
getBounds,
|
||||||
@ -163,6 +168,10 @@ export const handleChildWindow = (webContents: WebContents): void => {
|
|||||||
|
|
||||||
// Monitor window actions
|
// Monitor window actions
|
||||||
monitorWindowActions(browserWin);
|
monitorWindowActions(browserWin);
|
||||||
|
|
||||||
|
// Update initial bound changes
|
||||||
|
sendInitialBoundChanges(browserWin);
|
||||||
|
|
||||||
// Remove all attached event listeners
|
// Remove all attached event listeners
|
||||||
browserWin.on('close', () => {
|
browserWin.on('close', () => {
|
||||||
logger.info(`child-window-handler: close event occurred for window with url ${newWinUrl}!`);
|
logger.info(`child-window-handler: close event occurred for window with url ${newWinUrl}!`);
|
||||||
|
@ -23,12 +23,16 @@ const PERMISSIONS_NAMESPACE = 'Permissions';
|
|||||||
|
|
||||||
const saveWindowSettings = async (): Promise<void> => {
|
const saveWindowSettings = async (): Promise<void> => {
|
||||||
const browserWindow = BrowserWindow.getFocusedWindow() as ICustomBrowserWindow;
|
const browserWindow = BrowserWindow.getFocusedWindow() as ICustomBrowserWindow;
|
||||||
|
const mainWindow = windowHandler.getMainWindow();
|
||||||
|
|
||||||
if (browserWindow && windowExists(browserWindow)) {
|
if (browserWindow && windowExists(browserWindow)) {
|
||||||
const [ x, y ] = browserWindow.getPosition();
|
const [ x, y ] = browserWindow.getPosition();
|
||||||
const [ width, height ] = browserWindow.getSize();
|
const [ width, height ] = browserWindow.getSize();
|
||||||
if (x && y && width && height) {
|
if (x && y && width && height) {
|
||||||
browserWindow.webContents.send('boundsChange', { x, y, width, height, windowName: browserWindow.winName } as IBoundsChange);
|
// Only send bound changes over to client for pop-out windows
|
||||||
|
if (browserWindow.winName !== apiName.mainWindowName && mainWindow && windowExists(mainWindow)) {
|
||||||
|
mainWindow.webContents.send('boundsChange', { x, y, width, height, windowName: browserWindow.winName } as IBoundsChange);
|
||||||
|
}
|
||||||
|
|
||||||
// Update the config file
|
// Update the config file
|
||||||
if (browserWindow.winName === apiName.mainWindowName) {
|
if (browserWindow.winName === apiName.mainWindowName) {
|
||||||
@ -64,6 +68,28 @@ const throttledWindowRestore = throttle(async () => {
|
|||||||
notification.moveNotificationToTop();
|
notification.moveNotificationToTop();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends initial bound changes for pop-out windows
|
||||||
|
*
|
||||||
|
* @param childWindow {BrowserWindow} - window created via new-window event
|
||||||
|
*/
|
||||||
|
export const sendInitialBoundChanges = (childWindow: BrowserWindow): void => {
|
||||||
|
logger.info(`window-actions: Sending initial bounds`);
|
||||||
|
const mainWindow = windowHandler.getMainWindow();
|
||||||
|
if (!mainWindow || !windowExists(mainWindow)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!childWindow || !windowExists(childWindow)) {
|
||||||
|
logger.error(`window-actions: child window has already been destroyed - not sending bound change`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { x, y, width, height } = childWindow.getBounds();
|
||||||
|
const windowName = (childWindow as ICustomBrowserWindow).winName;
|
||||||
|
mainWindow.webContents.send('boundsChange', { x, y, width, height, windowName } as IBoundsChange);
|
||||||
|
logger.info(`window-actions: Initial bounds sent for ${(childWindow as ICustomBrowserWindow).winName}`, { x, y, width, height });
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries finding a window we have created with given name. If found, then
|
* Tries finding a window we have created with given name. If found, then
|
||||||
* brings to front and gives focus.
|
* brings to front and gives focus.
|
||||||
|
Loading…
Reference in New Issue
Block a user