From 7095e070eb540d2ea2af42b489e3d6c2a4b8175e Mon Sep 17 00:00:00 2001 From: manuel-91 <45081089+manuel-91@users.noreply.github.com> Date: Fri, 5 Feb 2021 00:30:37 +0100 Subject: [PATCH] GUI: Open settings window centered above mainwindow (#4880) On multiscreen setup or big monitor it is confusing if settings window opens far away. With that it will be centered. Co-authored-by: Manuel Stein --- main.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 7fbc2f8d7..11b61f948 100644 --- a/main.js +++ b/main.js @@ -693,9 +693,16 @@ function showSettingsWindow() { addDarkOverlay(); const size = mainWindow.getSize(); + // center settings window over main window + const settingwidth = Math.min(500, size[0]); + const settingheight = Math.max(size[1] - 100, MIN_HEIGHT); + const mainPos = mainWindow.getPosition(); + const mainSize = mainWindow.getSize(); const options = { - width: Math.min(500, size[0]), - height: Math.max(size[1] - 100, MIN_HEIGHT), + x: Math.round(mainPos[0] + mainSize[0] / 2 - settingwidth / 2), + y: Math.round(mainPos[1] + mainSize[1] / 2 - settingheight / 2), + width: settingwidth, + height: settingheight, frame: false, resizable: false, title: locale.messages.signalDesktopPreferences.message,