Update of move window to handle screen less than window, remove printouts

This commit is contained in:
Johan Kwarnmark
2019-12-09 15:39:26 +01:00
parent ba3b91e859
commit d5f4c9b63c

View File

@@ -434,7 +434,7 @@ export class WindowHandler {
/**
* Move window to the same screen as main window
*/
public MoveWindow(windowToMove: BrowserWindow) {
public moveWindow(windowToMove: BrowserWindow) {
const allWindows = BrowserWindow.getAllWindows();
const parentWindow = allWindows.find((window) => {
@@ -444,16 +444,32 @@ export class WindowHandler {
if (parentWindow && windowExists(parentWindow)) {
const display = electron.screen.getDisplayNearestPoint({x: parentWindow.getBounds().x, y: parentWindow.getBounds().y});
console.warn('QQQQ display: ' + JSON.stringify(display.bounds));
console.warn('QQQQ windowToMove.width: ' + windowToMove.getBounds().width);
console.warn('QQQQ windowToMove.heigth: ' + windowToMove.getBounds().height);
logger.info('window-handler: moveWindow, display: ' + JSON.stringify(display.workArea));
logger.info('window-handler: moveWindow, windowToMove: ' + JSON.stringify(windowToMove.getBounds()));
const positionX = Math.trunc(display.bounds.x + display.bounds.width / 2 - windowToMove.getBounds().width / 2);
const positionY = Math.trunc(display.bounds.y + display.bounds.height / 2 - windowToMove.getBounds().height / 2);
if (display.workArea.width < windowToMove.getBounds().width) {
windowToMove.setSize(display.workArea.width, windowToMove.getBounds().height);
}
console.warn('QQQQ positionX: ' + positionX);
console.warn('QQQQ positionY: ' + positionY);
if (display.workArea.height < windowToMove.getBounds().height) {
windowToMove.setSize(windowToMove.getBounds().width, display.workArea.height);
}
let positionX = Math.trunc(display.workArea.x + display.workArea.width / 2 - windowToMove.getBounds().width / 2);
if (positionX < display.workArea.x) {
positionX = display.workArea.x;
}
let positionY = Math.trunc(display.workArea.y + display.workArea.height / 2 - windowToMove.getBounds().height / 2);
if (positionY < display.workArea.y) {
positionY = display.workArea.y;
}
logger.info('window-handler: moveWindow, positionX: ' + positionX);
logger.info('window-handler: moveWindow, positionY: ' + positionY);
windowToMove.setPosition(positionX, positionY);
// Because of a bug for windows10 we need to call setPosition twice
windowToMove.setPosition(positionX, positionY);
}
}
@@ -498,7 +514,7 @@ export class WindowHandler {
}
this.aboutAppWindow = createComponentWindow('about-app', opts);
this.MoveWindow(this.aboutAppWindow);
this.moveWindow(this.aboutAppWindow);
this.aboutAppWindow.setVisibleOnAllWorkspaces(true);
this.aboutAppWindow.webContents.once('did-finish-load', async () => {
const ABOUT_SYMPHONY_NAMESPACE = 'AboutSymphony';
@@ -546,7 +562,7 @@ export class WindowHandler {
}
this.screenPickerWindow = createComponentWindow('screen-picker', opts);
this.MoveWindow(this.screenPickerWindow);
this.moveWindow(this.screenPickerWindow);
this.screenPickerWindow.webContents.once('did-finish-load', () => {
if (!this.screenPickerWindow || !windowExists(this.screenPickerWindow)) {
return;
@@ -605,7 +621,7 @@ export class WindowHandler {
});
opts.parent = window;
this.basicAuthWindow = createComponentWindow('basic-auth', opts);
this.MoveWindow(this.basicAuthWindow);
this.moveWindow(this.basicAuthWindow);
this.basicAuthWindow.setVisibleOnAllWorkspaces(true);
this.basicAuthWindow.webContents.once('did-finish-load', () => {
if (!this.basicAuthWindow || !windowExists(this.basicAuthWindow)) {
@@ -675,7 +691,7 @@ export class WindowHandler {
}
this.notificationSettingsWindow = createComponentWindow('notification-settings', opts);
this.MoveWindow(this.notificationSettingsWindow);
this.moveWindow(this.notificationSettingsWindow);
this.notificationSettingsWindow.setVisibleOnAllWorkspaces(true);
this.notificationSettingsWindow.webContents.on('did-finish-load', () => {
if (this.notificationSettingsWindow && windowExists(this.notificationSettingsWindow)) {
@@ -783,7 +799,6 @@ export class WindowHandler {
}
this.screenSharingIndicatorWindow = createComponentWindow('screen-sharing-indicator', opts);
this.MoveWindow(this.screenSharingIndicatorWindow);
this.screenSharingIndicatorWindow.setVisibleOnAllWorkspaces(true);
this.screenSharingIndicatorWindow.webContents.once('did-finish-load', () => {
if (!this.screenSharingIndicatorWindow || !windowExists(this.screenSharingIndicatorWindow)) {