From 9901cf433847055369b427483cd6e747e7d81a42 Mon Sep 17 00:00:00 2001 From: Allan Doensen Date: Fri, 5 May 2017 21:28:40 +1000 Subject: [PATCH] Fix for dash-qt issue with startup and multiple monitors. (#1461) * Fix for issues with startup and multiple monitors on windows. * Improvements to centering code after a suggestion from zander. --- src/qt/guiutil.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 521955d3eb87d..768614ad6715c 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -889,14 +889,17 @@ void restoreWindowGeometry(const QString& strSetting, const QSize& defaultSize, QPoint pos = settings.value(strSetting + "Pos").toPoint(); QSize size = settings.value(strSetting + "Size", defaultSize).toSize(); - if (!pos.x() && !pos.y()) { - QRect screen = QApplication::desktop()->screenGeometry(); - pos.setX((screen.width() - size.width()) / 2); - pos.setY((screen.height() - size.height()) / 2); - } - parent->resize(size); parent->move(pos); + + if ((!pos.x() && !pos.y()) || (QApplication::desktop()->screenNumber(parent) == -1)) + { + QRect screen = QApplication::desktop()->screenGeometry(); + QPoint defaultPos = screen.center() - + QPoint(defaultSize.width() / 2, defaultSize.height() / 2); + parent->resize(defaultSize); + parent->move(defaultPos); + } } // Return name of current UI-theme or default theme if no theme was found