From 4a292ad7c066fcef663970f11fa3ce9cb31d6fb0 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Fri, 6 Oct 2017 16:09:49 +0530 Subject: [PATCH] Electron-171 - Fixes the Configuration window positioning when multiple monitors are connected --- .../configure-notification-position.js | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/js/notify/settings/configure-notification-position.js b/js/notify/settings/configure-notification-position.js index 9606d1b5..6d2e131d 100644 --- a/js/notify/settings/configure-notification-position.js +++ b/js/notify/settings/configure-notification-position.js @@ -72,13 +72,27 @@ function getTemplatePath() { * @param windowName */ function openConfigurationWindow(windowName) { - let allWindows = BrowserWindow.getAllWindows(); - allWindows = allWindows.find((window) => { return window.winName === windowName }); + const allWindows = BrowserWindow.getAllWindows(); + const selectedParentWindow = allWindows.find((window) => { return window.winName === windowName }); // if we couldn't find any window matching the window name // it will render as a new window - if (allWindows) { - windowConfig.parent = allWindows; + if (selectedParentWindow) { + windowConfig.parent = selectedParentWindow; + + // This is a temporary work around until there + // is a fix for the modal window in windows from the electron + const { x, y, width, height } = selectedParentWindow.getBounds(); + + const windowWidth = Math.round(width * 0.5); + const windowHeight = Math.round(height * 0.5); + + // Calculating the center of the window + // to place the configuration window + const centerX = x + width / 2.0; + const centerY = y + height / 2.0; + windowConfig.x = Math.round(centerX - (windowWidth / 2.0)); + windowConfig.y = Math.round(centerY - (windowHeight / 2.0)); } configurationWindow = new BrowserWindow(windowConfig);