mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 17:31:36 -06:00
SDA-3409, SDA-3408, SDA-3402, SDA-3412 - Fix issues with electron bounds (#1274)
* SDA-3409 - Fix view's x position w.r.t external display * SDA-3408 - Fix zoom controls for browserView * SDA-3409 - Use main window bounds for browser view * SDA-3409 - Fix blank welcome screen * SDA-3409 - Fix blank welcome screen * SDA-3402 - Create a separate window for the welcome screen * SDA-3409 - Fix view size issues * SDA-3409 - Workaround for electron fullscreen event * SDA-3402 - Fixes issue with maximize and unmaximize * SDA-3409 - Rename let to const
This commit is contained in:
parent
94f6a62d49
commit
aad616d927
@ -119,7 +119,7 @@ exports[`windows title bar should render correctly 1`] = `
|
||||
onClick={[Function]}
|
||||
onContextMenu={[Function]}
|
||||
onMouseDown={[Function]}
|
||||
title="Restore"
|
||||
title="Maximize"
|
||||
>
|
||||
<svg
|
||||
viewBox="0 0 14 10.2"
|
||||
@ -127,7 +127,7 @@ exports[`windows title bar should render correctly 1`] = `
|
||||
y="0px"
|
||||
>
|
||||
<path
|
||||
d="M2.1,0v2H0v8.1h8.2v-2h2V0H2.1z M7.2,9.2H1.1V3h6.1V9.2z M9.2,7.1h-1V2H3.1V1h6.1V7.1z"
|
||||
d="M0,0v10.1h10.2V0H0z M9.2,9.2H1.1V1h8.1V9.2z"
|
||||
fill="rgba(255, 255, 255, 0.9)"
|
||||
/>
|
||||
</svg>
|
||||
|
@ -1,4 +1,5 @@
|
||||
import {
|
||||
app,
|
||||
BrowserWindow,
|
||||
clipboard,
|
||||
dialog,
|
||||
@ -152,7 +153,8 @@ ipcMain.on(
|
||||
if (
|
||||
browserWin &&
|
||||
windowExists(browserWin) &&
|
||||
browserWin.winName === apiName.mainWindowName
|
||||
(browserWin.winName === apiName.mainWindowName ||
|
||||
browserWin.winName === apiName.welcomeScreenName)
|
||||
) {
|
||||
showPopupMenu({ window: browserWin });
|
||||
}
|
||||
@ -332,6 +334,11 @@ ipcMain.on(
|
||||
: mainWindow.unmaximize();
|
||||
}
|
||||
break;
|
||||
case apiCmds.setPodUrl:
|
||||
await config.updateUserConfig({ url: arg.newPodUrl });
|
||||
app.relaunch();
|
||||
app.exit();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -292,12 +292,6 @@ const setSpecificAlwaysOnTop = () => {
|
||||
* @param window {BrowserWindow}
|
||||
*/
|
||||
export const monitorWindowActions = (window: BrowserWindow): void => {
|
||||
if (windowHandler.shouldShowWelcomeScreen) {
|
||||
logger.info(
|
||||
`Not saving window position as we are showing the welcome window!`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!window || window.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { ExecException, execFile } from 'child_process';
|
||||
import {
|
||||
app,
|
||||
BrowserView,
|
||||
BrowserWindow,
|
||||
BrowserWindowConstructorOptions,
|
||||
crashReporter,
|
||||
@ -104,8 +105,11 @@ export interface ICustomBrowserView extends Electron.BrowserView {
|
||||
}
|
||||
|
||||
// Default window width & height
|
||||
export let DEFAULT_WIDTH: number = 900;
|
||||
export let DEFAULT_HEIGHT: number = 900;
|
||||
export const DEFAULT_WIDTH: number = 900;
|
||||
export const DEFAULT_HEIGHT: number = 900;
|
||||
export const DEFAULT_WELCOME_SCREEN_WIDTH: number = 542;
|
||||
export const DEFAULT_WELCOME_SCREEN_HEIGHT: number = 333;
|
||||
export const TITLE_BAR_HEIGHT: number = 32;
|
||||
|
||||
// Timeout on restarting SDA in case it's stuck
|
||||
const LISTEN_TIMEOUT: number = 25 * 1000;
|
||||
@ -141,7 +145,6 @@ export class WindowHandler {
|
||||
public isWebPageLoading: boolean = true;
|
||||
public isLoggedIn: boolean = false;
|
||||
public screenShareIndicatorFrameUtil: string;
|
||||
public shouldShowWelcomeScreen: boolean = false;
|
||||
private readonly defaultPodUrl: string = 'https://[POD].symphony.com';
|
||||
private readonly contextIsolation: boolean;
|
||||
private readonly backgroundThrottling: boolean;
|
||||
@ -154,6 +157,7 @@ export class WindowHandler {
|
||||
private loadFailError: string | undefined;
|
||||
private mainWindow: ICustomBrowserWindow | null = null;
|
||||
private aboutAppWindow: Electron.BrowserWindow | null = null;
|
||||
private welcomeScreenWindow: Electron.BrowserWindow | null = null;
|
||||
private screenPickerWindow: Electron.BrowserWindow | null = null;
|
||||
private screenSharingIndicatorWindow: Electron.BrowserWindow | null = null;
|
||||
private screenSharingFrameWindow: Electron.BrowserWindow | null = null;
|
||||
@ -272,7 +276,7 @@ export class WindowHandler {
|
||||
JSON.stringify(this.config.mainWinPos),
|
||||
);
|
||||
|
||||
let { isFullScreen, isMaximized } = this.config.mainWinPos
|
||||
const { isFullScreen, isMaximized } = this.config.mainWinPos
|
||||
? this.config.mainWinPos
|
||||
: { isFullScreen: false, isMaximized: false };
|
||||
|
||||
@ -281,35 +285,18 @@ export class WindowHandler {
|
||||
);
|
||||
logger.info(`window-handler: setting url ${this.url} from config file!`);
|
||||
|
||||
// Get url to load from cmd line or from global config file
|
||||
const urlFromCmd = getCommandLineArgs(process.argv, '--url=', false);
|
||||
|
||||
// Displays welcome screen instead of starting the main application
|
||||
if (
|
||||
config.isFirstTimeLaunch() &&
|
||||
this.globalConfig.url.indexOf('https://my.symphony.com') >= 0
|
||||
this.globalConfig.url.indexOf('https://my.symphony.com') >= 0 &&
|
||||
urlFromCmd === null
|
||||
) {
|
||||
this.shouldShowWelcomeScreen = true;
|
||||
this.url = this.defaultPodUrl;
|
||||
isMaximized = false;
|
||||
isFullScreen = false;
|
||||
DEFAULT_HEIGHT = 333;
|
||||
DEFAULT_WIDTH = 542;
|
||||
this.windowOpts.resizable = false;
|
||||
this.windowOpts.maximizable = false;
|
||||
this.windowOpts.fullscreenable = false;
|
||||
|
||||
if (this.config.mainWinPos && this.config.mainWinPos.height) {
|
||||
this.config.mainWinPos.height = DEFAULT_HEIGHT;
|
||||
}
|
||||
|
||||
if (this.config.mainWinPos && this.config.mainWinPos.width) {
|
||||
this.config.mainWinPos.width = DEFAULT_WIDTH;
|
||||
}
|
||||
|
||||
if (this.config.mainWinPos && this.config.mainWinPos.x) {
|
||||
this.config.mainWinPos.x = undefined;
|
||||
}
|
||||
|
||||
if (this.config.mainWinPos && this.config.mainWinPos.y) {
|
||||
this.config.mainWinPos.y = undefined;
|
||||
}
|
||||
this.showWelcomeScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info('window-handler: windowSize: ' + JSON.stringify(windowSize));
|
||||
@ -320,11 +307,9 @@ export class WindowHandler {
|
||||
logger.info(
|
||||
'window-handler: windowSize: sizes: ' + JSON.stringify(sizes),
|
||||
);
|
||||
DEFAULT_WIDTH = Number(sizes[0]);
|
||||
DEFAULT_HEIGHT = Number(sizes[1]);
|
||||
if (this.config.mainWinPos) {
|
||||
this.config.mainWinPos.width = DEFAULT_WIDTH;
|
||||
this.config.mainWinPos.height = DEFAULT_HEIGHT;
|
||||
this.config.mainWinPos.width = Number(sizes[0]);
|
||||
this.config.mainWinPos.height = Number(sizes[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -340,8 +325,6 @@ export class WindowHandler {
|
||||
);
|
||||
|
||||
this.mainWindow.winName = apiName.mainWindowName;
|
||||
// Get url to load from cmd line or from global config file
|
||||
const urlFromCmd = getCommandLineArgs(process.argv, '--url=', false);
|
||||
|
||||
if (urlFromCmd) {
|
||||
const commandLineUrl = urlFromCmd.substr(6);
|
||||
@ -362,12 +345,6 @@ export class WindowHandler {
|
||||
`window-handler: setting ${commandLineUrl} from the command line as the main window url.`,
|
||||
);
|
||||
this.url = commandLineUrl;
|
||||
this.shouldShowWelcomeScreen = false;
|
||||
isMaximized = true;
|
||||
isFullScreen = false;
|
||||
this.mainWindow.resizable = true;
|
||||
this.mainWindow.maximizable = true;
|
||||
this.mainWindow.fullScreenable = true;
|
||||
} else {
|
||||
logger.info(
|
||||
`window-handler: url ${commandLineUrl} from command line is NOT WHITELISTED in the config file.`,
|
||||
@ -378,12 +355,6 @@ export class WindowHandler {
|
||||
`window-handler: setting ${commandLineUrl} from the command line as the main window url since pod whitelist is empty.`,
|
||||
);
|
||||
this.url = commandLineUrl;
|
||||
this.shouldShowWelcomeScreen = false;
|
||||
isMaximized = true;
|
||||
isFullScreen = false;
|
||||
this.mainWindow.resizable = true;
|
||||
this.mainWindow.maximizable = true;
|
||||
this.mainWindow.fullScreenable = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,10 +369,6 @@ export class WindowHandler {
|
||||
}
|
||||
|
||||
this.startUrl = this.url;
|
||||
if (this.shouldShowWelcomeScreen) {
|
||||
this.handleWelcomeScreen();
|
||||
}
|
||||
|
||||
cleanAppCacheOnCrash(this.mainWindow);
|
||||
// loads the main window with url from config/cmd line
|
||||
logger.info(`Loading main window with url ${this.url}`);
|
||||
@ -431,7 +398,7 @@ export class WindowHandler {
|
||||
this.mainWindow.origin = this.globalConfig.contextOriginUrl || this.url;
|
||||
|
||||
// Event needed to hide native menu bar on Windows 10 as we use custom menu bar
|
||||
this.mainView?.webContents.once('did-start-loading', () => {
|
||||
this.mainWebContents.once('did-start-loading', () => {
|
||||
logger.info(
|
||||
`window-handler: main window web contents started loading for url ${this.mainView?.webContents.getURL()}!`,
|
||||
);
|
||||
@ -708,60 +675,108 @@ export class WindowHandler {
|
||||
* Handles the use case of showing
|
||||
* welcome screen for first time installs
|
||||
*/
|
||||
public handleWelcomeScreen() {
|
||||
if (!this.url || !this.mainWindow) {
|
||||
public showWelcomeScreen() {
|
||||
if (!this.url) {
|
||||
return;
|
||||
}
|
||||
const opts: ICustomBrowserWindowConstructorOpts = this.getWindowOpts(
|
||||
{
|
||||
width: DEFAULT_WELCOME_SCREEN_WIDTH,
|
||||
height: DEFAULT_WELCOME_SCREEN_HEIGHT,
|
||||
frame: !this.isCustomTitleBar,
|
||||
alwaysOnTop: isMac,
|
||||
resizable: false,
|
||||
minimizable: false,
|
||||
fullscreenable: false,
|
||||
},
|
||||
{
|
||||
devTools: isDevEnv,
|
||||
},
|
||||
);
|
||||
|
||||
if (this.url.startsWith(this.defaultPodUrl)) {
|
||||
this.url = format({
|
||||
this.welcomeScreenWindow = createComponentWindow('welcome', opts);
|
||||
(this.welcomeScreenWindow as ICustomBrowserWindow).winName =
|
||||
apiName.welcomeScreenName;
|
||||
|
||||
if (
|
||||
this.config.isCustomTitleBar === CloudConfigDataTypes.ENABLED &&
|
||||
isWindowsOS
|
||||
) {
|
||||
const titleBarView = new BrowserView({
|
||||
webPreferences: {
|
||||
sandbox: !isNodeEnv,
|
||||
nodeIntegration: isNodeEnv,
|
||||
preload: path.join(__dirname, '../renderer/_preload-component.js'),
|
||||
devTools: isDevEnv,
|
||||
},
|
||||
}) as ICustomBrowserView;
|
||||
const titleBarWindowUrl = format({
|
||||
pathname: require.resolve('../renderer/react-window.html'),
|
||||
protocol: 'file',
|
||||
query: {
|
||||
componentName: 'welcome',
|
||||
componentName: 'title-bar',
|
||||
locale: i18n.getLocale(),
|
||||
},
|
||||
slashes: true,
|
||||
});
|
||||
|
||||
titleBarView.webContents.once('did-finish-load', async () => {
|
||||
if (!titleBarView || titleBarView.webContents.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
titleBarView?.webContents.send('page-load', {
|
||||
isWindowsOS,
|
||||
locale: i18n.getLocale(),
|
||||
resource: i18n.loadedResources,
|
||||
isMainWindow: true,
|
||||
});
|
||||
});
|
||||
titleBarView.webContents.loadURL(titleBarWindowUrl);
|
||||
titleBarView.setBounds({
|
||||
x: 0,
|
||||
y: 0,
|
||||
height: TITLE_BAR_HEIGHT,
|
||||
width: DEFAULT_WELCOME_SCREEN_WIDTH,
|
||||
});
|
||||
this.welcomeScreenWindow.setBrowserView(titleBarView);
|
||||
}
|
||||
|
||||
this.mainWindow.webContents.on('did-finish-load', () => {
|
||||
if (!this.url || !this.mainWindow) {
|
||||
this.welcomeScreenWindow.webContents.on('did-finish-load', () => {
|
||||
if (!this.welcomeScreenWindow || this.welcomeScreenWindow.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
logger.info(`finished loading welcome screen.`);
|
||||
if (this.url.indexOf('welcome')) {
|
||||
const ssoValue = !!(
|
||||
this.userConfig.url &&
|
||||
this.userConfig.url.indexOf('/login/sso/initsso') > -1
|
||||
);
|
||||
const ssoValue = !!(
|
||||
this.userConfig.url &&
|
||||
this.userConfig.url.indexOf('/login/sso/initsso') > -1
|
||||
);
|
||||
|
||||
this.mainWindow.webContents?.send('page-load-welcome', {
|
||||
locale: i18n.getLocale(),
|
||||
resource: i18n.loadedResources,
|
||||
});
|
||||
const userConfigUrl =
|
||||
this.userConfig.url &&
|
||||
this.userConfig.url.indexOf('/login/sso/initsso') > -1
|
||||
? this.userConfig.url.slice(
|
||||
0,
|
||||
this.userConfig.url.indexOf('/login/sso/initsso'),
|
||||
)
|
||||
: this.userConfig.url;
|
||||
this.welcomeScreenWindow.webContents.send('page-load-welcome', {
|
||||
locale: i18n.getLocale(),
|
||||
resource: i18n.loadedResources,
|
||||
});
|
||||
|
||||
this.mainWindow.webContents?.send('welcome', {
|
||||
url: userConfigUrl || this.startUrl,
|
||||
message: '',
|
||||
urlValid: !!userConfigUrl,
|
||||
sso: ssoValue,
|
||||
});
|
||||
}
|
||||
const userConfigUrl =
|
||||
this.userConfig.url &&
|
||||
this.userConfig.url.indexOf('/login/sso/initsso') > -1
|
||||
? this.userConfig.url.slice(
|
||||
0,
|
||||
this.userConfig.url.indexOf('/login/sso/initsso'),
|
||||
)
|
||||
: this.userConfig.url;
|
||||
this.welcomeScreenWindow.webContents.send('welcome', {
|
||||
url: userConfigUrl || this.startUrl,
|
||||
message: '',
|
||||
urlValid: !!userConfigUrl,
|
||||
sso: ssoValue,
|
||||
});
|
||||
this.addWindow(opts.winKey, this.welcomeScreenWindow);
|
||||
this.mainWindow = this.welcomeScreenWindow as ICustomBrowserWindow;
|
||||
});
|
||||
|
||||
ipcMain.on('set-pod-url', async (_event, newPodUrl: string) => {
|
||||
await config.updateUserConfig({ url: newPodUrl });
|
||||
app.relaunch();
|
||||
app.exit();
|
||||
this.welcomeScreenWindow.once('closed', () => {
|
||||
this.removeWindow(opts.winKey);
|
||||
this.welcomeScreenWindow = null;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ import {
|
||||
DEFAULT_WIDTH,
|
||||
ICustomBrowserView,
|
||||
ICustomBrowserWindow,
|
||||
TITLE_BAR_HEIGHT,
|
||||
windowHandler,
|
||||
} from './window-handler';
|
||||
|
||||
@ -60,10 +61,7 @@ enum styleNames {
|
||||
}
|
||||
|
||||
const checkValidWindow = true;
|
||||
const { ctWhitelist, mainWinPos } = config.getConfigFields([
|
||||
'ctWhitelist',
|
||||
'mainWinPos',
|
||||
]);
|
||||
const { ctWhitelist } = config.getConfigFields(['ctWhitelist']);
|
||||
|
||||
// Network status check variables
|
||||
const networkStatusCheckInterval = 10 * 1000;
|
||||
@ -256,14 +254,19 @@ export const showBadgeCount = (count: number): void => {
|
||||
|
||||
// handle ms windows...
|
||||
const mainWindow = windowHandler.getMainWindow();
|
||||
if (!mainWindow || !windowExists(mainWindow)) {
|
||||
const mainWebContents = windowHandler.getMainWebContents();
|
||||
if (!mainWebContents || mainWebContents.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get badge img from renderer process, will return
|
||||
// img dataUrl in setDataUrl func.
|
||||
if (count > 0) {
|
||||
mainWindow.webContents.send('create-badge-data-url', { count });
|
||||
mainWebContents.send('create-badge-data-url', { count });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mainWindow || !windowExists(mainWindow)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -770,7 +773,18 @@ export const zoomIn = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const { webContents } = focusedWindow;
|
||||
let { webContents } = focusedWindow;
|
||||
|
||||
// If the focused window is mainWindow we should use mainWebContents
|
||||
if (
|
||||
(focusedWindow as ICustomBrowserWindow).winName === apiName.mainWindowName
|
||||
) {
|
||||
const mainWebContents = windowHandler.mainWebContents;
|
||||
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
||||
webContents = mainWebContents;
|
||||
}
|
||||
}
|
||||
|
||||
if (windowHandler.isMana) {
|
||||
const zoomFactor = webContents.getZoomFactor();
|
||||
if (zoomFactor < 1.5) {
|
||||
@ -791,8 +805,8 @@ export const zoomIn = () => {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const currentZoomLevel = focusedWindow.webContents.getZoomLevel();
|
||||
focusedWindow.webContents.setZoomLevel(currentZoomLevel + 0.5);
|
||||
const currentZoomLevel = webContents.getZoomLevel();
|
||||
webContents.setZoomLevel(currentZoomLevel + 0.5);
|
||||
}
|
||||
};
|
||||
|
||||
@ -810,7 +824,18 @@ export const zoomOut = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const { webContents } = focusedWindow;
|
||||
let { webContents } = focusedWindow;
|
||||
|
||||
// If the focused window is mainWindow we should use mainWebContents
|
||||
if (
|
||||
(focusedWindow as ICustomBrowserWindow).winName === apiName.mainWindowName
|
||||
) {
|
||||
const mainWebContents = windowHandler.mainWebContents;
|
||||
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
||||
webContents = mainWebContents;
|
||||
}
|
||||
}
|
||||
|
||||
if (windowHandler.isMana) {
|
||||
const zoomFactor = webContents.getZoomFactor();
|
||||
if (zoomFactor > 0.7) {
|
||||
@ -831,8 +856,8 @@ export const zoomOut = () => {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const currentZoomLevel = focusedWindow.webContents.getZoomLevel();
|
||||
focusedWindow.webContents.setZoomLevel(currentZoomLevel - 0.5);
|
||||
const currentZoomLevel = webContents.getZoomLevel();
|
||||
webContents.setZoomLevel(currentZoomLevel - 0.5);
|
||||
}
|
||||
};
|
||||
|
||||
@ -845,7 +870,17 @@ export const resetZoomLevel = () => {
|
||||
if (!focusedWindow || !windowExists(focusedWindow)) {
|
||||
return;
|
||||
}
|
||||
focusedWindow.webContents.setZoomLevel(0);
|
||||
let { webContents } = focusedWindow;
|
||||
// If the focused window is mainWindow we should use mainWebContents
|
||||
if (
|
||||
(focusedWindow as ICustomBrowserWindow).winName === apiName.mainWindowName
|
||||
) {
|
||||
const mainWebContents = windowHandler.mainWebContents;
|
||||
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
||||
webContents = mainWebContents;
|
||||
}
|
||||
}
|
||||
webContents.setZoomLevel(0);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -893,7 +928,7 @@ export const updateFeaturesForCloudConfig = async (): Promise<void> => {
|
||||
'memoryThreshold',
|
||||
]) as IConfig;
|
||||
|
||||
const mainWindow = windowHandler.getMainWindow();
|
||||
const mainWebContents = windowHandler.getMainWebContents();
|
||||
|
||||
// Update Always on top feature
|
||||
await updateAlwaysOnTop(
|
||||
@ -907,14 +942,14 @@ export const updateFeaturesForCloudConfig = async (): Promise<void> => {
|
||||
? autoLaunchInstance.enableAutoLaunch()
|
||||
: autoLaunchInstance.disableAutoLaunch();
|
||||
|
||||
if (mainWindow && windowExists(mainWindow)) {
|
||||
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
||||
if (memoryRefresh) {
|
||||
logger.info(
|
||||
`window-utils: updating the memory threshold`,
|
||||
memoryThreshold,
|
||||
);
|
||||
memoryMonitor.setMemoryThreshold(parseInt(memoryThreshold, 10));
|
||||
mainWindow.webContents.send('initialize-memory-refresh');
|
||||
mainWebContents.send('initialize-memory-refresh');
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -933,19 +968,19 @@ export const monitorNetworkInterception = (url: string) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const mainWindow = windowHandler.getMainWindow();
|
||||
const mainWebContents = windowHandler.getMainWebContents();
|
||||
const podUrl = `${protocol}//${hostname}/`;
|
||||
logger.info('window-utils: monitoring network interception for url', podUrl);
|
||||
|
||||
// Filter applied w.r.t pod url
|
||||
const filter = { urls: [podUrl + '*'] };
|
||||
|
||||
if (mainWindow && windowExists(mainWindow)) {
|
||||
if (mainWebContents && !mainWebContents.isDestroyed()) {
|
||||
isNetworkMonitorInitialized = true;
|
||||
mainWindow.webContents.session.webRequest.onErrorOccurred(
|
||||
mainWebContents.session.webRequest.onErrorOccurred(
|
||||
filter,
|
||||
async (details) => {
|
||||
if (!mainWindow || !windowExists(mainWindow)) {
|
||||
if (!mainWebContents || mainWebContents.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
@ -956,7 +991,7 @@ export const monitorNetworkInterception = (url: string) => {
|
||||
details.error === 'net::ERR_NAME_NOT_RESOLVED')
|
||||
) {
|
||||
logger.error(`window-utils: URL failed to load`, details);
|
||||
mainWindow.webContents.send('show-banner', {
|
||||
mainWebContents.send('show-banner', {
|
||||
show: true,
|
||||
bannerType: 'error',
|
||||
url: podUrl,
|
||||
@ -982,9 +1017,15 @@ export const loadBrowserViews = async (
|
||||
devTools: isDevEnv,
|
||||
},
|
||||
}) as ICustomBrowserView;
|
||||
const mainWindowBounds = windowHandler.getMainWindow()?.getBounds();
|
||||
const mainView = new BrowserView({
|
||||
...windowHandler.getMainWindowOpts(),
|
||||
...getBounds(mainWinPos, DEFAULT_WIDTH, DEFAULT_HEIGHT),
|
||||
...{
|
||||
width: mainWindowBounds?.width || DEFAULT_WIDTH,
|
||||
height: mainWindowBounds?.height || DEFAULT_HEIGHT,
|
||||
x: 0,
|
||||
y: TITLE_BAR_HEIGHT,
|
||||
},
|
||||
}) as ICustomBrowserView;
|
||||
|
||||
mainWindow.addBrowserView(titleBarView);
|
||||
@ -1015,52 +1056,82 @@ export const loadBrowserViews = async (
|
||||
);
|
||||
|
||||
mainWindow?.on('enter-full-screen', () => {
|
||||
if (!titleBarView || !viewExists(titleBarView)) {
|
||||
return;
|
||||
}
|
||||
const titleBarBounds = titleBarView.getBounds();
|
||||
titleBarView.setBounds({ ...titleBarBounds, ...{ height: 0 } });
|
||||
|
||||
if (
|
||||
!mainView ||
|
||||
!viewExists(mainView) ||
|
||||
!titleBarView ||
|
||||
!viewExists(titleBarView) ||
|
||||
!mainWindow ||
|
||||
!windowExists(mainWindow)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const mainWindowBounds = mainWindow.getBounds();
|
||||
const mainViewBounds = mainView.getBounds();
|
||||
mainView.setBounds({
|
||||
width: mainWindowBounds.width,
|
||||
height: mainViewBounds.height,
|
||||
x: 0,
|
||||
y: 0,
|
||||
});
|
||||
// Workaround: Need to delay getting the window bounds
|
||||
// to get updated window bounds
|
||||
setTimeout(() => {
|
||||
const [width, height] = mainWindow.getSize();
|
||||
titleBarView.setBounds({ x: 0, y: 0, width, height: 0 });
|
||||
|
||||
if (!mainView || !viewExists(mainView)) {
|
||||
return;
|
||||
}
|
||||
mainView.setBounds({
|
||||
width,
|
||||
height,
|
||||
x: 0,
|
||||
y: 0,
|
||||
});
|
||||
}, 500);
|
||||
});
|
||||
mainWindow?.on('leave-full-screen', () => {
|
||||
if (!titleBarView || !viewExists(titleBarView)) {
|
||||
return;
|
||||
}
|
||||
const titleBarBounds = titleBarView.getBounds();
|
||||
titleBarView.setBounds({ ...titleBarBounds, ...{ height: 32 } });
|
||||
|
||||
if (
|
||||
!mainView ||
|
||||
!viewExists(mainView) ||
|
||||
!titleBarView ||
|
||||
!viewExists(titleBarView) ||
|
||||
!mainWindow ||
|
||||
!windowExists(mainWindow)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const mainWindowBounds = mainWindow.getBounds();
|
||||
// Workaround: Need to delay getting the window bounds
|
||||
// to get updated window bounds
|
||||
setTimeout(() => {
|
||||
const [width, height] = mainWindow.getSize();
|
||||
titleBarView.setBounds({ x: 0, y: 0, width, height: TITLE_BAR_HEIGHT });
|
||||
if (!mainView || !viewExists(mainView)) {
|
||||
return;
|
||||
}
|
||||
mainView.setBounds({
|
||||
width,
|
||||
height,
|
||||
x: 0,
|
||||
y: TITLE_BAR_HEIGHT,
|
||||
});
|
||||
}, 500);
|
||||
});
|
||||
|
||||
mainWindow?.on('maximize', () => {
|
||||
if (!mainView || !viewExists(mainView)) {
|
||||
return;
|
||||
}
|
||||
const [width, height] = mainWindow.getSize();
|
||||
mainView.setBounds({
|
||||
width: mainWindowBounds.width,
|
||||
height: mainWindowBounds.height,
|
||||
x: mainWindowBounds.x,
|
||||
y: 32,
|
||||
width,
|
||||
height,
|
||||
x: 0,
|
||||
y: TITLE_BAR_HEIGHT,
|
||||
});
|
||||
});
|
||||
mainWindow?.on('unmaximize', () => {
|
||||
if (!mainView || !viewExists(mainView)) {
|
||||
return;
|
||||
}
|
||||
const [width, height] = mainWindow.getSize();
|
||||
mainView.setBounds({
|
||||
width,
|
||||
height,
|
||||
x: 0,
|
||||
y: TITLE_BAR_HEIGHT,
|
||||
});
|
||||
});
|
||||
|
||||
if (mainWindow?.isMaximized()) {
|
||||
mainEvents.publish('maximize');
|
||||
}
|
||||
@ -1071,7 +1142,7 @@ export const loadBrowserViews = async (
|
||||
await titleBarView.webContents.loadURL(titleBarWindowUrl);
|
||||
titleBarView.setBounds({
|
||||
...mainWindow.getBounds(),
|
||||
...{ x: 0, y: 0, height: 32 },
|
||||
...{ x: 0, y: 0, height: TITLE_BAR_HEIGHT },
|
||||
});
|
||||
titleBarView.setAutoResize({
|
||||
vertical: false,
|
||||
@ -1081,7 +1152,12 @@ export const loadBrowserViews = async (
|
||||
});
|
||||
|
||||
await mainView.webContents.loadURL(url, { userAgent });
|
||||
mainView.setBounds({ ...mainWindow.getBounds(), ...{ y: 32 } });
|
||||
mainView.setBounds({
|
||||
width: mainWindowBounds?.width || DEFAULT_WIDTH,
|
||||
height: mainWindowBounds?.height || DEFAULT_HEIGHT,
|
||||
x: 0,
|
||||
y: TITLE_BAR_HEIGHT,
|
||||
});
|
||||
mainView.setAutoResize({
|
||||
horizontal: true,
|
||||
vertical: false,
|
||||
|
@ -57,12 +57,14 @@ export enum apiCmds {
|
||||
isAeroGlassEnabled = 'is-aero-glass-enabled',
|
||||
showScreenSharePermissionDialog = 'show-screen-share-permission-dialog',
|
||||
getMediaAccessStatus = 'get-media-access-status',
|
||||
setPodUrl = 'set-pod-url',
|
||||
}
|
||||
|
||||
export enum apiName {
|
||||
symphonyApi = 'symphony-api',
|
||||
mainWindowName = 'main',
|
||||
notificationWindowName = 'notification-window',
|
||||
welcomeScreenName = 'welcome-screen',
|
||||
}
|
||||
|
||||
export const NOTIFICATION_WINDOW_TITLE = 'Notification - Symphony';
|
||||
@ -102,6 +104,7 @@ export interface IApiArgs {
|
||||
clipboardType: 'clipboard' | 'selection';
|
||||
requestId: number;
|
||||
mediaStatus: IMediaPermission;
|
||||
newPodUrl: string;
|
||||
}
|
||||
|
||||
export type Themes = 'light' | 'dark';
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { ipcRenderer } from 'electron';
|
||||
import * as React from 'react';
|
||||
import { apiCmds, apiName } from '../../common/api-interface';
|
||||
import { i18n } from '../../common/i18n-preload';
|
||||
|
||||
interface IState {
|
||||
@ -107,7 +108,10 @@ export default class Welcome extends React.Component<{}, IState> {
|
||||
if (url.endsWith('/')) {
|
||||
ssoPath = 'login/sso/initsso';
|
||||
}
|
||||
ipcRenderer.send('set-pod-url', sso ? `${url}${ssoPath}` : url);
|
||||
ipcRenderer.send(apiName.symphonyApi, {
|
||||
cmd: apiCmds.setPodUrl,
|
||||
newPodUrl: sso ? `${url}${ssoPath}` : url,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@ export default class WindowsTitleBar extends React.Component<{}, IState> {
|
||||
this.state = {
|
||||
title: document.title || 'Symphony',
|
||||
isFullScreen: false,
|
||||
isMaximized: true,
|
||||
isMaximized: false,
|
||||
};
|
||||
// Adds borders to the window
|
||||
this.addWindowBorders();
|
||||
|
@ -9,7 +9,6 @@ import DownloadManager from './components/download-manager';
|
||||
import MessageBanner from './components/message-banner';
|
||||
import NetworkError from './components/network-error';
|
||||
import SnackBar from './components/snack-bar';
|
||||
import Welcome from './components/welcome';
|
||||
import { SSFApi } from './ssf-api';
|
||||
|
||||
interface ISSFWindow extends Window {
|
||||
@ -152,20 +151,6 @@ ipcRenderer.on('page-load', (_event, { locale, resources }) => {
|
||||
banner.showBanner(false, 'error');
|
||||
});
|
||||
|
||||
ipcRenderer.on('page-load-welcome', (_event, data) => {
|
||||
const { locale, resource } = data;
|
||||
i18n.setResource(locale, resource);
|
||||
|
||||
document.title = 'Welcome';
|
||||
const styles = document.createElement('link');
|
||||
styles.rel = 'stylesheet';
|
||||
styles.type = 'text/css';
|
||||
styles.href = `./styles/welcome.css`;
|
||||
document.getElementsByTagName('head')[0].appendChild(styles);
|
||||
const element = React.createElement(Welcome);
|
||||
ReactDOM.render(element, document.getElementById('Root'));
|
||||
});
|
||||
|
||||
// When the window fails to load
|
||||
ipcRenderer.on('page-load-failed', (_event, { locale, resources }) => {
|
||||
i18n.setResource(locale, resources);
|
||||
|
Loading…
Reference in New Issue
Block a user